update sorecop calcul
This commit is contained in:
parent
e8ebce23ed
commit
72cee7f797
@ -48,7 +48,7 @@ class PProductRef < ApplicationRecord
|
||||
:ean => {:name => "EAN"},
|
||||
:ca_deee => {:name => "DEEE", :as => :currency},
|
||||
:sorecop => {:name => "Sorecop", :as => :currency},
|
||||
:sorecop_comment => {:name => "Type de Sorecop"},
|
||||
:sorecop_comment => {:name => "Commentaire Sorecop"},
|
||||
:actions => {:name => "Actions", :reorder => false}
|
||||
}
|
||||
|
||||
@ -156,14 +156,17 @@ class PProductRef < ApplicationRecord
|
||||
end
|
||||
|
||||
def ca_sorecop
|
||||
if ct_sorecop
|
||||
return ct_sorecop
|
||||
end
|
||||
if self.sorecop_cat
|
||||
if self.cc_sorecop
|
||||
return self.cc_sorecop
|
||||
else
|
||||
if self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage"))
|
||||
find_sorecop_tax.price
|
||||
if self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).empty?
|
||||
"Pas de stockage"
|
||||
else
|
||||
"Pas de spec de Stockage"
|
||||
find_sorecop_tax
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -172,8 +175,13 @@ class PProductRef < ApplicationRecord
|
||||
end
|
||||
|
||||
def find_sorecop_tax
|
||||
storage_capacity = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first.p_spec_value.value
|
||||
self.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first
|
||||
storage_capacity = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first.p_spec_value.value.to_f
|
||||
tax = self.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first
|
||||
if tax.fixed_price
|
||||
tax.price
|
||||
else
|
||||
tax.price * storage_capacity
|
||||
end
|
||||
end
|
||||
|
||||
def ca_deee
|
||||
|
Reference in New Issue
Block a user