Skip to content

Commit 36464dd

Browse files
committed
feat: held bank lines on the close, the as-closed label, and backfill on the worker
1 parent f3c9a0c commit 36464dd

28 files changed

Lines changed: 347 additions & 647 deletions

‎robosystems_client/api/robo_ledger_fiscal_close/backfill_plan_history.py‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
from ...client import AuthenticatedClient, Client
99
from ...models.backfill_plan_history_operation import BackfillPlanHistoryOperation
1010
from ...models.error_response import ErrorResponse
11-
from ...models.operation_envelope_backfill_plan_history_response import (
12-
OperationEnvelopeBackfillPlanHistoryResponse,
13-
)
11+
from ...models.operation_envelope import OperationEnvelope
1412
from ...types import UNSET, Response, Unset
1513

1614

@@ -41,13 +39,11 @@ def _get_kwargs(
4139

4240
def _parse_response(
4341
*, client: AuthenticatedClient | Client, response: httpx.Response
44-
) -> ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse | None:
45-
if response.status_code == 200:
46-
response_200 = OperationEnvelopeBackfillPlanHistoryResponse.from_dict(
47-
response.json()
48-
)
42+
) -> ErrorResponse | OperationEnvelope | None:
43+
if response.status_code == 202:
44+
response_202 = OperationEnvelope.from_dict(response.json())
4945

50-
return response_200
46+
return response_202
5147

5248
if response.status_code == 400:
5349
response_400 = ErrorResponse.from_dict(response.json())
@@ -97,7 +93,7 @@ def _parse_response(
9793

9894
def _build_response(
9995
*, client: AuthenticatedClient | Client, response: httpx.Response
100-
) -> Response[ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse]:
96+
) -> Response[ErrorResponse | OperationEnvelope]:
10197
return Response(
10298
status_code=HTTPStatus(response.status_code),
10399
content=response.content,
@@ -112,7 +108,7 @@ def sync_detailed(
112108
client: AuthenticatedClient,
113109
body: BackfillPlanHistoryOperation,
114110
idempotency_key: None | str | Unset = UNSET,
115-
) -> Response[ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse]:
111+
) -> Response[ErrorResponse | OperationEnvelope]:
116112
"""Backfill Plan History
117113
118114
Compile monthly statement history behind the close boundary — the plan's historical columns. Seeds
@@ -122,7 +118,9 @@ def sync_detailed(
122118
call, oldest first — loop until `remaining_periods` comes back empty. Idempotent: already-stamped
123119
months are never touched. Months holding draft entries are skipped, never posted. `start_period` is
124120
clamped to the earliest month with ledger data, so deep-history tenants only backfill what actually
125-
exists.
121+
exists. Runs on the background worker, since a chunk recloses up to 24 months: returns a `pending`
122+
envelope at once, and the result — the outcome per month and `remaining_periods`, or a refusal under
123+
`error` — arrives on `/v1/operations/{operation_id}/stream`.
126124
127125
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
128126
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -138,7 +136,7 @@ def sync_detailed(
138136
httpx.TimeoutException: If the request takes longer than Client.timeout.
139137
140138
Returns:
141-
Response[ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse]
139+
Response[ErrorResponse | OperationEnvelope]
142140
"""
143141

144142
kwargs = _get_kwargs(
@@ -160,7 +158,7 @@ def sync(
160158
client: AuthenticatedClient,
161159
body: BackfillPlanHistoryOperation,
162160
idempotency_key: None | str | Unset = UNSET,
163-
) -> ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse | None:
161+
) -> ErrorResponse | OperationEnvelope | None:
164162
"""Backfill Plan History
165163
166164
Compile monthly statement history behind the close boundary — the plan's historical columns. Seeds
@@ -170,7 +168,9 @@ def sync(
170168
call, oldest first — loop until `remaining_periods` comes back empty. Idempotent: already-stamped
171169
months are never touched. Months holding draft entries are skipped, never posted. `start_period` is
172170
clamped to the earliest month with ledger data, so deep-history tenants only backfill what actually
173-
exists.
171+
exists. Runs on the background worker, since a chunk recloses up to 24 months: returns a `pending`
172+
envelope at once, and the result — the outcome per month and `remaining_periods`, or a refusal under
173+
`error` — arrives on `/v1/operations/{operation_id}/stream`.
174174
175175
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
176176
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -186,7 +186,7 @@ def sync(
186186
httpx.TimeoutException: If the request takes longer than Client.timeout.
187187
188188
Returns:
189-
ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse
189+
ErrorResponse | OperationEnvelope
190190
"""
191191

192192
return sync_detailed(
@@ -203,7 +203,7 @@ async def asyncio_detailed(
203203
client: AuthenticatedClient,
204204
body: BackfillPlanHistoryOperation,
205205
idempotency_key: None | str | Unset = UNSET,
206-
) -> Response[ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse]:
206+
) -> Response[ErrorResponse | OperationEnvelope]:
207207
"""Backfill Plan History
208208
209209
Compile monthly statement history behind the close boundary — the plan's historical columns. Seeds
@@ -213,7 +213,9 @@ async def asyncio_detailed(
213213
call, oldest first — loop until `remaining_periods` comes back empty. Idempotent: already-stamped
214214
months are never touched. Months holding draft entries are skipped, never posted. `start_period` is
215215
clamped to the earliest month with ledger data, so deep-history tenants only backfill what actually
216-
exists.
216+
exists. Runs on the background worker, since a chunk recloses up to 24 months: returns a `pending`
217+
envelope at once, and the result — the outcome per month and `remaining_periods`, or a refusal under
218+
`error` — arrives on `/v1/operations/{operation_id}/stream`.
217219
218220
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
219221
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -229,7 +231,7 @@ async def asyncio_detailed(
229231
httpx.TimeoutException: If the request takes longer than Client.timeout.
230232
231233
Returns:
232-
Response[ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse]
234+
Response[ErrorResponse | OperationEnvelope]
233235
"""
234236

