Skip to content

CAP-ACC-TRX-009Complete invoice settlement with credit and money

Markdown

CAP-ACC-TRX-009

Complete invoice settlement with credit and 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 settle several customer invoices through one coordinated request.An uncertain processor answer leaves the request pending until resolution. Completion explains any money the invoices did not consume.
Surfaces
consoleapijob
Intent sources
services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D4services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D5services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D6services-accounting:docs/milestones/plans/ACCT-M2-plan.md#D7services-accounting:docs/architecture/accounting-2.0/02-decisions.md#A-15services-accounting:docs/architecture/accounting-2.0/02-decisions.md#A-17services-accounting:docs/architecture/accounting-2.0/02-decisions.md#D-01

Controls

29 controls apply, from the corpus control catalogue.

TC-IAM-001 TC-IAM-002 TC-IAM-004 TC-IAM-005 TC-IAM-006 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-CRY-001 TC-DAT-001 TC-DAT-002 TC-DAT-003 TC-LOG-002 TC-LOG-003 TC-LOG-004 TC-LOG-005 TC-PI-001 TC-PI-003 TC-PI-005 TC-VEN-001 TC-VEN-002 TC-VEN-003 TC-PRV-001 TC-PRV-002

Permissions

KeyChecked atScope
accounting.settlements.createapitenant
accounting.settlements.readapitenant
accounting.payments.createapitenant
accounting.credit-applications.createapitenant

Business Rules

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

IdRuleKindEnforced atProvenance
01must prove
Proposed
Settlement creation requires settlement, payment and credit-application create authority together; reading requires settlement read plus payment or application read authority.
permissionapitest
services-accounting:modules/transactions/tests/e2e/settlements.e2e.spec.js#it is refused the settle route as a reader and the settlement read as an outsider (403)
02must prove
Proposed
Settlement targets must share its customer, unit and currency, remain outstanding and receive no more than their current balance.
validationservicetest
03must prove
Proposed
Settlement uses named credits first in request order, then other eligible customer credits oldest first, up to fifty, unless automatic credit use is disabled.
calculationservicetest
services-accounting:modules/transactions/tests/integration/services/settlements/settlements.integration.spec.js#it applies the open credit’s 500 first and takes a check of 8000 for the rest: completed with its payment
04must prove
Proposed
Chosen credit is reserved until the payment outcome, preventing competing settlements from spending it and releasing it on failure.
invariantservice, databasetest
services-accounting:modules/transactions/tests/integration/services/settlements/settlements.integration.spec.js#it refuses with the decline (processor_declined), the settlement failed with the code, the reservation released, nothing applied
05must prove
Proposed
Credits can complete settlement alone; any supplied payment must be positive, and a payment supplied after full credit coverage is retained entirely unapplied with that outcome disclosed.
policyservicetest
06must prove
Proposed
Overpayment remains unapplied or follows the configured credit policy, can explicitly become credit, or is rejected before writes when refusal is requested.
policyservicetest
services-accounting:modules/transactions/tests/integration/services/settlements/settlements.integration.spec.js#it completes with an overpayment credit of 1000 made from the payment, the payment’s unapplied money gone into it
07must prove
Proposed
Required or accepted optional card fees apply the unit’s percentage, fixed amount and minimum once across eligible tender value through a separate fee invoice settled with the tender.
calculationservicetest
services-accounting:modules/transactions/tests/integration/services/settlements/card-fees.integration.spec.js#it shares one fee over two required invoices in proportion, the fixed amount charged once: 20000 at 2.5% + 30 is 530
08must prove
Proposed
A declined required fee or missing required fee configuration blocks charging; offline money is fee-free and bank debits are fee-free when excluded by the unit rule.
validationservicetest
services-accounting:modules/transactions/tests/integration/services/settlements/card-fees.integration.spec.js#it refuses the settlement with card_fee_required naming the invoice, and writes nothing
09must prove
Proposed
A definite charge failure releases credit reservations, voids the fee invoice and permits a fresh settlement attempt under the same key.
lifecycleservicetest
services-accounting:modules/transactions/tests/integration/services/settlements/settlement-retry.integration.spec.js#it runs a new attempt under the key: a new settlement, completed with a payment, stored under the key with its attempt number
10must prove
Proposed
Uncertain tender outcomes leave settlement pending; a settlement with no started payment fails after a day and releases reserved credit.
lifecycleservicetest
services-accounting:modules/transactions/tests/integration/services/settlements/settlements.integration.spec.js#it is failed abandoned by the sweeper a day later, the reservation released
11
Proposed
Settlement, receipt, applications and intent retain reciprocal references for following the work across records.
invariantservicetest
12
Proposed
The console distributes credit before payment against the oldest invoices, selects the default open batch and blocks review until validation succeeds.
policyconsoleobserved

Scenarios

IdGivenWhenThenProvenance
01The member has 20.00 of credit and two outstanding invoices.Settle both documents with credit and a check.Completion consumes credit before applying check money to the remainder.test
02A settlement reserves credit before a card tender.Submit a card that definitely declines.Failure releases the credit and leaves the target lines unpaid.test
03A 100.00 invoice requires a fee under a 2.5 percent plus 0.30 rule.Tender the member’s card.The 102.80 capture settles both the main invoice and the separate 2.80 fee invoice.test
services-accounting:modules/transactions/tests/integration/services/settlements/card-fees.integration.spec.js#it charges 10280 in one tender: the invoice and the fee of 280 (2.5% + 30) both paid, the step card_fee done, the fee invoice answered

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.