28 lines
726 B
Ruby
28 lines
726 B
Ruby
class StockMovementLine < ApplicationRecord
|
|
belongs_to :stock_movement
|
|
belongs_to :p_product_ref
|
|
|
|
has_many :stock_movement_line_p_articles
|
|
has_many :p_articles, through: :stock_movement_line_p_articles
|
|
accepts_nested_attributes_for :stock_movement_line_p_articles, allow_destroy: true
|
|
accepts_nested_attributes_for :p_articles, allow_destroy: true, allow_destroy: true
|
|
|
|
acts_as_caching :fields => [:tot_amount_ht, :price_u_ht]
|
|
|
|
acts_as_sorting :fields => {
|
|
:qte => {:name => "Qté", :reorder => true},
|
|
:actions => {:name => "Actions"}
|
|
}
|
|
|
|
def ca_tot_amount_ht
|
|
if self.ct_tot_amount_ht
|
|
self.ct_tot_amount_ht
|
|
end
|
|
end
|
|
|
|
def affected_qty
|
|
return self.p_articles.count
|
|
end
|
|
|
|
end
|