protect from zero

This commit is contained in:
Barnabé 2021-10-15 18:24:23 +02:00
parent ad135f6ff8
commit cd0d3d2b53

View File

@ -277,9 +277,9 @@ class PProduct < ApplicationRecord
puts key puts key
case key case key
when "identifiant" when "identifiant"
ref.description = value ref.description = value if !value.blank?
when "gencode" when "gencode"
ref.genecode = value ref.genecode = value if !value.blank?
when "id" when "id"
when "marque" when "marque"
@ -289,10 +289,10 @@ class PProduct < ApplicationRecord
n.p_product_cat = PProductCat.find_or_create_by!(name: value) n.p_product_cat = PProductCat.find_or_create_by!(name: value)
when "reference" when "reference"
n.name = value n.name = value if !value.blank?
when "modele" when "modele"
ref.ct_sub_name = value if value.present? ref.ct_sub_name = value if !value.blank?
when "couleur" when "couleur"
ref.p_product_color = PProductColor.find_or_create_by!(name: value) ref.p_product_color = PProductColor.find_or_create_by!(name: value)
@ -350,51 +350,51 @@ class PProduct < ApplicationRecord
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec)
when "reference_fabricant" when "reference_fabricant"
ref.manufacturer_ref = value ref.manufacturer_ref = value if !value.blank?
when "etat" when "etat"
ref.used_state = value ref.used_state = value if !value.blank?
when "code_hs" when "code_hs"
ref.i_code_hs = value ref.i_code_hs = value if !value.blank?
when "indice_reparabilite" when "indice_reparabilite"
ref.prepair_score = value ref.prepair_score = value if !value.blank?
when "duree_dispo_pces_detachees" when "duree_dispo_pces_detachees"
ref.part_delay = value ref.part_delay = value if !value.blank?
when "das_tete" when "das_tete"
ref.das_head = value ref.das_head = value if !value.blank?
when "das_corps" when "das_corps"
ref.das_body = value ref.das_body = value if !value.blank?
when "das_membre" when "das_membre"
ref.das_membre = value ref.das_membre = value if !value.blank?
when "poids" when "poids"
ref.weight = value ref.weight = value if !value.blank?
when "nb_pcs_colis" when "nb_pcs_colis"
ref.nb_pcs_colis = value ref.nb_pcs_colis = value if !value.blank?
when "code_om" when "code_om"
ref.code_om = value ref.code_om = value if !value.blank?
when "gbh_code_971" when "gbh_code_971"
ref.gbh_code_971 = value ref.gbh_code_971 = value if !value.blank?
when "gbh_code_972" when "gbh_code_972"
ref.gbh_code_972 = value ref.gbh_code_972 = value if !value.blank?
when "gbh_code_973" when "gbh_code_973"
ref.gbh_code_973 = value ref.gbh_code_973 = value if !value.blank?
when "code_art" when "code_art"
ref.code_art = value ref.code_art = value if !value.blank?
when "sorecop" when "sorecop"
ref.p_product.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]]) ref.p_product.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]])
if ref.sorecop.kind_of?(String) if ref.sorecop.kind_of?(String)
ref.ct_sorecop = value if !value.blank? ref.ct_sorecop = value if !value.blank?
end end
when "pmp_hors_sorecop" when "pmp_hors_sorecop"
ref.i_pmp_hors_sorecop = value ref.i_pmp_hors_sorecop = value if !value.blank?
when "target_hors_sorecop" when "target_hors_sorecop"
ref.i_target_hors_sorecop = value ref.i_target_hors_sorecop = value if !value.blank?
when "frs" when "frs"
ref.p_fournisseur_id = PFournisseur.find_or_create_by!(name: value).id ref.p_fournisseur_id = PFournisseur.find_or_create_by!(name: value).id
when "spec" when "spec"
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by!(value: value)) spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
import_csv.import_csv_elements << ImportCsvElement.new(:element => spec) import_csv.import_csv_elements << ImportCsvElement.new(:element => spec)
when "commentaires" when "commentaires"
ref.i_comment = value ref.i_comment = value if !value.blank?
# champs ignorés # champs ignorés
when "date" when "date"