This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/models/p_sheet_line_stock.rb
2021-08-23 10:26:02 +02:00

30 lines
550 B
Ruby

class PSheetLineStock < ApplicationRecord
belongs_to :p_sheet_line
belongs_to :p_brut_product
belongs_to :p_product_brut_stock
validates :qte_ok, :presence => true, :if => :validate_ok?
validates :ok_at, :presence => true, :if => :validate_ok?
validates :price_ok, :presence => true, :if => :validate_ok?
def validate_ok?
if self.ok
true
else
false
end
end
def price_tot_ok
self.qte_ok.to_f * self.price_ok.to_f
end
after_destroy do
self.p_product_brut_stock.save
end
end