This commit is contained in:
Nicolas Bally 2020-06-18 17:05:10 +02:00
parent 2291ae9f0f
commit 65201a9ccb
4 changed files with 18 additions and 6 deletions

View File

@ -58,9 +58,11 @@ class ImportCsv < ApplicationRecord
def charge
self.import_csv_elements.each do |e|
e.element.destroy if e.element
e.destroy
if false
self.import_csv_elements.each do |e|
e.element.destroy if e.element
e.destroy
end
end
csv_text = File.read(self.file.path, :encoding => 'UTF-8')

View File

@ -73,12 +73,18 @@ class PCustomer < ApplicationRecord
validates :past_id, :uniqueness => true, :if => :imported
attr_accessor :refresh_import
def do_import
if self.imp_iban? and self.imp_bic?
self.m_odr_rep_ribs.create(:bic => self.imp_bic, :iban => self.imp_iban, :admin_ok => true)
end
part = Particular.new
if self.particular
part = self.particular
else
part = Particular.new
end
part.name = self.imp_name
part.firstname = self.imp_firstname
part.address_2 = self.imp_address
@ -125,6 +131,10 @@ class PCustomer < ApplicationRecord
after_create :do_import
after_save do
self.do_import if self.refresh_import
end
acts_as_csv_import :fields =>[:imported, :email, :password, :past_id,:imp_cp,:imp_country,:imp_ref,:imp_email,:imp_firstname,:imp_name,:imp_fonction,:imp_organisme,:imp_address,:imp_cp2,:imp_city,:imp_tel,:imp_portable,:imp_lien,:imp_comment,:imp_iban,:imp_bic,:imp_circuit_1,:imp_circuit_2,:imp_circuit_3,:imp_partenaire,:imp_ecran,:imp_blocage,:imp_valid,:imp_user_valid,:imp_offre,:imp_info,:imp_cgu,:imp_test,:imp_stickers,:imp_npai,:npai,:imp_relance_adresse,:imp_demande_info,:imp_creation,:imp_modification]
attr_accessor :actual_password, :valid_last_password, :valid_public, :generate_mdp, :valid_pswd_confirmation, :require_cgv

View File

@ -12,5 +12,5 @@
= f.input :bic, :label => "Bic :"
.actions=f.submit "sauvegarder" #, :class => "btn btn-primary"
%center=f.submit "sauvegarder" #, :class => "btn btn-primary"

View File

@ -21,7 +21,7 @@ module ActsAsCsvImport::Hook
def self.default_import_csv(list, import_csv)
list.each do |row|
if false
if row["past_id"] #false
if n = self.where(:past_id => row["past_id"]).first
else
n = self.new