CountSessionAppliedEvent
EventType: COUNT_SESSION_APPLIEDDomain: inventory Broker subject: —
Finalises an inventory count session after its async processing completes. Validates the session is in PROCESSING status, unlocks all positions locked by the session, tallies movements created vs failed, marks the adjustment MovementList as COMPLETED, and updates the session to APPLIED with result statistics.
No broker notification
CountSessionAppliedEvent extends BaseEvent directly — not BaseInventoryEvent. Its _notification_subtopic is null, so no broker message is published after commit. Downstream consumers poll or re-read the session state after async processing signals completion.
Sequence Diagram
Trigger
Triggered by: POST /event (universal event dispatcher)
Dispatched via POST /event in backend/api/endpoints/traceability.py with event_type: COUNT_SESSION_APPLIED. Called by the async count-session processing worker after all per-record movements have been applied.
Preconditions
InventoryCountSessionexists with keyinfo.session_key- Session
statusisPROCESSING(raisesValueErrorotherwise)
State Changes (Transaction)
Collections: InventoryCountSession, inventory_count_record, MovementList, movement, is_in_position
is_in_positionrecords withlocked == true AND locked_by == session_keyupdated:locked → false,locked_by → nullMovementList(the session'sadjustment_list_key) updated:status → COMPLETED,endtimestamp setInventoryCountSessionupdated:status → APPLIED,movements_created,movements_failed,processing_completedtimestamp
Side Effects (post_processing)
Inherits post_processing() from BaseEvent — no broker publish.
InfoModel Fields
| Field | Type | Description |
|---|---|---|
session_key | str | ArangoDB key of the inventory count session to finalize |
Related Events
None.