diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 282b46f..b2ee2c1 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -692,13 +692,14 @@ class PCustomer < ApplicationRecord particular_bill.fax = value when "mode_reglement" - next if value.nil? - if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Virement").id - elsif value == "TRAITE" - n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Traite").id - else - n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + if value.present? + if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Virement").id + elsif value == "TRAITE" + n.p_payment_type_id = PPaymentType.find_or_create_by(name: "Traite").id + else + n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id + end end when "libelle_mode_reglement" @@ -722,8 +723,9 @@ class PCustomer < ApplicationRecord end when "nom_banque" - next if value.nil? - bank = PBank.find_or_create_by(name: value) + if value.present? + bank = PBank.find_or_create_by(name: value) + end when "adresse_banque_1" bank_particular.address_1 = value @@ -766,18 +768,19 @@ class PCustomer < ApplicationRecord particular_bill.civilite = value when "fonction_contact" - next if value.nil? - contact.p_contact_types << PContactType.find_or_create_by(name: value) - + if value.present? + contact.p_contact_types << PContactType.find_or_create_by(name: value) + end when "telephone_contact" contact.tel = value when "portable_contact" - next if value.nil? - if contact.tel.nil? - contact.tel = value - else - contact_2 = PContact.new(tel: value) + if value.present? + if contact.tel.nil? + contact.tel = value + else + contact_2 = PContact.new(tel: value) + end end when "email_contact" diff --git a/app/models/p_fournisseur.rb b/app/models/p_fournisseur.rb index 44a7f77..f65ac86 100644 --- a/app/models/p_fournisseur.rb +++ b/app/models/p_fournisseur.rb @@ -63,32 +63,33 @@ class PFournisseur < ApplicationRecord when "tva_intracom" n.tva_num = value when "delai_paiement" - next if value.nil? - case value - when "A la commande" - n.payment_delais = 0 - when "A réception" - n.payment_delais = 0 - when "7 jours net" - n.payment_delais = 7 - when "21 jours net" - n.payment_delais = 21 - when "30 jours" - n.payment_delais = 30 - when "30 jours net" - n.payment_delais = 30 - when "30 jours fin de mois" - n.payment_delais = 30 - when "35 jours net" - n.payment_delais = 35 - when "40 jours net" - n.payment_delais = 40 - when "60 jours net" - n.payment_delais = 60 - when "60 jours fin de mois" - n.payment_delais = 60 - else - n.payment_delais = value + if value.present? + case value + when "A la commande" + n.payment_delais = 0 + when "A réception" + n.payment_delais = 0 + when "7 jours net" + n.payment_delais = 7 + when "21 jours net" + n.payment_delais = 21 + when "30 jours" + n.payment_delais = 30 + when "30 jours net" + n.payment_delais = 30 + when "30 jours fin de mois" + n.payment_delais = 30 + when "35 jours net" + n.payment_delais = 35 + when "40 jours net" + n.payment_delais = 40 + when "60 jours net" + n.payment_delais = 60 + when "60 jours fin de mois" + n.payment_delais = 60 + else + n.payment_delais = value + end end when "interlocuteur" contact_1.name = value