Skip to main content

Accrual event processor

This page is for administrators, accountants and accounting managers who schedule and watch the job that posts Earmark accruals. The Accrual event processor works through the accrual event queue that posting a packing slip, product receipt or invoice fills, and turns each queued event into an accrual transaction, a deal balance update and an unposted Earmark general journal. At the end of each run it also posts the journals that are set to post automatically.

Runs: a batch job you schedule. Nothing schedules it for you, and until it runs nothing accrues on its own. Set up by: Accounting manager or Accountant (a System administrator can too). Watched by: Accountant and Accounting manager.

Why it exists​

Posting a sales or purchase document never posts an accrual itself. As part of the posting, Earmark adds one row to the accrual event queue for each commitment (accrual instance) whose accrual point the document reached, and does nothing else. That keeps every money step away from the native document: a document that fails or is only simulated queues nothing, and nothing Earmark does later can refuse or slow the document.

The processor is where the work happens, in the order the events were queued and in bounded runs, so a backlog is worked steadily instead of in one long transaction. If it is not scheduled, the queue grows, deal balances do not move, caps are not checked and there is nothing to claim.

When it runs​

TriggerWhat runs
Its recurring batch jobThe whole run: reclaim, claim, process, then automatic journal posting. This is the only trigger that works through the queue on its own.
You open it and select OK with Batch processing offThe same run, once, straight away.
Process now on Accrual event queueOnly the rows you select that are already Processing (claimed by an earlier run that hit its limit or stopped, or held by a failure). A Queued row is left alone with "Event ... was not processed: it is Queued, and only an event that has been claimed for processing can be run. Wait for the sweep, or run the event processor." and the summary "... event(s) processed, ... left untouched." To process queued rows now, run the processor itself.
Retry selected on an Accrual movement row of the execution exceptions workbenchThat row's event, if it is still Processing.

To run it now or schedule it: open Earmark > Periodic tasks > Accrual event processor (also under Related links > Periodic tasks on the Deal control workspace, or select the Accrual event processor not scheduled tile on the Earmark configuration workspace). The Process Earmark accrual events dialog opens. To schedule it, use the Run in the background tab: switch Batch processing on and set a Recurrence. Schedule it in every company where an Earmark module is on: the queue and the job are per company.

How often: at least every Event sweep cadence minutes (15 as shipped). The Accrual event processor not scheduled setup gap stays open until the company has a recurring batch job that runs this processor at least that often. It counts a job whose status is Waiting, Executing, Ready or Scheduled; a job that is on hold, ended in error, finished or was canceled does not count. A recurrence counted in days is read as its number of days (one day for any other day pattern), and one in weeks, months or years as 7, 28 or 365 days. With Event sweep cadence set to 0, any recurrence closes the gap. A shorter recurrence makes accruals appear sooner after a shipment, at the cost of more batch runs.

On the Batch jobs page (System administration > Inquiries > Batch jobs) the job's task runs the class MGCEarmarkAccrualEventProcessorController.

Settings​

SettingWhereDefaultEffect
Events to process per runProcessor dialogAccrual event drain cap (per run), 2,000 as shippedThe most events this run processes, and the most journals it then sends for automatic posting. Must be greater than zero.
Staleness window (minutes)Processor dialogEvent staleness timeout (minutes), 60 as shippedHow long an event may stay Processing before this run returns it to the queue. Must be greater than zero while reclaim is on.
Reclaim abandoned events firstProcessor dialogYesReturns abandoned events to the queue before the run claims, so the same run takes them. Switch it off only for a diagnostic run.
Event sweep cadenceEarmark > Setup > Earmark parameters, Accrual processing tab15 minutesThe recurrence the setup gap checks the job against. It schedules nothing.
Accrual event drain cap (per run)Same tab2,000The default for Events to process per run. Zero means 2,000.
Event staleness timeout (minutes)Same tab60The default for Staleness window (minutes), and the age at which the queue's Flagged for reclaim column is set. Zero means 60.
Event processing modeSame tabImmediate and sweepHas no effect in this release: no step Earmark runs depends on it, and this job posts accruals the same way in either mode.
Post automatically (one row per movement type)Earmark parameters, Posting control tabOffWhether the journals this run creates are posted at the end of the run. See Post automatically.
Show infolog message (one row per movement type)Earmark parameters, Posting control tabOffAdds one infolog line per posted movement of that type, which lands in the run's log.
Publish accrual eventsEarmark parameters, Events tabYesWhether each posted movement raises an accrual business event.
Accrual event retention (days)Earmark parameters, Retention tab90How long Posted and Superseded queue rows are kept before retention cleanup deletes them. Zero turns this purge off.

