Invoices on a contract and FX recalculation – system description
Rules and write path of invoice linking, and the source order, side effects and limits of contract-based exchange rate recalculation.
Invoice linking writes the invoice's contract field through the invoice's owning model; the exchange rate recalculation sets the contract's foreign-currency invoices to the contract rate.
Data model
Table names carry the installation's own prefix in the database.
| Table | Role |
|---|---|
invoice | contract_id, rate, forint values, outstanding balance |
transaction_settlement | exchange differences of settlements |
transaction | related vouchers |
Invoice linking
invoicesearch,invoicelink,invoices(list+contractInScope).- The invoice must belong to the contract's client (
error_invoice_scope); an invoice linked to another contract cannot be moved (error_invoice_other_contract). - Writing goes through
finance/invoice::setInvoiceContract.
Exchange rate recalculation (fxrecalc)
apply=0preview,apply=1apply.- Source: the contract's, otherwise the client's
fx_income_sourcesetting, finally MNB; rate day and rate under the contract come from the exchange rate library. - Invoices in a closed period (
periodLockedUntil) are skipped. - On apply:
rebookRate(), settlement exchange differences (refreshSettlementFx), outstanding balance recalculated, interest document refreshed (ensureDoc); each row flags a ledger gross difference above HUF 1. - Error codes:
error_fx_no_contract,no_fx_source.
Permissions
- Linking:
edit+contractInScope; recalculation:fxrecalc+contractInScope(the button appears only with the right). - Models involved:
finance/invoice,finance/transaction,finance/entry,finance/interest; library: invoice service.