diff --git a/app/assets/javascripts/admin.coffee b/app/assets/javascripts/admin.coffee index c007e3c..3a1ef36 100644 --- a/app/assets/javascripts/admin.coffee +++ b/app/assets/javascripts/admin.coffee @@ -35,6 +35,8 @@ #= require admin/trunk8.js +#=require sheet_prices + portlet_to_move = false content_type_to_move =false window.disable_portlet_select = false diff --git a/app/assets/javascripts/public.js.coffee b/app/assets/javascripts/public.js.coffee index b3ab8fc..497bd6f 100644 --- a/app/assets/javascripts/public.js.coffee +++ b/app/assets/javascripts/public.js.coffee @@ -13,6 +13,7 @@ #= require redactor_plugins/fontsize #= require redactor_plugins/fontfamily #= require redactor_plugins/fontcolor +#= require vendor/accounting #= require vendor/flipclock.js #= require vendor/jquery.cookiebar.js @@ -22,6 +23,8 @@ #= require nested_fields +#=require sheet_prices + top = 20 @scroll_ajust = () -> diff --git a/app/assets/javascripts/sheet_prices.coffee b/app/assets/javascripts/sheet_prices.coffee new file mode 100644 index 0000000..0ec04cc --- /dev/null +++ b/app/assets/javascripts/sheet_prices.coffee @@ -0,0 +1,16 @@ +@udpate_sheet_lines = -> + $(".p_sheet_line_field").each -> + price = parseFloat($(this).find(".price").data("price")) + price_tot = 0 + qte_tot = 0 + $(this).find(".color_line").each -> + qte = 0 + $(this).find("input.qte").each -> + qte += parseFloat($(this).val()) if parseFloat($(this).val()) + price_color = qte * price + $(this).find(".price_color_tot").html(accounting.formatMoney(price_color)) + qte_tot += qte + + $(this).find(".qte_tot").html(qte_tot) + $(this).find(".price_tot").html(accounting.formatMoney(qte_tot*price)) + \ No newline at end of file diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 1c2552b..3c15690 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -130,6 +130,14 @@ class Admin::PCustomerSheetsController < ApplicationController end + def generate_fa + @p_customer_sheet = PCustomerSheet.find(params[:id]) + @p_customer_sheet.generate_fa + + redirect_to :back + + end + def generate_bc @p_customer_sheet = PCustomerSheet.find(params[:id]) @p_customer_sheet.generate_bc diff --git a/app/controllers/admin/p_customers_controller.rb b/app/controllers/admin/p_customers_controller.rb index 3b9410e..51ee13e 100644 --- a/app/controllers/admin/p_customers_controller.rb +++ b/app/controllers/admin/p_customers_controller.rb @@ -67,9 +67,10 @@ class Admin::PCustomersController < ApplicationController def create @p_customer = PCustomer.new(params.require(:p_customer).permit!) + if @p_customer.save - + @p_customer.generate_mdp_now if @p_customer.generate_mdp and @p_customer.generate_mdp != "0" else render action: "new" @@ -80,10 +81,10 @@ class Admin::PCustomersController < ApplicationController def update @p_customer = PCustomer.find(params[:id]) - + if @p_customer.update_attributes(params.require(:p_customer).permit!) - + @p_customer.generate_mdp_now if @p_customer.generate_mdp and @p_customer.generate_mdp != "0" else render action: "edit" diff --git a/app/controllers/admin/p_documents_controller.rb b/app/controllers/admin/p_documents_controller.rb index 4bdaa92..6596f05 100755 --- a/app/controllers/admin/p_documents_controller.rb +++ b/app/controllers/admin/p_documents_controller.rb @@ -24,7 +24,7 @@ class Admin::PDocumentsController < ApplicationController @p_document = PDocument.find_by_token(params[:id]) @element = @p_document.element params[:inline] = true - if true + if false @temp_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}_temp.pdf" @final_file = "#{Rails.root}/pdf/p_documents/#{@p_document.d_number}.pdf" diff --git a/app/controllers/public/p_customer_auths_controller.rb b/app/controllers/public/p_customer_auths_controller.rb index f2aa44d..bb72773 100755 --- a/app/controllers/public/p_customer_auths_controller.rb +++ b/app/controllers/public/p_customer_auths_controller.rb @@ -23,7 +23,7 @@ class Public::PCustomerAuthsController < ApplicationController user = PCustomer.find_by_email(params[:email]) - if user && user.authenticate(params[:password]) + if user && user.password_digest && user.authenticate(params[:password].to_s) #session[:forum_user_id] = user.id diff --git a/app/controllers/public/p_orders_controller.rb b/app/controllers/public/p_orders_controller.rb index aa6f8c3..17b147a 100644 --- a/app/controllers/public/p_orders_controller.rb +++ b/app/controllers/public/p_orders_controller.rb @@ -18,8 +18,12 @@ class Public::POrdersController < ApplicationController if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) + respond_to do |format| + format.html { redirect_to cart_public_p_orders_path()} + format.js { render :layout => false } + end + - redirect_to cart_public_p_orders_path() else render action: "cart" diff --git a/app/helpers/mail_helper.rb b/app/helpers/mail_helper.rb index c26dd7c..e76bf1a 100644 --- a/app/helpers/mail_helper.rb +++ b/app/helpers/mail_helper.rb @@ -1,13 +1,12 @@ # -*- encoding : utf-8 -*- module MailHelper - def mail_content(slug, lang, arguments = {}) + def mail_content(mail_content, lang_slug, arguments = {}) - lang_site = LangSite.find_by_slug(lang) + lang_site = LangSite.find_by_slug(lang_slug) + + - mail_content = MailContent.joins(:mail_type).where(:lang_site_id => lang_site.id, :mail_types => { :slug => slug}).first - - @new_site = true if mail_content.content_type == "blocs" and mail_content.block r = "
"+render(:partial => "public/blocks/block", :locals => {:block => mail_content.block})+render(:partial => "public/shared/render_block.html.haml")+"
" diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index c95300e..3027de4 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -1,10 +1,10 @@ class AdminMailer < ActionMailer::Base def password_reset(admin) @admin = admin - mail :to => admin.email, :subject => "Reinitialisation du mot de passe.", :from => "info@nicolasbally.com" + mail :to => admin.email, :subject => "Reinitialisation du mot de passe.", :from => "n.bally@quartz.xyz" end def notify_comments - mail :to => "info@3p.quartz.xyz,perrotmathilde@orange.fr", :subject => "Nouveaux commentaires à modérer sur le blog", :from => "info@3p.quartz.xyz" + mail :to => "n.bally@quartz.xyz", :subject => "Nouveaux commentaires à modérer sur le blog", :from => "n.bally@quartz.xyz" end end \ No newline at end of file diff --git a/app/mailers/general_mailer.rb b/app/mailers/general_mailer.rb new file mode 100755 index 0000000..b125758 --- /dev/null +++ b/app/mailers/general_mailer.rb @@ -0,0 +1,23 @@ +class GeneralMailer < ActionMailer::Base + default from: "contact@biocoton.net" + + add_template_helper(MailHelper) + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.question.deliver.subject + # + def send_qi_mail(lang_slug, slug, to, options) + + @mail_content = MailContent.find_key(LangSite.find_by_slug(lang_slug), slug) + + @lang_slug = lang_slug + + @options = options + + mail to: to, :subject => "[Biocoton] "+@mail_content.subject.to_s + end + + +end diff --git a/app/mailers/question_mailer.rb b/app/mailers/question_mailer.rb index 2190c02..09810b3 100755 --- a/app/mailers/question_mailer.rb +++ b/app/mailers/question_mailer.rb @@ -1,5 +1,5 @@ class QuestionMailer < ActionMailer::Base - default from: "info@3p.quartz.xyz" + default from: "info@quartz.xyz" # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: @@ -9,7 +9,7 @@ class QuestionMailer < ActionMailer::Base def send_contact(contact) @contact = contact - mail to: "info@3p.quartz.xyz",:reply_to => @contact.email.to_s, :subject => "[Contact site] "+@contact.raison_text + mail to: "info@quartz.xyz",:reply_to => @contact.email.to_s, :subject => "[Contact site] "+@contact.raison_text end diff --git a/app/models/mail_type.rb b/app/models/mail_type.rb index f05287d..d49dc94 100644 --- a/app/models/mail_type.rb +++ b/app/models/mail_type.rb @@ -2,4 +2,16 @@ class MailType < ActiveRecord::Base has_many :mail_contents belongs_to :mail_type_reference, :class_name => "MailType" + + + def self.generate_mail_content(slug) + mc = MailType.new(:slug => slug) + LangSite.all.each do |ls| + + mc.mail_contents.new(:lang_site_id => ls.id, :content_type => "text") + end + mc.save + end + + end diff --git a/app/models/p_box_fdp.rb b/app/models/p_box_fdp.rb new file mode 100644 index 0000000..f5026db --- /dev/null +++ b/app/models/p_box_fdp.rb @@ -0,0 +1,6 @@ +class PBoxFdp < ActiveRecord::Base + belongs_to :p_product + belongs_to :element, :polymorphic => true + + +end diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 00f1d74..05551b0 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -20,12 +20,34 @@ class PCustomer < ActiveRecord::Base + + belongs_to :p_price_cat - attr_accessor :valid_public - - + attr_accessor :valid_public, :generate_mdp + before_validation do + self.generate_token if !self.token? and self.email? + end + def generate_mdp_now + ps = SecureRandom.hex(4) + self.password = ps + self.password_confirmation = ps + + if !self.email? + errors.add(:email, "Doit être présent") + + end + + + if self.save + GeneralMailer.send_qi_mail("fr", "generation_mdp", self.email, {"mdp" => ps}).deliver + else + fgfdggdf = dfgdgf + end + + + end def public_validation? diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index d62b839..a54a40f 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -1,5 +1,10 @@ class PCustomerSheet < ActiveRecord::Base has_many :p_documents, :as => :element + + has_many :p_box_fdps, :as => :element + accepts_nested_attributes_for :p_box_fdps, allow_destroy: true + + belongs_to :p_customer accepts_nested_attributes_for :p_customer @@ -247,6 +252,15 @@ class PCustomerSheet < ActiveRecord::Base end + def generate_fa + + if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Facture acompte")) + self.state = "commande" + self.save + end + + end + def generate_bc if self.p_documents.create(:p_document_type => PDocumentType.find_by_label("Bon de commande")) @@ -297,6 +311,11 @@ class PCustomerSheet < ActiveRecord::Base end + def generate_fdp + + end + + STATES = ["panier", "brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"] ECOM_STATUS = ["commande", "commande validée", "en livraison", "livrée"] diff --git a/app/models/p_degressif.rb b/app/models/p_degressif.rb index 34eaa24..604a110 100644 --- a/app/models/p_degressif.rb +++ b/app/models/p_degressif.rb @@ -2,7 +2,7 @@ class PDegressif < ActiveRecord::Base belongs_to :p_product - has_many :p_price_cat_p_degressifs + has_many :p_price_cat_p_degressifs, :dependent => :destroy has_many :p_price_cats, :through => :p_price_cat_p_degressifs diff --git a/app/models/p_document.rb b/app/models/p_document.rb index 3c65be7..f377a76 100644 --- a/app/models/p_document.rb +++ b/app/models/p_document.rb @@ -18,6 +18,9 @@ class PDocument < ActiveRecord::Base archive_sheet_line end before_create do + self.fdp_force_price = self.element.fdp_force_price + self.acompte_percent = self.element.acompte_percent + if self.element_type == "PCustomerSheet" and self.element.particular_bill self.particular_bill = self.element.particular_bill.dup self.particular_bill.owner = nil @@ -35,6 +38,7 @@ class PDocument < ActiveRecord::Base self.th_paid_completed? if self.element_type == "PCustomerSheet" + self.p_customer = self.element.p_customer end @@ -54,7 +58,8 @@ class PDocument < ActiveRecord::Base def archive_sheet_line if self.element_type == "PCustomerSheet" - + + self.save self.element.p_sheet_lines.joins(:p_product).each do |p_sheet_line| n_sheet_line = p_sheet_line.dup @@ -67,10 +72,58 @@ class PDocument < ActiveRecord::Base + p_colors_archiveds = [] + + p_sizes_archiveds = [] + p_sheet_line.p_sheet_line_lines.each do |psll| new_psll = psll.dup - new_psll.fige + + + #Attention avant fonction fige + #new_psll.fige ######## + + + + if new_psll.p_product_stock.p_color + + if p_color = p_colors_archiveds[new_psll.p_product_stock.p_color_id] + + else + + p_color = new_psll.p_product_stock.p_color.dup + p_color.archived = true + + p_colors_archiveds[new_psll.p_product_stock.p_color_id] = p_color + + end + + new_psll.p_color = p_color + end + + if new_psll.p_product_stock.p_size + + if p_size = p_sizes_archiveds[new_psll.p_product_stock.p_size_id] + + else + p_size = new_psll.p_product_stock.p_size.dup + p_size.archived = true + + + p_sizes_archiveds[new_psll.p_product_stock.p_size_id] = p_size + end + + new_psll.p_size = p_size + end + + + new_psll.ok_code = new_psll.p_product_stock.code + + + + + #end ################ n_sheet_line.p_sheet_line_lines << new_psll diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 0c7f3bc..34c9011 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -8,16 +8,16 @@ class PProduct < ActiveRecord::Base belongs_to :p_ep - has_many :p_product_colors + has_many :p_product_colors, :dependent => :destroy has_many :p_colors, :through => :p_product_colors - has_many :p_product_certifs + has_many :p_product_certifs, :dependent => :destroy has_many :p_certifs, :through => :p_product_certifs - has_many :p_product_sizes + has_many :p_product_sizes, :dependent => :destroy has_many :p_sizes, :through => :p_product_sizes - has_many :p_product_qtes + has_many :p_product_qtes, :dependent => :destroy has_many :p_qtes, :through => :p_product_qtes @@ -51,11 +51,11 @@ class PProduct < ActiveRecord::Base def generate_degressif - vals = [100,200,300,400,500,1000,3000,5000,10000] + vals = [0]#[100,200,300,400,500,1000,3000,5000,10000] vals.each do |val| - self.p_degressifs.create(:nbr => val) + self.p_degressifs.create(:nbr => val, :p_price_cat_ids => PPriceCat.all.ids) end diff --git a/app/models/p_product_stock.rb b/app/models/p_product_stock.rb index f9778be..710fa63 100644 --- a/app/models/p_product_stock.rb +++ b/app/models/p_product_stock.rb @@ -2,4 +2,7 @@ class PProductStock < ActiveRecord::Base belongs_to :p_product belongs_to :p_color belongs_to :p_size + + has_many :p_sheet_line_lines, :dependent => :delete_all + end diff --git a/app/models/p_sheet_line.rb b/app/models/p_sheet_line.rb index 1837138..a55c0ac 100644 --- a/app/models/p_sheet_line.rb +++ b/app/models/p_sheet_line.rb @@ -1,6 +1,8 @@ class PSheetLine < ActiveRecord::Base belongs_to :p_customer_sheet + belongs_to :p_document + has_one :p_customer, :through => :p_customer_sheet belongs_to :p_product belongs_to :p_tank @@ -138,7 +140,7 @@ class PSheetLine < ActiveRecord::Base - product_degressif = self.p_product.p_degressifs.joins(:p_price_cats).where("nbr >= ?", self.qte).where(:p_price_cats => {:id => p_price_cat.id}).order("nbr ASC").first + product_degressif = self.p_product.p_degressifs.joins(:p_price_cats).where("nbr <= ?", self.qte).where(:p_price_cats => {:id => p_price_cat.id}).order("nbr DESC").first if product_degressif price = product_degressif.price.to_f @@ -355,8 +357,8 @@ class PSheetLine < ActiveRecord::Base r[:fdp] = {:label =>"Frais de port HT",:value => fdp} - total = total +fdp - total_ttc = total_ttc + (fdp*1.2) + total = total +fdp.to_f + total_ttc = total_ttc + (fdp.to_f*1.2) r[:total] = {:label =>"Total HT",:value => total} r[:tva] = {:label =>"TVA",:value => total_ttc - total} r[:total_ttc] = {:label =>"Total TTC",:value => total_ttc} @@ -370,14 +372,30 @@ class PSheetLine < ActiveRecord::Base def self.frais_de_port(p_sheet_lines) - if PSheetLine.total_articles(p_sheet_lines)[:total] > PSheetLine.franco_port - 0.0 + + if p_sheet_lines[0] and ((p_sheet_lines[0].p_customer_sheet and p_sheet_lines[0].p_customer_sheet.fdp_force_price) or (p_sheet_lines[0].p_document and p_sheet_lines[0].p_document.fdp_force_price)) + if p_sheet_lines[0].p_document + p_sheet_lines[0].p_document.fdp_force_price + elsif p_sheet_lines[0].p_customer_sheet + p_sheet_lines[0].p_customer_sheet.fdp_force_price + end + else - PSheetLine.ship_affects(p_sheet_lines) * PSheetLine.carton_price + if PSheetLine.total_articles(p_sheet_lines)[:total] > PSheetLine.franco_port + 0.0 + else + PSheetLine.ship_affects(p_sheet_lines) * PSheetLine.carton_price + end + end + + + + + end def self.ship_affects(p_sheet_lines) diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index 9dfd9eb..e808b3e 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -1,7 +1,7 @@ -=semantic_form_for [:admin, @p_customer_sheet], :remote => false do |form| +=semantic_form_for [:admin, @p_customer_sheet], :remote => false, :html => {:id => "cart_form"} do |form| .content %h3 Client @@ -201,29 +201,32 @@ =form.semantic_fields_for :p_sheet_lines do |form| =render :partial => "admin/p_sheet_lines/form", :locals => {:form => form} - %p= link_to_add_fields "Ajouter une ligne", form, :p_sheet_lines - - - %p - %strong Totaux + %p= link_to_add_fields "Ajouter une ligne", form, :p_sheet_lines - %table{:style => "width:100%;"} - %td{:style => "text-align:right;"} - Total HT : - %td.price_td - .price_emp.p_sheet_lines_tot_ht + = form.input :fdp_force_price, :label => "Frais de port (calculés automatiquement si vides) :" - %table{:style => "width:100%;"} - %td{:style => "text-align:right;"} - TVA : - %td.price_td - .price_emp.p_sheet_lines_tot_tva + + -if false + %p + %strong Totaux + + %table{:style => "width:100%;"} + %td{:style => "text-align:right;"} + Total HT : + %td.price_td + .price_emp.p_sheet_lines_tot_ht + + %table{:style => "width:100%;"} + %td{:style => "text-align:right;"} + TVA : + %td.price_td + .price_emp.p_sheet_lines_tot_tva - %table{:style => "width:100%;"} - %td{:style => "text-align:right;"} - Total TTC : - %td.price_td - .price_emp.p_sheet_lines_tot_ttc + %table{:style => "width:100%;"} + %td{:style => "text-align:right;"} + Total TTC : + %td.price_td + .price_emp.p_sheet_lines_tot_ttc %hr @@ -292,4 +295,16 @@ margin-bottom:0} } - } \ No newline at end of file + } + + +:coffeescript + + + udpate_sheet_lines() + + $("#cart_form").change -> + udpate_sheet_lines() + + $("#cart_form").keyup -> + udpate_sheet_lines() diff --git a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml index be3e105..7744d47 100644 --- a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml +++ b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml @@ -9,10 +9,7 @@ %td -totals = PSheetLine.totals(p_customer_sheet.p_sheet_lines) - -if p_customer_sheet.state_ok? - =number_to_currency totals[:ok_total] - -else - =number_to_currency totals[:total] + =number_to_currency totals[:total] %td=raw p_customer_sheet.state_html diff --git a/app/views/admin/p_customer_sheets/show.html.haml b/app/views/admin/p_customer_sheets/show.html.haml index 7a22bd0..bfdf666 100644 --- a/app/views/admin/p_customer_sheets/show.html.haml +++ b/app/views/admin/p_customer_sheets/show.html.haml @@ -121,6 +121,9 @@ %p=link_to "Générer la facture proforma", generate_fp_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" %p=link_to "Générer le bon de commande", generate_bc_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-success" %p=link_to "Marquer l'offre comme refusée", reject_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-danger" + + -if @p_customer_sheet.acompte_percent? + %p=link_to "Générer la facture d'acompte", generate_fa_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" -elsif @p_customer_sheet.state == "commande" and @p_customer_sheet.p_sheet_lines.joins(:p_product).where("bl = 0 and (p_products.p_product_cat_id != 6 OR (p_products.p_product_cat_id = 6 and externe = 1))").count > 0 %p=link_to "Générer le bon de livraison", generate_bl_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" @@ -128,6 +131,9 @@ =#-elsif @p_customer_sheet.state == "livrée" %p=link_to "Générer la facture", generate_f_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" + -if @p_customer_sheet.acompte_percent? + %p=link_to "Générer la facture d'acompte", generate_fa_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" + .clear diff --git a/app/views/admin/p_customers/_form.html.haml b/app/views/admin/p_customers/_form.html.haml index 9db6ef2..f99763a 100755 --- a/app/views/admin/p_customers/_form.html.haml +++ b/app/views/admin/p_customers/_form.html.haml @@ -9,6 +9,9 @@ = form.input :code, :label => "Code client :" = form.input :email, :label => "Email client (login) :" + + = form.input :generate_mdp, :label => "Forcer la génération d'un nouveau mot de passe ? (un mail sera envoyé au client)", :as => :boolean + = form.input :password, :label => "Mot de passe :" @@ -44,9 +47,7 @@ %p= link_to_add_fields "Ajouter une contact au client", form, :p_contacts - %hr - = form.input :mlm_token, :label => "Code parrain :" - + %hr =form.input :p_price_cat_id, :label => "Catégories de prix :", :as => :select, :collection => PPriceCat.all, :include_blank => false diff --git a/app/views/admin/p_degressifs/_form.html.haml b/app/views/admin/p_degressifs/_form.html.haml index e8631a8..55cf94e 100644 --- a/app/views/admin/p_degressifs/_form.html.haml +++ b/app/views/admin/p_degressifs/_form.html.haml @@ -1,7 +1,7 @@ %tr.p_degressif_form.field %td{:style => "width:30%"} - =form.input :nbr, :label => "Nombre max :" + =form.input :nbr, :label => "Nombre min :" %td{:style => "width:40%"} =form.input :price, :label => "Prix" %td{:style => "width:20%"} diff --git a/app/views/admin/p_documents/_general.html.haml b/app/views/admin/p_documents/_general.html.haml index b57ad05..f82c98b 100644 --- a/app/views/admin/p_documents/_general.html.haml +++ b/app/views/admin/p_documents/_general.html.haml @@ -2,6 +2,7 @@ %div{:style => "position:absolute;top:4.4cm;right:1cm;text-align:right;"} =@p_document.label +   n° =@p_document.d_number %br diff --git a/app/views/admin/p_products/_p_product.html.haml b/app/views/admin/p_products/_p_product.html.haml index 25b492e..7278c80 100644 --- a/app/views/admin/p_products/_p_product.html.haml +++ b/app/views/admin/p_products/_p_product.html.haml @@ -24,10 +24,7 @@ %td - p_product.p_qtes.each do |p_qte| =p_qte.qte - - =debug p_product.p_degressifs.count - - + %td.actions diff --git a/app/views/admin/p_sheet_lines/_form.html.haml b/app/views/admin/p_sheet_lines/_form.html.haml index 63dbd82..81ffe03 100755 --- a/app/views/admin/p_sheet_lines/_form.html.haml +++ b/app/views/admin/p_sheet_lines/_form.html.haml @@ -1,98 +1,215 @@ -.product_stock_form.field - %hr - %table{:style => "width:100%;"} - %tr - %td - %label Produit : - %input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)} +-if true + #p_sheet_line.product_stock_form.field.p_sheet_line_field{:id => form.object.id} + + -if form.object.lock != true + =link_to_remove_fields ic(:"trash-o"), form + + %label Produit : + %input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)} + + + = form.hidden_field :p_product_id, :class => "p_product_id" + + :javascript + $( function() { + + $('.p_product_autocomplete_input').autocomplete({ + source: function( request, response ) { + $.ajax( { + url: "/admin/p_products/autocomplete.json", + dataType: "json", + data: { + search: request.term + }, + success: function(data){ + + arr = jQuery.map( data, function( item ) { + return { + label: item.code+" "+item.name, + value: item.code+" "+item.name, + id: item.id + } + }); + + response(arr) + + } + + } ); + }, + minLength: 2, + select: function( event, ui ) { + + $(this).next(".p_product_id").val(ui.item.id) + + //return false + } + }); + + + + } ); + + + + + + + + + -p_product = form.object.p_product if form.object.p_product + %table.table.order_table + %tr + %th + + + + + -if form.object.p_product + + -p_product.p_sizes.all.each do |p_size| + %th.size_th + =p_size.name + + %th.price_td PU + %th.price_td + Prix tot. + -if form.object.p_product + -p_product.p_colors.all.each do |p_color| + %tr.color_line + %td=p_color.name + + -p_product.p_sizes.all.each do |p_size| + %td + -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first + + -if ps + -p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock_id => ps.id).first + -if p_sheet_line_line + =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| + =builder.hidden_field :p_product_stock_id,:label => false, :as => :string + =builder.input :qte,:label => false, :as => :string, :input_html => {:class => "qte"} + + %td.price.price_td{:data => {:price => form.object.price}} + =number_to_currency form.object.price + + %td.price_color_tot.price_td + + -if form.object.p_product + %table{:style => "width:100%"} + + + + %tr + + %td +   + %td.qte_tot.price_td{:style => "font-weight:bold;"} + %strong=form.object.qte + + %td.price.price_td{:style => "font-weight:bold;", :data => {:price => form.object.price}} + %strong=number_to_currency form.object.price + + + %td.price_tot.price_td{:style => "font-weight:bold;"} + =number_to_currency form.object.price_tot + %br + +-if false + .product_stock_form.field + %hr + %table{:style => "width:100%;"} + %tr + %td + %label Produit : + %input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)} - = form.hidden_field :p_product_id, :class => "p_product_id" + = form.hidden_field :p_product_id, :class => "p_product_id" - :javascript - $( function() { + :javascript + $( function() { - $('.p_product_autocomplete_input').autocomplete({ - source: function( request, response ) { - $.ajax( { - url: "/admin/p_products/autocomplete.json", - dataType: "json", - data: { - search: request.term - }, - success: function(data){ + $('.p_product_autocomplete_input').autocomplete({ + source: function( request, response ) { + $.ajax( { + url: "/admin/p_products/autocomplete.json", + dataType: "json", + data: { + search: request.term + }, + success: function(data){ - arr = jQuery.map( data, function( item ) { - return { - label: item.code+" "+item.name, - value: item.code+" "+item.name, - id: item.id - } - }); + arr = jQuery.map( data, function( item ) { + return { + label: item.code+" "+item.name, + value: item.code+" "+item.name, + id: item.id + } + }); - response(arr) + response(arr) - } + } - } ); - }, - minLength: 2, - select: function( event, ui ) { + } ); + }, + minLength: 2, + select: function( event, ui ) { - $(this).next(".p_product_id").val(ui.item.id) + $(this).next(".p_product_id").val(ui.item.id) - //return false - } - }); + //return false + } + }); - } ); + } ); - %td - -if form.object.p_product + %td + -if form.object.p_product - -p_product = form.object.p_product + -p_product = form.object.p_product - %table.table - %tr - %th Taille - %th Couleur - %th Qte - -s = "a" - -si = 1 + %table.table + %tr + %th Taille + %th Couleur + %th Qte + -s = "a" + -si = 1 - -if true - -p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps| + -if true + -p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps| - -si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count() + -si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count() - %tr - -if ps.p_size_id != s - -s = ps.p_size_id + %tr + -if ps.p_size_id != s + -s = ps.p_size_id - %td{:rowspan => si} - =si - =ps.p_size.name if ps.p_size + %td{:rowspan => si} + =si + =ps.p_size.name if ps.p_size - %td - =ps.p_color.name if ps.p_color + %td + =ps.p_color.name if ps.p_color - %td - -p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock => ps.id).first + %td + -p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock => ps.id).first - =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| - =builder.input :qte,:label => false, :as => :string + =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| + =builder.input :qte,:label => false, :as => :string - -if form.object.lock != true - =link_to_remove_fields ic(:"trash-o"), form \ No newline at end of file + \ No newline at end of file diff --git a/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml b/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml index 6e542dd..d7fb661 100644 --- a/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml +++ b/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml @@ -8,9 +8,9 @@ %th Description %th - Taille + %th - Couleur + %th Qte %th @@ -25,45 +25,77 @@ -p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0") -nbr_lines = p_sheet_line_lines.count -ok = true if sheet_line.shiped - %tr.sheet_line_head - - %td - =sheet_line.product_name - - %td - %td - - + + + %tr + %td{:colspan => 3, :style => "text-align:right;"} + %table.size_table + %tr + %th{:style => "text-align:left !important;"} + =sheet_line.product_name + fdfd + + -p_sheet_line_lines.group(:p_size_id).uniq.each do |psize| + %th.p_size_td=psize.p_size.name + + + %td{:colspan => 4} + -p_sheet_line_lines.group(:p_color_id).uniq.each do |pc| + -qte_tot = 0.0 + %tr + %td{:colspan => 3, :style => "text-align:right;"} + %table.size_table + + + + + %tr + %td + =pc.p_color.name + + -p_sheet_line_lines.group(:p_size_id).uniq.each do |psize| + + %td.p_size_td + -psl = p_sheet_line_lines.where(:p_size_id => psize.p_size_id, :p_color_id => pc.p_color_id ).first + -if psl + =psl.qte + -qte_tot += psl.qte + + + %td{} + =qte_tot.to_i + %td + =number_to_currency sheet_line.price.to_f + %td + =number_to_currency sheet_line.price.to_f * qte_tot.to_i + + %td + =number_to_currency sheet_line.price.to_f * (sheet_line.tva.to_f+1) * qte_tot.to_i + + %tr.tr_sheet_line_head + + %td + + + %td + %td + + + %td =sheet_line.qte - + %td =number_to_currency sheet_line.price if sheet_line.price - + %td =number_to_currency sheet_line.price_tot if sheet_line.price_tot - + %td =number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc - - - -p_sheet_line_lines.each do |p_sheet_line_line| - %tr - - %td - - %td - =p_sheet_line_line.p_size.name if p_sheet_line_line.p_size - %td - =p_sheet_line_line.p_color.name if p_sheet_line_line.p_color - %td - =p_sheet_line_line.qte - - %td - %td - %td - + + -total_with_labels = PSheetLine.total_with_labels(sheet_lines) -total_with_labels.each do |index, total| @@ -75,8 +107,26 @@ =total[:label] %td =number_to_currency total[:value] - - + + -if @p_document and @p_document.label == "Facture Acompte" + %tr + %td{:style => "text-align:right;padding-right:10px;", :colspan =>6} + Pourcentage d'acompte : + %td + =@p_document.acompte_percent.to_s+"%" + %tr + %td{:style => "text-align:right;padding-right:10px;", :colspan =>6} + Acompte HT : + %td + =number_to_currency @p_document.total_with_labels_table[:total][:value] * (@p_document.acompte_percent.to_f/100) + + %tr.sheet_line_head + %td{:style => "text-align:right;padding-right:10px;", :colspan =>6} + %strong Acompte TTC : + %td + %strong=number_to_currency @p_document.total_with_labels_table[:total_ttc][:value] * (@p_document.acompte_percent.to_f/100) + + :scss .sheet_line_head{ @@ -85,6 +135,16 @@ } } + + + .tr_sheet_line_head{ + td, th{ + border:0; + border-bottom: 1px solid rgba(0,0,0,0.5) !important; + } + + } + .marges{ td{ vertical-align:top; @@ -93,4 +153,22 @@ + } + + .size_table{ + width:97%; + + text-align:center; + margin-right:3%; + td,th{ + text-align:right; + border:0; + border-right:solid 1px rgba(0,0,0,0.1) !important; + padding:0 3px; + } + .p_size_td{ + width:60px; + text-align:center; + } + } \ No newline at end of file diff --git a/app/views/general_mailer/send_qi_mail.html.haml b/app/views/general_mailer/send_qi_mail.html.haml new file mode 100644 index 0000000..de4a378 --- /dev/null +++ b/app/views/general_mailer/send_qi_mail.html.haml @@ -0,0 +1 @@ +=mail_content(@mail_content, @lang_slug, @options) \ No newline at end of file diff --git a/app/views/public/p_orders/_cart_totals.html.haml b/app/views/public/p_orders/_cart_totals.html.haml new file mode 100644 index 0000000..d0c49bd --- /dev/null +++ b/app/views/public/p_orders/_cart_totals.html.haml @@ -0,0 +1,15 @@ +-total_with_labels = @p_customer_sheet.total_with_labels_table + + + +%table{:style => "width:100%;"} + -total_with_labels.each do |index, total| + + + %tr + %td{:style => "text-align:right;"} + %strong + =total[:label] + %td.price_td + =number_to_currency total[:value] + \ No newline at end of file diff --git a/app/views/public/p_orders/cart.html.haml b/app/views/public/p_orders/cart.html.haml index 3856600..8113c44 100644 --- a/app/views/public/p_orders/cart.html.haml +++ b/app/views/public/p_orders/cart.html.haml @@ -9,53 +9,19 @@ .qi_row .qi_pannel.qi_plain.padding - =semantic_form_for [:public, @p_customer_sheet],:url => update_cart_public_p_orders_path(), :html => { :method => :post, :onchange =>""}, :remote => false do |form| + =semantic_form_for [:public, @p_customer_sheet],:url => update_cart_public_p_orders_path(), :html => { :method => :post, :onchange =>"", :id => "cart_form"}, :remote => true do |form| .p_sheet_lines_form =form.semantic_fields_for :p_sheet_lines do |form| - #p_sheet_line.product_stock_form.field{:id => form.object.id} - %hr - %table{:style => "width:100%"} - %tr - %th Produit : - - %th{:style => "width:15px;"} - Quantité - - %th - Prix U - - %th - Prix Tot - - %th{:style => "width:15px;"} - %tr - %td + #p_sheet_line.product_stock_form.field.p_sheet_line_field{:id => form.object.id} - =form.object.p_product.name + + + - - - - - - - - - - %td.qte - =form.object.qte - %td.price - =number_to_currency form.object.price - - %td.price_tot - =number_to_currency form.object.price_tot - - %td - =link_to_remove_fields ic(:"trash-o"), form @@ -67,39 +33,61 @@ -p_product = form.object.p_product - - %table.table + + %table.table.order_table %tr - %th Taille - %th Couleur - %th Qte - -s = "a" - -si = 1 - - - -if true - -p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps| - - -si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count() - - %tr - -if ps.p_size_id != s - -s = ps.p_size_id - - %td{:rowspan => si} - =si - =ps.p_size.name if ps.p_size - + %th + =form.object.p_product.name + =link_to_remove_fields ic(:"trash-o"), form + + -p_product.p_sizes.all.each do |p_size| + %th.size_th + =p_size.name + + %th.price_td PU + %th.price_td + Prix tot. + + -p_product.p_colors.all.each do |p_color| + %tr.color_line + %td=p_color.name + + -p_product.p_sizes.all.each do |p_size| %td - =ps.p_color.name if ps.p_color - - %td - -p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock => ps.id).first - - =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| - =builder.input :qte,:label => false, :as => :string, :input_html => {:maxlength => 10} - - + -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first + + -if ps + -p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock_id => ps.id).first + -if p_sheet_line_line + =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| + =builder.hidden_field :p_product_stock_id,:label => false, :as => :string + =builder.input :qte,:label => false, :as => :string, :input_html => {:class => "qte"} + + %td.price.price_td{:data => {:price => form.object.price}} + =number_to_currency form.object.price + + %td.price_color_tot.price_td + + + %table{:style => "width:100%"} + + + + %tr + + %td +   + %td.qte_tot.price_td{:style => "font-weight:bold;"} + %strong=form.object.qte + + %td.price.price_td{:style => "font-weight:bold;", :data => {:price => form.object.price}} + %strong=number_to_currency form.object.price + + + %td.price_tot.price_td{:style => "font-weight:bold;"} + =number_to_currency form.object.price_tot + %br + @@ -107,33 +95,17 @@ - %p - %strong Totaux + - - -total_with_labels = form.object.total_with_labels_table - - - - %table{:style => "width:100%;"} - -total_with_labels.each do |index, total| - - - %tr - %td{:style => "text-align:right;"} - %strong - =total[:label] - %td.price_td - =number_to_currency total[:value] - + #cart_totals=render :partial => "cart_totals" %hr - =form.submit "sauvegarder", :class => "btn btn-primary" + =#form.submit "sauvegarder", :class => "btn btn-primary" - =link_to "Suivant", particulars_public_p_orders_path + =link_to "Suivant", particulars_public_p_orders_path, :class => "btn btn-primary" :scss @@ -161,4 +133,22 @@ margin-bottom:0} } - } \ No newline at end of file + } + +:scss + .size_th{ + width:80px; + + } + +:coffeescript + + + udpate_sheet_lines() + + $("#cart_form").change -> + udpate_sheet_lines() + $(this).submit() + $("#cart_form").keyup -> + udpate_sheet_lines() + $(this).submit() diff --git a/app/views/public/p_orders/update_cart.js.erb b/app/views/public/p_orders/update_cart.js.erb new file mode 100644 index 0000000..c676d3a --- /dev/null +++ b/app/views/public/p_orders/update_cart.js.erb @@ -0,0 +1 @@ +$('#cart_totals').html("<%= escape_javascript(render(:partial => "cart_totals"))%>"); diff --git a/app/views/public/p_products/show.html.haml b/app/views/public/p_products/show.html.haml index 32221cd..8cfe56f 100644 --- a/app/views/public/p_products/show.html.haml +++ b/app/views/public/p_products/show.html.haml @@ -56,39 +56,70 @@ -p_product = form.object.p_product - %table.table.order_table - %tr - %th Taille - %th Couleur - %th Qte - -s = "a" - -si = 1 + -if false + %table.table.order_table + %tr + %th Taille + %th Couleur + %th Qte + -s = "a" + -si = 1 - -if true - -p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps| + -if true + -p_product.p_product_stocks.order("p_size_id ASC, p_color_id ASC").each do |ps| - -si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count() + -si = p_product.p_product_stocks.where(:p_size_id => ps.p_size_id).count() - %tr - -if ps.p_size_id != s - -s = ps.p_size_id + %tr + -if ps.p_size_id != s + -s = ps.p_size_id - %td{:rowspan => si} + %td{:rowspan => si} - =ps.p_size.name if ps.p_size + =ps.p_size.name if ps.p_size - %td - =ps.p_color.name if ps.p_color + %td + =ps.p_color.name if ps.p_color - %td - -p_sheet_line_line = @p_sheet_line.p_sheet_line_lines.new(:p_product_stock_id => ps.id) + %td + -p_sheet_line_line = @p_sheet_line.p_sheet_line_lines.new(:p_product_stock_id => ps.id) - =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| - =builder.hidden_field :p_product_stock_id,:label => false, :as => :string - =builder.input :qte,:label => false, :as => :string + =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| + =builder.hidden_field :p_product_stock_id,:label => false, :as => :string + =builder.input :qte,:label => false, :as => :string + + + + %table.table.order_table + %tr + %th + -p_product.p_sizes.all.each do |p_size| + %th.size_th + =p_size.name + + -p_product.p_colors.all.each do |p_color| + %tr + %td=p_color.name + + -p_product.p_sizes.all.each do |p_size| + %td + -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first + + -if ps + -p_sheet_line_line = @p_sheet_line.p_sheet_line_lines.new(:p_product_stock_id => ps.id) + + =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder| + =builder.hidden_field :p_product_stock_id,:label => false, :as => :string + =builder.input :qte,:label => false, :as => :string + =form.submit "Commander", :class => "btn btn-primary" +:scss + .size_th{ + width:80px; + + } diff --git a/config/environments/development.rb b/config/environments/development.rb index 0d8cc37..a09af37 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -44,11 +44,11 @@ Rails.application.configure do #config.action_mailer.delivery_method = :file config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } + config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 1025 } config.action_mailer.default_url_options = { :host => HOSTNAME } Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'http' } - ANGORA_HOSTNAME = "angora.local:3000" + end diff --git a/config/nginx.conf b/config/nginx.conf index 8e1bf81..d99f7d7 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -4,7 +4,7 @@ upstream coton_app_unicorn { server { listen [::]:80; - server_name 3p.quartz.xyz ; + server_name biocoton.quartz.xyz ; root /srv/www/web/coton_app/current/public; try_files $uri/index.html $uri @unicorn; @@ -24,8 +24,8 @@ server { server { listen [::]:80; - server_name www.3p.quartz.xyz; - rewrite ^(.*) http://3p.quartz.xyz$1 permanent; + server_name www.biocoton.quartz.xyz; + rewrite ^(.*) http://biocoton.quartz.xyz$1 permanent; } diff --git a/config/routes.rb b/config/routes.rb index db794aa..299c6e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -192,6 +192,7 @@ Rails.application.routes.draw do member do get :generate_d get :generate_fp + get :generate_fa get :generate_bc get :generate_bl get :generate_f diff --git a/db/migrate/20181217084852_create_p_box_fdps.rb b/db/migrate/20181217084852_create_p_box_fdps.rb new file mode 100644 index 0000000..b6307bd --- /dev/null +++ b/db/migrate/20181217084852_create_p_box_fdps.rb @@ -0,0 +1,18 @@ +class CreatePBoxFdps < ActiveRecord::Migration + def change + create_table :p_box_fdps do |t| + t.references :p_product, index: true, foreign_key: true + t.references :p_sheet_line + t.integer :p_product_archived_id + t.decimal :nbr_el, precision: 10, scale: 2 + t.decimal :nbr_in_box, precision: 10, scale: 2 + t.integer :qte + t.decimal :price, precision: 10, scale: 2 + t.text :notes + t.integer :element_id + t.string :element_type + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20181217085735_add_fdp_force_price_to_p_customer_sheets.rb b/db/migrate/20181217085735_add_fdp_force_price_to_p_customer_sheets.rb new file mode 100644 index 0000000..1699b1f --- /dev/null +++ b/db/migrate/20181217085735_add_fdp_force_price_to_p_customer_sheets.rb @@ -0,0 +1,5 @@ +class AddFdpForcePriceToPCustomerSheets < ActiveRecord::Migration + def change + add_column :p_customer_sheets, :fdp_force_price, :decimal, precision: 10, scale: 2 + end +end diff --git a/db/migrate/20181217085809_add_fdp_force_price_to_p_documents.rb b/db/migrate/20181217085809_add_fdp_force_price_to_p_documents.rb new file mode 100644 index 0000000..ef62e4b --- /dev/null +++ b/db/migrate/20181217085809_add_fdp_force_price_to_p_documents.rb @@ -0,0 +1,5 @@ +class AddFdpForcePriceToPDocuments < ActiveRecord::Migration + def change + add_column :p_documents, :fdp_force_price, :decimal, precision: 10, scale: 2 + end +end diff --git a/db/migrate/20181217112205_add_acompte_to_p_documents.rb b/db/migrate/20181217112205_add_acompte_to_p_documents.rb new file mode 100644 index 0000000..b5e67c2 --- /dev/null +++ b/db/migrate/20181217112205_add_acompte_to_p_documents.rb @@ -0,0 +1,6 @@ +class AddAcompteToPDocuments < ActiveRecord::Migration + def change + add_column :p_documents, :acompte_percent, :decimal, precision: 10, scale: 2 + add_column :p_documents, :acompte_value, :decimal, precision: 10, scale: 2 + end +end diff --git a/db/schema.rb b/db/schema.rb index 11eb4de..a696df9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20181126002517) do +ActiveRecord::Schema.define(version: 20181217112205) do create_table "admin_admin_roles", force: :cascade do |t| t.integer "admin_id", limit: 4 @@ -706,6 +706,23 @@ ActiveRecord::Schema.define(version: 20181126002517) do t.datetime "updated_at" end + create_table "p_box_fdps", force: :cascade do |t| + t.integer "p_product_id", limit: 4 + t.integer "p_sheet_line_id", limit: 4 + t.integer "p_product_archived_id", limit: 4 + t.decimal "nbr_el", precision: 10, scale: 2 + t.decimal "nbr_in_box", precision: 10, scale: 2 + t.integer "qte", limit: 4 + t.decimal "price", precision: 10, scale: 2 + t.text "notes", limit: 65535 + t.integer "element_id", limit: 4 + t.string "element_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "p_box_fdps", ["p_product_id"], name: "index_p_box_fdps_on_p_product_id", using: :btree + create_table "p_certifs", force: :cascade do |t| t.string "name", limit: 255 t.text "description", limit: 65535 @@ -781,6 +798,7 @@ ActiveRecord::Schema.define(version: 20181126002517) do t.boolean "paid", default: false t.datetime "paid_at" t.integer "p_price_cat_id", limit: 4 + t.decimal "fdp_force_price", precision: 10, scale: 2 end add_index "p_customer_sheets", ["p_payment_type_id"], name: "index_p_customer_sheets_on_p_payment_type_id", using: :btree @@ -894,6 +912,9 @@ ActiveRecord::Schema.define(version: 20181126002517) do t.datetime "theo_paid_at" t.boolean "paid", default: false t.datetime "paid_at" + t.decimal "fdp_force_price", precision: 10, scale: 2 + t.decimal "acompte_percent", precision: 10, scale: 2 + t.decimal "acompte_value", precision: 10, scale: 2 end create_table "p_eps", force: :cascade do |t| @@ -1549,6 +1570,7 @@ ActiveRecord::Schema.define(version: 20181126002517) do add_foreign_key "mail_contents", "mail_types" add_foreign_key "menu_item_langs", "image_files" add_foreign_key "menu_item_langs", "lang_sites" + add_foreign_key "p_box_fdps", "p_products" add_foreign_key "p_customer_sheets", "p_payment_types" add_foreign_key "p_customer_sheets", "p_price_cats" add_foreign_key "p_customers", "p_price_cats" diff --git a/test/fixtures/p_box_fdps.yml b/test/fixtures/p_box_fdps.yml new file mode 100644 index 0000000..ad91449 --- /dev/null +++ b/test/fixtures/p_box_fdps.yml @@ -0,0 +1,23 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + p_product_id: + p_product_archived_id: 1 + nbr_el: 9.99 + nbr_in_box: 9.99 + qte: 1 + price: 9.99 + notes: MyText + element_id: 1 + element_type: MyString + +two: + p_product_id: + p_product_archived_id: 1 + nbr_el: 9.99 + nbr_in_box: 9.99 + qte: 1 + price: 9.99 + notes: MyText + element_id: 1 + element_type: MyString diff --git a/test/models/p_box_fdp_test.rb b/test/models/p_box_fdp_test.rb new file mode 100644 index 0000000..ea30d4a --- /dev/null +++ b/test/models/p_box_fdp_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PBoxFdpTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end