Postman collection
Payments Write

pixiCreateBanklineMatch

Matches a bank line to an order by creating a manual bank match and can optionally release the order from hold.

Creates a manual entry in BankMatch that links a bank line (BanklineKey) to an order.

  1. Either OrderNr or OrderNrExternal must be passed, otherwise an error row is returned.
  2. The order is looked up in OrderHeader with OrderNr = @OrderNr OR OrderNrExternal = @OrderNrExternal. The open amount is the order total, rounded to the number of decimal places from the setting NumberOfDecimalPlacesForPrices (default 2), minus PaidByCustomer.
  3. The match difference is calculated as the absolute value of the remaining bank amount (BankAmount - UsedAmount) minus the open amount. If MaxMatchDelta is set and this difference is larger, nothing is written and an error row is returned.
  4. If a match between this order and this bank line already exists, an error row is returned.
  5. Otherwise a row is inserted into BankMatch with ManualMatch = 1, the current date and AmountMatched = the smaller of the remaining bank amount and the open amount.
  6. If AutoReleaseOrder = 1, the difference between OrderTotal and PaidByCustomer of the order is checked again. If it is less than or equal to MaxMatchDelta (or 0 if not set), the order lines with status HAL are set to ANG (order released from hold). Otherwise the newly created match is deleted again.

The call always returns exactly one row with Status, Message and the current values of the bank line.

Notes

  • Status does not reveal the auto-release outcome: after the insert, Status is always OK and Message is always empty, even when the match was deleted again because the order could not be released. Check the order or BankMatch afterwards if this matters.
  • The auto-release check relies on PaidByCustomer having been updated after the insert. The code itself does not update it; this presumably happens via logic outside this procedure (e.g. a trigger), which is not visible here. If PaidByCustomer is NULL, the order is never released and the match is removed.
  • If both OrderNr and OrderNrExternal are passed, the OR filter may match several orders; then one of them is taken arbitrarily.
  • The existence of the bank line is not checked. For a non-existing BanklineKey no match is inserted, but Status is still OK. In this case the match key is taken from IDENT_CURRENT('BankMatch'), which is not session-scoped; together with AutoReleaseOrder = 1 and a failed release check this can delete an unrelated BankMatch row. The same risk exists under concurrent inserts.
  • If UsedAmount is NULL, AmountMatched becomes NULL (no ISNULL in the insert), while the delta check treats it as 0.
  • Reads use NOLOCK. The work runs in one transaction that is committed in all branches after the order lookup.
  • Errors in the release step (GOS_ReleaseOnHold) are logged to LogTable and re-raised; they reach the caller as SqlMessage.
  • Released order lines get UpdateEmp = BanklineMatch - API (payments), truncated to 20 characters.

Tables used

OrderHeader · Read BankLines · Read BankMatch · Write Numbers · Read Settings · Read Orderlines · Write LogTable · Write
SQL object:
dbo.pipiCreateBanklineMatch
Updated at 2026-10-30