Skip to main content

StockTransaction

The StockTransaction entity, mapped to the stock_transaction table.

Tablestock_transaction
Tenant-scopedYes — extends TenantOwned
Columns18
Relationships4
Sourcebackend/src/main/java/com/motorph/payroll/model/StockTransaction.java

Columns​

FieldTypeColumnNullNotes
transactionIdIntegertransaction_id—primary key, generated
transactionTypeStringtransaction_type——
quantityIntegerquantity——
referenceNoStringreference_noYes—
notesStringnotesYes—
serialNoStringserial_noYes—
lotNoStringlot_noYes—
createdAtLocalDateTimecreated_at——
qtyDeltaIntegerqty_delta—Signed change in quantity at this location.
unitCostBigDecimalunit_costYesCost per unit this movement was valued at (receipt cost, or the moving average).
totalCostBigDecimaltotal_cost—Signed change in the item's carrying value.
qtyAfterIntegerqty_afterYesItem-level (all locations) quantity after this movement.
avgCostAfterBigDecimalavg_cost_afterYes—
valueAfterBigDecimalvalue_afterYes—
businessDateLocalDatebusiness_date—The date the movement belongs to for reporting (receipt date, delivery date, count date).
sourceTypeStringsource_type——
sourceIdIntegersource_idYes—
reasonCodeStringreason_codeYes—

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​

FieldKindTargetJoin columnRequired
item@ManyToOneInventoryItemitem_idYes
location@ManyToOneWarehouseLocationlocation_idYes
performedBy@ManyToOneUserperformed_by—
counterLocation@ManyToOneWarehouseLocationcounter_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

MethodReturnsNotes
findAllByItem_ItemId(Integer itemId, Pageable pageable)Page<StockTransaction>derived
findAllByOrderByCreatedAtDesc(Pageable pageable)Page<StockTransaction>derived
lastTransactionId()Integerexplicit @Query
valueThrough(@org.springframework.data.repository.query.Param("id") Integer transactionId)java.math.BigDecimalexplicit @Query

Reached by​

These controllers hold — directly or through a service they depend on — a repository over StockTransaction.

ControllerBase pathEndpointsModule
InventoryController/api/inventory38Inventory & 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/.