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
|
has_many :p_product_ref_price_histories
|
||||||
|
|
||||||
belongs_to :p_product_color
|
belongs_to :p_product_color
|
||||||
|
belongs_to :sorecop_cat
|
||||||
|
|
||||||
has_many :p_articles
|
has_many :p_articles
|
||||||
has_many :p_article_serial_nums, through: :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},
|
:ct_price_ht => {:name => "Prix de vente", :as => :currency},
|
||||||
:ean => {:name => "EAN"},
|
:ean => {:name => "EAN"},
|
||||||
:ca_deee => {:name => "DEEE", :as => :currency},
|
:ca_deee => {:name => "DEEE", :as => :currency},
|
||||||
:ca_sorecop => {:name => "Sorecop", :as => :currency},
|
:sorecop => {:name => "Sorecop", :as => :currency},
|
||||||
:sorecop_comment => {:name => "Type de Sorecop"},
|
:sorecop_comment => {:name => "Type de Sorecop"},
|
||||||
:actions => {:name => "Actions", :reorder => false}
|
:actions => {:name => "Actions", :reorder => false}
|
||||||
}
|
}
|
||||||
@ -155,12 +156,25 @@ class PProductRef < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ca_sorecop
|
def ca_sorecop
|
||||||
|
if self.sorecop_cat
|
||||||
if self.cc_sorecop
|
if self.cc_sorecop
|
||||||
return self.cc_sorecop
|
return self.cc_sorecop
|
||||||
else
|
else
|
||||||
"TODO Calcul sorecop"
|
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
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
"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
|
def ca_deee
|
||||||
if self.cc_deee
|
if self.cc_deee
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
%td
|
%td
|
||||||
=form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true
|
=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
|
%td
|
||||||
=form.input :ct_sorecop, :label => "Sorecop personalisée :"
|
=form.input :ct_sorecop, :label => "Sorecop personalisée :"
|
||||||
%td
|
%td
|
||||||
=form.input :sorecop_comment, :label => "Type de Sorecop :"
|
=form.input :sorecop_comment, :label => "Commentaire de Sorecop :"
|
||||||
%td
|
%td
|
||||||
=form.input :ct_deee, :label => "DEEE personalisée :"
|
=form.input :ct_deee, :label => "DEEE personalisée :"
|
||||||
%td
|
%td
|
||||||
|
Reference in New Issue
Block a user