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