From 5da52468000065cbd1a616c5f5ea566b57eeef3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 18 Oct 2021 09:42:12 +0200 Subject: [PATCH] protect from blank --- app/models/p_customer.rb | 66 ++++++++++++++++++------------------- app/models/p_fournisseur.rb | 22 ++++++------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index a0e3a00..42bf4cd 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -653,43 +653,43 @@ class PCustomer < ApplicationRecord else case key when "societe_raison_sociale" - particular_bill.organisation = value + particular_bill.organisation = value if !value.blank? when "nom_enseigne" - particular_bill.com_name = value + particular_bill.com_name = value if !value.blank? when "adresse_facturation_1" - particular_bill.address_1 = value + particular_bill.address_1 = value if !value.blank? when "adresse_livraison_2" - send_address_2 = value + send_address_2 = value if !value.blank? when "adresse_3" - particular_bill.address_3 = value + particular_bill.address_3 = value if !value.blank? when "cp" - particular_bill.cp = value + particular_bill.cp = value if !value.blank? when "ville_1" - particular_bill.city = value + particular_bill.city = value if !value.blank? when "pays" - particular_bill.country = value + particular_bill.country = value if !value.blank? when "societe_livraison" - particular_bill.address_4 = value + particular_bill.address_4 = value if !value.blank? when "forme_juridique" - particular_bill.address_5 = value + particular_bill.address_5 = value if !value.blank? when "telephone_1" - particular_bill.tel = value + particular_bill.tel = value if !value.blank? when "telephone_2" - particular_bill.tel2 = value + particular_bill.tel2 = value if !value.blank? when "fax" - particular_bill.fax = value + particular_bill.fax = value if !value.blank? when "mode_reglement" if value.present? @@ -719,7 +719,7 @@ class PCustomer < ApplicationRecord when "Mensuel - 30j fin de mois du dépôt" n.payment_delais = 30 else - n.payment_delais = value + n.payment_delais = value if !value.blank? end when "nom_banque" @@ -728,66 +728,66 @@ class PCustomer < ApplicationRecord end when "adresse_banque_1" - bank_particular.address_1 = value + bank_particular.address_1 = value if !value.blank? when "adresse_banque_2" - bank_particular.address_2 = value + bank_particular.address_2 = value if !value.blank? when "code_banque" - bank_particular.cp = value + bank_particular.cp = value if !value.blank? when "ville_banque" - bank_particular.city = value + bank_particular.city = value if !value.blank? when "pays_banque" - bank_particular.country = value + bank_particular.country = value if !value.blank? when "telephone_livraison" - send_tel = value + send_tel = value if !value.blank? when "portable_livraison" - send_tel2 = value + send_tel2 = value if !value.blank? when "fax_livraison" - send_fax = value + send_fax = value if !value.blank? when "representant" - p_commercial_code = value + p_commercial_code = value if !value.blank? when "nom_representant" - p_commercial_firstname = value + p_commercial_firstname = value if !value.blank? when "code_iban" - iban = value + iban = value if !value.blank? when "code_bic" - bic = value + bic = value if !value.blank? when "nom_contact" - contact.name = value + contact.name = value if !value.blank? when "titre_contact" - particular_bill.civilite = value + particular_bill.civilite = value if !value.blank? when "fonction_contact" if value.present? contact.p_contact_types << PContactType.find_or_create_by!(name: value) end when "telephone_contact" - contact.tel = value + contact.tel = value if !value.blank? when "portable_contact" if value.present? if contact.tel.nil? - contact.tel = value + contact.tel = value if !value.blank? else contact_2 = PContact.new(tel: value) end end when "email_contact" - contact.email = value + contact.email = value if !value.blank? when "observation" - n.p_customer_sheet_note = value + n.p_customer_sheet_note = value if !value.blank? @@ -829,7 +829,7 @@ class PCustomer < ApplicationRecord when "client_divers" else - eval "n.#{key} = value" + eval "n.#{key} = value if !value.blank?" end diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index 344c669..6f0cacb 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -53,15 +53,15 @@ class PFournisseur < ApplicationRecord else case key when "nom_fournisseur" - n.name = value + n.name = value if !value.blank? when "address" - n.address1 = value + n.address1 = value if !value.blank? when "ville" - n.city = value + n.city = value if !value.blank? when "pays" - n.country = value + n.country = value if !value.blank? when "tva_intracom" - n.tva_num = value + n.tva_num = value if !value.blank? when "delai_paiement" if value.present? case value @@ -88,19 +88,19 @@ class PFournisseur < ApplicationRecord when "60 jours fin de mois" n.payment_delais = 60 else - n.payment_delais = value + n.payment_delais = value if !value.blank? end end when "interlocuteur" - contact_1.name = value + contact_1.name = value if !value.blank? when "fonction" contact_1.p_contact_types << PContactType.find_or_create_by!(name: value) when "tel" - contact_1.tel = value + contact_1.tel = value if !value.blank? when "skype" - contact_1.skype = value + contact_1.skype = value if !value.blank? when "email_1" - contact_1.email = value + contact_1.email = value if !value.blank? when "email_2" contact_2 = PContact.new(email: value) when "email_3" @@ -108,7 +108,7 @@ class PFournisseur < ApplicationRecord when "reglement_par" n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id else - eval "n.#{key} = value" + eval "n.#{key} = value if !value.blank?" end end