1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-05 20:46:14 +01:00
fab-manager/app/models/accounting_line.rb

25 lines
742 B
Ruby

# frozen_string_literal: false
# Stores an accounting datum related to an invoice, matching the French accounting system (PCG).
# Accounting data are configured by settings starting with accounting_* and by AdvancedAccounting
class AccountingLine < ApplicationRecord
belongs_to :invoice
belongs_to :invoicing_profile
def invoice_payment_method
# if the invoice was 100% payed with the wallet ...
return 'wallet' if (!invoice.wallet_amount.nil? && (invoice.wallet_amount - invoice.total == 0)) || invoice.payment_method == 'wallet'
# else
if invoice.paid_by_card?
'card'
elsif invoice.paid_by_transfer?
'transfer'
elsif invoice.paid_by_check?
'check'
else
'other'
end
end
end