Skip to content

Commit 66ff988

Browse files
authored
feat: the group close's blockers and override (#262)
## What Regenerated against robosystems with #1857–#1860, the group close (C3, first part): - **The fiscal calendar read names what holds the group close:** `group_open_entities`, `group_pending_adjustments`, `group_unexplained` and `group_not_footing`. They're selected in the hand-written calendar query, and they populate on the consolidation entity's calendar, whose close is the group's. - **The close facade takes the residual override** (`allow_unexplained_residuals`), threaded the same way as the other overrides. - **Also in the regeneration:** the field descriptions changed by #1857 (`up_to_date`) and the backfill request's new override. These are additive changes to the generated tier, so a **client minor**. ## Server dependency **Publish only after robosystems v1.18.10 is live in prod.** That release carries #1860. The calendar query now selects the four `group*` fields, and on v1.18.9 GraphQL refuses an unknown field, which would break every calendar read through this client. The roboledger-app change that shows these blockers waits on this publish. ## Verified The full gate passes, plus a new test that the group's blockers map and the override is sent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01M6TRefZ8MTAxax6pMxer4q
2 parents f647369 + f2ace85 commit 66ff988

10 files changed

Lines changed: 137 additions & 4 deletions

‎robosystems_client/clients/ledger_client.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,7 @@ def close_period(
26942694
allow_reconciling_items: bool | None = None,
26952695
allow_unposted_source_events: bool | None = None,
26962696
entity_id: str | None = None,
2697+
allow_unexplained_residuals: bool | None = None,
26972698
) -> ClosePeriodResponse:
26982699
"""Close a fiscal period — the final commit action — on the group parent,
26992700
or on the entity ``entity_id`` names. Each entity closes on its own.
@@ -2709,6 +2710,9 @@ def close_period(
27092710
changed afterwards (`resolve_reconciling_item`).
27102711
- ``allow_unposted_source_events``: source events dated in the period
27112712
that were never committed, and cannot post into it once it closes.
2713+
- ``allow_unexplained_residuals``: on the consolidation entity, whose
2714+
close is the group's, a residual or intercompany disagreement left
2715+
unexplained; its difference stays in the consolidated statements.
27122716
"""
27132717

27142718
def flag(value: bool | None) -> bool | Unset:
@@ -2723,6 +2727,7 @@ def flag(value: bool | None) -> bool | Unset:
27232727
allow_stranded_obligations=flag(allow_stranded_obligations),
27242728
allow_reconciling_items=flag(allow_reconciling_items),
27252729
allow_unposted_source_events=flag(allow_unposted_source_events),
2730+
allow_unexplained_residuals=flag(allow_unexplained_residuals),
27262731
)
27272732
response = op_close_period(graph_id=graph_id, body=body, client=self._get_client())
27282733
envelope = self._call_op("Close period", response)

‎robosystems_client/graphql/generated/get_ledger_fiscal_calendar.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class GetLedgerFiscalCalendarFiscalCalendar(BaseModel):
3636
unposted_source_event_sample: list[str] = Field(alias="unpostedSourceEventSample")
3737
unreconciled_account_count: int = Field(alias="unreconciledAccountCount")
3838
unreconciled_account_sample: list[str] = Field(alias="unreconciledAccountSample")
39+
group_open_entities: list[str] = Field(alias="groupOpenEntities")
40+
group_pending_adjustments: list[str] = Field(alias="groupPendingAdjustments")
41+
group_unexplained: list[str] = Field(alias="groupUnexplained")
42+
group_not_footing: list[str] = Field(alias="groupNotFooting")
3943
sync_stale_days: Optional[int] = Field(alias="syncStaleDays")
4044
last_close_at: Optional[str] = Field(alias="lastCloseAt")
4145
initialized_at: Optional[str] = Field(alias="initializedAt")

‎robosystems_client/graphql/generated/operations.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,10 @@
723723
unpostedSourceEventSample
724724
unreconciledAccountCount
725725
unreconciledAccountSample
726+
groupOpenEntities
727+
groupPendingAdjustments
728+
groupUnexplained
729+
groupNotFooting
726730
syncStaleDays
727731
lastCloseAt
728732
initializedAt

