bugfix import
This commit is contained in:
parent
56820f3f04
commit
6ed30defc6
@ -732,12 +732,16 @@ class PCustomer < ApplicationRecord
|
|||||||
n.payment_delais = 0
|
n.payment_delais = 0
|
||||||
when "30 JOURS FIN DE MOIS"
|
when "30 JOURS FIN DE MOIS"
|
||||||
n.payment_delais = 30
|
n.payment_delais = 30
|
||||||
|
n.comptant = false
|
||||||
when "VIR 60J NET DATE RELEVE"
|
when "VIR 60J NET DATE RELEVE"
|
||||||
n.payment_delais = 60
|
n.payment_delais = 60
|
||||||
|
n.comptant = false
|
||||||
when "TRAITE A 60 JOURS FIN DE MOIS"
|
when "TRAITE A 60 JOURS FIN DE MOIS"
|
||||||
n.payment_delais = 60
|
n.payment_delais = 60
|
||||||
|
n.comptant = false
|
||||||
when "Mensuel - 30j fin de mois du dépôt"
|
when "Mensuel - 30j fin de mois du dépôt"
|
||||||
n.payment_delais = 30
|
n.payment_delais = 30
|
||||||
|
n.comptant = false
|
||||||
else
|
else
|
||||||
n.payment_delais = value if !value.blank?
|
n.payment_delais = value if !value.blank?
|
||||||
end
|
end
|
||||||
@ -860,20 +864,22 @@ class PCustomer < ApplicationRecord
|
|||||||
|
|
||||||
n.particulars << particular_bill
|
n.particulars << particular_bill
|
||||||
|
|
||||||
n.save
|
n.save!
|
||||||
|
|
||||||
if bank
|
if bank
|
||||||
bank.bic = bic
|
bank.bic = bic
|
||||||
bank.particulars << bank_particular if bank_particular.address_1
|
bank.particulars << bank_particular if bank_particular.address_1
|
||||||
bank.save
|
bank.save!
|
||||||
import_csv.import_csv_elements << ImportCsvElement.new(:element => bank)
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => bank)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if bic || iban
|
if bic || iban
|
||||||
rib = PCustomerRib.create(bic: bic, iban: iban)
|
rib = PCustomerRib.find_or_create_by!(bic: bic, iban: iban)
|
||||||
rib.bank = bank.name if bank
|
rib.bank = bank.name if bank
|
||||||
account = PBankAccount.create(bic: bic, iban: iban, p_bank: bank, p_customer: n)
|
account = PBankAccount.find_or_create_by!(bic: bic, iban: iban, p_customer: n)
|
||||||
|
account.update(p_bank: bank) if bank
|
||||||
|
|
||||||
n.p_customer_ribs << rib
|
n.p_customer_ribs << rib
|
||||||
import_csv.import_csv_elements << ImportCsvElement.new(:element => rib)
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => rib)
|
||||||
import_csv.import_csv_elements << ImportCsvElement.new(:element => account)
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => account)
|
||||||
@ -882,6 +888,7 @@ class PCustomer < ApplicationRecord
|
|||||||
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
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => p_commercial)
|
||||||
end
|
end
|
||||||
|
|
||||||
if send_tel || send_tel2 || send_fax || send_address_2
|
if send_tel || send_tel2 || send_fax || send_address_2
|
||||||
|
Reference in New Issue
Block a user