Skip to content

Commit 267e8d8

Browse files
authored
feat: per-entity counterparty defaults (#264)
## Summary Regenerated against robosystems #1870 (RoboFinSystems/robosystems#1870), which keeps a counterparty's learned default per entity. This is the Python twin of RoboFinSystems/robosystems-typescript-client#280. - **`get_agent` / `list_agents`**: the GraphQL operations select `classifications`, one default per entity, each with its `entityId`. `classification` also gains `entityId` and is now the group parent's default. `schema.graphql` is refreshed. - **`update_agent`** takes `classification_entity_id`, which names the entity the default is for. Omitted, it is the group parent. - **`AcceptSuggestionLine.reason`** documents the new `suggestion_changed`. Additive, generated tier only, so a client **minor**. Nothing the integration template imports changes. **Waits on server release v1.19.1**, the release carrying robosystems #1870. Against v1.19.0, the agent queries select a field the server doesn't have yet. Publish after v1.19.1 is deployed. ## Test plan - `just test-all`: 697 passed. The agent fixtures carry the new fields, and `test_get_agent` asserts both entities' defaults. - Regenerated from a local stack running #1870. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XtkkKJao4sah3RsHdV3wG5
2 parents 37c6c6c + 34aa017 commit 267e8d8

16 files changed

Lines changed: 207 additions & 42 deletions

‎robosystems_client/api/robo_ledger_ledger_events/learn_classification_defaults.py‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ def sync_detailed(
117117
) -> Response[ErrorResponse | OperationEnvelopeLearnClassificationDefaultsResponse]:
118118
"""Learn Classification Defaults
119119
120-
Seed each counterparty's default account from the bank lines already committed to the books: the
121-
account most of its lines went to becomes its default, with the lines that agreed counted as
122-
confirmations. A counterparty that already has a default keeps it. Its still-open lines are then
123-
suggested from the default. Run it once on books that were classified before defaults were learned;
124-
after that, every commit teaches the default by itself. `dry_run` reports what would be learned
125-
without writing it.
120+
Seed each counterparty's default account from the bank lines already committed to the books, one for
121+
each entity whose lines it has: the account most of those lines went to becomes the default, with
122+
the lines that agreed counted as confirmations. A default already there is kept. Its still-open
123+
lines are then suggested from the default. Run it once on books that were classified before defaults
124+
were learned; after that, every commit teaches the default by itself. `dry_run` reports what would
125+
be learned without writing it.
126126
127127
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
128128
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -163,12 +163,12 @@ def sync(
163163
) -> ErrorResponse | OperationEnvelopeLearnClassificationDefaultsResponse | None:
164164
"""Learn Classification Defaults
165165
166-
Seed each counterparty's default account from the bank lines already committed to the books: the
167-
account most of its lines went to becomes its default, with the lines that agreed counted as
168-
confirmations. A counterparty that already has a default keeps it. Its still-open lines are then
169-
suggested from the default. Run it once on books that were classified before defaults were learned;
170-
after that, every commit teaches the default by itself. `dry_run` reports what would be learned
171-
without writing it.
166+
Seed each counterparty's default account from the bank lines already committed to the books, one for
167+
each entity whose lines it has: the account most of those lines went to becomes the default, with
168+
the lines that agreed counted as confirmations. A default already there is kept. Its still-open
169+
lines are then suggested from the default. Run it once on books that were classified before defaults
170+
were learned; after that, every commit teaches the default by itself. `dry_run` reports what would
171+
be learned without writing it.
172172
173173
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
174174
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -204,12 +204,12 @@ async def asyncio_detailed(
204204
) -> Response[ErrorResponse | OperationEnvelopeLearnClassificationDefaultsResponse]:
205205
"""Learn Classification Defaults
206206
207-
Seed each counterparty's default account from the bank lines already committed to the books: the
208-
account most of its lines went to becomes its default, with the lines that agreed counted as
209-
confirmations. A counterparty that already has a default keeps it. Its still-open lines are then
210-
suggested from the default. Run it once on books that were classified before defaults were learned;
211-
after that, every commit teaches the default by itself. `dry_run` reports what would be learned
212-
without writing it.
207+
Seed each counterparty's default account from the bank lines already committed to the books, one for
208+
each entity whose lines it has: the account most of those lines went to becomes the default, with
209+
the lines that agreed counted as confirmations. A default already there is kept. Its still-open
210+
lines are then suggested from the default. Run it once on books that were classified before defaults
211+
were learned; after that, every commit teaches the default by itself. `dry_run` reports what would
212+
be learned without writing it.
213213
214214
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
215215
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -248,12 +248,12 @@ async def asyncio(
248248
) -> ErrorResponse | OperationEnvelopeLearnClassificationDefaultsResponse | None:
249249
"""Learn Classification Defaults
250250
251-
Seed each counterparty's default account from the bank lines already committed to the books: the
252-
account most of its lines went to becomes its default, with the lines that agreed counted as
253-
confirmations. A counterparty that already has a default keeps it. Its still-open lines are then
254-
suggested from the default. Run it once on books that were classified before defaults were learned;
255-
after that, every commit teaches the default by itself. `dry_run` reports what would be learned
256-
without writing it.
251+
Seed each counterparty's default account from the bank lines already committed to the books, one for
252+
each entity whose lines it has: the account most of those lines went to becomes the default, with
253+
the lines that agreed counted as confirmations. A default already there is kept. Its still-open
254+
lines are then suggested from the default. Run it once on books that were classified before defaults
255+
were learned; after that, every commit teaches the default by itself. `dry_run` reports what would
256+
be learned without writing it.
257257
258258
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
259259
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/api/robo_ledger_ledger_events/update_agent.py‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ def sync_detailed(
117117
(agents are never deleted — they are reference data referenced by events and transactions).
118118
`classification_element_id` sets the account this counterparty's bank lines are suggested (an empty
119119
string clears it), and `classification_mode='always_ask'` stops suggesting one for a counterparty
120-
whose lines go to different accounts; its still-open lines are re-suggested at once. A default is
121-
also learned as lines are committed, so set one by hand only to correct it.
120+
whose lines go to different accounts; its still-open lines are re-suggested at once. Each entity of
121+
a group keeps its own default, on its own chart: `classification_entity_id` names the one these
122+
fields are for, omitted the group parent. A default is also learned as lines are committed, so set
123+
one by hand only to correct it.
122124
123125
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
124126
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -164,8 +166,10 @@ def sync(
164166
(agents are never deleted — they are reference data referenced by events and transactions).
165167
`classification_element_id` sets the account this counterparty's bank lines are suggested (an empty
166168
string clears it), and `classification_mode='always_ask'` stops suggesting one for a counterparty
167-
whose lines go to different accounts; its still-open lines are re-suggested at once. A default is
168-
also learned as lines are committed, so set one by hand only to correct it.
169+
whose lines go to different accounts; its still-open lines are re-suggested at once. Each entity of
170+
a group keeps its own default, on its own chart: `classification_entity_id` names the one these
171+
fields are for, omitted the group parent. A default is also learned as lines are committed, so set
172+
one by hand only to correct it.
169173
170174
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
171175
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -206,8 +210,10 @@ async def asyncio_detailed(
206210
(agents are never deleted — they are reference data referenced by events and transactions).
207211
`classification_element_id` sets the account this counterparty's bank lines are suggested (an empty
208212
string clears it), and `classification_mode='always_ask'` stops suggesting one for a counterparty
209-
whose lines go to different accounts; its still-open lines are re-suggested at once. A default is
210-
also learned as lines are committed, so set one by hand only to correct it.
213+
whose lines go to different accounts; its still-open lines are re-suggested at once. Each entity of
214+
a group keeps its own default, on its own chart: `classification_entity_id` names the one these
215+
fields are for, omitted the group parent. A default is also learned as lines are committed, so set
216+
one by hand only to correct it.
211217
212218
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
213219
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -251,8 +257,10 @@ async def asyncio(
251257
(agents are never deleted — they are reference data referenced by events and transactions).
252258
`classification_element_id` sets the account this counterparty's bank lines are suggested (an empty
253259
string clears it), and `classification_mode='always_ask'` stops suggesting one for a counterparty
254-
whose lines go to different accounts; its still-open lines are re-suggested at once. A default is
255-
also learned as lines are committed, so set one by hand only to correct it.
260+
whose lines go to different accounts; its still-open lines are re-suggested at once. Each entity of
261+
a group keeps its own default, on its own chart: `classification_entity_id` names the one these
262+
fields are for, omitted the group parent. A default is also learned as lines are committed, so set
263+
one by hand only to correct it.
256264
257265
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
258266
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/clients/ledger_client.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,9 @@ def update_agent(
23482348
metadata; all other fields replace. ``classification_element_id`` sets
23492349
the account its bank lines are suggested (an empty string clears it) and
23502350
``classification_mode="always_ask"`` stops suggesting one; its open lines
2351-
are re-suggested at once.
2351+
are re-suggested at once. Each entity keeps its own default:
2352+
``classification_entity_id`` names the one these are for, omitted the
2353+
group parent.
23522354
"""
23532355
request = UpdateAgentRequest.from_dict(body)
23542356
response = op_update_agent(

‎robosystems_client/graphql/generated/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
GetLedgerAgent,
7474
GetLedgerAgentAgent,
7575
GetLedgerAgentAgentClassification,
76+
GetLedgerAgentAgentClassifications,
7677
)
7778
from .get_ledger_closing_book_structures import (
7879
GetLedgerClosingBookStructures,
@@ -251,6 +252,7 @@
251252
ListLedgerAgents,
252253
ListLedgerAgentsAgents,
253254
ListLedgerAgentsAgentsClassification,
255+
ListLedgerAgentsAgentsClassifications,
254256
)
255257
from .list_ledger_bank_accounts import (
256258
ListLedgerBankAccounts,
@@ -510,6 +512,7 @@
510512
"GetLedgerAgent",
511513
"GetLedgerAgentAgent",
512514
"GetLedgerAgentAgentClassification",
515+
"GetLedgerAgentAgentClassifications",
513516
"GetLedgerClosingBookStructures",
514517
"GetLedgerClosingBookStructuresClosingBookStructures",
515518
"GetLedgerClosingBookStructuresClosingBookStructuresCategories",
@@ -672,6 +675,7 @@
672675
"ListLedgerAgents",
673676
"ListLedgerAgentsAgents",
674677
"ListLedgerAgentsAgentsClassification",
678+
"ListLedgerAgentsAgentsClassifications",
675679
"ListLedgerBankAccounts",
676680
"ListLedgerBankAccountsBankAccounts",
677681
"ListLedgerBankAccountsBankAccountsAccounts",

‎robosystems_client/graphql/generated/get_ledger_agent.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,23 @@ class GetLedgerAgentAgent(BaseModel):
2929
updated_at: Optional[str] = Field(alias="updatedAt")
3030
created_by: Optional[str] = Field(alias="createdBy")
3131
classification: Optional["GetLedgerAgentAgentClassification"]
32+
classifications: list["GetLedgerAgentAgentClassifications"]
3233

3334

3435
class GetLedgerAgentAgentClassification(BaseModel):
36+
entity_id: str = Field(alias="entityId")
37+
element_id: str = Field(alias="elementId")
38+
account_name: Optional[str] = Field(alias="accountName")
39+
mode: str
40+
confirmations: int
41+
overrides: int
42+
set_by: Optional[str] = Field(alias="setBy")
43+
set_at: Optional[str] = Field(alias="setAt")
44+
learned_from: Optional[str] = Field(alias="learnedFrom")
45+
46+
47+
class GetLedgerAgentAgentClassifications(BaseModel):
48+
entity_id: str = Field(alias="entityId")
3549
element_id: str = Field(alias="elementId")
3650
account_name: Optional[str] = Field(alias="accountName")
3751
mode: str

‎robosystems_client/graphql/generated/list_ledger_agents.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,23 @@ class ListLedgerAgentsAgents(BaseModel):
2929
updated_at: Optional[str] = Field(alias="updatedAt")
3030
created_by: Optional[str] = Field(alias="createdBy")
3131
classification: Optional["ListLedgerAgentsAgentsClassification"]
32+
classifications: list["ListLedgerAgentsAgentsClassifications"]
3233

3334

3435
class ListLedgerAgentsAgentsClassification(BaseModel):
36+
entity_id: str = Field(alias="entityId")
37+
element_id: str = Field(alias="elementId")
38+
account_name: Optional[str] = Field(alias="accountName")
39+
mode: str
40+
confirmations: int
41+
overrides: int
42+
set_by: Optional[str] = Field(alias="setBy")
43+
set_at: Optional[str] = Field(alias="setAt")
44+
learned_from: Optional[str] = Field(alias="learnedFrom")
45+
46+
47+
class ListLedgerAgentsAgentsClassifications(BaseModel):
48+
entity_id: str = Field(alias="entityId")
3549
element_id: str = Field(alias="elementId")
3650
account_name: Optional[str] = Field(alias="accountName")
3751
mode: str

‎robosystems_client/graphql/generated/operations.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,18 @@
581581
updatedAt
582582
createdBy
583583
classification {
584+
entityId
585+
elementId
586+
accountName
587+
mode
588+
confirmations
589+
overrides
590+
setBy
591+
setAt
592+
learnedFrom
593+
}
594+
classifications {
595+
entityId
584596
elementId
585597
accountName
586598
mode
@@ -1486,6 +1498,18 @@
14861498
updatedAt
14871499
createdBy
14881500
classification {
1501+
entityId
1502+
elementId
1503+
accountName
1504+
mode
1505+
confirmations
1506+
overrides
1507+
setBy
1508+
setAt
1509+
learnedFrom
1510+
}
1511+
classifications {
1512+
entityId
14891513
elementId
14901514
accountName
14911515
mode

‎robosystems_client/graphql/operations/ledger/GetLedgerAgent.graphql‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ query GetLedgerAgent($id: String!) {
44
email phone address source externalId
55
isActive is1099Recipient createdAt updatedAt createdBy
66
classification {
7+
entityId
8+
elementId accountName mode confirmations overrides setBy setAt learnedFrom
9+
}
10+
classifications {
11+
entityId
712
elementId accountName mode confirmations overrides setBy setAt learnedFrom
813
}
914
}

‎robosystems_client/graphql/operations/ledger/ListLedgerAgents.graphql‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ query ListLedgerAgents(
1616
email phone address source externalId
1717
isActive is1099Recipient createdAt updatedAt createdBy
1818
classification {
19+
entityId
20+
elementId accountName mode confirmations overrides setBy setAt learnedFrom
21+
}
22+
classifications {
23+
entityId
1924
elementId accountName mode confirmations overrides setBy setAt learnedFrom
2025
}
2126
}

‎robosystems_client/graphql/schema.graphql‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,7 @@ type Agent {
16311631
isActive: Boolean!
16321632
is1099Recipient: Boolean!
16331633
classification: AgentClassification
1634+
classifications: [AgentClassification!]!
16341635
createdAt: DateTime
16351636
updatedAt: DateTime
16361637
createdBy: String
@@ -1639,10 +1640,13 @@ type Agent {
16391640
}
16401641

16411642
"""
1642-
A counterparty's default account, learned from committed lines or set by
1643-
hand.
1643+
A counterparty's default account for one entity's lines, learned from
1644+
committed lines or set by hand.
16441645
"""
16451646
type AgentClassification {
1647+
"""The entity whose lines it is for."""
1648+
entityId: String!
1649+
16461650
"""The default chart account."""
16471651
elementId: String!
16481652

0 commit comments

Comments
 (0)