-PCustomer.destroy_all %table.table -@result.each do |result| -p_customer = PCustomer.new(:enabled => true, :imported => true) -particular = p_customer.particulars.new(:open_range_ids => OpenRange.all.ids, :imported => true) %tr %td =p_customer.code = result["No_"] %td =particular.organisation = result["Name"] %td =p_customer.nav_payment_terms_code = result["Payment Terms Code"] %td NBR JOURS =p_customer.nav_payment_terms_code.delete('JFDM15').delete('JFDM10').delete('^0-9') -if jours = p_customer.nav_payment_terms_code.gsub('JFDM15','').gsub('JFDM10','').delete('^0-9').to_i and jours > 0 -p_customer.comptant = false -p_customer.payment_delais = jours %td =particular.address_2 = result["Address"] %td =particular.address_3 = result["Address 2"] %td =particular.cp = result["Post Code"] %td =particular.city = result["City"] %td =particular.country = result["Country_Region Code"] -c = false -if result["Phone No_"].to_s != "" -c = true -p_customer.p_contacts.new(:name => result["Contact"], :comment => "Importé, tel", :tel => result["Phone No_"]) -if result["Fax No_"].to_s != "" -c = true -p_customer.p_contacts.new(:name => result["Contact"], :comment => "Importé, fax", :tel => result["Fax No_"]) -if result["E-Mail"].to_s != "" -c = true -p_customer.p_contacts.new(:name => result["Contact"], :comment => "Importé, email", :email => result["E-Mail"]) -if result["Mobile Phone No_"].to_s != "" -c = true -p_customer.p_contacts.new(:name => result["Contact"], :comment => "Importé, mobile", :email => result["Mobile Phone No_"]) -if result["Contact"].to_s != "" and !c -p_customer.p_contacts.new(:name => result["Contact"], :comment => "Importé, nom") %td =p_customer.tva_intra = result["VAT Registration No_"] %td =p_customer.siret = result["SIRET"] %td =p_customer.website = result["Home Page"] %td =p_customer.ape = result["APE"] %td =p_customer.nav_vat_posting_group = result["VAT Prod_ Posting Group"] %td =p_customer.nav_search_name = result["Search Name"] %td =p_customer.nav_name_2 = result["Name 2"] %td =p_customer.nav_modified_ny = result["Modified by"] %td =p_customer.nav_sales_representative_code = result["Sales Representative Code"] %td =p_customer.nav_customer_posting_group = result["Customer Posting Group"] %td =p_customer.nav_invoice_disc_code = result["Invoice Disc_ Code"] %td =p_customer.nav_country_region_code = result["Country_Region Code"] %td =p_customer.nav_payment_method_code = result["Payment Method Code"] -if p_customer.nav_payment_method_code? -if p_payment_type = PPaymentType.where(:code => p_customer.nav_payment_method_code).first -else -p_payment_type = PPaymentType.create(:code => p_customer.nav_payment_method_code, :name => p_customer.nav_payment_method_code) -p_customer.p_payment_type = p_payment_type -else -p_customer.p_payment_type = nil %td =p_customer.nav_gen_bus_posting_group = result["Gen_ Bus_ Posting Group"] %td =p_customer.nav_reminder_terms_code = result["Reminder Terms Code"] %td =p_customer.nav_no_series = result["No_ Series"] %td =p_customer.nav_vat_bus_posting_group = result["VAT Bus_ Posting Group"] %td =p_customer.nav_primary_contact_no = result["Primary Contact No_"] %td =p_customer.nav_last_date_modified = result["Last Date Modified"] %td=p_customer.save %td =p_customer.errors.messages