Skip to main content

Multiple transactions

Stock transaction service is transactional, so transactions are immutable, and a single transaction updates a single stock type. Some operations therefore result in several transactions — and in a transfer, in two different business units.

They are published as separate events, linked by linkIdRelated, which every transaction produced from the same operation shares. A consumer that needs to see an operation as a whole should group on that field.

Stock transfer

Sending the goods — one operation, three transactions:

#Business unitStock typeChangeWhy
1A (sending)SalesStockdecreaseno longer available to sell
2A (sending)InTransitincreaseon its way, still A's stock
3B (receiving)InOrderincreaseincoming, visible to B before it arrives

Receiving the goods — the receiving store performs a stock transfer received operation, producing three more:

#Business unitStock typeChangeWhy
4A (sending)InTransitdecreaseno longer in transit
5B (receiving)InOrderdecreaseno longer incoming
6B (receiving)SalesStockincreaseavailable to sell

Note that the goods remain accounted for at every step. Between transactions 1 and 6 they are neither sellable at A nor sellable at B, but they are never invisible — they sit in InTransit and InOrder.

Store transfer

A store transfer adds a reservation step, so goods can be committed to a transfer while still physically present in the sending store.

Initiating the transfer:

Business unitStock typeChangeWhy
A (sending)Reservedincreasecommitted to the transfer, must not be sold
B (receiving)InOrderincreaseincoming

Completing the transfer — when the goods actually leave A:

Business unitStock typeChangeWhy
A (sending)SalesStockdecreasehas now left the store
A (sending)InTransitincreaseon its way
A (sending)Reservedreleasedthe reservation has been fulfilled
B (receiving)InOrderreconciledadjusted to what actually shipped

The receiving store then performs a stock transfer received operation, exactly as above.

Why the extra step matters: the quantity actually shipped may differ from the quantity requested. The completion reconciles both the reservation at A and the incoming quantity at B against what really left, so a partial transfer does not leave a permanent phantom reservation or a permanent phantom incoming quantity.

Sales that touch a reservation

A sale of goods that were reserved releases the reservation as well as reducing sales stock, so the same grouping applies — one PosLog line, more than one transaction.

Note: The transactions are immutable, so any adjustment of previously created transactions needs to be handled by creating a delta transaction. This is also how movements that arrive out of sequence are corrected — see Delayed transactions.


Return