Skip to content

Commit 5dc3d34

Browse files
authored
feat(ledger): list_industries, the industry classification an entity chooses from (#311)
## Summary Adds `LedgerClient.list_industries(graph_id)`: the industry classification an entity's `industry` is chosen from (`id`, `parent_id`, `level`, `label`, `path`, `carried`, `replaced_by`), parents before children. Regenerated from the API for the changed `industry` descriptions, with the GraphQL schema snapshot refreshed. The Python twin of RoboFinSystems/robosystems-typescript-client#332. ## Waits on the server The `industries` GraphQL field ships in RoboFinSystems/robosystems#2124. Until the robosystems release that carries it is deployed, `list_industries` fails against production with an unknown-field error. Nothing else in this release depends on it. ## Contract - Additive: one facade method. A client minor. Nothing in the integration template's emit path is touched. - To name in the release notes: with that server release, `create_entity` and `update_entity` refuse a free-text `industry` (422, naming the closest ids) where they accepted it before; pass a node id from `list_industries`. `update_entity(graph_id, {"industry": None})` now clears the field. No shape changes. ## Testing `just test-all`: 757 passed, lint, format and typecheck clean. The schema drift gate regenerates clean. Generated against a local API running the server branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 5f66628 + 6b7aab3 commit 5dc3d34

13 files changed

Lines changed: 175 additions & 12 deletions

File tree

‎robosystems_client/api/robo_ledger_setup/create_entity.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def sync_detailed(
124124
access to it sees every entity. `ownership_pct` implies the `consolidation_method` (50 and above
125125
full, 20 to 50 equity, below 20 cost) unless one is given; `entity_role: consolidation` makes this
126126
the group's entity for consolidating entries, read by the consolidated statements only; `joined_on`
127-
dates an acquired subsidiary's membership.
127+
dates an acquired subsidiary's membership. `industry` is an id from the industry classification, at
128+
any level (`technology`, `health-care/biotechnology`); an unknown value is refused (422) with the
129+
closest ids.
128130
129131
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
130132
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -182,7 +184,9 @@ def sync(
182184
access to it sees every entity. `ownership_pct` implies the `consolidation_method` (50 and above
183185
full, 20 to 50 equity, below 20 cost) unless one is given; `entity_role: consolidation` makes this
184186
the group's entity for consolidating entries, read by the consolidated statements only; `joined_on`
185-
dates an acquired subsidiary's membership.
187+
dates an acquired subsidiary's membership. `industry` is an id from the industry classification, at
188+
any level (`technology`, `health-care/biotechnology`); an unknown value is refused (422) with the
189+
closest ids.
186190
187191
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
188192
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -235,7 +239,9 @@ async def asyncio_detailed(
235239
access to it sees every entity. `ownership_pct` implies the `consolidation_method` (50 and above
236240
full, 20 to 50 equity, below 20 cost) unless one is given; `entity_role: consolidation` makes this
237241
the group's entity for consolidating entries, read by the consolidated statements only; `joined_on`
238-
dates an acquired subsidiary's membership.
242+
dates an acquired subsidiary's membership. `industry` is an id from the industry classification, at
243+
any level (`technology`, `health-care/biotechnology`); an unknown value is refused (422) with the
244+
closest ids.
239245
240246
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
241247
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -291,7 +297,9 @@ async def asyncio(
291297
access to it sees every entity. `ownership_pct` implies the `consolidation_method` (50 and above
292298
full, 20 to 50 equity, below 20 cost) unless one is given; `entity_role: consolidation` makes this
293299
the group's entity for consolidating entries, read by the consolidated statements only; `joined_on`
294-
dates an acquired subsidiary's membership.
300+
dates an acquired subsidiary's membership. `industry` is an id from the industry classification, at
301+
any level (`technology`, `health-care/biotechnology`); an unknown value is refused (422) with the
302+
closest ids.
295303
296304
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
297305
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/api/robo_ledger_setup/update_entity.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def sync_detailed(
119119
`consolidation_method` overrides the treatment the share implies (a new share re-derives it unless
120120
both are given), `entity_role: consolidation` marks the group's entity for consolidating entries,
121121
and `joined_on` / `left_on` bound its membership by month — set `left_on` when a subsidiary leaves
122-
the group and its history stays readable under it.
122+
the group and its history stays readable under it. `industry` is an id from the industry
123+
classification, refused (422) with the closest ids when unknown; an explicit null clears it.
123124
124125
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
125126
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -171,7 +172,8 @@ def sync(
171172
`consolidation_method` overrides the treatment the share implies (a new share re-derives it unless
172173
both are given), `entity_role: consolidation` marks the group's entity for consolidating entries,
173174
and `joined_on` / `left_on` bound its membership by month — set `left_on` when a subsidiary leaves
174-
the group and its history stays readable under it.
175+
the group and its history stays readable under it. `industry` is an id from the industry
176+
classification, refused (422) with the closest ids when unknown; an explicit null clears it.
175177
176178
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
177179
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -218,7 +220,8 @@ async def asyncio_detailed(
218220
`consolidation_method` overrides the treatment the share implies (a new share re-derives it unless
219221
both are given), `entity_role: consolidation` marks the group's entity for consolidating entries,
220222
and `joined_on` / `left_on` bound its membership by month — set `left_on` when a subsidiary leaves
221-
the group and its history stays readable under it.
223+
the group and its history stays readable under it. `industry` is an id from the industry
224+
classification, refused (422) with the closest ids when unknown; an explicit null clears it.
222225
223226
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
224227
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -268,7 +271,8 @@ async def asyncio(
268271
`consolidation_method` overrides the treatment the share implies (a new share re-derives it unless
269272
both are given), `entity_role: consolidation` marks the group's entity for consolidating entries,
270273
and `joined_on` / `left_on` bound its membership by month — set `left_on` when a subsidiary leaves
271-
the group and its history stays readable under it.
274+
the group and its history stays readable under it. `industry` is an id from the industry
275+
classification, refused (422) with the closest ids when unknown; an explicit null clears it.
272276
273277
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
274278
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

‎robosystems_client/clients/ledger_client.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@
316316
from ..graphql.generated.list_chart_templates import (
317317
ListChartTemplates,
318318
)
319+
from ..graphql.generated.list_industries import (
320+
ListIndustries,
321+
)
322+
from ..graphql.generated.list_industries import (
323+
ListIndustriesIndustries as Industry,
324+
)
319325
from ..graphql.generated.list_chart_templates import (
320326
ListChartTemplatesChartTemplates as ChartTemplate,
321327
)
@@ -547,6 +553,7 @@
547553
GET_LEDGER_EVENT_BLOCK_GQL,
548554
GET_LEDGER_FISCAL_CALENDAR_GQL,
549555
LIST_CHART_TEMPLATES_GQL,
556+
LIST_INDUSTRIES_GQL,
550557
LIST_LEDGER_RECONCILIATIONS_GQL,
551558
GET_LEDGER_MAPPED_TRIAL_BALANCE_GQL,
552559
GET_LEDGER_MAPPING_COVERAGE_GQL,
@@ -3230,6 +3237,16 @@ def initialize_ledger(
32303237
envelope = self._call_op("Initialize ledger", response)
32313238
return self._typed_result("Initialize ledger", envelope, InitializeLedgerResponse)
32323239

3240+
def list_industries(self, graph_id: str) -> list[Industry]:
3241+
"""The industry classification an entity's ``industry`` is chosen from.
3242+
3243+
Every node, parents before children; the same list for every graph. Pass
3244+
a node's ``id`` as ``industry`` to `create_entity` or `update_entity`, at
3245+
any level. An unknown value is refused with the closest ids.
3246+
"""
3247+
data = self._query(graph_id, LIST_INDUSTRIES_GQL)
3248+
return ListIndustries.model_validate(data).industries
3249+
32333250
# ── Chart of accounts ───────────────────────────────────────────────────
32343251

32353252
def list_chart_templates(self, graph_id: str) -> list[ChartTemplate]:

‎robosystems_client/graphql/generated/__init__.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@
246246
)
247247
from .get_library_taxonomy import GetLibraryTaxonomy, GetLibraryTaxonomyLibraryTaxonomy
248248
from .list_chart_templates import ListChartTemplates, ListChartTemplatesChartTemplates
249+
from .list_industries import ListIndustries, ListIndustriesIndustries
249250
from .list_information_block_summaries import (
250251
ListInformationBlockSummaries,
251252
ListInformationBlockSummariesInformationBlockSummaries,
@@ -462,6 +463,7 @@
462463
GET_LIBRARY_ELEMENT_GQL,
463464
GET_LIBRARY_TAXONOMY_GQL,
464465
LIST_CHART_TEMPLATES_GQL,
466+
LIST_INDUSTRIES_GQL,
465467
LIST_INFORMATION_BLOCK_SUMMARIES_GQL,
466468
LIST_INFORMATION_BLOCKS_GQL,
467469
LIST_INVESTOR_PORTFOLIOS_GQL,
@@ -728,6 +730,7 @@
728730
"GraphQLClientHttpError",
729731
"GraphQLClientInvalidResponseError",
730732
"LIST_CHART_TEMPLATES_GQL",
733+
"LIST_INDUSTRIES_GQL",
731734
"LIST_INFORMATION_BLOCKS_GQL",
732735
"LIST_INFORMATION_BLOCK_SUMMARIES_GQL",
733736
"LIST_INVESTOR_PORTFOLIOS_GQL",
@@ -759,6 +762,8 @@
759762
"LIST_LIBRARY_TAXONOMY_ARCS_GQL",
760763
"ListChartTemplates",
761764
"ListChartTemplatesChartTemplates",
765+
"ListIndustries",
766+
"ListIndustriesIndustries",
762767
"ListInformationBlockSummaries",
763768
"ListInformationBlockSummariesInformationBlockSummaries",
764769
"ListInformationBlocks",

‎robosystems_client/graphql/generated/client.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from .get_library_element_equivalents import GetLibraryElementEquivalents
4343
from .get_library_taxonomy import GetLibraryTaxonomy
4444
from .list_chart_templates import ListChartTemplates
45+
from .list_industries import ListIndustries
4546
from .list_information_block_summaries import ListInformationBlockSummaries
4647
from .list_information_blocks import ListInformationBlocks
4748
from .list_investor_portfolios import ListInvestorPortfolios
@@ -113,6 +114,7 @@
113114
GET_LIBRARY_ELEMENT_GQL,
114115
GET_LIBRARY_TAXONOMY_GQL,
115116
LIST_CHART_TEMPLATES_GQL,
117+
LIST_INDUSTRIES_GQL,
116118
LIST_INFORMATION_BLOCK_SUMMARIES_GQL,
117119
LIST_INFORMATION_BLOCKS_GQL,
118120
LIST_INVESTOR_PORTFOLIOS_GQL,
@@ -743,6 +745,17 @@ def list_chart_templates(self, **kwargs: Any) -> ListChartTemplates:
743745
data = self.get_data(response)
744746
return ListChartTemplates.model_validate(data)
745747

748+
def list_industries(self, **kwargs: Any) -> ListIndustries:
749+
variables: dict[str, object] = {}
750+
response = self.execute(
751+
query=LIST_INDUSTRIES_GQL,
752+
operation_name="ListIndustries",
753+
variables=variables,
754+
**kwargs,
755+
)
756+
data = self.get_data(response)
757+
return ListIndustries.model_validate(data)
758+
746759
def list_information_block_summaries(
747760
self,
748761
block_type: Union[Optional[str], UnsetType] = UNSET,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import Optional
2+
3+
from pydantic import Field
4+
5+
from .base_model import BaseModel
6+
7+
8+
class ListIndustries(BaseModel):
9+
industries: list["ListIndustriesIndustries"]
10+
11+
12+
class ListIndustriesIndustries(BaseModel):
13+
id: str
14+
parent_id: Optional[str] = Field(alias="parentId")
15+
level: str
16+
label: str
17+
path: list[str]
18+
carried: bool
19+
replaced_by: Optional[str] = Field(alias="replacedBy")
20+
21+
22+
ListIndustries.model_rebuild()

‎robosystems_client/graphql/generated/operations.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"GET_LIBRARY_ELEMENT_GQL",
3939
"GET_LIBRARY_TAXONOMY_GQL",
4040
"LIST_CHART_TEMPLATES_GQL",
41+
"LIST_INDUSTRIES_GQL",
4142
"LIST_INFORMATION_BLOCKS_GQL",
4243
"LIST_INFORMATION_BLOCK_SUMMARIES_GQL",
4344
"LIST_INVESTOR_PORTFOLIOS_GQL",
@@ -1603,6 +1604,20 @@
16031604
}
16041605
"""
16051606

1607+
LIST_INDUSTRIES_GQL = """
1608+
query ListIndustries {
1609+
industries {
1610+
id
1611+
parentId
1612+
level
1613+
label
1614+
path
1615+
carried
1616+
replacedBy
1617+
}
1618+
}
1619+
"""
1620+
16061621
LIST_INFORMATION_BLOCK_SUMMARIES_GQL = """
16071622
query ListInformationBlockSummaries($blockType: String, $category: String, $limit: Int, $offset: Int, $scenarioId: String, $entityId: String) {
16081623
informationBlockSummaries(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
query ListIndustries {
2+
industries {
3+
id parentId level label path carried replacedBy
4+
}
5+
}

‎robosystems_client/graphql/schema.graphql‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ type Query {
9191
entityId: String = null
9292
): LedgerEntity
9393

94+
"""
95+
The industry classification: every node an entity's `industry` can name,
96+
parents before children. One list for every graph.
97+
"""
98+
industries: [Industry!]!
99+
94100
"""List entities for a graph, optionally filtered by source."""
95101
entities(
96102
"""Filter by the system an entity came from, e.g. `quickbooks`."""
@@ -1796,7 +1802,9 @@ type LedgerEntity {
17961802
"""Legal Entity Identifier (ISO 17442)."""
17971803
lei: String
17981804

1799-
"""Free-form industry label."""
1805+
"""
1806+
Industry, as an id from the industry classification (the `industries` field). An entity set before the classification may still hold free text.
1807+
"""
18001808
industry: String
18011809

18021810
"""Legal form (e.g. 'corporation', 'llc', 'lp')."""
@@ -1870,6 +1878,34 @@ type LedgerEntity {
18701878
updatedAt: String
18711879
}
18721880

1881+
"""One node of the industry classification."""
1882+
type Industry {
1883+
"""The node's slug path; its ancestors are its id's prefixes."""
1884+
id: String!
1885+
1886+
"""The parent node; null on a sector."""
1887+
parentId: String
1888+
1889+
"""`sector`, `subsector`, `industry` or `sub-industry`."""
1890+
level: String!
1891+
1892+
"""The node's own name."""
1893+
label: String!
1894+
1895+
"""The names from the sector down to this node, for display."""
1896+
path: [String!]!
1897+
1898+
"""
1899+
True on the single industry of a subsector nobody has divided; it repeats the subsector's name and `path` shows it once.
1900+
"""
1901+
carried: Boolean!
1902+
1903+
"""
1904+
Set on a retired node: the id that stands for it now. Not offered for new choices.
1905+
"""
1906+
replacedBy: String
1907+
}
1908+
18731909
type Agent {
18741910
id: String!
18751911
agentType: String!

‎robosystems_client/models/create_entity_request.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ class CreateEntityRequest:
7474
cadence, and every entity's calendar follows it.
7575
tax_id (None | str | Unset):
7676
lei (None | str | Unset):
77-
industry (None | str | Unset):
77+
industry (None | str | Unset): Industry, as an id from the industry classification (the `industries` GraphQL
78+
field), at any level: `technology`, `health-care/biotechnology`, `technology/software/application/payroll-and-
79+
hcm`. An unknown value is refused with the closest ids.
7880
phone (None | str | Unset):
7981
website (None | str | Unset):
8082
address_line1 (None | str | Unset):

0 commit comments

Comments
 (0)