Bank import — finalising, storno, skipping, deletion

The steps from staged items to a document, duplicate protection and the import row balance match, the rules of storno and skipping, and the rights.

Finalising (final, finalizerow) builds a bank document (transaction header + items) from the staged items, settles the invoices' outstanding balances and sets the row to Booked. A row becomes booked only if at least one live document belongs to it and its balance matches.

Finalising (finalizeAllStagedTransactions())

  1. Processes every (or one) status-1 row by value date, in a database transaction.
  2. Duplicate protection: if the row already has a live document, it is skipped.
  3. Header + items from the staged items; number in the form account-direction-sequence (finance/transaction::nextTransactionNo, otherwise the IMP- prefix with the row ID); value date, statement number, opening and closing balance.
  4. The invoice outstanding balance is settled; payment order items become “bank settled” (paymentorder::markItemsBankSettled); a cross-client mirror draft is created; the partner bank account is linked to the partner.
  5. Finally the import row balance is compared with the documents (importRowBalance()); on a mismatch it rolls back. On success the row is Booked.
  6. Per-row database errors in the response (error_finalize_row).

Storno (stornorow)

Deletes the row's documents with finance/transaction::deleteTransactionWithRollback() (outstanding balances are restored); if there is no document (orphan row), it sets the row to New. Blocked for a finalised (status 1) document: reset it to draft in the document module first.

Skipping and deletion (delete)

  • skip: sets the row to status 5 (staged items deleted); called again 5 → 0.
  • delete: physically deletes the RAW row and its staged items; the template has no button for it.
  • A Booked (2) row cannot be skipped or deleted.

Data model

Table names carry the installation's own prefix in the database: transaction, transaction_item, transaction_settlement, invoice, transaction_import_row, transaction_import_staged, payment_order_item, bankaccount (balance).

Permissions

  • final + core modify: final, finalizerow, stornorow. finalizerow and stornorow check content scope (the company resolved from the row's owner_account must be allowed); the bulk final has no content scope.
  • delete + core modify: skip, delete.
  • None of the keys is in the catalogue seeds.