%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