StockTransaction
The StockTransaction entity, mapped to the stock_transaction table.
| Table | stock_transaction |
| Tenant-scoped | Yes — extends TenantOwned |
| Columns | 18 |
| Relationships | 4 |
| Source | backend/src/main/java/com/motorph/payroll/model/StockTransaction.java |
Columns
| Field | Type | Column | Null | Notes |
|---|---|---|---|---|
transactionId | Integer | transaction_id | — | primary key, generated |
transactionType | String | transaction_type | — | — |
quantity | Integer | quantity | — | — |
referenceNo | String | reference_no | Yes | — |
notes | String | notes | Yes | — |
serialNo | String | serial_no | Yes | — |
lotNo | String | lot_no | Yes | — |
createdAt | LocalDateTime | created_at | — | — |
qtyDelta | Integer | qty_delta | — | Signed change in quantity at this location. |
unitCost | BigDecimal | unit_cost | Yes | Cost per unit this movement was valued at (receipt cost, or the moving average). |
totalCost | BigDecimal | total_cost | — | Signed change in the item's carrying value. |
qtyAfter | Integer | qty_after | Yes | Item-level (all locations) quantity after this movement. |
avgCostAfter | BigDecimal | avg_cost_after | Yes | — |
valueAfter | BigDecimal | value_after | Yes | — |
businessDate | LocalDate | business_date | — | The date the movement belongs to for reporting (receipt date, delivery date, count date). |
sourceType | String | source_type | — | — |
sourceId | Integer | source_id | Yes | — |
reasonCode | String | reason_code | Yes | — |
Plus tenant_id, inherited from TenantOwned. Hibernate stamps it on insert and adds where tenant_id = ? to every query, so it is never written or read by application code.
Relationships
| Field | Kind | Target | Join column | Required |
|---|---|---|---|---|
item | @ManyToOne | InventoryItem | item_id | Yes |
location | @ManyToOne | WarehouseLocation | location_id | Yes |
performedBy | @ManyToOne | User | performed_by | — |
counterLocation | @ManyToOne | WarehouseLocation | counter_location_id | — |
Neighbourhood
Repository
StockTransactionRepository
Declared over StockTransaction with id type Integer, with JpaSpecificationExecutor for dynamic filtering. Source: backend/src/main/java/com/motorph/payroll/repository/StockTransactionRepository.java
| Method | Returns | Notes |
|---|---|---|
findAllByItem_ItemId(Integer itemId, Pageable pageable) | Page<StockTransaction> | derived |
findAllByOrderByCreatedAtDesc(Pageable pageable) | Page<StockTransaction> | derived |
lastTransactionId() | Integer | explicit @Query |
valueThrough(@org.springframework.data.repository.query.Param("id") Integer transactionId) | java.math.BigDecimal | explicit @Query |
Reached by
These controllers hold — directly or through a service they depend on — a repository over StockTransaction.
| Controller | Base path | Endpoints | Module |
|---|---|---|---|
| InventoryController | /api/inventory | 38 | Inventory & Portal |
Generated page
This page is rebuilt from the source on every docs build by docs-site/scripts/gen-code-wiki.mjs. Editing it has no effect — change the code, or, if what you want to say is prose, write it in docs/.