basic_app/app/views/admin/p_customers/import3.html.haml
Nicolas Bally fd027c16c1 initial
2020-04-21 21:53:16 +02:00

33 lines
1.0 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%table.table
-@csv.each do |row|
-#if p_product = PProduct.where(:code => row["Ref"]).first
-percent = row["Décision 2020"].gsub(" %", "").first
%tr
%td
=nom = row["nom"].force_encoding('UTF-8').gsub(/\s+$/,'')
%td
=row["Décision 2020"]
%td
=percent
%td
=p_customer = PCustomer.joins(:particulars).where("p_customers.code LIKE ? or particulars.organisation LIKE ? or particulars.name LIKE ? or particulars.firstname LIKE ?","%#{nom}%", "%#{nom}%", "%#{nom}%", "%#{nom}%").first
%td
-if p_customer
=market_discount = MarketDiscount.where(:p_customer_cat_id => p_customer.p_customer_cat_id).where(:percent => percent).first
%td
-if percent.to_i > 0 and p_customer and market_discount
-p_customer.market_discount = market_discount
=p_customer.save
%td
=p_customer.p_customer_cat.name if p_customer and p_customer.p_customer_cat