-PProduct.destroy_all 


%table.table
  -@result.each do |result|
    
    -p_product = PProduct.new(:enabled => true, :imported => true)
    -p_product_ref = p_product.p_product_refs.new
    %tr
      %td
        
        =p_product_ref.ref = result["No_"]
      
      %td
        =p_product.name = result["Description"]
      
      %td
        =p_product.description = result["Description 2"]
      
      %td
        
        =p_product_ref.uv = result["Base Unit of Measure"]
      
      
      
      =#--------
      
      %td
        =p_product.nav_base_unit_of_measure = result["Base Unit of Measure"]
        
      %td
        =p_product.nav_price_unit_convertion = result["Price Unit Conversion"]
      
      %td
        =p_product.nav_price_unit_convertion = result["Inventory Posting Group"]
      
      %td
        =p_product.nav_price_unit_convertion = result["Shelf No_"]
      
      
      %td
        =p_product.nav_item_disc_group = result["Item Disc Group"]
        
      %td
        =p_product.nav_costing_method = result["Costing Method"]
      
      %td
        =p_product.nav_unit_price = result["Unit Price"]
        -p_product_ref.ct_price_ht = p_product.nav_unit_price 
        
      %td
        =p_product.nav_vendor_no = result["Vendor No_"]
        
      %td
        =p_product.nav_vendor_item_no = result["Vendor Item No_"]
        
      %td
        =p_product.nav_lead_time_calculation = result["Lead Time Calculation"]
        
      %td
        =p_product.nav_last_date_modified = result["Last Date Modified"]
      
      %td
        =p_product.nav_blocked = result["Blocked"]
        
        -if p_product.nav_blocked.to_s == "1"
          -p_product.enabled = false
        
      %td
        =p_product.nav_global_dimension_2_code = result["Global Dimension 2 Code"]
        -if p_product.nav_global_dimension_2_code?
          -if p_product_cat = PProductCat.where(:code =>  p_product.nav_global_dimension_2_code).first
          
          -else
            -p_product_cat = PProductCat.create(:code =>  p_product.nav_global_dimension_2_code, :name => p_product.nav_global_dimension_2_code)
          -p_product.p_product_cat = p_product_cat
        -else
          -p_product.p_product_cat = nil
        
      
      %td
        =p_product.nav_vat_bus_posting_group = result["VAT Prod_ Posting Group"]
        
        
      %td
        =p_product.nav_no_series = result["No_ Series"]
        
      %td
        =p_product.nav_rolled_up_material_cost = result["Rolled-up Material Cost"]
        
      %td
        =p_product.sales_unit_of_measure = result["Sales Unit of Measure"]
        
      %td
        =p_product.purch_unit_of_measure = result["Purch Unit of Measure"]
        
      %td
        =p_product.sales_unit_of_measure = result["Sales Unit of Measure"]
        
      %td
        =p_product.nav_reordering_policy = result["Reordering Policy"]
      %td
        =p_product.nav_include_inventory = result["Include Inventory"]
      
      %td
        =p_product.nav_item_category_code = result["Item Category Code"]
      
      %td
        =p_product.nav_item_type = result["Item Type"]
      
      %td
        =p_product.nav_workshop = result["Workshop"]
      
      
      
      
      %td=p_product.save
      
      %td
        =p_product.errors.messages
        
     
      