ca_sorecop for p_product_ref
This commit is contained in:
parent
91754a6192
commit
e8ebce23ed
@ -10,6 +10,7 @@ class PProductRef < ApplicationRecord
|
||||
has_many :p_product_ref_price_histories
|
||||
|
||||
belongs_to :p_product_color
|
||||
belongs_to :sorecop_cat
|
||||
|
||||
has_many :p_articles
|
||||
has_many :p_article_serial_nums, through: :p_articles
|
||||
@ -46,7 +47,7 @@ class PProductRef < ApplicationRecord
|
||||
:ct_price_ht => {:name => "Prix de vente", :as => :currency},
|
||||
:ean => {:name => "EAN"},
|
||||
:ca_deee => {:name => "DEEE", :as => :currency},
|
||||
:ca_sorecop => {:name => "Sorecop", :as => :currency},
|
||||
:sorecop => {:name => "Sorecop", :as => :currency},
|
||||
:sorecop_comment => {:name => "Type de Sorecop"},
|
||||
:actions => {:name => "Actions", :reorder => false}
|
||||
}
|
||||
@ -155,13 +156,26 @@ class PProductRef < ApplicationRecord
|
||||
end
|
||||
|
||||
def ca_sorecop
|
||||
if self.cc_sorecop
|
||||
return self.cc_sorecop
|
||||
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
|
||||
else
|
||||
"Pas de spec de Stockage"
|
||||
end
|
||||
end
|
||||
else
|
||||
"TODO Calcul sorecop"
|
||||
"Pas de catégorie Sorecop"
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
def ca_deee
|
||||
if self.cc_deee
|
||||
return self.cc_deee
|
||||
|
@ -20,10 +20,12 @@
|
||||
|
||||
%td
|
||||
=form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true
|
||||
%td
|
||||
=form.input :sorecop_cat_id, label: "Catgorie Sorecop :", :collection => SorecopCat.all, :as => :select, :include_blank => true
|
||||
%td
|
||||
=form.input :ct_sorecop, :label => "Sorecop personalisée :"
|
||||
%td
|
||||
=form.input :sorecop_comment, :label => "Type de Sorecop :"
|
||||
=form.input :sorecop_comment, :label => "Commentaire de Sorecop :"
|
||||
%td
|
||||
=form.input :ct_deee, :label => "DEEE personalisée :"
|
||||
%td
|
||||
|
Reference in New Issue
Block a user