A scheduled job keeps the dialog values it was saved with. If you change the parameters later, open the batch job's parameters to change the job too.

What it does​

  1. Reclaims. With Reclaim abandoned events first on, every event that has been Processing for longer than the staleness window goes back to Queued. The infolog says "... abandoned accrual events returned to the queue." This is the only way an event ever moves back.
  2. Claims the queue. Every Queued event in the company moves to Processing in one step, stamped with this run's session and time, and its Attempts count goes up by one.
  3. Takes up to the limit. The run works through at most Events to process per run of the events it claimed, oldest first. The rest stay Processing until the staleness window passes; the next run's reclaim then returns them and that run takes them.
  4. Answers each event in its own transaction:
    • An event that already names a resulting movement becomes Superseded with "Superseded: the movement for this event had already been posted under an earlier claim." Nothing posts twice.
    • The vendor side of a supplier-funded mirror becomes Superseded: it accrues only through mirror pairing.
    • A return reverses the accrual of the shipment it came back from. If that shipment's accrual is itself still waiting in the queue, the return waits in Processing ("Waiting: return document ... found nothing accrued ...") and is offered again after the rest of the run.
    • A forward event whose document was canceled before the run reached it is answered without posting.
    • Every other event goes to the movement engine, which applies the deal's controls (cap, quantity thresholds, per-transaction minimum and maximum), resolves accounts and dimensions, writes the accrual transaction, updates the deal balance and creates the journal, all in one step. The movement is dated with the document's date (a catch-up event uses the processing date). An accrual or a return whose document date falls in a closed or on-hold period posts on the processing date instead and says so in Last message.
    • The event ends Posted ("Movement posted.", with Resulting movement filled) or Superseded ("No movement posted." followed by the verdict, for example the cap was reached).
  5. Pairs mirrors. After each event finishes, Earmark posts the supplier's share of any supplier-funded mirror on that commitment, in a session of its own.
  6. Reports "... accrual events processed."
  7. Posts journals automatically. Journals that are waiting to post automatically are posted, up to the same limit, and the infolog says "... Earmark journals were sent for automatic posting." See Post automatically.

Before it can run​

  • An Earmark module is on in the company. Otherwise the menu item is not shown.
  • The posting setup is complete for each movement type: a journal name on the Posting control tab, the Earmark posting profile and the accrual dimension rules. A gap does not stop the run, but every event that meets it fails and lands on the workbench. The setup-gap tiles on Deal control and Earmark configuration name the gap; see Fix a setup gap that stopped an accrual posting.
  • A batch server is running, for a scheduled job.

What goes in and what comes out​

InOut
Queued rows on Accrual event queue, written by packing slip, product receipt and invoice posting, by the unaccrued transaction sweep, and by catch-up after a deal crosses its qualifying quantityAccrual transactions (Earmark > Inquiries and reports > Accrual transactions)
Processing rows a stopped or capped run left behind (after the staleness window)Updated deal balances (Deal balances on Deal control)
One unposted Earmark general journal per movement that moves money, posted at the end of the run when its movement type is set to Post automatically
Control verdicts for anything a control stopped or clipped (the Breaches list)
Queue rows at Posted or Superseded, with Last message

