Postman collection
Orders Read

pixiCanMergeOrders

Checks whether two orders can be merged and returns a flag and a reason code with text.

Validates whether the source order (SourceOrderNr) can be merged into the target order (TargetOrderNr). The call does not change any data.

The checks run in this order. The first check that fails sets CanMerge = 0 and the matching reason. The remaining checks are then skipped:

  1. Both orders exist: exactly two rows must exist in OrderHeader for the two order numbers. Otherwise the reason is 401.
  2. Same customer: CustRef of both orders must be equal. Otherwise the reason is 402.
  3. Orderline status: no orderline of either order may have a status other than ANG. Otherwise the reason is 403.
  4. Payment type: APayment of the addresses referenced by the orders (AddrRef) must be equal and must not be K (credit card). Otherwise the reason is 404.
  5. Picklists: no orderline of either order may be on a picklist whose PLHexpiryDate is in the future and whose ReservedOrderNr is empty or 0. Otherwise the reason is 405.
  6. Currency and order type: CurrencyId must match, otherwise the reason is 406. Then OrderType must match, otherwise the reason is 407.

If all checks pass, the call returns CanMerge = 1 and Reason = '200 OK'. It always returns one row with CanMerge and Reason. The same values are set in the output parameters, and CanMerge is also the procedure's return value.

Notes

  • All reads use NOLOCK, so the result can be based on uncommitted data. Re-check right before the actual merge.
  • If TargetOrderNr and SourceOrderNr are equal, only one header row is found, so the result is 401.
  • A NULL value in CustRef, APayment, CurrencyId or OrderType makes the comparison fail and leads to the corresponding error code.
  • Orders without orderlines pass the status check (403).
  • If an order's address (AddrRef) is not found in Addresses, the join returns no row and the payment check (404) is effectively skipped.
  • The column ReservedOrderNr in the picklist check is not qualified with a table name. From the code it is not clear whether it belongs to PLitem or plheader.
  • The reason text starts with an HTTP-like numeric code (200, 401–407), which is useful for programmatic evaluation.

Tables used

OrderHeader · Read Orderlines · Read Addresses · Read PLitem · Read plheader · Read
SQL object:
dbo.pipiCanMergeOrders
Updated at 2026-10-30