MGCEarmarkAccrualEvent
The queue that decouples a posted document from the accrual engine. When a packing slip, invoice, product receipt or credit note posts, Earmark observes it after the document has committed and does one thing only: it adds a row here. No journal is written, no balance moves and no engine code runs inside the native posting, so a document always posts whether or not Earmark can accrue against it. The drain then claims queued rows and posts the movements. One row exists for each combination of inventory transaction origin, source document, movement type, origin and accrual instance, and that combination is unique - which is what makes a re-posted document incapable of accruing twice. Rows are removed only by retention, only once they have reached Posted or Superseded.
Fields
| Name | Type | Mandatory | Description |
|---|---|---|---|
InventTransOrigin | RefRecId | Yes | The inventory transaction origin the event is anchored on. This is the origin record, not the individual inventory transaction, and the difference matters: one order line that ships in three deliveries has three inventory transactions but one origin, so anchoring on the origin keeps an event tied to the line it belongs to across partial deliveries, returns and re-reservations. It is part of the unique event key. |
SourceDocumentType | MGCEarmarkSourceDocType | No | The kind of document whose posting produced this event - sales packing slip, sales invoice, product receipt, vendor invoice, return packing slip, credit note, purchase return, a manual act or a migration load. It is part of the unique event key, so the packing slip and the invoice that follows it are two separate events against the same order line rather than one event posted twice. |
SourceDocumentId | MGCEarmarkNaturalKey | Yes | The readable number of the document that produced this event - the packing slip number, invoice number or product receipt number. It is stored as text beside the record references so that the event stays traceable in an export, a data load and after a migration, when a record identifier alone means nothing. It is part of the unique event key. |
MovementType | MGCEarmarkMovementType | No | The movement the drain will post for this event - an accrual, an accrual reversal, a claim, a claim reversal or a claim approval. It is part of the unique event key, which is what lets a document carry both an accrual and the reversal of an earlier accrual without the two colliding. Movement type is always set explicitly by whatever enqueues the event; it is never left to default, because the default value of the movement type list is Accrual and an accrual arrived at by omission would post money from nothing. |
Origin | MGCEarmarkMovementOrigin | No | Whether the event came from a posted document or from a catch-up run that is repairing a transaction an earlier control verdict skipped. Both are legitimate against the same anchor and the same movement type, which is why origin is part of the unique event key rather than a note beside it. Migrated is never used on this table - a migrated opening position was never queued from a document, so it appears on the accrual transaction instead. |
AccrualInstance | RefRecId | Yes | The accrual instance this event will post against - one deal's commitment on one order line. It is part of the unique event key because one order line can carry several deals at once: without it, the second deal's event on a shipped line would collide with the first deal's and be silently dropped, and that deal would never accrue. |
Status | MGCEarmarkAccrualEventStatus | No | Where the event stands in the drain. It advances Queued, then Processing when a drain claims it, then Posted or Superseded, and it never moves backwards - with one exception. If the session that claimed an event dies before finishing, the staleness sweep returns the event from Processing to Queued so another drain can take it; that is the only backward move the product permits, and only the sweep can perform it. An event is deletable only once it has reached Posted or Superseded. |
Attempts | MGCEarmarkEventAttempts | No | How many times a drain has claimed this event. It is incremented as part of the claim itself, so an event that was reclaimed after a dead session and taken again carries its true attempt count. A rising number against an event that is not reaching Posted is the signal to look for a matching row in the execution-exceptions workbench. |
LastMessage | Notes | No | What the last processing attempt reported. It is a diagnostic note for whoever is triaging the queue and is not the record of a failure: a genuine malfunction raises an execution exception, which is retryable and is where recovery happens. Treat this column as the short explanation and the workbench row as the case. |
ClaimedBySession | Integer | No | The session that claimed this event. It is stamped by the claim and cleared when the staleness sweep returns an abandoned event to the queue, so a non-zero value beside a Processing status names the session that owes the work. It is a diagnostic, not a lock: what actually prevents two drains taking the same event is that the claim flips Queued to Processing in one set-based statement rather than reading and then writing. |
ClaimedDateTime | TransDateTime | No | When the event was last claimed. The staleness sweep measures its window from this instant, so an event whose claiming session died is returned to the queue once the window has passed. The stamp is deliberately left in place when an event is reclaimed, because it is the evidence of when the abandoned claim happened; what decides whether the event is eligible again is its status, not this value. |
ResultAccrualTrans | RefRecId | No | The accrual transaction this event produced. One event produces one movement, so this reference is single-valued and cannot be pointed at a different transaction once it has been set - a re-pointed event would leave one posted movement claiming to be two. It is the link a reviewer follows from a posted document to the accrual it caused. |
CatchUpSourceTrans | RefRecId | No | Optional. On a catch-up event this may name the transaction being repaired, but it is usually blank and that is correct. A catch-up event exists because a movement was skipped by a Below qualifying quantity verdict, and section 5.5 rules that a zero-amount outcome writes a verdict and no transaction at all - so in the ordinary case there is no earlier transaction to name. Section 4.2.4 called this column the idempotency predicate; it is not, and does not need to be. Idempotency for a catch-up is carried by the six-column unique index EventKeyIdx, which includes the origin and therefore keeps the catch-up event distinct from the document event for the same instance and the same source document. A Document event may never carry this reference at all. |