class PhotographerBillingCompany < InvoicingRecord
  belongs_to :user
  belongs_to :vat, class_name: 'ClientVat', foreign_key: :vat_id
  belongs_to :billing_country, class_name: 'Country', foreign_key: :billing_country_id
  belongs_to :payment_type
  has_many :photographer_billings

  def full_address
    [billing_address, billing_zip_code, billing_city].reject(&:blank?).join(' ')
  end

  def conditions
    [
      ("#{time_limit} jours" if time_limit.to_i > 0),
      ("fin de mois" if end_of_month)
    ].compact.join(' ')
  end

  def country_type
    billing_country_id == 74 ? :france : :foreign
  end

  def company_details
    [billing_company,
     billing_address,
     [billing_zip_code, billing_city].delete_if(&:blank?).join(', '),
     billing_country&.name
    ].delete_if(&:blank?).join("\n")
  end
end
