Skip to content

Commit 2d3bfa3

Browse files
committed
feat(ledger): reclassify a mapped account in place (replaces_association_id)
Regenerated against robosystems #1804: replaces_association_id and reason on create-mapping-association, replaced_association_id and reclassified_periods on its response, created_at on FactSetLite, the schema refreshed to match. Claude-Session: https://claude.ai/code/session_014Wxgk4yttBxgdE2uBHT71R
1 parent 577f08c commit 2d3bfa3

7 files changed

Lines changed: 177 additions & 22 deletions

File tree

‎robosystems_client/api/robo_ledger_taxonomy_mapping/create_mapping_association.py‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ def sync_detailed(
118118
Link a chart-of-accounts element to a US GAAP reporting concept. One mapping edge per call — use
119119
`auto-map-elements` for bulk AI-assisted mapping. Duplicate (from, to, type) tuples return 409. The
120120
target must be a leaf concept: a subtotal the statement sums from its children is refused (422). Map
121-
before you close: an account with landed history in a closed month cannot be re-mapped (422) — the
122-
closed month's stamped statements were computed through the old arcs. Reopen latest-first down to
123-
the earliest month named, map, then close forward.
121+
before you close: a new arc for an account with landed history in a closed month is refused (422),
122+
since the month's stamped statements were computed through the arcs as they stood. To move such an
123+
account, pass `replaces_association_id` (its current arc, removed in the same write). A move within
124+
the same primary statement is a reclassification and goes through: the stamped statements keep the
125+
answer as closed, live renders follow the new arc, and `reclassified_periods` names the months. A
126+
move across statements restates net income and is refused, naming the months to reopen latest-first.
124127
125128
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
126129
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -168,9 +171,12 @@ def sync(
168171
Link a chart-of-accounts element to a US GAAP reporting concept. One mapping edge per call — use
169172
`auto-map-elements` for bulk AI-assisted mapping. Duplicate (from, to, type) tuples return 409. The
170173
target must be a leaf concept: a subtotal the statement sums from its children is refused (422). Map
171-
before you close: an account with landed history in a closed month cannot be re-mapped (422) — the
172-
closed month's stamped statements were computed through the old arcs. Reopen latest-first down to
173-
the earliest month named, map, then close forward.
174+
before you close: a new arc for an account with landed history in a closed month is refused (422),
175+
since the month's stamped statements were computed through the arcs as they stood. To move such an
176+
account, pass `replaces_association_id` (its current arc, removed in the same write). A move within
177+
the same primary statement is a reclassification and goes through: the stamped statements keep the
178+
answer as closed, live renders follow the new arc, and `reclassified_periods` names the months. A
179+
move across statements restates net income and is refused, naming the months to reopen latest-first.
174180
175181
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
176182
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -213,9 +219,12 @@ async def asyncio_detailed(
213219
Link a chart-of-accounts element to a US GAAP reporting concept. One mapping edge per call — use
214220
`auto-map-elements` for bulk AI-assisted mapping. Duplicate (from, to, type) tuples return 409. The
215221
target must be a leaf concept: a subtotal the statement sums from its children is refused (422). Map
216-
before you close: an account with landed history in a closed month cannot be re-mapped (422) — the
217-
closed month's stamped statements were computed through the old arcs. Reopen latest-first down to
218-
the earliest month named, map, then close forward.
222+
before you close: a new arc for an account with landed history in a closed month is refused (422),
223+
since the month's stamped statements were computed through the arcs as they stood. To move such an
224+
account, pass `replaces_association_id` (its current arc, removed in the same write). A move within
225+
the same primary statement is a reclassification and goes through: the stamped statements keep the
226+
answer as closed, live renders follow the new arc, and `reclassified_periods` names the months. A
227+
move across statements restates net income and is refused, naming the months to reopen latest-first.
219228
220229
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
221230
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -261,9 +270,12 @@ async def asyncio(
261270
Link a chart-of-accounts element to a US GAAP reporting concept. One mapping edge per call — use
262271
`auto-map-elements` for bulk AI-assisted mapping. Duplicate (from, to, type) tuples return 409. The
263272
target must be a leaf concept: a subtotal the statement sums from its children is refused (422). Map
264-
before you close: an account with landed history in a closed month cannot be re-mapped (422) — the
265-
closed month's stamped statements were computed through the old arcs. Reopen latest-first down to
266-
the earliest month named, map, then close forward.
273+
before you close: a new arc for an account with landed history in a closed month is refused (422),
274+
since the month's stamped statements were computed through the arcs as they stood. To move such an
275+
account, pass `replaces_association_id` (its current arc, removed in the same write). A move within
276+
the same primary statement is a reclassification and goes through: the stamped statements keep the
277+
answer as closed, live renders follow the new arc, and `reclassified_periods` names the months. A
278+
move across statements restates net income and is refused, naming the months to reopen latest-first.
267279
268280
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
269281
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/api/robo_ledger_taxonomy_mapping/delete_mapping_association.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def sync_detailed(
117117
only the association row is dropped. Use this to correct a wrong mapping — delete the bad edge, then
118118
`create-mapping-association` the right one. Find the association id via the `library_element_arcs`
119119
GraphQL field. Library-seeded rows cannot be deleted (403). An edge for an account with landed
120-
history in a closed month cannot be removed (422) until those months are reopened, latest-first.
120+
history in a closed month cannot be removed on its own (422): move the account with `create-mapping-
121+
association` and `replaces_association_id` instead.
121122
122123
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
123124
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -162,7 +163,8 @@ def sync(
162163
only the association row is dropped. Use this to correct a wrong mapping — delete the bad edge, then
163164
`create-mapping-association` the right one. Find the association id via the `library_element_arcs`
164165
GraphQL field. Library-seeded rows cannot be deleted (403). An edge for an account with landed
165-
history in a closed month cannot be removed (422) until those months are reopened, latest-first.
166+
history in a closed month cannot be removed on its own (422): move the account with `create-mapping-
167+
association` and `replaces_association_id` instead.
166168
167169
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
168170
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -202,7 +204,8 @@ async def asyncio_detailed(
202204
only the association row is dropped. Use this to correct a wrong mapping — delete the bad edge, then
203205
`create-mapping-association` the right one. Find the association id via the `library_element_arcs`
204206
GraphQL field. Library-seeded rows cannot be deleted (403). An edge for an account with landed
205-
history in a closed month cannot be removed (422) until those months are reopened, latest-first.
207+
history in a closed month cannot be removed on its own (422): move the account with `create-mapping-
208+
association` and `replaces_association_id` instead.
206209
207210
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
208211
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -245,7 +248,8 @@ async def asyncio(
245248
only the association row is dropped. Use this to correct a wrong mapping — delete the bad edge, then
246249
`create-mapping-association` the right one. Find the association id via the `library_element_arcs`
247250
GraphQL field. Library-seeded rows cannot be deleted (403). An edge for an account with landed
248-
history in a closed month cannot be removed (422) until those months are reopened, latest-first.
251+
history in a closed month cannot be removed on its own (422): move the account with `create-mapping-
252+
association` and `replaces_association_id` instead.
249253
250254
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
251255
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/api/robo_ledger_taxonomy_mapping/update_taxonomy_block.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def sync_detailed(
122122
`custom_ontology` authoring may be disabled per environment (TAXONOMY_AUTHORING_ENABLED) — disabled
123123
surfaces 403. Closed months are immutable against curation: a mapping arc added or removed for an
124124
account with landed history in a closed month, or a `balance_type` / `period_type` / `trait` change
125-
on such an account, is refused (422, `protected_facts`) naming the months to reopen first.
125+
on such an account, is refused (422, `protected_facts`) naming the months to reopen first. An
126+
envelope that removes an account's arc and adds one on the same primary statement moves it: a
127+
reclassification, allowed.
126128
127129
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
128130
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -176,7 +178,9 @@ def sync(
176178
`custom_ontology` authoring may be disabled per environment (TAXONOMY_AUTHORING_ENABLED) — disabled
177179
surfaces 403. Closed months are immutable against curation: a mapping arc added or removed for an
178180
account with landed history in a closed month, or a `balance_type` / `period_type` / `trait` change
179-
on such an account, is refused (422, `protected_facts`) naming the months to reopen first.
181+
on such an account, is refused (422, `protected_facts`) naming the months to reopen first. An
182+
envelope that removes an account's arc and adds one on the same primary statement moves it: a
183+
reclassification, allowed.
180184
181185
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
182186
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -225,7 +229,9 @@ async def asyncio_detailed(
225229
`custom_ontology` authoring may be disabled per environment (TAXONOMY_AUTHORING_ENABLED) — disabled
226230
surfaces 403. Closed months are immutable against curation: a mapping arc added or removed for an
227231
account with landed history in a closed month, or a `balance_type` / `period_type` / `trait` change
228-
on such an account, is refused (422, `protected_facts`) naming the months to reopen first.
232+
on such an account, is refused (422, `protected_facts`) naming the months to reopen first. An
233+
envelope that removes an account's arc and adds one on the same primary statement moves it: a
234+
reclassification, allowed.
229235
230236
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
231237
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -277,7 +283,9 @@ async def asyncio(
277283
`custom_ontology` authoring may be disabled per environment (TAXONOMY_AUTHORING_ENABLED) — disabled
278284
surfaces 403. Closed months are immutable against curation: a mapping arc added or removed for an
279285
account with landed history in a closed month, or a `balance_type` / `period_type` / `trait` change
280-
on such an account, is refused (422, `protected_facts`) naming the months to reopen first.
286+
on such an account, is refused (422, `protected_facts`) naming the months to reopen first. An
287+
envelope that removes an account's arc and adds one on the same primary statement moves it: a
288+
reclassification, allowed.
281289
282290
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
283291
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/graphql/schema.graphql‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,9 @@ type Query {
510510
): MappingDetail
511511

512512
"""
513-
How one month's bank lines were classified, per suggestion source:
514-
taken as suggested, overridden, split, or chosen with no suggestion to
513+
How one month's bank lines were classified, per suggestion source.
514+
515+
Taken as suggested, overridden, split, or chosen with no suggestion to
515516
take, and the share that needed a person's choice. Counted from the
516517
lines committed in the month; lines posted before outcomes were recorded
517518
are `unstamped` and outside the share.
@@ -2491,6 +2492,16 @@ type Association {
24912492
confidence: Float
24922493
suggestedBy: String
24932494
approvedBy: String
2495+
2496+
"""
2497+
The arc this write removed in the same transaction, when the call named one in `replaces_association_id`.
2498+
"""
2499+
replacedAssociationId: String
2500+
2501+
"""
2502+
Closed months whose live statements now read through this arc while their stamped sets keep the answer as closed. Empty unless the write replaced an arc on an account with landed history in a closed month.
2503+
"""
2504+
reclassifiedPeriods: [String!]!
24942505
}
24952506

24962507
"""How a month's bank lines were classified, counted from the lines."""
@@ -3469,6 +3480,11 @@ type InformationBlockFactSet {
34693480
Typed `FactProvenance` descriptor (discriminated on `origin`: pivot | schedule | derived | asserted | document | forecast | filed) recording how this FactSet was constructed. It describes the set, not each fact: a `pivot` set's mapped leaves aggregate posted line items, while its subtotals and derivations are computed from those leaves. Surfaced as JSON, mirroring how mechanics is exposed. Null when the FactSet carries no descriptor.
34703481
"""
34713482
provenance: JSON
3483+
3484+
"""
3485+
When the set was computed. For a close-stamped canonical set (`reportId` null, type `report`) this is the month as closed on this date: its facts keep that answer while a live render reads through the mapping arcs as they stand now.
3486+
"""
3487+
createdAt: DateTime
34723488
}
34733489

34743490
"""

‎robosystems_client/models/association_response.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class AssociationResponse:
3737
confidence (float | None | Unset):
3838
suggested_by (None | str | Unset):
3939
approved_by (None | str | Unset):
40+
replaced_association_id (None | str | Unset): The arc this write removed in the same transaction, when the call
41+
named one in `replaces_association_id`.
42+
reclassified_periods (list[str] | Unset): Closed months whose live statements now read through this arc while
43+
their stamped sets keep the answer as closed. Empty unless the write replaced an arc on an account with landed
44+
history in a closed month.
4045
"""
4146

4247
id: str
@@ -53,6 +58,8 @@ class AssociationResponse:
5358
confidence: float | None | Unset = UNSET
5459
suggested_by: None | str | Unset = UNSET
5560
approved_by: None | str | Unset = UNSET
61+
replaced_association_id: None | str | Unset = UNSET
62+
reclassified_periods: list[str] | Unset = UNSET
5663
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
5764

5865
def to_dict(self) -> dict[str, Any]:
@@ -120,6 +127,16 @@ def to_dict(self) -> dict[str, Any]:
120127
else:
121128
approved_by = self.approved_by
122129

130+
replaced_association_id: None | str | Unset
131+
if isinstance(self.replaced_association_id, Unset):
132+
replaced_association_id = UNSET
133+
else:
134+
replaced_association_id = self.replaced_association_id
135+
136+
reclassified_periods: list[str] | Unset = UNSET
137+
if not isinstance(self.reclassified_periods, Unset):
138+
reclassified_periods = self.reclassified_periods
139+
123140
field_dict: dict[str, Any] = {}
124141
field_dict.update(self.additional_properties)
125142
field_dict.update(
@@ -149,6 +166,10 @@ def to_dict(self) -> dict[str, Any]:
149166
field_dict["suggested_by"] = suggested_by
150167
if approved_by is not UNSET:
151168
field_dict["approved_by"] = approved_by
169+
if replaced_association_id is not UNSET:
170+
field_dict["replaced_association_id"] = replaced_association_id
171+
if reclassified_periods is not UNSET:
172+
field_dict["reclassified_periods"] = reclassified_periods
152173

153174
return field_dict
154175

@@ -246,6 +267,19 @@ def _parse_approved_by(data: object) -> None | str | Unset:
246267

247268
approved_by = _parse_approved_by(d.pop("approved_by", UNSET))
248269

270+
def _parse_replaced_association_id(data: object) -> None | str | Unset:
271+
if data is None:
272+
return data
273+
if isinstance(data, Unset):
274+
return data
275+
return cast(None | str | Unset, data)
276+
277+
replaced_association_id = _parse_replaced_association_id(
278+
d.pop("replaced_association_id", UNSET)
279+
)
280+
281+
reclassified_periods = cast(list[str], d.pop("reclassified_periods", UNSET))
282+
249283
association_response = cls(
250284
id=id,
251285
structure_id=structure_id,
@@ -261,6 +295,8 @@ def _parse_approved_by(data: object) -> None | str | Unset:
261295
confidence=confidence,
262296
suggested_by=suggested_by,
263297
approved_by=approved_by,
298+
replaced_association_id=replaced_association_id,
299+
reclassified_periods=reclassified_periods,
264300
)
265301

266302
association_response.additional_properties = d

0 commit comments

Comments
 (0)