Skip to content

Commit 3d0b358

Browse files
authored
feat(ledger): statement cycle, outstanding lines and roll-forward on reconciliations (#248)
## Summary Picks up bank reconciliation by statement cycle from robosystems #1771. A statement reconciliation now has a cycle (monthly, quarterly or annual). On an account a bank feed keeps, its components list the ledger lines the bank had not cleared. A statement that ends before the period's last day carries a roll-forward to that day. **This waits on robosystems #1771** (merged, not yet released). `ListLedgerReconciliations` selects `statementCycle`, `rollForward` and the new component fields, so it fails validation against a server without them. Release this once the next server release carrying #1771 is deployed, or together with it. ## Changes - `LedgerClient.set_reconciliation_policy` takes `statement_cycle` (`monthly`, `quarterly`, `annual`). - `ListLedgerReconciliations.graphql` selects `statementCycle`, `rollForward`, and the component fields `kind`, `postingDate` and `entryId`. The typed models are regenerated (`just generate-graphql`). - `schema.graphql` refreshed, and the OpenAPI SDK regenerated, from a local stack serving #1771. The generated changes are only this feature: - `statement_cycle` on the policy request, the policy response and the mechanics; - `ReconciliationRollForward`; - the new component fields; - descriptions. - The write methods (`record_statement_balance`, `refresh_reconciliations`, `set_reconciliation_policy`) return the generated models, so they carry the new fields as regenerated. ## Compatibility Additive: one new keyword argument on a facade method, plus new optional fields on generated models. The integration template's emit path is untouched. Shipping as a patch on the 2.11 line. ## Testing - [x] New tests: a bank statement's outstanding line and roll-forward parse through `list_reconciliations`, and `set_reconciliation_policy` sends `statement_cycle`. The existing list fixture now carries the new fields. - [x] `just test-all`: 675 passed, 17 skipped; lint and typecheck clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01AQkGGPDmpba9eBV9PkLTfv
2 parents 3e91ac4 + f56788d commit 3d0b358

22 files changed

Lines changed: 924 additions & 105 deletions

‎robosystems_client/api/robo_ledger_ledger_events/record_statement_balance.py‎

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,19 @@ def sync_detailed(
117117
account, and reconcile the account to it. Give the balance as the statement shows it, as a positive
118118
number in the account's normal direction, with the statement's ending date. The ledger's balance at
119119
that date is set beside it, counting the drafts the close will post, and the result is recorded on
120-
the account's statement reconciliation for the period the statement ends in. Attach the statement as
121-
evidence by passing the `document_id` of its stored file (create-document-upload, then complete-
122-
document-upload); recording it again with another document lapses a sign-off. Writes no books. The
123-
first statement recorded for an account creates its reconciliation, which does not hold the close:
124-
turn `required_for_close` on with set-reconciliation-policy to make every period's close wait for a
125-
statement on that account. Recording the same account and date again replaces the earlier balance;
126-
when more than one statement ends in a period, the one with the latest date stands. Recording a
127-
balance that differs from one already signed off lapses that sign-off. A difference is not explained
128-
here: it is activity one side has and the other does not yet, or an error on either. Returns the
129-
reconciliation's standing for the period.
120+
the account's statement reconciliation for the period the statement ends in. On an account a bank
121+
feed keeps, ledger lines that did not come from the feed and are dated on or before the statement
122+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; a
123+
statement ending before the period's last day is carried to it by the feed's own lines
124+
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
125+
(create-document-upload, then complete-document-upload); recording it again with another document
126+
lapses a sign-off. Writes no books. The first statement recorded for an account creates its
127+
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
128+
policy to make every period's close wait for a statement on that account. Recording the same account
129+
and date again replaces the earlier balance; when more than one statement ends in a period, the one
130+
with the latest date stands. Recording a balance that differs from one already signed off lapses
131+
that sign-off. A difference left after the outstanding lines is activity one side has and the other
132+
does not yet, or an error on either. Returns the reconciliation's standing for the period.
130133
131134
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
132135
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -171,16 +174,19 @@ def sync(
171174
account, and reconcile the account to it. Give the balance as the statement shows it, as a positive
172175
number in the account's normal direction, with the statement's ending date. The ledger's balance at
173176
that date is set beside it, counting the drafts the close will post, and the result is recorded on
174-
the account's statement reconciliation for the period the statement ends in. Attach the statement as
175-
evidence by passing the `document_id` of its stored file (create-document-upload, then complete-
176-
document-upload); recording it again with another document lapses a sign-off. Writes no books. The
177-
first statement recorded for an account creates its reconciliation, which does not hold the close:
178-
turn `required_for_close` on with set-reconciliation-policy to make every period's close wait for a
179-
statement on that account. Recording the same account and date again replaces the earlier balance;
180-
when more than one statement ends in a period, the one with the latest date stands. Recording a
181-
balance that differs from one already signed off lapses that sign-off. A difference is not explained
182-
here: it is activity one side has and the other does not yet, or an error on either. Returns the
183-
reconciliation's standing for the period.
177+
the account's statement reconciliation for the period the statement ends in. On an account a bank
178+
feed keeps, ledger lines that did not come from the feed and are dated on or before the statement
179+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; a
180+
statement ending before the period's last day is carried to it by the feed's own lines
181+
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
182+
(create-document-upload, then complete-document-upload); recording it again with another document
183+
lapses a sign-off. Writes no books. The first statement recorded for an account creates its
184+
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
185+
policy to make every period's close wait for a statement on that account. Recording the same account
186+
and date again replaces the earlier balance; when more than one statement ends in a period, the one
187+
with the latest date stands. Recording a balance that differs from one already signed off lapses
188+
that sign-off. A difference left after the outstanding lines is activity one side has and the other
189+
does not yet, or an error on either. Returns the reconciliation's standing for the period.
184190
185191
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
186192
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -220,16 +226,19 @@ async def asyncio_detailed(
220226
account, and reconcile the account to it. Give the balance as the statement shows it, as a positive
221227
number in the account's normal direction, with the statement's ending date. The ledger's balance at
222228
that date is set beside it, counting the drafts the close will post, and the result is recorded on
223-
the account's statement reconciliation for the period the statement ends in. Attach the statement as
224-
evidence by passing the `document_id` of its stored file (create-document-upload, then complete-
225-
document-upload); recording it again with another document lapses a sign-off. Writes no books. The
226-
first statement recorded for an account creates its reconciliation, which does not hold the close:
227-
turn `required_for_close` on with set-reconciliation-policy to make every period's close wait for a
228-
statement on that account. Recording the same account and date again replaces the earlier balance;
229-
when more than one statement ends in a period, the one with the latest date stands. Recording a
230-
balance that differs from one already signed off lapses that sign-off. A difference is not explained
231-
here: it is activity one side has and the other does not yet, or an error on either. Returns the
232-
reconciliation's standing for the period.
229+
the account's statement reconciliation for the period the statement ends in. On an account a bank
230+
feed keeps, ledger lines that did not come from the feed and are dated on or before the statement
231+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; a
232+
statement ending before the period's last day is carried to it by the feed's own lines
233+
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
234+
(create-document-upload, then complete-document-upload); recording it again with another document
235+
lapses a sign-off. Writes no books. The first statement recorded for an account creates its
236+
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
237+
policy to make every period's close wait for a statement on that account. Recording the same account
238+
and date again replaces the earlier balance; when more than one statement ends in a period, the one
239+
with the latest date stands. Recording a balance that differs from one already signed off lapses
240+
that sign-off. A difference left after the outstanding lines is activity one side has and the other
241+
does not yet, or an error on either. Returns the reconciliation's standing for the period.
233242
234243
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
235244
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -272,16 +281,19 @@ async def asyncio(
272281
account, and reconcile the account to it. Give the balance as the statement shows it, as a positive
273282
number in the account's normal direction, with the statement's ending date. The ledger's balance at
274283
that date is set beside it, counting the drafts the close will post, and the result is recorded on
275-
the account's statement reconciliation for the period the statement ends in. Attach the statement as
276-
evidence by passing the `document_id` of its stored file (create-document-upload, then complete-
277-
document-upload); recording it again with another document lapses a sign-off. Writes no books. The
278-
first statement recorded for an account creates its reconciliation, which does not hold the close:
279-
turn `required_for_close` on with set-reconciliation-policy to make every period's close wait for a
280-
statement on that account. Recording the same account and date again replaces the earlier balance;
281-
when more than one statement ends in a period, the one with the latest date stands. Recording a
282-
balance that differs from one already signed off lapses that sign-off. A difference is not explained
283-
here: it is activity one side has and the other does not yet, or an error on either. Returns the
284-
reconciliation's standing for the period.
284+
the account's statement reconciliation for the period the statement ends in. On an account a bank
285+
feed keeps, ledger lines that did not come from the feed and are dated on or before the statement
286+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; a
287+
statement ending before the period's last day is carried to it by the feed's own lines
288+
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
289+
(create-document-upload, then complete-document-upload); recording it again with another document
290+
lapses a sign-off. Writes no books. The first statement recorded for an account creates its
291+
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
292+
policy to make every period's close wait for a statement on that account. Recording the same account
293+
and date again replaces the earlier balance; when more than one statement ends in a period, the one
294+
with the latest date stands. Recording a balance that differs from one already signed off lapses
295+
that sign-off. A difference left after the outstanding lines is activity one side has and the other
296+
does not yet, or an error on either. Returns the reconciliation's standing for the period.
285297
286298
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
287299
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/api/robo_ledger_ledger_events/refresh_reconciliations.py‎

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ def sync_detailed(
118118
Run every reconciliation that applies at a period end and record each result on its block. A ledger
119119
synced from QuickBooks is compared with QuickBooks' own trial balance, on one block for the whole
120120
ledger. Each asset account a schedule carries a balance on is compared with what its schedules say
121-
it holds, on a block of its own. Each account with a statement balance recorded in the period
122-
(record-statement-balance) is compared with that balance. A block reconciles for the period when its
123-
difference is within its materiality. Running it again replaces the period's comparison, so the
124-
answer is always as of the last run. A block is created the first time its check applies, and from
125-
then on the period's close waits on it until set-reconciliation-policy releases it. The one
126-
exception is an account block whose first comparison does not tie: it is created without holding the
127-
close, so a difference found on first contact is reported and becomes a close requirement only when
128-
you turn it on. Returns every reconciliation's standing for the period. Use preview-reconciliations
129-
to see a comparison without recording it.
121+
it holds, on a block of its own. Each account with a statement covering the period (record-
122+
statement-balance; the latest within its statement cycle) is compared with that balance. A block
123+
reconciles for the period when its difference is within its materiality. Running it again replaces
124+
the period's comparison, so the answer is always as of the last run. A block is created the first
125+
time its check applies, and from then on the period's close waits on it until set-reconciliation-
126+
policy releases it. The one exception is an account block whose first comparison does not tie: it is
127+
created without holding the close, so a difference found on first contact is reported and becomes a
128+
close requirement only when you turn it on. Returns every reconciliation's standing for the period.
129+
Use preview-reconciliations to see a comparison without recording it.
130130
131131
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
132132
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -170,15 +170,15 @@ def sync(
170170
Run every reconciliation that applies at a period end and record each result on its block. A ledger
171171
synced from QuickBooks is compared with QuickBooks' own trial balance, on one block for the whole
172172
ledger. Each asset account a schedule carries a balance on is compared with what its schedules say
173-
it holds, on a block of its own. Each account with a statement balance recorded in the period
174-
(record-statement-balance) is compared with that balance. A block reconciles for the period when its
175-
difference is within its materiality. Running it again replaces the period's comparison, so the
176-
answer is always as of the last run. A block is created the first time its check applies, and from
177-
then on the period's close waits on it until set-reconciliation-policy releases it. The one
178-
exception is an account block whose first comparison does not tie: it is created without holding the
179-
close, so a difference found on first contact is reported and becomes a close requirement only when
180-
you turn it on. Returns every reconciliation's standing for the period. Use preview-reconciliations
181-
to see a comparison without recording it.
173+
it holds, on a block of its own. Each account with a statement covering the period (record-
174+
statement-balance; the latest within its statement cycle) is compared with that balance. A block
175+
reconciles for the period when its difference is within its materiality. Running it again replaces
176+
the period's comparison, so the answer is always as of the last run. A block is created the first
177+
time its check applies, and from then on the period's close waits on it until set-reconciliation-
178+
policy releases it. The one exception is an account block whose first comparison does not tie: it is
179+
created without holding the close, so a difference found on first contact is reported and becomes a
180+
close requirement only when you turn it on. Returns every reconciliation's standing for the period.
181+
Use preview-reconciliations to see a comparison without recording it.
182182
183183
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
184184
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -217,15 +217,15 @@ async def asyncio_detailed(
217217
Run every reconciliation that applies at a period end and record each result on its block. A ledger
218218
synced from QuickBooks is compared with QuickBooks' own trial balance, on one block for the whole
219219
ledger. Each asset account a schedule carries a balance on is compared with what its schedules say
220-
it holds, on a block of its own. Each account with a statement balance recorded in the period
221-
(record-statement-balance) is compared with that balance. A block reconciles for the period when its
222-
difference is within its materiality. Running it again replaces the period's comparison, so the
223-
answer is always as of the last run. A block is created the first time its check applies, and from
224-
then on the period's close waits on it until set-reconciliation-policy releases it. The one
225-
exception is an account block whose first comparison does not tie: it is created without holding the
226-
close, so a difference found on first contact is reported and becomes a close requirement only when
227-
you turn it on. Returns every reconciliation's standing for the period. Use preview-reconciliations
228-
to see a comparison without recording it.
220+
it holds, on a block of its own. Each account with a statement covering the period (record-
221+
statement-balance; the latest within its statement cycle) is compared with that balance. A block
222+
reconciles for the period when its difference is within its materiality. Running it again replaces
223+
the period's comparison, so the answer is always as of the last run. A block is created the first
224+
time its check applies, and from then on the period's close waits on it until set-reconciliation-
225+
policy releases it. The one exception is an account block whose first comparison does not tie: it is
226+
created without holding the close, so a difference found on first contact is reported and becomes a
227+
close requirement only when you turn it on. Returns every reconciliation's standing for the period.
228+
Use preview-reconciliations to see a comparison without recording it.
229229
230230
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
231231
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -267,15 +267,15 @@ async def asyncio(
267267
Run every reconciliation that applies at a period end and record each result on its block. A ledger
268268
synced from QuickBooks is compared with QuickBooks' own trial balance, on one block for the whole
269269
ledger. Each asset account a schedule carries a balance on is compared with what its schedules say
270-
it holds, on a block of its own. Each account with a statement balance recorded in the period
271-
(record-statement-balance) is compared with that balance. A block reconciles for the period when its
272-
difference is within its materiality. Running it again replaces the period's comparison, so the
273-
answer is always as of the last run. A block is created the first time its check applies, and from
274-
then on the period's close waits on it until set-reconciliation-policy releases it. The one
275-
exception is an account block whose first comparison does not tie: it is created without holding the
276-
close, so a difference found on first contact is reported and becomes a close requirement only when
277-
you turn it on. Returns every reconciliation's standing for the period. Use preview-reconciliations
278-
to see a comparison without recording it.
270+
it holds, on a block of its own. Each account with a statement covering the period (record-
271+
statement-balance; the latest within its statement cycle) is compared with that balance. A block
272+
reconciles for the period when its difference is within its materiality. Running it again replaces
273+
the period's comparison, so the answer is always as of the last run. A block is created the first
274+
time its check applies, and from then on the period's close waits on it until set-reconciliation-
275+
policy releases it. The one exception is an account block whose first comparison does not tie: it is
276+
created without holding the close, so a difference found on first contact is reported and becomes a
277+
close requirement only when you turn it on. Returns every reconciliation's standing for the period.
278+
Use preview-reconciliations to see a comparison without recording it.
279279
280280
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
281281
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

0 commit comments

Comments
 (0)