Skip to content
ERPForAll DocsDevelopment

    Payments and payment methods

    erp_addon_account::payment holds the payment account.payment ([AccountPayment]), the payment method account.payment.method and the method line account.payment.method.line (a method on one journal).

    The addon ships two methods, Manual Payment inbound and outbound (data/account_payment_data.xml). Every bank, cash and credit-card journal created through the ORM, or changed into one, gets one line of each; journals that existed before version 1.3 of the addon get them at the 1.4 upgrade step, and the demo bank and cash journals their demo outstanding accounts there as on a fresh install (the step fails by name when the two methods did not load). A line’s payment_account_id is the outstanding receipts (inbound) or payments (outbound) account of its payments. Methods and lines are written by accounting managers.

    StatusHow it gets thereJournal entry
    Draftcreatednone (ADR 0048, parity treatment A4 W10)
    Paidaction_postcreated and posted through moves::post_moves, numbered in the journal’s payment chain (P before the code)
    Reconciledits liquidity item is settled, or it is matched with invoices (or bills) that are all paid and its outstanding account is not a bank or cash account; or action_validateunchanged
    Cancelledaction_cancel on a draftnone

    state, name, move_id, the reconciliation flags, the outstanding account and is_sent are written by these actions only: a value given to create or write, or a default_* context key, is refused by name (a new payment may say state = "draft"). action_post never books a payment that already has an entry. The reference resets a confirmed payment and its entry to draft; under the reversal-only policy (ADR 0146) that is refused here.

    action_draft returns a cancelled or rejected payment to draft. A confirmed payment cannot be cancelled, reset or deleted, and its date, amount, partner, journal, method and accounts cannot change: its posted entry is undone by a reversal (ADR 0146), which is not built yet. The memo stays writable and becomes the entry’s reference.

    Posting builds one entry per payment: a liquidity item on the outstanding account (the method line’s, else the root company’s transfer account, else the payment is refused by name) and a counterpart item on the destination account (the one given, else the company’s receivable or payable account, chosen as for invoices). Both carry the commercial partner, the payment date as due date and the label “method: memo”. The entry’s origin_payment_id links it to the payment and is written by the service only.

    state, is_reconciled and is_matched are written by payment::refresh_payments, which runs in the unit that posts, matches or unmatches (reconcile::apply::refresh_moves, after the invoices’ status). is_matched is also true when the outstanding account is the journal’s own account. Callers cannot write them, nor name, move_id, outstanding_account_id and is_sent, given or as default_<field> context keys.

    account.move.action_register_payment() (the Register Payment button of a confirmed invoice, bill or credit note) returns a dialog action on account.payment.register with default_invoice_ids. The transient model computes from its documents the company, the commercial partner, the direction (from the sign of the netted amount due), the amount due, the amount and the memo (the document numbers, sorted); the journal is the company’s first bank journal, else its first cash journal, and the method line the journal’s first line of the direction. journal_id and payment_method_line_id stay editable; amount and communication only while single_payment (the dialog makes one payment). A row is its creator’s only (the access row’s create_uid predicate, as the base wizards have) and of its documents’ company.

    The client opens the dialog as a new record: its first onchange sees the documents as in-memory records, so the computes read their stored rows through the records’ origin. The client then creates the dialog with one save that carries the documents and what the user entered (amount, memo, journal, method line). The company and its currency come from a read-only #[compute(candidate, ...)]: that only keeps such a create from being refused for an async currency. The documents are linked after the INSERT, so the company and currency arrive with the recompute that follows the link, and that recompute keeps what the row already holds: the entered amount and memo on the first computation, the chosen journal, and the chosen method line while it is a line of that journal and direction.

    action_create_payments() asks the write right on the dialog row and locks it, reads the documents after the caller’s read check, refuses by name what cannot be paid together (not an invoice, bill or credit note; not confirmed; blocked; nothing left to pay; another currency than the company’s; an amount due on several receivable or payable accounts; several companies; customer and vendor documents mixed; documents that cancel each other out; an amount of zero or less; an amount due that changed since the dialog opened; a changed amount when several payments would be made; a journal of neither the documents’ company nor one of its parents; a payment method of the other direction), then creates the payments in the documents’ company, each with the chosen method line, through account.payment.create with the caller’s rights, posts them with post_payments and matches each payment’s counterpart item with the documents’ open items through reconcile_lines. With group_payment (the default) there is one payment per commercial partner and account; without it, one payment per document for its own amount due. When there is one payment it carries the entered amount. The dialog row is deleted with the registration, so a second call finds it gone (Missing) and registers nothing. The dialog closes with a notification naming the payments.

    Read-only accounting users read payments; accounting users create, post, cancel and reset them (the posting and reconciliation services ask account.group_account_user); records are isolated per company.

    Payments in another currency are posted (the items are converted at the payment date) but cannot be matched yet; duplicate detection, the receipt report, check printing, online providers, withholding lines, internal transfers, reversal of a confirmed payment come with their slices. The Register Payment dialog does not yet pay documents in other currencies, write off a difference, split installments, apply early-payment discounts or propose the partner’s preferred method line.