diff --git a/app/controllers/admin/import_csvs_controller.rb b/app/controllers/admin/import_csvs_controller.rb index 9d3ebb1..bac0c29 100644 --- a/app/controllers/admin/import_csvs_controller.rb +++ b/app/controllers/admin/import_csvs_controller.rb @@ -94,19 +94,11 @@ class Admin::ImportCsvsController < ApplicationController end def temp_p_product - dev_mode = false - if dev_mode - @p_product_ref = PProductRef.last #DEV mode only + if params[:price_line_id] @price_line = PriceLine.find(params[:price_line_id]) - - @p_product_ref.ct_price_ht = @price_line.ct_u_price_ht #DEV ode onmy + p_product = PProduct.find_or_create_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--") + @p_product_ref = PProductRef.find_or_create_by(p_product: p_product, ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) @p_product_ref.p_product_ref_specs.build - else - if params[:price_line_id] - @price_line = PriceLine.find(params[:price_line_id]) - @p_product_ref = PProductRef.find_or_create_by(p_product: PProduct.find_by(name: "--> Selectioner un produit <--"), ct_sub_name: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht) - @p_product_ref.p_product_ref_specs.build - end end end end