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