Postman collection
Invoices Write

pixiCreateDirectInvoice

Creates a direct invoice (Rechnung) for an order, either for selected order lines or for all open lines, and returns the result as a status row.

Wrapper around the internal procedure Pixi_CreateDirectInvInvoices. It always uses CreationMode = 'Direct' and language 1. The 1SS, bin and best-before options of the internal procedure are not used.

Processing steps

  1. Open lines check. If the order has no order line in one of the statuses RAS, OPA, NAO, ANG, BES, BOR, NAS, OPH, NAD (for example only MIN lines), the call stops without a result set.
  2. Line selection. OrderlineRefs is split at commas into order line keys. An empty or NULL value means all eligible lines of the order.
  3. Active picklist check. If OrderlineRefs is empty and any line of the order is on an active picklist (PLitem.Expired = 0), the call stops without a result set.
  4. Customer and address check. Customer, billing address, shipping address, ship vendor and currency are read from OrderHeader. No invoice is created if the customer (SLocked) or the shipping address (ASlocked) is locked.
  5. Picklist for stock release. If setting DoNotReleaseStockOnDirectInvoiceScanOut is '0' or AllInvoiceItemsInStock = 'Y', a picklist is created for the selected lines (partial orders and partial quantities allowed).
    • With AllInvoiceItemsInStock = 'Y', the picklist is deleted and no invoice is created if it is empty or if the picked quantity differs from the sum of the ordered quantities.
    • If the setting is '1', the picklist is deleted again after the check.
  6. Invoice creation (in a transaction).
    • The invoice header is created. VAT type is N if the billing address has a VAT ID (UsStID) or the customer has TaxOnInvoice = 'N', otherwise I.
    • The exchange rate, return tracking ID and SEPA data are determined.
    • Invoice lines are inserted for the selected lines in the statuses above plus MIN that are not yet invoiced.
    • The next invoice number of the shop is assigned. The package weight is the setting DefaultShippingWeight, or the sum of item weights if CalculateWeightFromItems = 1, capped at 999999.999.
  7. Order line update. Invoiced non-MIN lines get InvRef and status EIN. MIN lines get only InvRef.
  8. Cancel remaining lines. If setting Invoice_CancelPartialDelivery = '1', remaining ANG/HAL/BOR lines of orders with ForceToPickListIfNotFULL = 1 and OHCancelAfterForcedShipOut = 1 are set to STO.
  9. Automatic scan-out. If the ship vendor (DoScanOutOnInvoiceCreate) or the payment method (AutoScanOutInvoice) requests it:
    • a box is created and scanned out;
    • a stock release job is queued in ExecQueries;
    • the box is deleted if setting 1SS_ForceAutoScanOut = 1, and ScanOutDone becomes 1.
  10. Event. The MQ event InvoiceCreated is published and the transaction is committed.

The call finally returns one status row with Success, InvoiceKey, CreatedInv and InvoicePackageId.

Notes

  • No result set in some cases. The call returns no result set at all if the order has no open (non-MIN) lines, if OrderlineRefs is empty and part of the order is on an active picklist, or if AllInvoiceItemsInStock = 'Y' and the picked quantity does not match. Clients must handle a missing SqlRowSet1.
  • Success = 1 does not guarantee an invoice. In these cases InvoiceKey/CreatedInv stay 0:
    • the customer or the shipping address is locked;
    • no eligible lines were found;
    • the picklist was empty with AllInvoiceItemsInStock = 'Y'. Always check CreatedInv > 0.
  • Errors are reported twice. If an error occurs during invoice creation:
    • the transaction is rolled back and the error is logged via LOG.InsertError;
    • the picklist is deleted;
    • a row with Success = 0 is returned;
    • the error is then re-raised (sp_Exception_ReRaise), so a SqlMessage is also returned.
  • OrderlineRefs format. The value must be comma-separated, e.g. ,1234,1235,. Only numeric elements greater than 0 are used.
  • LocID. Used for picklist creation and scan-out only. The invoice location comes from the order lines (LocationID).
  • Side effects:
    • picklists may be created and deleted;
    • a job Pixi_ReleaseStockFrominvoicePicklist is queued in ExecQueries on auto scan-out;
    • the MQ event InvoiceCreated is published;
    • Pixi_CA_AddPixiInvoice is executed;
    • duration logging is written via LOG.EventDurationInsert.
  • Settings read at runtime: DoNotReleaseStockOnDirectInvoiceScanOut, DefaultShippingWeight, CalculateWeightFromItems, PutThisStatusesOnInvoice, Invoice_CancelPartialDelivery, 1SS_ForceAutoScanOut.
  • Not attached. The behaviour of the called procedures (e.g. Pixi_CreatePickList, GOS_Qi_InvoiceNOD, Pixi_ScanOutBox) is not attached and may raise further errors.
  • Locking. Most reads use NOLOCK.

Tables used

Orderlines · Write OrderHeader · Read PLitem · Write PLheader · Write ShipVendor · Read Addresses · Read Customers · Read InvLines · Write Invoices · Write Currency · Read items · Read InvoicePackage · Write Payments · Read ExecQueries · Write boxes · Write
SQL object:
dbo.pipiCreateDirectInvoice
Updated at 2026-10-30