Skip to main content

MGCEarmarkDealBalance

The maintained Earmark balance for one deal, at one of three grains: the whole deal, one counterparty within it, or one funding rule. It holds the money accrued and posted, the money accrued into a journal that has not been posted yet, the money reversed, returned, claimed and claim-approved, the quantity accumulated to date, the quantity accumulated while still below the deal's qualifying minimum, the value waiting to be caught up once that minimum is crossed, and the headroom left against the lifetime cap. It is derived state: it is written only by the balance service, inside the movement transaction and under the global lock order, and it is rebuildable from the accrual transactions if it is ever doubted. There is deliberately no settled column: the settled figure is derived on read from the open claim lines, because a stored copy would be wrong the moment accounts receivable settled an invoice and nothing in the product would notice. Implements requirement C14.

Fields​

NameTypeMandatoryDescription
AccruedPendingMGCEarmarkBalanceAmountNoMoney accrued against this deal whose general journal exists but has not been posted, in the deal currency. It is NOT the same thing as accrued and posted, and the two are deliberately separate columns: this bucket has no voucher behind it yet and cannot be tied to the general ledger. It arises when auto-posting is off, and it drains when the journal is posted and the post-commit journal sync moves the amount into the posted bucket. A balance that is heavy in this column is a signal that journals are being created and not posted, which is what the reconciliation explains as pending journals rather than as a variance.
AccruedPostedMGCEarmarkBalanceAmountNoMoney accrued against this deal whose general journal has been posted, in the deal currency. This is the figure a general ledger reader can tie to: every amount in it has a voucher behind it. Money moves into this bucket either at accrual time, when auto-posting is on and the journal posts inside the movement transaction, or later, when the journal is posted by hand and the post-commit journal sync moves it out of the pending bucket.
ClaimApprovedMGCEarmarkBalanceAmountNoMoney against this deal on claims that have been approved, in the deal currency. Approval is where a claim becomes a customer credit; settlement of that credit is ordinary accounts receivable and is deliberately NOT tracked here. The settled figure is derived on read from the open claim lines, because a stored copy would go stale the moment accounts receivable settled an invoice.
ClaimedMGCEarmarkBalanceAmountNoMoney against this deal that has been drawn into a claim but not yet approved, in the deal currency. It is written by the movement engine when the claims package generates a claim, in the same transaction as the movement itself.
CounterpartyAccountMGCEarmarkAccountRelationNoThe customer or vendor account this balance row is kept for. It is blank at Deal level, required at Counterparty level, and optional at Funding rule level. A deal that accrues for many counterparties carries one Deal-level row and one Counterparty-level row per account, and the cap is evaluated against whichever grain the deal's criteria type names.
DealRefRecIdYesThe record reference of the deal this balance belongs to. It is stored beside the deal ID rather than instead of it, because a record ID is unreadable in an export and meaningless after a migration while a deal ID alone is not unique across companies.
DealIdMGCEarmarkDealIdYesThe identifier of the deal this balance belongs to, stored beside the record reference so that the row stays readable in an export and meaningful after a migration. It is supplied by the balance service, which already holds the deal under the first lock of the order; the table deliberately does not read the deal to verify it, because that read would reach backwards to a lock this row sits below.
FundingRuleRefRecIdNoThe record reference of the funding rule this balance row is kept for. It is populated only at Funding rule level and only by the vendor-shape package, which owns funding rules; it is blank at the other two levels. The level exists in this package even though nothing here writes it, because the lock protocol switches over the balance level and that switch has to be exhaustive - a level added later would be a level the lock order had never heard of.
HeadroomAmountMGCEarmarkHeadroomAmountNoHow much of a deal's lifetime cap is still available to accrue against, in the deal currency. It extends the standard transaction-currency amount type so that it inherits currency formatting and rounding. Headroom is recomputed on every balance apply and again whenever an approved amendment changes the cap, because the control evaluator reads the live control set through the locked balance row rather than the instance's display-only snapshot. On a negative deal, headroom is displayed on magnitude.
HeadroomPercentMGCEarmarkHeadroomPercentNoThe share of a deal's lifetime cap still available, expressed as a percentage. It extends the standard percentage type so that it inherits precision and formatting. The deal control workspace sorts on this column, and the headroom warning verdict fires when it falls below the deal's alert threshold. Like the headroom amount it is recomputed on every apply and on amendment, never cached across a parameter change.
LastAccrualDateTransDateNoThe posting date of the most recent accrual that moved this balance. It is a monitoring column: a deal that is live and inside its validity window but has not accrued for a long time is the signal the unaccrued-transaction sweep exists to chase.
LevelMGCEarmarkBalanceLevelNoThe grain this balance row is kept at. A Deal row is the whole deal and carries no counterparty and no funding rule; a Counterparty row is one customer or vendor within the deal and carries no funding rule; a Funding rule row is one funding rule and is written by the vendor-shape package. The three levels are also the second, third and fourth steps of the product's global lock order, in that sequence, which is why the balance key leads on this column: each lock step is every row of one deal at one level, and a level-leading key makes that a seek rather than a scan.
PendingCatchUpValueMGCEarmarkCatchUpValueNoThe money computed for this deal but not accrued, because the deal's qualifying quantity had not been reached, in the deal currency. It is the running sum of the amounts behind the Below qualifying quantity verdicts, and it is what the catch-up run pays out once the minimum is crossed. Movements whose origin is Migrated are excluded from it while still counting into quantity to date.
QuantityBelowThresholdMGCEarmarkDealQtyNoThe quantity accumulated against this deal while it was still below the deal's qualifying minimum, in the deal unit. It is what the deal control workspace shows before the minimum is crossed, and it is what sizes the catch-up run at the moment it is crossed. It is not a second copy of quantity to date: it stops growing once the minimum is reached.
QuantityToDateMGCEarmarkDealQtyNoThe quantity accumulated against this deal so far, expressed in the deal unit. It INCLUDES movements whose origin is Migrated: an opening position loaded during cut-over is real quantity that really moved, so it counts toward a qualifying minimum. That is deliberately asymmetric with the catch-up base, which excludes migrated movements, because migrated quantity was never eligible for the money the minimum unlocks and must not size a catch-up.
RebuildVarianceMGCEarmarkBalanceAmountNoThe difference the last rebuild found between the maintained balance and the balance recomputed from the accrual transactions, in the deal currency. Zero is the expected answer and anything else is a finding: the rebuild writes a Balance variance verdict alongside it. The rebuild deliberately excludes the settled figure, which is derived on read and has no stored counterpart to compare against.
RebuiltDateTimeTransDateTimeNoWhen this balance row was last recomputed from the accrual transactions by the balance rebuild. A blank value means the row has never been rebuilt, which is the ordinary state: rebuild is a check, not the maintenance path.
ReturnedMGCEarmarkBalanceAmountNoMoney reversed against this deal because the goods came back, in the deal currency. It is kept apart from an ordinary reversal because the two answer different questions: a reversal says somebody undid an accrual, a return says the trade itself was undone. A return against an accrual that has already been claimed does not rewrite the chain - it posts a negative accumulation as a new root and flags the claim.
ReversedMGCEarmarkBalanceAmountNoMoney that was accrued against this deal and then reversed, in the deal currency. A reversal takes its amount from the parent movement rather than recalculating it, so an accrual and its reversal net to exactly zero rather than to a rounding residue.