class PhotographerBillingLine < InvoicingRecord
  belongs_to :photographer_billing
  belongs_to :product_type, optional: true
  belongs_to :image, optional: true

  validates :product_type_id, :quantity, :price, :vat, :total_ht, :discount, :total_ttc, presence: true

  delegate :discount_type, to: :billing, allow_nil: true

  def country_type
    photographer_billing&.photographer_billing_company&.country_type || :foreign
  end

  def vat_amount
    total_ttc - total_ht
  end
end