Watching it​

  • Batch job history (System administration > Inquiries > Batch jobs): each run's log holds the three counts above, any error for a failed event, and the per-movement lines of movement types with Show infolog message on.
  • Accrual event queue (Earmark > Inquiries and reports > Accrual event queue): filter on Status. Read Attempts, Claimed, Last message and Resulting movement. Flagged for reclaim marks a Processing row older than the staleness timeout, which the next run returns to the queue. Status meanings are in Understand what happens when a packing slip or invoice posts.
  • Setup gap: the Accrual event processor not scheduled tile on Earmark configuration and the matching row of the setup checklist (Setup checklist).
  • Deal control tiles: Accrual execution exceptions counts the open accrual failures; Accruals pending posting and Journals pending review count movements and journals still waiting for the ledger.
  • Execution exceptions workbench (Earmark > Inquiries and reports > Earmark execution exceptions): rows with operation Accrual movement, Mirror vendor-side movement and Journal post.
  • Earmark timeline (Earmark > Inquiries and reports > Earmark timeline): one row for each posted movement, under the document type Accrual transaction.
  • Business events: Earmark accrual accrued (accruals and adjustments), Earmark accrual reversed and Earmark accrual returned, when Publish accrual events is on. See Business events.

When it fails​

A verdict is not a failure. When a control stops or clips a movement (the cap is reached, the quantity is below the qualifying minimum), the event ends Superseded with the verdict in Last message, and the verdict is on the Breaches list. Nothing lands on the workbench and nothing is retried: the policy answer stands. A movement skipped below the qualifying quantity comes back on its own as a catch-up event once the deal crosses it. A forward accrual whose document date is in a closed period is not refused: it posts on the processing date. An event that an earlier run did refuse for a closed period is put back on the queue by the Unaccrued transaction sweep. See Tell a verdict from a failure.

A failure (an account that cannot be resolved, a dimension list that runs out, a journal that cannot be created) rolls back that one event and nothing else. The event stays Processing with Last message "The accrual movement for event ... could not be posted. ...", the error is in the run's log, and an Accrual movement row, keyed on the commitment, is added to the execution exceptions workbench. The rest of the run carries on.

To recover:

  1. Read the workbench row's Message and fix the cause, usually a setup gap.
  2. Then do one of these:
    • Retry selected on the row (Accounting manager, Accounts receivable manager or Accounts payable manager).
    • Process now on the event's row in Accrual event queue (Accountant or Accounting manager).
    • Wait: once the staleness window has passed, the next run returns the event to the queue and takes it again.
  3. If the reclaim has already returned the event to the queue, Retry selected does nothing and says so ("Accrual event ..., named by exception ..., has been returned to the queue by the staleness reclaim ..."). Leave the row open; after the next run, a retry finds the event finished and closes the row. The message suggests Process now, but Process now does not take a Queued row: run the processor instead.
  4. Retry in the company shown in the row's Company column. In any other company the event is not found and the row stays open (see Background steps and retry).

The reclaim has no limit on attempts, so an event whose cause is not fixed is tried again after every staleness window, and each failed attempt adds another Accrual movement row. A rising Attempts count on the queue shows it.

If a run stops (the batch server or the AOS restarts), the events it had claimed stay Processing until the staleness window passes, then the next run takes them.

Running it again is safe at any time. The claim is one step, so two runs cannot both take the same event. Each movement carries a key made from its event, and an event that already names its movement is superseded instead of posted again. A document that is posted again cannot queue the same work twice.

Effects on the rest of Earmark​

  • Deal balances, caps and headroom move with each posted movement, so Deals near cap and Deals over cap depend on this job having run.
  • Claims can only claim accruals that have been processed. Claim generation finds nothing for a shipment whose event is still queued.
  • Journals wait as Journal pending until posted, automatically or by hand (Post automatically).
  • Supplier-funded mirrors accrue the supplier's share only after the customer's accrual is processed.
  • Closing a deal needs at least one accrual whose journal has posted.
  • The Unaccrued transaction sweep puts lost events back on the queue; this job posts them.
  • Retention cleanup deletes Posted and Superseded queue rows after the retention days; Queued and Processing rows are never deleted.
  • The license block never stops this job: existing deals keep accruing.