Skip to content

Inventory Ticket

1. Overview

PropertyValue
IDFEAT-INV-TICKET
StatusBeta (P2 phase)
Ownerinventory-team
Depends onInventoryStock, InventoryLocation, Vendor (partner type), Customer (partner type), Material / ProductVariant (line items)

InventoryTicket is a workflow document for stock operations that need approval before execution: transfer between locations, manual adjustment, cycle count reconciliation, returns, and scrap. The ticket has lines (InventoryTicketItem) and a multi-stage lifecycle. No stock effect until the ticket reaches COMPLETED — at that point the lines drive adjustStock calls.

2. Entity Model

InventoryTicket fields

FieldTypeRequiredDescription
merchantIdtextOwner
typetextSee §3
statustextSee §4
partnerTypetextVENDOR / CUSTOMER / NULL
partnerIdtextFK target
sourceLocationIdtextFor TRANSFER
destinationLocationIdtextFor TRANSFER
submittedAt / approvedAt / startedAt / completedAt / cancelledAttimestamptzPer-status timestamps
notetextFree-form

InventoryTicketItem fields

FieldTypeRequiredDescription
inventoryTicketIdtextFK
inventoryStockIdtextTarget bucket (resolved at submit)
itemTypetextMATERIAL / PRODUCT_VARIANT
itemIdtextFK target id
plannedQuantitydecimal(15,4)What was requested
actualQuantitydecimal(15,4)What was applied (for cycle count vs adjustment)
uomIdtextSoft ref
multiplierdecimal(15,4)UoM-to-base

3. Ticket Types

Source: InventoryTicketTypes.

TypeStock effect on COMPLETENotes
PURCHASE_REQUESTNone (informational)Triggers PO creation downstream (manual today)
STOCK_IN+plannedQuantity per lineManual receipt without a PO
TRANSFER source + + destination per lineAtomic per pair; emits MATERIAL_TRANSFERRED if material
INTERNAL_USE−plannedQuantity per lineInternal kitchen / office use
ADJUSTMENT± actualQuantity per lineOperator-driven correction
CYCLE_COUNT± actualQuantity−countedReconciliation with physical count
RETURN_TO_VENDOR−plannedQuantity per lineLinked to Vendor partner
RETURN_FROM_CUSTOMER+plannedQuantity per lineLinked to Customer partner
SCRAP_DISPOSAL−plannedQuantity per lineMarked with reason (DAMAGED / EXPIRED)

4. Lifecycle

FromEventToEffect
DRAFTsubmitSUBMITTEDLock items
SUBMITTEDapproveAPPROVEDAuthorization gate
APPROVEDstartIN_PROGRESSPicker begins work
IN_PROGRESScompleteCOMPLETEDApply stock effects per line
any non-terminalcancelCANCELLEDTerminal — no stock effect
Status codeDisplay
001_DRAFTDRAFT
200_SUBMITTEDSUBMITTED
250_APPROVEDAPPROVED
300_IN_PROGRESSIN_PROGRESS
303_COMPLETEDCOMPLETED
505_CANCELLEDCANCELLED

5. Operations

InventoryTicketService (inventory-ticket.service.ts — 40 lines)

Inherits CRUD from MerchantScopedService<TInventoryTicketSchema, ...>. Lifecycle transitions wire up via update endpoints + service-level guards (TBD — currently lifecycle methods minimal).

InventoryTicketItemService (inventory-ticket-item.service.ts — 89 lines)

MethodPurpose
CRUD (inherited)Manage lines
Stock-effect on parent COMPLETEIterates lines and calls InventoryStockRepository.adjustStock per line

6. REST Endpoints

VerbPathAuthPermission
6× CRUD/inventory-ticketsJWT/BASICInventoryTicket.<crud>
6× CRUD/inventory-ticket-itemsJWT/BASICInventoryTicketItem.<crud>
LifecycleTBD (submit / approve / start / complete / cancel)JWT/BASICInventoryTicket.<action>

7. Events

Outbound:

TopicWhen
material.transferredAfter TRANSFER ticket completes for a material line
WebSocket observation/inventory/inventory-stockAfter per-line adjustStock

8. Idempotency on COMPLETE

Each line writes one tracking row keyed (INVENTORY_TICKET, ticketId, inventoryStockId). Re-running complete (e.g. from a retry) hits the idempotency lookup and skips already-applied lines.

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.