Skip to content

CAP-BIL-BIL-004Prepare a population for billing review

Markdown

CAP-BIL-BIL-004

Prepare a population for billing review

Markdown
  • DocumentDraft
  • Product intentProposed
  • ImplementationObserved

KindCapabilityProduct areaBillingModuleBillingRevision1

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
Preparation creates named review items by action kind and target.Refresh retains explicit exclusions.Ready work offers a population review before manual execution.
Surfaces
consoleapijob
Preconditions
Preparation starts from draft or scheduled; refresh and exclusion changes start from ready.
Postconditions
Completed preparation returns a ready run with item-derived candidate counts.
Intent sources
services-accounting:docs/billing/architecture.md#15. Porting rule (Andrew, 2026-10-15)services-accounting:docs/milestones/plans/ACCT-M4-plan.md#4a (rule 45)

Controls

29 controls apply, from the corpus control catalogue.

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

Permissions

KeyChecked atScope
accounting.billing-runs.createapitenant
accounting.billing-runs.readapitenant
accounting.billing-runs.createconsoletenant

Business Rules

9 rules, 8 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
Preparation claims a draft or scheduled run atomically, refresh claims a ready run, and incompatible states return the current and required statuses.
lifecycleservice, databasetest
services-accounting:modules/billing/tests/e2e/billing-runs.e2e.spec.js#refuses to prepare a run that is already preparing, with 409
02must prove
Proposed
Preparation selects with the run user's access and commits each page's review items alongside its cursor, preventing duplicate items after interruption or redelivery.
invariantservice, databasetest
03must prove
Proposed
A saved-query refusal ends preparation with Platform's explanation and leaves the unread page unwritten, while transient faults remain retryable.
policyservicetest
04must prove
Proposed
Completing population selection records preparation time, derives candidate counts from review items and makes the run ready.
calculationservicetest
services-accounting:modules/billing/tests/integration/services/billing-run-preparation/prepare-billing-run.integration.spec.js#counts the run’s candidates from its items rather than from a tally the task kept
05must prove
Proposed
Refresh preserves exclusions, attribution and outcomes, adds new candidates as pending and retains departed candidates as no longer eligible.
invariantservice, databasetest
services-accounting:modules/billing/tests/integration/services/persistence/billing-run-items.integration.spec.js#keeps an excluded item excluded, which 1.0 silently undid on every refresh
06must prove
Proposed
Ready runs allow one to five hundred exclusions or inclusions per request, leave settled items alone and report requested and changed counts.
validationapi, servicetest
services-accounting:modules/billing/tests/e2e/billing-runs.e2e.spec.js#refuses to change the review of a run that is not ready, with 409 and its own code
07must prove
Proposed
Review names reflect CRM at preparation time, and unavailable CRM names produce identifier-only review items without failing preparation.
policyservicetest
08
Proposed
Review lists default to twenty-five items and cap at one hundred, with outcome, action, exclusion, name and identifier filters.
policyapitest
services-accounting:modules/billing/tests/e2e/billing-runs.e2e.spec.js#pages the review, answering the cursor of the next page
09must prove
Proposed
Reading review items requires run-read permission; preparing, refreshing and changing exclusions require run-create permission.
permissionapi, consoletest

Scenarios

IdGivenWhenThenProvenance
01One of three candidates is excluded on a ready run.Staff change the population query and refresh the run.The exclusion survives, the added candidate appears and the removed candidate remains as no longer eligible.test

Edge Cases

IdGivenWhenThenProvenance
02A controller reviews 520 candidates.They exclude the full population in the console.The console splits submissions into at most five hundred items, while the API refuses 501 in one request.documented

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.