-PFournisseur.destroy_all 


%table.table
  -@result.each do |result|
    
    -p_fournisseur = PFournisseur.new(:enabled => true, :imported => true)
    -particular = p_fournisseur.particulars.new(:open_range_ids => OpenRange.all.ids, :imported => true)
    %tr
      %td
        =p_fournisseur.code = result["No_"]
      %td
        =particular.organisation = result["Name"]
      
      %td
        =p_fournisseur.nav_payment_terms_code = result["Payment Terms Code"]
      
      
      
      %td
        NBR JOURS
        
        =p_fournisseur.nav_payment_terms_code.delete('JFDM15').delete('JFDM10').delete('^0-9')
        -if jours = p_fournisseur.nav_payment_terms_code.gsub('JFDM15','').gsub('JFDM10','').delete('^0-9').to_i and jours > 0
          -p_fournisseur.payment_comptant = false
          -p_fournisseur.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_fournisseur.p_contacts.new(:name => result["Contact"], :comment => "Importé, tel", :tel => result["Phone No_"])
      
      -if result["Fax No_"].to_s != ""
        -c = true
        -p_fournisseur.p_contacts.new(:name => result["Contact"], :comment => "Importé, fax", :tel => result["Fax No_"])
      
      -if result["E-Mail"].to_s != ""
        -c = true
        -p_fournisseur.p_contacts.new(:name => result["Contact"], :comment => "Importé, email", :email => result["E-Mail"])
        
      -if result["Mobile Phone No_"].to_s != ""
        -c = true
        -p_fournisseur.p_contacts.new(:name => result["Contact"], :comment => "Importé, mobile", :email => result["Mobile Phone No_"])
      
      -if result["Contact"].to_s != "" and !c
        -p_fournisseur.p_contacts.new(:name => result["Contact"], :comment => "Importé, nom")
        
      %td
        =p_fournisseur.tva_intra = result["VAT Registration No_"]
      %td
        =p_fournisseur.siren = result["SIRET"]
        
        
      %td
        =p_fournisseur.website = result["Home Page"]
        
      
        
      %td
        =p_fournisseur.ape = result["APE"]
        
        
        
        
        
      
      %td
        =p_fournisseur.nav_vat_posting_group = result["VAT Prod_ Posting Group"]
        
      %td
        =p_fournisseur.nav_search_name = result["Search Name"]
      
      %td
        =p_fournisseur.nav_name_2 = result["Name 2"]
        
      %td
        =p_fournisseur.nav_modified_by = result["Modified by"]
        
      %td
        =p_fournisseur.nav_sales_representative_code = result["Sales Representative Code"]
        
      %td
        =p_fournisseur.nav_customer_posting_group = result["Vendor Posting Group"]
        
      
        
      %td
        =p_fournisseur.nav_invoice_disc_code = result["Invoice Disc_ Code"]
        
      %td
        =p_fournisseur.nav_country_region_code = result["Country_Region Code"]
        
      %td
        =p_fournisseur.nav_payment_method_code = result["Payment Method Code"]
        -if p_fournisseur.nav_payment_method_code?
          -if p_payment_type = PPaymentType.where(:code =>  p_fournisseur.nav_payment_method_code).first
          
          -else
            -p_payment_type = PPaymentType.create(:code =>  p_fournisseur.nav_payment_method_code, :name => p_fournisseur.nav_payment_method_code)
          -p_fournisseur.p_payment_type = p_payment_type
        -else
          -p_fournisseur.p_payment_type = nil
      
      
        
      %td
        =p_fournisseur.nav_gen_bus_posting_group = result["Gen_ Bus_ Posting Group"]
      
      %td
        =p_fournisseur.nav_reminder_terms_code = result["Reminder Terms Code"]
        
      %td
        =p_fournisseur.nav_no_series = result["No_ Series"]
        
      %td
        =p_fournisseur.nav_vat_bus_posting_group = result["VAT Bus_ Posting Group"]
        
      %td
        =p_fournisseur.nav_primary_contact_no = result["Primary Contact No_"]
      
      %td
        =p_fournisseur.nav_purchaser_code = result["Purchaser Code"]
        
      %td
        =p_fournisseur.nav_shipment_method_code = result["Shipment Method Code"]
        
      %td
        =p_fournisseur.nav_blocked = result["Blocked"]
        
      
      %td
        =p_fournisseur.nav_vendor_qualification = result["Vendor Qualification"]
      
      %td
        =p_fournisseur.nav_last_date_modified = result["Last Date Modified"]
      
      %td=p_fournisseur.save
      
      %td
        =p_fournisseur.errors.messages
        
     
      