From 398cf587bed8b5b4e2a60f530b132bef3be18a12 Mon Sep 17 00:00:00 2001 From: Philippe Date: Tue, 16 Nov 2021 18:03:15 +0100 Subject: [PATCH] Auto stash before checking out "HEAD" --- .../admin/price_documents_controller.rb | 7 +- app/controllers/application_controller.rb | 14 +-- app/helpers/translation_helper.rb | 60 +++++++----- app/models/p_customer_sheet.rb | 81 +++++++++++----- app/models/p_product_ref.rb | 4 +- app/models/particular.rb | 19 ++++ app/models/price_document.rb | 12 +-- app/models/price_line_block.rb | 71 +++++++------- .../admin/accounting_zones/_form.html.haml | 5 +- .../admin/admin_permissions/_form.html.haml | 5 +- app/views/admin/admin_roles/_form.html.haml | 4 +- app/views/admin/import_csvs/_form.html.haml | 4 +- .../admin/line_stock_usages/_form.html.haml | 4 +- app/views/admin/line_stocks/_form.html.haml | 4 +- app/views/admin/mail_hists/_form.html.haml | 6 +- .../p_article_serial_nums/_form.html.haml | 5 +- app/views/admin/p_articles/_form.html.haml | 3 +- .../admin/p_commercial_cats/_form.html.haml | 4 +- app/views/admin/p_commercials/_form.html.haml | 13 +-- .../admin/p_customer_cats/_form.html.haml | 9 +- .../_p_customer_sheet.html.haml | 8 +- .../admin/p_customer_sheets/index.html.haml | 9 +- .../admin/p_customer_sheets/show.html.haml | 10 +- app/views/admin/p_customers/show.html.haml | 24 ++++- app/views/admin/p_devises/_form.html.haml | 5 +- app/views/admin/p_documents/_form.html.haml | 4 +- app/views/admin/p_grades/_form.html.haml | 9 +- .../admin/p_product_cats/_form.html.haml | 4 +- .../admin/p_product_zones/_form.html.haml | 4 +- .../admin/p_serial_num_types/_form.html.haml | 4 +- .../admin/particulars/_large_form.html.haml | 4 +- app/views/admin/partitions/_form.html.haml | 11 +-- .../price_documents/_form_avoir.html.haml | 5 +- .../price_documents/_price_document.html.haml | 2 +- .../admin/price_documents/show.html.haml | 33 +++++-- .../admin/price_line_blocks/_form.html.haml | 2 +- app/views/admin/price_lines/_form.html.haml | 96 ++++++++++++++----- .../admin/price_lines/_form_old.html.haml | 1 - .../_reponse_pane_hover_form.html.haml | 57 +---------- app/views/admin/price_lines/edit.js.erb | 2 +- app/views/admin/s_brands/_form.html.haml | 8 +- .../admin/stock_movements/_form.html.haml | 12 +-- app/views/admin/tva_rates/_form.html.haml | 5 +- ...115181445_add_br_ok_to_price_line_block.rb | 5 + ...d_particular_infos_to_p_custommer_sheet.rb | 6 ++ db/schema.rb | 5 +- 46 files changed, 378 insertions(+), 291 deletions(-) create mode 100644 db/migrate/20211115181445_add_br_ok_to_price_line_block.rb create mode 100644 db/migrate/20211116144749_add_particular_infos_to_p_custommer_sheet.rb diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 4e02801..3840432 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -701,7 +701,9 @@ class Admin::PriceDocumentsController < ApplicationController @p_customer_sheet = @past_price_document.ref_element if @p_customer_sheet - price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) + price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), + :demande_de_prix_id => @past_price_document.id, + :date => Date.today) else price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today) end @@ -743,7 +745,9 @@ class Admin::PriceDocumentsController < ApplicationController new_pl.qte = new_pl.qte - qte_ok end + new_pl.p_articles = pl.p_articles price_document.price_line_block.price_lines << new_pl + price_document.price_line_block.br_ok = true end if price_document.save @@ -770,6 +774,7 @@ class Admin::PriceDocumentsController < ApplicationController @p_customer_sheet = @past_price_document.ref_element if @p_customer_sheet + price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Facture achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) else diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dddda40..05e0c17 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -118,8 +118,8 @@ class ApplicationController < ActionController::Base end if current_admin.has_permission?("boutique") - set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_colors, "Couleurs" - set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_article_serial_nums, "Numeros série" + # set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_colors, "Couleurs" + #set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_article_serial_nums, "Numeros série" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_serial_num_types, "Types de Numero série" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_ref_specs, "Specs" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_types, "Types de specs" @@ -128,9 +128,9 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csvs, "Import Excel" - set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csv_match_refs, "Rapprochement références", match_refs_admin_import_csvs_path - set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_cats, "Catégories SORECOP" - set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_taxes, "taxe SORECOP" + # set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csv_match_refs, "Rapprochement références", match_refs_admin_import_csvs_path + # set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_cats, "Catégories SORECOP" + # set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_taxes, "taxe SORECOP" end @@ -143,7 +143,7 @@ class ApplicationController < ActionController::Base set_sub_menu :ventes, :p_customer_sheets, "Demande de commande", admin_p_customer_sheets_path - if false + #if false PriceDocumentType.where(:label => PriceDocument::SALES).order("id DESC").all.each do |p_document_type| set_sub_menu :ventes, :"p_document_type_#{p_document_type.label.to_s.to_slug}", p_document_type.label, admin_price_documents_path(:price_document_type_id => p_document_type.id) @@ -151,7 +151,7 @@ class ApplicationController < ActionController::Base end set_sub_menu :ventes, :price_documents_all, "Tous documents", admin_price_documents_path - end + #end diff --git a/app/helpers/translation_helper.rb b/app/helpers/translation_helper.rb index a608c96..068f0ab 100755 --- a/app/helpers/translation_helper.rb +++ b/app/helpers/translation_helper.rb @@ -46,31 +46,45 @@ module TranslationHelper def state_helper(value) value = value.to_s - if ["brouillon","Reçue", "Panier web", "AV BPA"].include?(value) - r = ''+value+'' - elsif ["Virement envoyé", "Validé"].include?(value) - r = ''+value+'' - elsif value == "commande" or value == "Commande" or value == "Réglée" or value == "PAS BPA" - r = ''+value+'' - elsif value == "En cours d'expédition" or value == "Expédiée" or value == "BPA" - r = ''+value+'' - elsif ["Virement demandé"].include?(value) - r = ''+value+'' - elsif value =="Livrée" - r = ''+value+'' - elsif value == "annulée" - r = ''+value+'' - elsif ["Erreur sur virement", "Refusé", "Refusée","refusée"].include?(value) - r = ''+value+'' - elsif ["En cours de traitement"].include?(value) - r = ''+value+'' + # if ["Brouillon", "Validée", "Préparation", "Livraison", "Réceptionné", "Payé"].include?(value) + # r = ''+value+'' + # elsif ["Virement envoyé", "Validé"].include?(value) + # r = ''+value+'' + # elsif value == "commande" or value == "Commande" or value == "Réglée" or value == "PAS BPA" + # r = ''+value+'' + # elsif value == "En cours d'expédition" or value == "Expédiée" or value == "BPA" + # r = ''+value+'' + # elsif ["Virement demandé"].include?(value) + # r = ''+value+'' + # elsif value =="Livrée" + # r = ''+value+'' + # elsif value == "annulée" + # r = ''+value+'' + # elsif ["Erreur sur virement", "Refusé", "Refusée","refusée"].include?(value) + # r = ''+value+'' + # elsif ["En cours de traitement"].include?(value) + # r = ''+value+'' - elsif ["Disponible en boutique", "Disponible en point retrait"].include?(value) - r = ''+value+'' - else - r = ''+value+'' + # elsif ["Disponible en boutique", "Disponible en point retrait"].include?(value) + # r = ''+value+'' + # else + # r = ''+value+'' + # end + + if value == "Brouillon" + r = ''+value+'' + elsif value == "Validée" + r = ''+value+'' + elsif value == "Préparation" + r = ''+value+'' + elsif value == "Livraison" + r = ''+value+'' + elsif value == "Réceptionné" + r = ''+value+'' + elsif value == "Payé" + r = ''+value+'' end - + return raw(r) end diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 19358f0..f3e4801 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -25,7 +25,7 @@ class PCustomerSheet < ApplicationRecord has_many :price_documents, :as => :ref_element - acts_as_caching :fields => %w(weight_tot com_counter accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva payment_days payment_delais payment_month_end payment_end_at ) + acts_as_caching :fields => %w(weight_tot com_counter accounting_zone_id accounting_zone_name tot_amount_ht tot_amount_ttc tot_amount_tva payment_days payment_delais payment_month_end payment_end_at particular_infos) acts_as_sorting :fields => { @@ -35,9 +35,10 @@ class PCustomerSheet < ApplicationRecord :d_number => {:name => "N° BC", :reorder => false}, :created_at => {:name => "Date", :reorder => true, :sort_name => "p_customer_sheets.created_at"}, :admin_id => {:name => "Déposée par", :reorder => true}, - :wish_date => {:name => "Semaine de livraison", :reorder => true, :sort_name => "price_line_blocks.wish_date"}, - :wish_date_2 => {:name => "Date de livraison souhaitée ", :reorder => true, :sort_name => "price_line_blocks.wish_date"}, + #:wish_date => {:name => "Semaine de livraison", :reorder => true, :sort_name => "price_line_blocks.wish_date"}, + #:wish_date_2 => {:name => "Date de livraison souhaitée ", :reorder => true, :sort_name => "price_line_blocks.wish_date"}, :p_customer => {:name => "Client", :reorder => false, :member_label => :show_name, :as => :ref_link}, + :particular_infos => {:name => "Client final", :reorder => false}, :tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"}, :tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"}, :state => {:name => "Statut", :reorder => false, :as => :state}, @@ -46,8 +47,8 @@ class PCustomerSheet < ApplicationRecord } # STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"] - STATES = ["AV BPA", "PAS BPA","BPA", "Traitée"] - + # STATES = ["AV BPA", "PAS BPA","BPA", "Traitée"] + STATES = ["Brouillon", "Validée", "Préparation", "Livraison", "Réceptionné", "Payé"] def personalised_archive self.price_line_block.archive_now @@ -106,6 +107,9 @@ class PCustomerSheet < ApplicationRecord end + def ca_particular_infos + self.price_line_block.particular_bill.organisation + self.price_line_block.particular_bill.firstname + self.price_line_block.particular_bill.name + end def ca_com_counter @@ -237,17 +241,17 @@ class PCustomerSheet < ApplicationRecord def state_html if self.state == "Panier web" 'Panier web' - elsif self.state == "brouillon" + elsif self.state == "Brouillon" ''+self.demande_type.to_s+'' elsif self.state == "offre" 'Offre' - elsif self.state == "commande" + elsif self.state == "Validée" 'Commande' - elsif self.state == "en livraison" + elsif self.state == "Livraison" 'En livraison' elsif self.state == "livrée" 'livrée' - elsif self.state =="facturée" + elsif self.state =="Payée" 'Facturée' elsif self.state == "annulée" 'Annulée' @@ -260,7 +264,7 @@ class PCustomerSheet < ApplicationRecord after_create do - self.state = "brouillon" if self.state != "Panier web" + self.state = "Brouillon" if self.state != "Panier web" self.save end @@ -268,29 +272,54 @@ class PCustomerSheet < ApplicationRecord def generate_doc(label, state) self.archive_now if !self.archived self.block_price if !self.price_blocked - self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1) + + puts "TVA TYPE IDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2).empty? + puts !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2).empty? + puts "TVA TYPE IDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" + + if !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 1).empty? price_document_standard_tva = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today, :tva_type_id => 1) price_document_standard_tva.p_customer = self.p_customer price_document_standard_tva.price_line_block = self.price_line_block.dup price_document_standard_tva.price_line_block.ac_block_type = nil - + self.price_line_block.price_lines.each do |pl| if !pl.p_articles.where(tva_type_id: 1).empty? + new_pl = pl.dup new_pl.ac_block_type = nil + puts "PARTICLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + puts "PARTICLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + puts "PARTICLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + puts pl.p_articles.where(tva_type_id: 1) pl.p_articles.where(tva_type_id: 1).each { |p_article| new_pl.p_articles << p_article } + puts "PARTICLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + puts "PARTICLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + puts "PARTICLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + + + raise price_document_standard_tva.price_line_block.price_lines << new_pl end end + + if price_document_standard_tva.save + price_document_standard_tva.archive_now + self.state = state + self.save + end end - if price_document_standard_tva.save - price_document_standard_tva.archive_now - self.state = state - self.save - end + if !self.price_line_block.price_lines.joins(:p_articles).where("p_articles.tva_type_id = ?", 2).empty? price_document_sur_marge_tva = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today, :tva_type_id => 2) @@ -306,13 +335,15 @@ class PCustomerSheet < ApplicationRecord price_document_sur_marge_tva.price_line_block.price_lines << new_pl end end + + if price_document_sur_marge_tva.save + price_document_sur_marge_tva.archive_now + self.state = state + self.save + end end - if price_document_sur_marge_tva.save - price_document_sur_marge_tva.archive_now - self.state = state - self.save - end + # price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today) # price_document.p_customer = self.p_customer @@ -349,19 +380,19 @@ class PCustomerSheet < ApplicationRecord def generate_bc - generate_doc("Bon de commande client", "commande") + generate_doc("Bon de commande client", "Validée") end def generate_bl() - generate_doc("Bon de livraison", "en livraison") + generate_doc("Bon de livraison", "Livraison") end def generate_f() - generate_doc("Facture", "facturée") + generate_doc("Facture", "Payé") end diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 6da7f5f..e79a790 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -51,8 +51,8 @@ class PProductRef < ApplicationRecord :ct_price_ht => {:name => "Prix de vente", :as => :currency}, :ean => {:name => "EAN"}, :deee => {:name => "DEEE", :as => :currency}, - :sorecop => {:name => "Sorecop", :as => :currency}, - :sorecop_comment => {:name => "Commentaire Sorecop"}, + # :sorecop => {:name => "Sorecop", :as => :currency}, + # :sorecop_comment => {:name => "Commentaire Sorecop"}, :actions => {:name => "Actions", :reorder => false} } diff --git a/app/models/particular.rb b/app/models/particular.rb index 9fbe2bd..ca23dfe 100644 --- a/app/models/particular.rb +++ b/app/models/particular.rb @@ -21,6 +21,25 @@ class Particular < ApplicationRecord attr_accessor :validate_email, :skip_email belongs_to :particular_ref, :class_name => "Particular" + + + + def self.qi_table_order + { + :created_at => {:name => "Date de création", :reorder => true, :as => :date}, + :organisation => {:name => "Raison sociale", :reorder => true}, + :name => {:name => "Nom", :reorder => true}, + :firstname => {:name => "Prénom", :reorder => true}, + :address_1 => {:name => "Adresse", :reorder => true}, + :address_2 => {:name => "Adresse", :reorder => true}, + :city => {:name => "Ville", :reorder => true}, + :country => {:name => "Pays", :reorder => true}, + :actions => {:name => "Actions", :reorder => false} + } + #, :sort_name => "code" + end + + def validate_pro true if self.force_validation and self.pro end diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 4f47d8e..582ffb6 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -6,7 +6,7 @@ class PriceDocument < ApplicationRecord belongs_to :p_devise belongs_to :p_payment_type belongs_to :tva_type - + validates :tva_type, :presence => true has_one :p_compta_element, :dependent => :destroy, :as => :element @@ -21,13 +21,12 @@ class PriceDocument < ApplicationRecord has_many :p_payments, :through => :p_payment_documents has_many :line_stocks, :as => :stockable - has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument" accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true #PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture achat", "Consultation fournisseur"] - PURCHASES = ["Facture achat"] - SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] + PURCHASES = ["Facture achat", "Bon de réception achat"] + SALES = ["Devis", "Avoir", "Facture", "Bon de livraison", "Bon de commande"] # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] @@ -282,7 +281,7 @@ class PriceDocument < ApplicationRecord :com_counter => {:name => "N° Offre", :reorder => false}, :label => {:name => "Type", :reorder => false}, :stock_ok => {:name => "Stock mis à jour ?", :reorder => true}, - :tva_type_name => {:name => "ID Type de TVA", :reorder => true}, + #:tva_type_name => {:name => "Type de TVA", :reorder => true}, #:package_number => {:name => "Nombre de colis", :reorder => true}, :d_number => {:name => "Numéro", :reorder => true}, :date => {:name => "Date", :reorder => true}, @@ -444,9 +443,10 @@ class PriceDocument < ApplicationRecord last_dt = PriceDocument.where("d_number is not null").where(:d_year => self.d_year,:price_document_type_id => self.price_document_type_id).order("d_index DESC").first last_number = last_dt.d_index if last_dt + tva_prefix = self.tva_type.name == "Standard" ? "S" : "M" self.d_index = last_number+1 - self.d_number = self.d_prefix+self.d_year.to_s+('%05d' % self.d_index) + self.d_number = self.d_prefix+tva_prefix+self.d_year.to_s+('%05d' % self.d_index) self.save diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index abee8ee..e63b0df 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -127,12 +127,18 @@ class PriceLineBlock < ApplicationRecord puts "TEST" puts "Référence : #{p_product_ref.id} #{p_product_ref.p_product.name}" if qte.to_f != 0.0 - decr_line_stock = LineStock.create(:date => self.price_lineable.date, :p_product_ref => p_product_ref, :qte => qte*-1, :description => "Attribution à la ligne d'une facture", :price_ht => 0.0, :price_line => pl, :price_line_block => self, :stockable => self.price_lineable) + decr_line_stock = LineStock.create(:date => self.price_lineable.date, + :p_product_ref => p_product_ref, + :qte => qte*-1, + :description => "Attribution à la ligne d'une facture", + :price_ht => 0.0, + :price_line => pl, + :price_line_block => self, + :stockable => self.price_lineable) price = 0.0 line_stock_usages = [] - qte_to_affect = qte LineStock.where(:p_product_ref_id => p_product_ref.id).where("date <= ?", self.price_lineable.date).where("qte_available > 0.0").each do |ls| @@ -140,22 +146,18 @@ class PriceLineBlock < ApplicationRecord qte_here = qte_to_affect else qte_here = ls.qte_available - end qte_to_affect = qte_to_affect - qte_here - lsu = LineStockUsage.create(:qte => qte_here, :line_stock => ls, :dest_line_stock_id => decr_line_stock.id) line_stock_usages << lsu - price += lsu.price_ht ls.save break if qte_to_affect == 0.0 - #price_u_ht - end + decr_line_stock.p_articles = pl.p_articles decr_line_stock.price_ht = price * -1 decr_line_stock.save end @@ -163,47 +165,39 @@ class PriceLineBlock < ApplicationRecord end def update_stocks - if self.block_type == "Facture" and !self.cost_ok + puts "UPDATE STOCKSSSSSSSSSSSSSSSSSSSSSSSSSSS" + puts self.block_type == "Facture" + puts self.block_type == "Bon de commande client" + puts self.block_type + puts self.block_type + puts self.block_type + puts self.block_type + puts self.block_type + puts !self.cost_ok + puts "UPDATE STOCKSSSSSSSSSSSSSSSSSSSSSSSSSSS" + + + + if self.block_type == "Facture" or self.block_type == "Bon de commande client" or self.block_type == "Bon de réception achat" && !self.cost_ok if self.test_if_stock_ok? - self.price_lines.each do |pl| if pl.p_product_ref && pl.p_product_ref.stocked if pl.p_product_ref.assembled - pl.p_product_ref.p_product_assembleds.all.each do |ppa| - - self.update_stocks_for(ppa.p_product_ref, (pl.qte.to_f * ppa.qte.to_f), pl) - end - else - self.update_stocks_for(pl.p_product_ref, pl.qte, pl) - - - end - - end - end self.cost_ok = true - - self.save self.save # deuxième sauvegarde pour prendre en compte les couts de price_line - - self.price_lineable.save if self.price_lineable return true - end - - - end end @@ -223,7 +217,19 @@ class PriceLineBlock < ApplicationRecord ls.p_articles = pl.p_articles ls.save end - + pl.p_articles.joins(:p_grade).where(p_grades: {grade: "RMA"}).each do |p_article| + decr_line_stock = LineStock.new( + :date => self.price_lineable.date, + :p_product_ref => pl.p_product_ref, + :qte => -1, + :description => "Sortie de stock automatique des RMA", + :price_ht => 0.0, + :price_line => pl, + :price_line_block => self, + :stockable => self.price_lineable) + decr_line_stock.p_articles << p_article + decr_line_stock.save + end end @@ -276,7 +282,7 @@ class PriceLineBlock < ApplicationRecord def wish_date_needed? if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) false - elsif self.block_type == "Devis" + elsif self.block_type == "Devis" or self.block_type == "Demande de commande" false else true @@ -453,9 +459,6 @@ class PriceLineBlock < ApplicationRecord end if self.particular_bill_needed? and (!self.p_customer or !self.particular_bill or !self.particular_bill.owner or self.particular_bill.owner != self.p_customer) - puts "PARTICULEARRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" - puts self.particular_bill - puts "PARTICULEARRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" errors.add(:particular_bill_id, 'doit être une adresse du client') end diff --git a/app/views/admin/accounting_zones/_form.html.haml b/app/views/admin/accounting_zones/_form.html.haml index 11f012e..ebeaf0f 100644 --- a/app/views/admin/accounting_zones/_form.html.haml +++ b/app/views/admin/accounting_zones/_form.html.haml @@ -4,11 +4,12 @@ =f.inputs do = f.input :enabled, :label => "Actif ?" = f.input :name, :label => "Nom de la zone :" - =# f.input :description, :label => "description :" + =# f.input :description, :label => "description :" + =render :partial => "qi/actions", :locals => {:f => f} - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + -# .actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/admin_permissions/_form.html.haml b/app/views/admin/admin_permissions/_form.html.haml index 687700c..2894429 100755 --- a/app/views/admin/admin_permissions/_form.html.haml +++ b/app/views/admin/admin_permissions/_form.html.haml @@ -11,9 +11,10 @@ = f.input :slug, :label => "Slug :" - = f.input :position, :label => "Position :" + = f.input :position, :label => "Position :" + =render :partial => "qi/actions", :locals => {:f => f} - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/admin_roles/_form.html.haml b/app/views/admin/admin_roles/_form.html.haml index f3b279a..60f1f68 100755 --- a/app/views/admin/admin_roles/_form.html.haml +++ b/app/views/admin/admin_roles/_form.html.haml @@ -6,6 +6,6 @@ = f.input :name, :label => "Nom :" =f.input :admin_permissions, :label => "Permissions :", :collection => AdminPermission.all, :as => :check_boxes, :member_label => :member_label - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/import_csvs/_form.html.haml b/app/views/admin/import_csvs/_form.html.haml index 71bbec7..a2d1d01 100644 --- a/app/views/admin/import_csvs/_form.html.haml +++ b/app/views/admin/import_csvs/_form.html.haml @@ -21,6 +21,6 @@ - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/line_stock_usages/_form.html.haml b/app/views/admin/line_stock_usages/_form.html.haml index 40d9b10..e2eb6db 100644 --- a/app/views/admin/line_stock_usages/_form.html.haml +++ b/app/views/admin/line_stock_usages/_form.html.haml @@ -13,6 +13,6 @@ - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/line_stocks/_form.html.haml b/app/views/admin/line_stocks/_form.html.haml index 736979f..6fcd608 100644 --- a/app/views/admin/line_stocks/_form.html.haml +++ b/app/views/admin/line_stocks/_form.html.haml @@ -12,6 +12,6 @@ - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/mail_hists/_form.html.haml b/app/views/admin/mail_hists/_form.html.haml index 8253451..2f95060 100644 --- a/app/views/admin/mail_hists/_form.html.haml +++ b/app/views/admin/mail_hists/_form.html.haml @@ -17,8 +17,6 @@ = f.input :nbr_send, :label => "nbr_send :" - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml index 88de8b6..c1305c9 100644 --- a/app/views/admin/p_article_serial_nums/_form.html.haml +++ b/app/views/admin/p_article_serial_nums/_form.html.haml @@ -7,9 +7,10 @@ = f.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) = f.input :value + - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" - else .ml-5 diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index 4ba3f64..6ed23d2 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -13,7 +13,8 @@ =render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form} %p= link_to_add_fields "Ajouter un numéro de série", f, :p_article_serial_nums, {:class => "btn btn-primary"} - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" - elsif params[:controller] == "admin/price_lines" = form.inputs do diff --git a/app/views/admin/p_commercial_cats/_form.html.haml b/app/views/admin/p_commercial_cats/_form.html.haml index 03ed408..71993d8 100644 --- a/app/views/admin/p_commercial_cats/_form.html.haml +++ b/app/views/admin/p_commercial_cats/_form.html.haml @@ -9,6 +9,6 @@ - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_commercials/_form.html.haml b/app/views/admin/p_commercials/_form.html.haml index 3d27b29..dd892be 100755 --- a/app/views/admin/p_commercials/_form.html.haml +++ b/app/views/admin/p_commercials/_form.html.haml @@ -30,14 +30,7 @@ = f.input :birth, :label => "Date de naissance :", :as => :date = f.input :objectif_ht, :label => "Objectif CA (HT)" - - - - - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_customer_cats/_form.html.haml b/app/views/admin/p_customer_cats/_form.html.haml index 2c34830..960762b 100755 --- a/app/views/admin/p_customer_cats/_form.html.haml +++ b/app/views/admin/p_customer_cats/_form.html.haml @@ -7,11 +7,6 @@ =# f.input :payment_days, :label => "Délais de paiement par défaut :" =# f.input :encourt_max, :label => "Encours max par défaut :" - - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + \ No newline at end of file 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 7d589a3..992af6d 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 @@ -29,11 +29,11 @@ -tr[:created_at] = capture do %td=l p_customer_sheet.created_at, :format => :date - -tr[:wish_date] = capture do - %td=l p_customer_sheet.price_line_block.wish_date, :format => "semaine %V (%Y)" + -# -tr[:wish_date] = capture do + -# %td=l p_customer_sheet.price_line_block.wish_date, :format => "semaine %V (%Y)" - -tr[:wish_date_2] = capture do - %td=l p_customer_sheet.price_line_block.wish_date, :format => :date + -# -tr[:wish_date_2] = capture do + -# %td=l p_customer_sheet.price_line_block.wish_date, :format => :date -tr[:tot_amount_ht] = capture do diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index b8341f9..de3a613 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -63,19 +63,14 @@ %span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"} =ic(:times) - - - - - - =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_customer_sheets} + .qi_kpi -params[:active_kpi] = [] if params[:active_kpi].to_s == "" - -[["brouillon", "Brouillon", "#ffc107"], ["commande", "Commande", "#fd7e14"], ["en livraison", "En livraison", "#28a745"], ["facturée", "Facturée", "#3B7DDD"]].each do |state| #,["refusée", "Refusée", "#dc3545"] + -[["Brouillon", "Brouillon", "#a3a3a3"], ["Validée", "Validée", "#fab92b"], ["Préparation", "Préparation", "#e97a1c"], ["Livraison", "Livraison", "#28a745"], ["Payée", "Payée", "#3B7DDD"]].each do |state| #,["refusée", "Refusée", "#dc3545"] -p_customer_sheets = @p_customer_sheets.where(:state => state[0]) -if p_customer_sheets.count > 0 diff --git a/app/views/admin/p_customer_sheets/show.html.haml b/app/views/admin/p_customer_sheets/show.html.haml index d664b6d..7315b0d 100644 --- a/app/views/admin/p_customer_sheets/show.html.haml +++ b/app/views/admin/p_customer_sheets/show.html.haml @@ -7,7 +7,7 @@ - -if !@p_customer_sheet.archived and (current_admin.has_permission?("gestion-des-commandes") or @p_customer_sheet.demande_type.to_s == "Brouillon" or @p_customer_sheet.state == "commande") + -if !@p_customer_sheet.archived and (current_admin.has_permission?("gestion-des-commandes") or @p_customer_sheet.demande_type.to_s == "Brouillon" or @p_customer_sheet.state == "Validée") = link_to i(:pencil), edit_admin_p_customer_sheet_path(@p_customer_sheet), :remote => false @@ -45,7 +45,7 @@ -if current_admin.has_permission?("gestion-des-commandes") - -if @p_customer_sheet.state == "brouillon" + -if @p_customer_sheet.state == "Brouillon" %p -if @p_customer_sheet.price_blocked @@ -55,14 +55,14 @@ - -if @p_customer_sheet.state == "brouillon" or @p_customer_sheet.state == "offre"# or @p_customer_sheet.state == "commande" - -if @p_customer_sheet.state == "brouillon" + -if @p_customer_sheet.state == "Brouillon" or @p_customer_sheet.state == "offre"# or @p_customer_sheet.state == "Validée" + -if @p_customer_sheet.state == "Brouillon" %p=link_to "Générer le devis", generate_d_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary" %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 btn-ap-add" %p=link_to "Marquer l'offre comme refusée", reject_admin_p_customer_sheet_path(@p_customer_sheet), :class => "btn btn-primary btn-ap-error " - -if( @p_customer_sheet.state == "commande" or (@p_customer_sheet.state == "en livraison" and @p_customer_sheet.price_documents.where(:cc_label => "Bon de livraison", :cancelled => false).count == 0)) and @bon_de_commande + -if( @p_customer_sheet.state == "Validée" or (@p_customer_sheet.state == "en livraison" and @p_customer_sheet.price_documents.where(:cc_label => "Bon de livraison", :cancelled => false).count == 0)) and @bon_de_commande -if price_line_block.nbr_ship %p -if @bon_de_commande.label == "Bon de commande" and @p_customer_sheet and @p_customer_sheet.price_documents.where(:cc_label => "Bon de livraison", :cancelled => false).count == 0 diff --git a/app/views/admin/p_customers/show.html.haml b/app/views/admin/p_customers/show.html.haml index ea0dbf2..a877a99 100644 --- a/app/views/admin/p_customers/show.html.haml +++ b/app/views/admin/p_customers/show.html.haml @@ -160,9 +160,7 @@ #customer_adresses - =render(:partial => "admin/particulars/customer_preview", :locals => {:p_customer => @p_customer}) - - + =render(:partial => "admin/particulars/customer_preview", :locals => {:p_customer => @p_customer}) if !@p_customer.p_customer_cat.name == "Plateforme" @@ -181,6 +179,8 @@ %li.nav-item=link_to "Factures & Avoirs", "?tab=bills#tabs", :class => "nav-link"+(" active" if params[:tab] == "bills").to_s -if current_admin.has_permission?("payments") %li.nav-item=link_to "Paiements", "?tab=payments#tabs", :class => "nav-link"+(" active" if params[:tab] == "payments").to_s + -if current_admin.has_permission?("payments") and @p_customer.p_customer_cat.name == "Plateforme" + %li.nav-item=link_to "Adresses", "?tab=adresses#tabs", :class => "nav-link"+(" active" if params[:tab] == "adresses").to_s @@ -281,6 +281,24 @@ -@p_payments = @p_payments.page(page).per(per_page) =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_payments} + + + -if params[:tab] == "adresses" and @p_customer.p_customer_cat.name == "Plateforme" + #adresses + .qi_tab_header + .right{:style => "text-align:right;"} + /= link_to 'Ajouter une adresse', new_admin_p_payment_path(:p_customer_id => @p_customer.id), :class => "btn btn-primary bgbd-payments", :remote => true + + .clear + + -params[:search][:per_page] = params[:search][:per_page] || 50 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + -@adresses =@p_customer.particulars + -@adresses = sort_by_sorting(@adresses, "created_at DESC") + -@adresses = @adresses.page(page).per(per_page) + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @adresses} diff --git a/app/views/admin/p_devises/_form.html.haml b/app/views/admin/p_devises/_form.html.haml index c8d8d8c..a4c51c9 100644 --- a/app/views/admin/p_devises/_form.html.haml +++ b/app/views/admin/p_devises/_form.html.haml @@ -8,7 +8,6 @@ - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_documents/_form.html.haml b/app/views/admin/p_documents/_form.html.haml index 2d96aad..1dc4676 100755 --- a/app/views/admin/p_documents/_form.html.haml +++ b/app/views/admin/p_documents/_form.html.haml @@ -11,6 +11,6 @@ = f.input :i_archive, :label => "Indiquer le lettrage comme effectué ? (forcer, même si aucun paiements rattachés)" - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_grades/_form.html.haml b/app/views/admin/p_grades/_form.html.haml index 00d2fa0..3da7ffa 100644 --- a/app/views/admin/p_grades/_form.html.haml +++ b/app/views/admin/p_grades/_form.html.haml @@ -3,10 +3,7 @@ .content =f.inputs do = f.input :grade, :label => f.object.label_for(:grade) - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_product_cats/_form.html.haml b/app/views/admin/p_product_cats/_form.html.haml index fc64cdf..e2c34ee 100755 --- a/app/views/admin/p_product_cats/_form.html.haml +++ b/app/views/admin/p_product_cats/_form.html.haml @@ -13,5 +13,5 @@ =# f.input :purchase_account, :label => "Compte achat :" =# f.input :sale_account, :label => "Compte vente :" - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/p_product_zones/_form.html.haml b/app/views/admin/p_product_zones/_form.html.haml index c0bea09..d95fde4 100644 --- a/app/views/admin/p_product_zones/_form.html.haml +++ b/app/views/admin/p_product_zones/_form.html.haml @@ -7,6 +7,6 @@ - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/_form.html.haml b/app/views/admin/p_serial_num_types/_form.html.haml index 99f609b..30c0ec7 100644 --- a/app/views/admin/p_serial_num_types/_form.html.haml +++ b/app/views/admin/p_serial_num_types/_form.html.haml @@ -7,6 +7,6 @@ - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/particulars/_large_form.html.haml b/app/views/admin/particulars/_large_form.html.haml index 955e106..8d3e124 100755 --- a/app/views/admin/particulars/_large_form.html.haml +++ b/app/views/admin/particulars/_large_form.html.haml @@ -6,6 +6,6 @@ =f.inputs do = render :partial => "form", :locals => {:form => f} - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/partitions/_form.html.haml b/app/views/admin/partitions/_form.html.haml index 7fc7ed9..00a6121 100644 --- a/app/views/admin/partitions/_form.html.haml +++ b/app/views/admin/partitions/_form.html.haml @@ -12,12 +12,7 @@ =render :partial => "admin/partition_lines/form", :locals => {:form => f} %p= link_to_add_fields "Ajouter une ligne", f, :partition_lines, {:class => "btn btn-primary", :partial =>( "admin/partition_lines/form")} - - - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/price_documents/_form_avoir.html.haml b/app/views/admin/price_documents/_form_avoir.html.haml index 38556a2..d07f214 100644 --- a/app/views/admin/price_documents/_form_avoir.html.haml +++ b/app/views/admin/price_documents/_form_avoir.html.haml @@ -15,9 +15,8 @@ - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index a18ec45..3ebbc8b 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -202,7 +202,7 @@ -if price_document.cc_label == "Bon de réception achat" %br - =link_to "Générer la facture", facture_achat_admin_price_document_path(price_document) + =link_to "Générer la factureeee", facture_achat_admin_price_document_path(price_document) =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_document} diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 9b78bee..7631d82 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -246,8 +246,10 @@ -if current_admin.has_permission?("show-costs") %p -if @price_document.price_document_type_id == 6 - =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable - =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable + -# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable + -# =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable + =link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable + =link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable -elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 %p Coût : @@ -257,7 +259,11 @@ =number_to_currency @price_document.marge_ht -if !@price_document.cost_ok - =#link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" + =link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable + =link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary disabled" if !@price_document.stock_ok and !@price_document.stock_generable + -elsif @price_document.price_document_type_id == 12 + =link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok and @price_document.stock_generable + -if @price_document.d_number -if @price_document.cc_label == "Commande achat" %p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" @@ -334,20 +340,29 @@ -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] -page = (params[:page] and params[:page] != "") ? params[:page] : 1 - -@line_stocks = @price_document.line_stocks.order("date DESC, created_at DESC") -if params[:price_document_ids] -@line_stocks = @line_stocks.where(:id => params[:price_document_ids]) - - -@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC") -@line_stocks = @line_stocks.page(page).per(per_page) %br - - - .clear =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks} + -if @price_document.price_line_block.br_ok + %h3 Bons de reception générés + #bills + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@price_documents = PriceDocument.where(facture_achat_id: @price_document.id).order("date DESC, created_at DESC") + -# -if params[:price_document_ids] + -# -@line_stocks = @line_stocks.where(:id => params[:price_document_ids]) + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") + -@price_documents = @price_documents.page(page).per(per_page) + %br + .clear + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents} -if @price_document.label == "Demande prix" diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml index a600eef..08a6a60 100644 --- a/app/views/admin/price_line_blocks/_form.html.haml +++ b/app/views/admin/price_line_blocks/_form.html.haml @@ -9,7 +9,7 @@ .col-6 = f.input :customer_ref, :label => "Référence commande client :" .col-6 - = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date + /= f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date = f.input :validation_date, :label => "Date de validation :", :as => :date = f.hidden_field :p_customer_id, :class => "p_customer_id" diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index e1c9540..0d0765a 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -1,33 +1,78 @@ .row.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} - .take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} + .take =ic :arrows - .col-3 - = form.input :p_product_ref, as: :select, collection: PProductRef.all.map{ |p_product_ref| [p_product_ref.member_label, p_product_ref.id] }, label: "Référence :", input_html: {class:"p_product_ref_select"} - .input-group - -# %label Référence - -# %input.p_product_ref_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref), :class => "p_product_ref_name"} - -# = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" + .col-3 + = form.input :ct_title, :label => "Designation personnalisée : " if @avoir + %div{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} + %label Produit : + + %input.p_product_ref_autocomplete_input.form-control{:type => "text", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)} + = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" + + :javascript + $('.p_product_ref_autocomplete_input').focus() + $( function() { + + $('.p_product_ref_autocomplete_input').autocomplete({ + source: function( request, response ) { + $.ajax( { + url: "/admin/p_product_refs/autocomplete.json", + dataType: "json", + data: { + search: request.term, + p_customer_id: $(".p_customer_id").val() + }, + success: function(data){ + + arr = jQuery.map( data, function( item ) { + return { + label: item.member_label, + value: item.member_label, + id: item.id + } + }); + + response(arr) + + } + + } ); + }, + minLength: 2, + select: function( event, ui ) { - -# .input-group-append - -# =link_to "#", class: "btn btn-dark",:onclick => "key=genRanHex(12);select_product_from_manager(key);$(this).closest('tr').find('.p_product_ref_id').attr('id', 'p_product_ref_id_'+key);$(this).closest('tr').find('.p_product_ref_name').attr('id', 'p_product_ref_name_'+key);$(this).closest('tr').find('.p_product_ref_qte').attr('id', 'p_product_ref_qte_'+key);return false;" do - -# =ic(:search) + $(this).next(".p_product_ref_id").val(ui.item.id) + + form = $(this).closest(".price_line_form") + + + + $.ajax( { + url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json", + dataType: "json", + data: { + type: "price", + qte: form.find(".input_price_line_qte").val(), + p_customer_id: $(".p_customer_id").val() + }, + success: function (data) { + form.find(".input_price_line_price_u_ht").val(data.price); + form.find(".input_price_line_tva_account_id").val(data.tva_account_id); + form.find(".input_price_line_tva_account_value").val(data.tva_account_value); + form.find(".input_price_line_weight_u").val(data.weight); + + + + } + } ); + //return false + } + }); + } ); + + - -form.object.forced_price = true if form.object.ct_u_price_ht - -# -if form.object.forced_price and form.object.p_product_ref - -# .col-3 - -# .mx-2 - -# .form-inline - -# =qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label => false, label_class: "mr-1", :value => form.object.th_price_u_ht) - -# -else - -# .col-3 - -# .mx-2 - -# .form-inline - -# =qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label =>false, label_class: "mr-1") - -# .col-3 - -# .form-inline.mr-2{:style => ("display:none;" if !current_admin or !current_admin.has_permission?("customer-sheets-personalised-price"))} - -# = form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "form-inline input_price_line_forced_price"} - -# .forced_price_wrapper.mx-2{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"} .col-3 = form.input :qte, :label => "Quantité :", :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1} .col-3 @@ -39,3 +84,4 @@ %span.destroy{style: "font-size: 2rem;"}=link_to_remove_fields ic(:"trash-o"), form = qi_js_field(form, :price_line, :tva_account_value, :hidden => true) = form.hidden_field :position, :class => "price_line_position_input" + diff --git a/app/views/admin/price_lines/_form_old.html.haml b/app/views/admin/price_lines/_form_old.html.haml index 60e70c1..2fab6d6 100644 --- a/app/views/admin/price_lines/_form_old.html.haml +++ b/app/views/admin/price_lines/_form_old.html.haml @@ -1,4 +1,3 @@ - .qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} %table{:style => "width:100%;"} %tr diff --git a/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml index 7bf404a..22fce64 100644 --- a/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml +++ b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml @@ -1,59 +1,10 @@ =semantic_form_for [:admin, @price_line], :remote => true do |form| .content - Produit : - =form.object.p_product_ref.cc_name if form.object.p_product_ref - %br - Quantité à satisfaire : - =form.object.qte - - %br - %br - - %table.top_td{:style => "width:100%;"} - %tr - - %td - = form.input :p_product_power_id, :label => "Type de chargeur", :collection => PProductPower.all, :include_blank => false, :as => :select - - %td - = form.input :qte_available, :label => "Qté disponible :", :input_html => {:class => "input_price_line_qte"} - - - %td - = form.input :ct_u_price_ht, :label => "Prix vente" - - %td - = form.input :ready_stock, :label => "Ready stock", :as => :select - - %td - = form.input :ram, :label => "Ram" - - %td - = form.input :ram_unit, :label => "Ram unité" - - - %td - = form.input :eu, :label => "EU ?", :as => :select - - - %td - = form.input :p_product_zone_id, :label => "Zone", :collection => PProductZone.all, :include_blank => true, :as => :select - - - - %td - = form.input :fullkit, :label => "Fullkit", :as => :select - - %td - = form.input :lang_start, :label => "Démarage sur l'écran de langue (starting on screen language)", :as => :select - - - - - - + = form.input :p_product_ref, label: "Produit :" if form.object.p_product_ref + = form.input :qte, label: "Quantité à satisfaire :" + = form.input :ct_u_price_ht, :label => "Prix vente" = form.input :comment, :label => "Commentaire", :input_html => {:style => "height:70px;"} - .actions= form.submit "Sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => form} diff --git a/app/views/admin/price_lines/edit.js.erb b/app/views/admin/price_lines/edit.js.erb index 30200cb..78ab72e 100644 --- a/app/views/admin/price_lines/edit.js.erb +++ b/app/views/admin/price_lines/edit.js.erb @@ -1 +1 @@ -show_pane_hover("<%= escape_javascript(render(:partial => "reponse_pane_hover_form"))%>",1200,900); \ No newline at end of file +show_pane_hover("<%= escape_javascript(render(:partial => "reponse_pane_hover_form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/s_brands/_form.html.haml b/app/views/admin/s_brands/_form.html.haml index 515ea9b..cb67cf4 100644 --- a/app/views/admin/s_brands/_form.html.haml +++ b/app/views/admin/s_brands/_form.html.haml @@ -3,10 +3,12 @@ .content =f.inputs do = f.input :code, :label => "Code :" - = f.input :name, :label => "Nom :" + = f.input :name, :label => "Nom :" + + =render :partial => "qi/actions", :locals => {:f => f} + - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/stock_movements/_form.html.haml b/app/views/admin/stock_movements/_form.html.haml index 7aa0dd0..4ce17fa 100644 --- a/app/views/admin/stock_movements/_form.html.haml +++ b/app/views/admin/stock_movements/_form.html.haml @@ -2,7 +2,8 @@ .content =f.inputs do - = f.input :movement_type, :label => "movement_type :", :as => :hidden + -# = f.input :movement_type, :label => "movement_type :", :as => :hidden + = f.hidden_field :movement_type = f.input :description, :label => "Description :", :as => :string = f.input :date, :label => "Date :", :as => :date @@ -14,12 +15,7 @@ =render :partial => "admin/stock_movement_lines/form", :locals => {:form => f} %p= link_to_add_fields "Ajouter une ligne", f, :stock_movement_lines, {:class => "btn btn-primary", :partial =>(@stock_movement.movement_type == "cred" ? "admin/stock_movement_lines/form_cred" : "admin/stock_movement_lines/form")} + + =render :partial => "qi/actions", :locals => {:f => f} - - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/tva_rates/_form.html.haml b/app/views/admin/tva_rates/_form.html.haml index 912d303..8a054cc 100644 --- a/app/views/admin/tva_rates/_form.html.haml +++ b/app/views/admin/tva_rates/_form.html.haml @@ -13,7 +13,6 @@ - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + =render :partial => "qi/actions", :locals => {:f => f} + /.actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/db/migrate/20211115181445_add_br_ok_to_price_line_block.rb b/db/migrate/20211115181445_add_br_ok_to_price_line_block.rb new file mode 100644 index 0000000..cd7ca46 --- /dev/null +++ b/db/migrate/20211115181445_add_br_ok_to_price_line_block.rb @@ -0,0 +1,5 @@ +class AddBrOkToPriceLineBlock < ActiveRecord::Migration[6.0] + def change + add_column :price_line_blocks, :br_ok, :boolean + end +end diff --git a/db/migrate/20211116144749_add_particular_infos_to_p_custommer_sheet.rb b/db/migrate/20211116144749_add_particular_infos_to_p_custommer_sheet.rb new file mode 100644 index 0000000..5dbbef9 --- /dev/null +++ b/db/migrate/20211116144749_add_particular_infos_to_p_custommer_sheet.rb @@ -0,0 +1,6 @@ +class AddParticularInfosToPCustommerSheet < ActiveRecord::Migration[6.0] + def change + add_column :p_customer_sheets, :cc_particular_infos, :string + add_column :p_customer_sheets, :ac_particular_infos, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bb52740..dd6f2ee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_11_12_130721) do +ActiveRecord::Schema.define(version: 2021_11_16_144749) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1271,6 +1271,8 @@ ActiveRecord::Schema.define(version: 2021_11_12_130721) do t.datetime "customer_validation_at" t.boolean "web_order", default: false t.string "past_id" + t.string "cc_particular_infos" + t.string "ac_particular_infos" t.index ["p_customer_id"], name: "index_p_customer_sheets_on_p_customer_id" end @@ -2474,6 +2476,7 @@ ActiveRecord::Schema.define(version: 2021_11_12_130721) do t.date "stock_entrance_date" t.decimal "ct_tot_amount_ht", precision: 14, scale: 2 t.bigint "price_document_id" + t.boolean "br_ok" t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id" t.index ["price_document_id"], name: "index_price_line_blocks_on_price_document_id" end