SudoSOS Back-end API / transactions
Transactions ​
A Transaction is one purchase at a SudoSOS point of sale: one person paid for a basket of products. The buyer is on the transaction (from); the products and prices live one level down on SubTransactions.
Why it splits ​
A PointOfSale can expose products from containers belonging to different sellers (typically different GEWIS organs), so a single basket can mix sellers. The basket is recorded as one transaction with one sub-transaction per container. Each sub-transaction credits its container's owner; the transaction itself only debits the buyer.
From vs. createdBy ​
fromis the user whose balance is charged.createdByis the user that recorded the transaction.
They are usually the same person. They differ on shared bar shifts: a cashier rings up purchases for buyers who do not have an authenticated session of their own, so the cashier is createdBy and the buyer is from. Whether this is allowed depends on the POS's useAuthentication flag and the cashier role on the PointOfSale.
Price freezing ​
The pointOfSale reference is a PointOfSaleRevision, not a live PointOfSale. Sub-transaction rows reference ProductRevisions; their containers reference ContainerRevisions. Everything the transaction needs to reproduce the basket -- product price, VAT group, category, container membership, POS layout -- is pinned at the revision in force at the moment of sale. Editing any of those later creates a new revision and leaves historical transactions untouched.
Balance impact ​
Each SubTransactionRow debits the transaction's from user (the buyer) and credits its sub-transaction's to user (the container owner). See Balance for how these movements roll up.
PDF receipts ​
Transaction is PdfAble. GET /transactions/{id}/pdf returns a PDF receipt via TransactionPdfService.
Classes ​
| Class | Description |
|---|---|
| TmpSubTransaction | - |
| TmpSubTransactionRow | - |
| TmpTransaction | - |
| Transaction | TypeORM entity for the transaction table. Holds the buyer-side record of one purchase at a PointOfSale. The actual product lines and seller-side credits live on the related SubTransactions, which cascade on save. |
| TransactionController | Controller for the transactions module. Exposes the buyer-facing CRUD for transactions, a validate-before-create endpoint, the invoices-touching-this-transaction lookup, and a PDF receipt. See the module page for how a transaction relates to its sub-transactions. |
| TransactionService | - |
Interfaces ​
| Interface | Description |
|---|---|
| BaseTransactionResponse | - |
| PaginatedBaseTransactionResponse | - |
| SubTransactionRequest | - |
| SubTransactionResponse | - |
| SubTransactionRowRequest | - |
| SubTransactionRowResponse | - |
| TransactionContext | Context object to cache loaded entities and calculated values during transaction processing |
| TransactionFilterParameters | - |
| TransactionRequest | - |
| TransactionResponse | - |
Functions ​
| Function | Description |
|---|---|
| parseGetTransactionsFilters | - |