Skip to content

CAP-ACC-TRX-008Allocate and relocate received money

Markdown

CAP-ACC-TRX-008

Allocate and relocate received money

Markdown
  • DocumentDraft
  • Product intentProposed
  • ImplementationObserved

KindCapabilityProduct areaAccountingModuleTransactionsRevision1

Read atservices-accounting f47cb263react-console baf6dae3

The Formal Contract

The narrative above explains; the sections below are authoritative — the rules, scenarios and tests this document binds.

Outcomes
Staff put held receipts against the correct customer debt while retaining earlier allocation history.Both changes commit together. A first payment can recognize a previously unconverted quote.
Surfaces
consoleapi
Constraints
One allocation request names at most five hundred targets.
Intent sources
services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D1services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D2services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D4services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D6services-accounting:docs/architecture/accounting-2.0/02-decisions.md#M2-9

Controls

24 controls apply, from the corpus control catalogue.

TC-IAM-001 TC-IAM-002 TC-IAM-004 TC-IAM-005 TC-AZ-001 TC-AZ-002 TC-AZ-003 TC-AZ-004 TC-AZ-006 TC-TEN-001 TC-TEN-002 TC-TEN-003 TC-TEN-004 TC-DAT-001 TC-DAT-002 TC-DAT-003 TC-LOG-002 TC-LOG-003 TC-LOG-004 TC-PI-001 TC-PI-003 TC-PI-005 TC-PRV-001 TC-PRV-002

Permissions

KeyChecked atScope
accounting.payments.updateapitenant
accounting.payments.readapitenant

Business Rules

9 rules, 8 to be proved before approval. A rule's product intent is derived from its origin: 1 confirmed by a product decision, the rest inheriting this capability's proposed.

IdRuleKindEnforced atProvenance
01must prove
Proposed
Allocations target issued eligible invoice lines in the payment’s unit and currency; drafts and void invoices cannot receive money.
validationservice, databasetest
02must prove
Proposed
Every allocation path restricts payment to the receipt’s own customer until a later multi-customer model is implemented.
policyservicetest
services-accounting:modules/transactions/tests/integration/services/payments/customer-guard.integration.spec.js#it refuses allocating unapplied money to another customer’s invoice, leaving the payment unapplied
03must prove
Proposed
A line target receives its stated amount, while an invoice target distributes the amount by line payment priority up to each outstanding balance.
calculationservicetest
services-accounting:modules/transactions/tests/integration/services/payments/allocate.integration.spec.js#it spreads the invoice target by pay priority: the second invoice’s first line takes 5000
04must prove
Proposed
Allocation cannot exceed either a line’s balance or the payment’s available money, including concurrent attempts protected by database constraints.
invariantservice, databasetest
services-accounting:modules/transactions/tests/integration/services/payments/allocate.integration.spec.js#it serialize, and the second is refused by the database’s balance CHECK, not by code
05must prove
Confirmed
Allocation history accepts additions only; taking money away requires an opposite entry referring to the original.
invariantdatabasetest
06must prove
Proposed
Reallocation negates selected live applications and applies the resulting available money to new targets atomically; an already reversed application is ineligible.
lifecycleservicetest
services-accounting:modules/transactions/tests/integration/services/payments/allocate.integration.spec.js#it writes a reversing row for the 5000 and a new row for the 4000, the original marked reversed in full
07must prove
Proposed
Only live payments can be allocated; voided, returned and charged-back receipts have no usable money.
validationservice, databasetest
08must prove
Proposed
The first payment against an issued pro forma recognizes it as a real invoice within the same operation.
lifecycleservicetest
services-accounting:modules/transactions/tests/integration/services/payments/receive-offline.integration.spec.js#it converts an unconverted pro forma the first payment names, in the payment’s batch, and pays it (Commerce’s first payment makes it real)
09
Proposed
Later allocation chooses the requested batch, otherwise the payment’s still-open batch, otherwise the unit’s assigned batch.
policyservicedocumented

Scenarios

IdGivenWhenThenProvenance
01A receipt paid the wrong invoice.Move its allocation from the payment record.The original and opposing entries remain alongside the replacement, which settles the intended invoice.test
02Only 10.00 remains available on one receipt.Two staff submit applications simultaneously.Database protection permits one spend and rejects the competing request.test

The Markdown files under specs/ in rhythmsoftware/rhythm-v2-docs are the canonical source of truth. This reader is a generated, read-only projection of them.