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_commercial_object_brand.rb
2021-08-23 10:26:02 +02:00

20 lines
519 B
Ruby

class PCommercialObjectBrand < ApplicationRecord
belongs_to :p_commercial
belongs_to :p_commercial_objective
belongs_to :s_brand
validates :objective_percent, :presence => true
validates :weight_objective, :presence => true
def ca_total_ca
(self.objective_percent.to_f * self.p_commercial_objective.total_ca) / 100 if self.p_commercial_objective
end
def ca_total_weight
(self.weight_objective.to_f * self.p_commercial_objective.total_weight) / 100 if self.p_commercial_objective
end
end