Skip to content

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

  • InventoryCountSession exists with key info.session_key
  • Session status is PROCESSING (raises ValueError otherwise)

State Changes (Transaction)

Collections: InventoryCountSession, inventory_count_record, MovementList, movement, is_in_position

  • is_in_position records with locked == true AND locked_by == session_key updated: locked → false, locked_by → null
  • MovementList (the session's adjustment_list_key) updated: status → COMPLETED, end timestamp set
  • InventoryCountSession updated: status → APPLIED, movements_created, movements_failed, processing_completed timestamp

Side Effects (post_processing)

Inherits post_processing() from BaseEvent — no broker publish.

InfoModel Fields

FieldTypeDescription
session_keystrArangoDB key of the inventory count session to finalize

None.

Source

CountSessionAppliedEvent on GitHub

Released under the Apache 2.0 License.