235237
kwargs = _get_kwargs(
@@ -249,7 +251,7 @@ async def asyncio(
249251
client: AuthenticatedClient,
250252
body: BackfillPlanHistoryOperation,
251253
idempotency_key: None | str | Unset = UNSET,
252-
) -> ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse | None:
254+
) -> ErrorResponse | OperationEnvelope | None:
253255
"""Backfill Plan History
254256
255257
Compile monthly statement history behind the close boundary — the plan's historical columns. Seeds
@@ -259,7 +261,9 @@ async def asyncio(
259261
call, oldest first — loop until `remaining_periods` comes back empty. Idempotent: already-stamped
260262
months are never touched. Months holding draft entries are skipped, never posted. `start_period` is
261263
clamped to the earliest month with ledger data, so deep-history tenants only backfill what actually
262-
exists.
264+
exists. Runs on the background worker, since a chunk recloses up to 24 months: returns a `pending`
265+
envelope at once, and the result — the outcome per month and `remaining_periods`, or a refusal under
266+
`error` — arrives on `/v1/operations/{operation_id}/stream`.
263267
264268
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
265269
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -275,7 +279,7 @@ async def asyncio(
275279
httpx.TimeoutException: If the request takes longer than Client.timeout.
276280
277281
Returns:
278-
ErrorResponse | OperationEnvelopeBackfillPlanHistoryResponse
282+
ErrorResponse | OperationEnvelope
279283
"""
280284

281285
return (

‎robosystems_client/api/robo_ledger_ledger_events/record_statement_balance.py‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ def sync_detailed(
119119
that date is set beside it, counting the drafts the close will post, and the result is recorded on
120120
the account's statement reconciliation for the period the statement ends in. On an account a bank
121121
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
122+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; one
123+
dated before the statement's own cycle is listed as `stale_outstanding` and does not, since the bank
124+
should have cleared it by now, so the difference stays until it clears, is voided or is re-dated; a
123125
statement ending before the period's last day is carried to it by the feed's own lines
124126
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
125127
(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
128+
lapses a sign-off, and recording it again without one keeps the document already attached (an empty
129+
string detaches it). Writes no books. The first statement recorded for an account creates its
127130
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
128131
policy to make every period's close wait for a statement on that account. Recording the same account
129132
and date again replaces the earlier balance; when more than one statement ends in a period, the one
@@ -176,11 +179,14 @@ def sync(
176179
that date is set beside it, counting the drafts the close will post, and the result is recorded on
177180
the account's statement reconciliation for the period the statement ends in. On an account a bank
178181
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
182+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; one
183+
dated before the statement's own cycle is listed as `stale_outstanding` and does not, since the bank
184+
should have cleared it by now, so the difference stays until it clears, is voided or is re-dated; a
180185
statement ending before the period's last day is carried to it by the feed's own lines
181186
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
182187
(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
188+
lapses a sign-off, and recording it again without one keeps the document already attached (an empty
189+
string detaches it). Writes no books. The first statement recorded for an account creates its
184190
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
185191
policy to make every period's close wait for a statement on that account. Recording the same account
186192
and date again replaces the earlier balance; when more than one statement ends in a period, the one
@@ -228,11 +234,14 @@ async def asyncio_detailed(
228234
that date is set beside it, counting the drafts the close will post, and the result is recorded on
229235
the account's statement reconciliation for the period the statement ends in. On an account a bank
230236
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
237+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; one
238+
dated before the statement's own cycle is listed as `stale_outstanding` and does not, since the bank
239+
should have cleared it by now, so the difference stays until it clears, is voided or is re-dated; a
232240
statement ending before the period's last day is carried to it by the feed's own lines
233241
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
234242
(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
243+
lapses a sign-off, and recording it again without one keeps the document already attached (an empty
244+
string detaches it). Writes no books. The first statement recorded for an account creates its
236245
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
237246
policy to make every period's close wait for a statement on that account. Recording the same account
238247
and date again replaces the earlier balance; when more than one statement ends in a period, the one
@@ -283,11 +292,14 @@ async def asyncio(
283292
that date is set beside it, counting the drafts the close will post, and the result is recorded on
284293
the account's statement reconciliation for the period the statement ends in. On an account a bank
285294
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
295+
are listed as outstanding and adjust the statement balance, since the bank had not cleared them; one
296+
dated before the statement's own cycle is listed as `stale_outstanding` and does not, since the bank
297+
should have cleared it by now, so the difference stays until it clears, is voided or is re-dated; a
287298
statement ending before the period's last day is carried to it by the feed's own lines
288299
(`roll_forward`). Attach the statement as evidence by passing the `document_id` of its stored file
289300
(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
301+
lapses a sign-off, and recording it again without one keeps the document already attached (an empty
302+
string detaches it). Writes no books. The first statement recorded for an account creates its
291303
reconciliation, which does not hold the close: turn `required_for_close` on with set-reconciliation-
292304
policy to make every period's close wait for a statement on that account. Recording the same account
293305
and date again replaces the earlier balance; when more than one statement ends in a period, the one

0 commit comments

Comments
 (0)