class PProductCat < ApplicationRecord
  has_many :p_products
  has_many :p_product_refs, :through => :p_products

  has_many :tvable_tva_rates, :as => :tvable
  has_many :tva_rates, :through => :tvable_tva_rates

  before_save :update_stocked

  def update_stocked
    self.p_product_refs.update_all(:stocked => self.stocked)
  end

end
