20 lines
519 B
Ruby
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
|