raise if creation abort
This commit is contained in:
parent
cd0d3d2b53
commit
3a7b510e64
@ -694,11 +694,11 @@ class PCustomer < ApplicationRecord
|
||||
when "mode_reglement"
|
||||
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
|
||||
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
|
||||
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
|
||||
n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id
|
||||
end
|
||||
end
|
||||
|
||||
@ -724,7 +724,7 @@ class PCustomer < ApplicationRecord
|
||||
|
||||
when "nom_banque"
|
||||
if value.present?
|
||||
bank = PBank.find_or_create_by(name: value)
|
||||
bank = PBank.find_or_create_by!(name: value)
|
||||
end
|
||||
|
||||
when "adresse_banque_1"
|
||||
@ -769,7 +769,7 @@ class PCustomer < ApplicationRecord
|
||||
|
||||
when "fonction_contact"
|
||||
if value.present?
|
||||
contact.p_contact_types << PContactType.find_or_create_by(name: value)
|
||||
contact.p_contact_types << PContactType.find_or_create_by!(name: value)
|
||||
end
|
||||
when "telephone_contact"
|
||||
contact.tel = value
|
||||
@ -860,7 +860,7 @@ class PCustomer < ApplicationRecord
|
||||
end
|
||||
|
||||
if p_commercial_code || p_commercial_firstname
|
||||
p_commercial = PCommercial.find_or_create_by(code: p_commercial_code, firstname: p_commercial_firstname)
|
||||
p_commercial = PCommercial.find_or_create_by!(code: p_commercial_code, firstname: p_commercial_firstname)
|
||||
n.p_commercial = p_commercial
|
||||
end
|
||||
|
||||
|
@ -94,7 +94,7 @@ class PFournisseur < ApplicationRecord
|
||||
when "interlocuteur"
|
||||
contact_1.name = value
|
||||
when "fonction"
|
||||
contact_1.p_contact_types << PContactType.find_or_create_by(name: value)
|
||||
contact_1.p_contact_types << PContactType.find_or_create_by!(name: value)
|
||||
when "tel"
|
||||
contact_1.tel = value
|
||||
when "skype"
|
||||
@ -106,7 +106,7 @@ class PFournisseur < ApplicationRecord
|
||||
when "email_3"
|
||||
contact_3 = PContact.new(email: value)
|
||||
when "reglement_par"
|
||||
n.p_payment_type_id = PPaymentType.find_or_create_by(name: value).id
|
||||
n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id
|
||||
else
|
||||
eval "n.#{key} = value"
|
||||
end
|
||||
@ -114,7 +114,7 @@ class PFournisseur < ApplicationRecord
|
||||
|
||||
end
|
||||
# particular.organisation = self.name
|
||||
n.save
|
||||
n.save!
|
||||
if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email)
|
||||
n.p_contacts << contact_1
|
||||
import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_1)
|
||||
|
@ -753,7 +753,7 @@ class PriceDocument < ApplicationRecord
|
||||
n.price_line_block.price_lines << price_line
|
||||
|
||||
|
||||
n.save
|
||||
n.save!
|
||||
import_csv.import_csv_elements << ImportCsvElement.new(:element => n)
|
||||
import_csv.import_csv_elements << ImportCsvElement.new(:element => price_line)
|
||||
end
|
||||
|
Reference in New Issue
Block a user