‎robosystems_client/graphql/operations/ledger/GetLedgerFiscalCalendar.graphql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ query GetLedgerFiscalCalendar($entityId: String) {
1010
reconcilingItemCount reconcilingItemSample
1111
unpostedSourceEventCount unpostedSourceEventSample
1212
unreconciledAccountCount unreconciledAccountSample
13+
groupOpenEntities groupPendingAdjustments groupUnexplained groupNotFooting
1314
syncStaleDays
1415
lastCloseAt initializedAt lastSyncAt
1516
periods { name startDate endDate status closedAt }

‎robosystems_client/graphql/schema.graphql‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ type FiscalCalendar {
28212821
closeableNow: Boolean!
28222822

28232823
"""
2824-
Structured blocker codes when closeable_now is False: 'sequence_violation', 'period_incomplete', 'sync_stale', 'calendar_not_initialized', 'period_already_closed', 'pending_obligations', 'stranded_obligations', 'reconciling_items', 'unposted_source_events', 'unreconciled_accounts'
2824+
Structured blocker codes when closeable_now is False: 'sequence_violation', 'period_incomplete', 'sync_stale', 'calendar_not_initialized', 'period_already_closed', 'pending_obligations', 'stranded_obligations', 'reconciling_items', 'unposted_source_events', 'unreconciled_accounts'; on the consolidation entity, whose close is the group's, also 'entity_open', 'adjustments_unposted', 'residual_unexplained', 'consolidated_does_not_foot'
28252825
"""
28262826
blockers: [String!]!
28272827

@@ -2884,6 +2884,26 @@ type FiscalCalendar {
28842884
Name and status of up to 5 of those reconciliations, so the blocker names what is holding the close.
28852885
"""
28862886
unreconciledAccountSample: [String!]!
2887+
2888+
"""
2889+
The group close: the entities the month consolidates, the parent and its equity-method members included, that have not closed it. Close each first.
2890+
"""
2891+
groupOpenEntities: [String!]!
2892+
2893+
"""
2894+
The group close: the consolidating entries the consolidation entity neither holds nor has drafted, by kind and member, or what the engine left out and why. Run propose-consolidation-entries.
2895+
"""
2896+
groupPendingAdjustments: [String!]!
2897+
2898+
"""
2899+
The group close: residuals and intercompany disagreements left unexplained. Correct the books or post the explaining entry, or close over them knowingly with allow_unexplained_residuals.
2900+
"""
2901+
groupUnexplained: [String!]!
2902+
2903+
"""
2904+
The group close: the consolidated balance sheet's and equity statement's validation failures for the month.
2905+
"""
2906+
groupNotFooting: [String!]!
28872907
lastCloseAt: DateTime
28882908
initializedAt: DateTime
28892909

‎robosystems_client/models/backfill_plan_history_operation.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class BackfillPlanHistoryOperation:
3636
allow_unreconciled_accounts (bool | Unset): Override the reconciliation gate on each reclose. Needed when a
3737
month inside the backfill window has a reconciliation the close waits on that was never compared for it, which
3838
is every month closed before the reconciliation existed. Default: False.
39+
allow_unexplained_residuals (bool | Unset): Override the group close's residual gate on each reclose of the
40+
consolidation entity's months. Default: False.
3941
restamp (bool | Unset): Also re-derive months that ALREADY have canonical statement sets (default: skip them).
4042
Use after an engine improvement changes what a stamp produces — each month reruns the full reopen → reclose
4143
cycle and replaces its sets. A restamp run is not self-resuming (every month in range stays a candidate);
@@ -51,6 +53,7 @@ class BackfillPlanHistoryOperation:
5153
allow_reconciling_items: bool | Unset = False
5254
allow_unposted_source_events: bool | Unset = False
5355
allow_unreconciled_accounts: bool | Unset = False
56+
allow_unexplained_residuals: bool | Unset = False
5457
restamp: bool | Unset = False
5558
note: None | str | Unset = UNSET
5659
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
@@ -80,6 +83,8 @@ def to_dict(self) -> dict[str, Any]:
8083

8184
allow_unreconciled_accounts = self.allow_unreconciled_accounts
8285

86+
allow_unexplained_residuals = self.allow_unexplained_residuals
87+
8388
restamp = self.restamp
8489

8590
note: None | str | Unset
@@ -107,6 +112,8 @@ def to_dict(self) -> dict[str, Any]:
107112
field_dict["allow_unposted_source_events"] = allow_unposted_source_events
108113
if allow_unreconciled_accounts is not UNSET:
109114
field_dict["allow_unreconciled_accounts"] = allow_unreconciled_accounts
115+
if allow_unexplained_residuals is not UNSET:
116+
field_dict["allow_unexplained_residuals"] = allow_unexplained_residuals
110117
if restamp is not UNSET:
111118
field_dict["restamp"] = restamp
112119
if note is not UNSET:
@@ -148,6 +155,8 @@ def _parse_start_period(data: object) -> None | str | Unset:
148155

149156
allow_unreconciled_accounts = d.pop("allow_unreconciled_accounts", UNSET)
150157

158+
allow_unexplained_residuals = d.pop("allow_unexplained_residuals", UNSET)
159+
151160
restamp = d.pop("restamp", UNSET)
152161

153162
def _parse_note(data: object) -> None | str | Unset:
@@ -168,6 +177,7 @@ def _parse_note(data: object) -> None | str | Unset:
168177
allow_reconciling_items=allow_reconciling_items,
169178
allow_unposted_source_events=allow_unposted_source_events,
170179
allow_unreconciled_accounts=allow_unreconciled_accounts,
180+
allow_unexplained_residuals=allow_unexplained_residuals,
171181
restamp=restamp,
172182
note=note,
173183
)

‎robosystems_client/models/close_period_operation.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class ClosePeriodOperation:
4141
reconciliation the close waits on is not reconciled for the period, or was never compared for it. The books are
4242
then closed without that check. Prefer refresh-reconciliations and clearing what it reports first. The override
4343
is recorded in the close audit note. Default: False.
44+
allow_unexplained_residuals (bool | Unset): On the consolidation entity, the group close: close even though a
45+
residual or an intercompany disagreement is left unexplained. Its difference stays in the consolidated
46+
statements. Prefer correcting the books or posting the explaining entry with its basis. The override, and each
47+
item it closed over, is recorded in the close audit note. Default: False.
4448
"""
4549

4650
period: str
@@ -51,6 +55,7 @@ class ClosePeriodOperation:
5155
allow_reconciling_items: bool | Unset = False
5256
allow_unposted_source_events: bool | Unset = False
5357
allow_unreconciled_accounts: bool | Unset = False
58+
allow_unexplained_residuals: bool | Unset = False
5459
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
5560

5661
def to_dict(self) -> dict[str, Any]:
@@ -78,6 +83,8 @@ def to_dict(self) -> dict[str, Any]:
7883

7984
allow_unreconciled_accounts = self.allow_unreconciled_accounts
8085

86+
allow_unexplained_residuals = self.allow_unexplained_residuals
87+
8188
field_dict: dict[str, Any] = {}
8289
field_dict.update(self.additional_properties)
8390
field_dict.update(
@@ -99,6 +106,8 @@ def to_dict(self) -> dict[str, Any]:
99106
field_dict["allow_unposted_source_events"] = allow_unposted_source_events
100107
if allow_unreconciled_accounts is not UNSET:
101108
field_dict["allow_unreconciled_accounts"] = allow_unreconciled_accounts
109+
if allow_unexplained_residuals is not UNSET:
110+
field_dict["allow_unexplained_residuals"] = allow_unexplained_residuals
102111

103112
return field_dict
104113

@@ -135,6 +144,8 @@ def _parse_note(data: object) -> None | str | Unset:
135144

136145
allow_unreconciled_accounts = d.pop("allow_unreconciled_accounts", UNSET)
137146

147+
allow_unexplained_residuals = d.pop("allow_unexplained_residuals", UNSET)
148+
138149
close_period_operation = cls(
139150
period=period,
140151
entity_id=entity_id,
@@ -144,6 +155,7 @@ def _parse_note(data: object) -> None | str | Unset:
144155
allow_reconciling_items=allow_reconciling_items,
145156
allow_unposted_source_events=allow_unposted_source_events,
146157
allow_unreconciled_accounts=allow_unreconciled_accounts,
158+
allow_unexplained_residuals=allow_unexplained_residuals,
147159
)
148160

149161
close_period_operation.additional_properties = d

‎robosystems_client/models/fiscal_calendar_response.py‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class FiscalCalendarResponse:
3636
Default: False.
3737
blockers (list[str] | Unset): Structured blocker codes when closeable_now is False: 'sequence_violation',
3838
'period_incomplete', 'sync_stale', 'calendar_not_initialized', 'period_already_closed', 'pending_obligations',
39-
'stranded_obligations', 'reconciling_items', 'unposted_source_events', 'unreconciled_accounts'
39+
'stranded_obligations', 'reconciling_items', 'unposted_source_events', 'unreconciled_accounts'; on the
40+
consolidation entity, whose close is the group's, also 'entity_open', 'adjustments_unposted',
41+
'residual_unexplained', 'consolidated_does_not_foot'
4042
pending_obligation_count (int | Unset): Number of pending schedule_entry_due events blocking close. Non-zero
4143
only when `pending_obligations` is in `blockers`. Default: 0.
4244
pending_obligation_sample (list[PendingObligationDetailResponse] | Unset): Sample of up to 5 pending obligations
@@ -68,6 +70,16 @@ class FiscalCalendarResponse:
6870
with set-reconciliation-policy, or close over them knowingly with allow_unreconciled_accounts. Default: 0.
6971
unreconciled_account_sample (list[str] | Unset): Name and status of up to 5 of those reconciliations, so the
7072
blocker names what is holding the close.
73+
group_open_entities (list[str] | Unset): The group close: the entities the month consolidates, the parent and
74+
its equity-method members included, that have not closed it. Close each first.
75+
group_pending_adjustments (list[str] | Unset): The group close: the consolidating entries the consolidation
76+
entity neither holds nor has drafted, by kind and member, or what the engine left out and why. Run propose-
77+
consolidation-entries.
78+
group_unexplained (list[str] | Unset): The group close: residuals and intercompany disagreements left
79+
unexplained. Correct the books or post the explaining entry, or close over them knowingly with
80+
allow_unexplained_residuals.
81+
group_not_footing (list[str] | Unset): The group close: the consolidated balance sheet's and equity statement's
82+
validation failures for the month.
7183
last_close_at (datetime.datetime | None | Unset):
7284
initialized_at (datetime.datetime | None | Unset):
7385
last_sync_at (datetime.datetime | None | Unset): Most recent QB sync timestamp (if connected)
@@ -95,6 +107,10 @@ class FiscalCalendarResponse:
95107
unposted_source_event_sample: list[str] | Unset = UNSET
96108
unreconciled_account_count: int | Unset = 0
97109
unreconciled_account_sample: list[str] | Unset = UNSET
110+
group_open_entities: list[str] | Unset = UNSET
111+
group_pending_adjustments: list[str] | Unset = UNSET
112+
group_unexplained: list[str] | Unset = UNSET
113+
group_not_footing: list[str] | Unset = UNSET
98114
last_close_at: datetime.datetime | None | Unset = UNSET
99115
initialized_at: datetime.datetime | None | Unset = UNSET
100116
last_sync_at: datetime.datetime | None | Unset = UNSET
@@ -184,6 +200,22 @@ def to_dict(self) -> dict[str, Any]:
184200
if not isinstance(self.unreconciled_account_sample, Unset):
185201
unreconciled_account_sample = self.unreconciled_account_sample
186202

203+
group_open_entities: list[str] | Unset = UNSET
204+
if not isinstance(self.group_open_entities, Unset):
205+
group_open_entities = self.group_open_entities
206+
207+
group_pending_adjustments: list[str] | Unset = UNSET
208+
if not isinstance(self.group_pending_adjustments, Unset):
209+
group_pending_adjustments = self.group_pending_adjustments
210+
211+
group_unexplained: list[str] | Unset = UNSET
212+
if not isinstance(self.group_unexplained, Unset):
213+
group_unexplained = self.group_unexplained
214+
215+
group_not_footing: list[str] | Unset = UNSET
216+
if not isinstance(self.group_not_footing, Unset):
217+
group_not_footing = self.group_not_footing
218+
187219
last_close_at: None | str | Unset
188220
if isinstance(self.last_close_at, Unset):
189221
last_close_at = UNSET
@@ -261,6 +293,14 @@ def to_dict(self) -> dict[str, Any]:
261293
field_dict["unreconciled_account_count"] = unreconciled_account_count
262294
if unreconciled_account_sample is not UNSET:
263295
field_dict["unreconciled_account_sample"] = unreconciled_account_sample
296+
if group_open_entities is not UNSET:
297+
field_dict["group_open_entities"] = group_open_entities
298+
if group_pending_adjustments is not UNSET:
299+
field_dict["group_pending_adjustments"] = group_pending_adjustments
300+
if group_unexplained is not UNSET:
301+
field_dict["group_unexplained"] = group_unexplained
302+
if group_not_footing is not UNSET:
303+
field_dict["group_not_footing"] = group_not_footing
264304
if last_close_at is not UNSET:
265305
field_dict["last_close_at"] = last_close_at
266306
if initialized_at is not UNSET:
@@ -381,6 +421,16 @@ def _parse_sync_stale_days(data: object) -> int | None | Unset:
381421
list[str], d.pop("unreconciled_account_sample", UNSET)
382422
)
383423

424+
group_open_entities = cast(list[str], d.pop("group_open_entities", UNSET))
425+
426+
group_pending_adjustments = cast(
427+
list[str], d.pop("group_pending_adjustments", UNSET)
428+
)
429+
430+
group_unexplained = cast(list[str], d.pop("group_unexplained", UNSET))
431+
432+
group_not_footing = cast(list[str], d.pop("group_not_footing", UNSET))
433+
384434
def _parse_last_close_at(data: object) -> datetime.datetime | None | Unset:
385435
if data is None:
386436
return data
@@ -463,6 +513,10 @@ def _parse_last_sync_at(data: object) -> datetime.datetime | None | Unset:
463513
unposted_source_event_sample=unposted_source_event_sample,
464514
unreconciled_account_count=unreconciled_account_count,
465515
unreconciled_account_sample=unreconciled_account_sample,
516+
group_open_entities=group_open_entities,
517+
group_pending_adjustments=group_pending_adjustments,
518+
group_unexplained=group_unexplained,
519+
group_not_footing=group_not_footing,
466520
last_close_at=last_close_at,
467521
initialized_at=initialized_at,
468522
last_sync_at=last_sync_at,

‎robosystems_client/models/preview_consolidation_entries_response.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class PreviewConsolidationEntriesResponse:
2727
period_start (datetime.date): The month's first day.
2828
period_end (datetime.date): The month's last day.
2929
consolidation_entity_id (str): The entity the entries post in.
30-
up_to_date (bool): True when nothing is proposed, withheld or left out: the consolidation entity already holds
31-
what the month needs. A closed month is up to date as posted; read `closed` first.
30+
up_to_date (bool): True when nothing is withheld or left out and the consolidation entity holds what the month
31+
needs, posted or in the month's drafts (then `proposals` lists what the drafts hold). A closed month is up to
32+
date as posted; read `closed` first.
3233
proposals (list[ConsolidationProposal] | Unset): The entries to post; empty when the month is up to date.
3334
residuals (list[ConsolidationResidual] | Unset): Differences withheld from the proposals until explained.
3435
reconciling_items (list[ConsolidationReconcilingItem] | Unset): Intercompany figures the two sides do not agree

‎tests/test_ledger_client.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ def test_get_fiscal_calendar(self, mock_execute, mock_config, graph_id):
306306
"unpostedSourceEventSample": [],
307307
"unreconciledAccountCount": 0,
308308
"unreconciledAccountSample": [],
309+
"groupOpenEntities": [],
310+
"groupPendingAdjustments": [],
311+
"groupUnexplained": [],
312+
"groupNotFooting": [],
309313
"syncStaleDays": None,
310314
"lastCloseAt": None,
311315
"initializedAt": "2026-01-01T00:00:00Z",
@@ -361,6 +365,10 @@ def test_get_fiscal_calendar_names_blocking_obligations(
361365
"unpostedSourceEventSample": ["evt_3", "INV-1042"],
362366
"unreconciledAccountCount": 1,
363367
"unreconciledAccountSample": ["Equipment Loan (statement): unreconciled"],
368+
"groupOpenEntities": [],
369+
"groupPendingAdjustments": [],
370+
"groupUnexplained": [],
371+
"groupNotFooting": [],
364372
"syncStaleDays": None,
365373
"lastCloseAt": None,
366374
"initializedAt": "2026-01-01T00:00:00Z",
@@ -471,6 +479,20 @@ def test_close_period_can_override_the_reconciliation_gate(
471479
body = mock_op.call_args.kwargs["body"]
472480
assert body.to_dict()["allow_unreconciled_accounts"] is True
473481

482+
@patch("robosystems_client.clients.ledger_client.op_close_period")
483+
def test_the_group_close_can_override_the_residual_gate(
484+
self, mock_op, mock_config, graph_id
485+
):
486+
envelope = _envelope("close-period", {"period": "2026-03", "fiscal_calendar": {}})
487+
mock_op.return_value = _mock_response(envelope)
488+
client = LedgerClient(mock_config)
489+
client.close_period(
490+
graph_id, "2026-03", entity_id="ent_cons", allow_unexplained_residuals=True
491+
)
492+
body = mock_op.call_args.kwargs["body"].to_dict()
493+
assert body["allow_unexplained_residuals"] is True
494+
assert body["entity_id"] == "ent_cons"
495+
474496
@patch("robosystems_client.clients.ledger_client.op_close_period")
475497
def test_close_period_sends_each_override_it_is_given(
476498
self, mock_op, mock_config, graph_id

0 commit comments

Comments
 (0)