Skip to content

Commit 8d8a394

Browse files
authored
feat: management dimensions — get_dimensions, create_dimension, update_dimension, sliced trial balance (#269)
## Summary The management-dimensions surface from robosystems #1888, #1889 and #1890, regenerated, plus facades for it: the dimension catalog, a trial balance sliced by one member, and the department/class/location tags on journal and transaction lines. **Waits on the robosystems release after v1.19.3**, which carries those three PRs. Against v1.19.3 the new GraphQL fields (`trialBalance.sliced`, line `dimensions`, `dimensions`) do not exist and the affected queries fail. ## Changes - **Regenerated** (`api/`, `models/`, `graphql/generated/`, `graphql/schema.graphql`), all from this effort's server changes; no unrelated drift: - operations `create_dimension` / `update_dimension`, with their request, response and envelope types - `StatementDimension` / `StatementDimensionResponse` on the live statement request and response - `JournalEntryLineDimensions` and `line_dimensions` on `UpdateJournalEntryRequest` - `dimension_ids` on journal lines, events and schedule entry templates - **Query documents:** - new `ledger/ListLedgerDimensions.graphql` - `GetLedgerTrialBalance.graphql` takes `$dimensionType` / `$dimensionMemberId` and selects `sliced` - the journal and transaction line selections add `dimensions { id dimensionType name }`; the transaction lines also add `flowQname`, which the journal lines already had - **Facades** (`LedgerClient`): - `get_dimensions(graph_id, *, dimension_type=None, include_inactive=False)` - `create_dimension` / `update_dimension` - `get_trial_balance` gains keyword-only `dimension_type` / `dimension_member_id` - `live_financial_statement` takes `dimension` in its body dict through the regenerated request model - sync path only, as the existing ledger facades are ## Compatibility ADDITIVE. New operations, optional request fields, new exports. The added query selections return new response fields; no existing field changed type or became narrower. ## Testing - Regenerated against the local stack rebuilt from robosystems `main` at the #1890 merge (`just generate-sdk`, which also refreshes `schema.graphql`), then `just generate-graphql`. - `just test-all`: 712 tests passed, 17 skipped; ruff, format and basedpyright clean. Four new facade tests. Two existing mocks gained the fields their queries now select (`sliced`, line `dimensions`). ## Certification - [x] I have the right to submit this work under the Apache 2.0 license, and do so. Where any part of it is owned by my employer, I have their permission. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013UXnatpnbiixt1ZVHfdZAP
2 parents df85fd1 + 139d83b commit 8d8a394

35 files changed

Lines changed: 2121 additions & 58 deletions

‎robosystems_client/api/robo_ledger_analytical_views/live_financial_statement.py‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ def sync_detailed(
120120
materialization required. One entity's books: `entity_id` names a subsidiary, omitted means the
121121
group parent. On the parent, `scope: combined` sums every member consolidated in full at the rs-gaap
122122
concepts for the months each was a member, nothing eliminated, and `scope: consolidated` adds the
123-
consolidation entity's entries — the eliminations and noncontrolling interest. Rejected on shared-
124-
repository graphs; those should use `financial-statement-analysis` instead.
123+
consolidation entity's entries — the eliminations and noncontrolling interest. `dimension` slices an
124+
income statement by department, class, location or project: one member's lines, or a column per
125+
member with Unallocated and Total. Rejected on shared-repository graphs; those should use
126+
`financial-statement-analysis` instead.
125127
126128
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
127129
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -167,8 +169,10 @@ def sync(
167169
materialization required. One entity's books: `entity_id` names a subsidiary, omitted means the
168170
group parent. On the parent, `scope: combined` sums every member consolidated in full at the rs-gaap
169171
concepts for the months each was a member, nothing eliminated, and `scope: consolidated` adds the
170-
consolidation entity's entries — the eliminations and noncontrolling interest. Rejected on shared-
171-
repository graphs; those should use `financial-statement-analysis` instead.
172+
consolidation entity's entries — the eliminations and noncontrolling interest. `dimension` slices an
173+
income statement by department, class, location or project: one member's lines, or a column per
174+
member with Unallocated and Total. Rejected on shared-repository graphs; those should use
175+
`financial-statement-analysis` instead.
172176
173177
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
174178
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -209,8 +213,10 @@ async def asyncio_detailed(
209213
materialization required. One entity's books: `entity_id` names a subsidiary, omitted means the
210214
group parent. On the parent, `scope: combined` sums every member consolidated in full at the rs-gaap
211215
concepts for the months each was a member, nothing eliminated, and `scope: consolidated` adds the
212-
consolidation entity's entries — the eliminations and noncontrolling interest. Rejected on shared-
213-
repository graphs; those should use `financial-statement-analysis` instead.
216+
consolidation entity's entries — the eliminations and noncontrolling interest. `dimension` slices an
217+
income statement by department, class, location or project: one member's lines, or a column per
218+
member with Unallocated and Total. Rejected on shared-repository graphs; those should use
219+
`financial-statement-analysis` instead.
214220
215221
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
216222
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
@@ -254,8 +260,10 @@ async def asyncio(
254260
materialization required. One entity's books: `entity_id` names a subsidiary, omitted means the
255261
group parent. On the parent, `scope: combined` sums every member consolidated in full at the rs-gaap
256262
concepts for the months each was a member, nothing eliminated, and `scope: consolidated` adds the
257-
consolidation entity's entries — the eliminations and noncontrolling interest. Rejected on shared-
258-
repository graphs; those should use `financial-statement-analysis` instead.
263+
consolidation entity's entries — the eliminations and noncontrolling interest. `dimension` slices an
264+
income statement by department, class, location or project: one member's lines, or a column per
265+
member with Unallocated and Total. Rejected on shared-repository graphs; those should use
266+
`financial-statement-analysis` instead.
259267
260268
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
261269
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.create_dimension_request import CreateDimensionRequest
10+
from ...models.error_response import ErrorResponse
11+
from ...models.operation_envelope_dimension_response import (
12+
OperationEnvelopeDimensionResponse,
13+
)
14+
from ...types import UNSET, Response, Unset
15+
16+
17+
def _get_kwargs(
18+
graph_id: str,
19+
*,
20+
body: CreateDimensionRequest,
21+
idempotency_key: None | str | Unset = UNSET,
22+
) -> dict[str, Any]:
23+
headers: dict[str, Any] = {}
24+
if not isinstance(idempotency_key, Unset):
25+
headers["Idempotency-Key"] = idempotency_key
26+
27+
_kwargs: dict[str, Any] = {
28+
"method": "post",
29+
"url": "/extensions/roboledger/{graph_id}/operations/create-dimension".format(
30+
graph_id=quote(str(graph_id), safe=""),
31+
),
32+
}
33+
34+
_kwargs["json"] = body.to_dict()
35+
36+
headers["Content-Type"] = "application/json"
37+
38+
_kwargs["headers"] = headers
39+
return _kwargs
40+
41+
42+
def _parse_response(
43+
*, client: AuthenticatedClient | Client, response: httpx.Response
44+
) -> ErrorResponse | OperationEnvelopeDimensionResponse | None:
45+
if response.status_code == 200:
46+
response_200 = OperationEnvelopeDimensionResponse.from_dict(response.json())
47+
48+
return response_200
49+
50+
if response.status_code == 400:
51+
response_400 = ErrorResponse.from_dict(response.json())
52+
53+
return response_400
54+
55+
if response.status_code == 401:
56+
response_401 = ErrorResponse.from_dict(response.json())
57+
58+
return response_401
59+
60+
if response.status_code == 403:
61+
response_403 = ErrorResponse.from_dict(response.json())
62+
63+
return response_403
64+
65+
if response.status_code == 404:
66+
response_404 = ErrorResponse.from_dict(response.json())
67+
68+
return response_404
69+
70+
if response.status_code == 409:
71+
response_409 = ErrorResponse.from_dict(response.json())
72+
73+
return response_409
74+
75+
if response.status_code == 422:
76+
response_422 = ErrorResponse.from_dict(response.json())
77+
78+
return response_422
79+
80+
if response.status_code == 429:
81+
response_429 = ErrorResponse.from_dict(response.json())
82+
83+
return response_429
84+
85+
if response.status_code == 500:
86+
response_500 = ErrorResponse.from_dict(response.json())
87+
88+
return response_500
89+
90+
if client.raise_on_unexpected_status:
91+
raise errors.UnexpectedStatus(response.status_code, response.content)
92+
else:
93+
return None
94+
95+
96+
def _build_response(
97+
*, client: AuthenticatedClient | Client, response: httpx.Response
98+
) -> Response[ErrorResponse | OperationEnvelopeDimensionResponse]:
99+
return Response(
100+
status_code=HTTPStatus(response.status_code),
101+
content=response.content,
102+
headers=response.headers,
103+
parsed=_parse_response(client=client, response=response),
104+
)
105+
106+
107+
def sync_detailed(
108+
graph_id: str,
109+
*,
110+
client: AuthenticatedClient,
111+
body: CreateDimensionRequest,
112+
idempotency_key: None | str | Unset = UNSET,
113+
) -> Response[ErrorResponse | OperationEnvelopeDimensionResponse]:
114+
"""Create Dimension
115+
116+
Add a member to a management dimension: a department, class, location or project (or an axis of your
117+
own) that ledger lines can carry, one member per axis per line. `value` is the member's stable key
118+
within its axis, a slug of the name when omitted; a second member with the same key returns 409. Tag
119+
lines with its id through `dimension_ids` on a journal line, and read the income statement by it
120+
with `live-financial-statement`'s `dimension`.
121+
122+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
123+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
124+
125+
Args:
126+
graph_id (str):
127+
idempotency_key (None | str | Unset):
128+
body (CreateDimensionRequest): Add a member to a management dimension.
129+
130+
Raises:
131+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132+
httpx.TimeoutException: If the request takes longer than Client.timeout.
133+
134+
Returns:
135+
Response[ErrorResponse | OperationEnvelopeDimensionResponse]
136+
"""
137+
138+
kwargs = _get_kwargs(
139+
graph_id=graph_id,
140+
body=body,
141+
idempotency_key=idempotency_key,
142+
)
143+
144+
response = client.get_httpx_client().request(
145+
**kwargs,
146+
)
147+
148+
return _build_response(client=client, response=response)
149+
150+
151+
def sync(
152+
graph_id: str,
153+
*,
154+
client: AuthenticatedClient,
155+
body: CreateDimensionRequest,
156+
idempotency_key: None | str | Unset = UNSET,
157+
) -> ErrorResponse | OperationEnvelopeDimensionResponse | None:
158+
"""Create Dimension
159+
160+
Add a member to a management dimension: a department, class, location or project (or an axis of your
161+
own) that ledger lines can carry, one member per axis per line. `value` is the member's stable key
162+
within its axis, a slug of the name when omitted; a second member with the same key returns 409. Tag
163+
lines with its id through `dimension_ids` on a journal line, and read the income statement by it
164+
with `live-financial-statement`'s `dimension`.
165+
166+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
167+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
168+
169+
Args:
170+
graph_id (str):
171+
idempotency_key (None | str | Unset):
172+
body (CreateDimensionRequest): Add a member to a management dimension.
173+
174+
Raises:
175+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
176+
httpx.TimeoutException: If the request takes longer than Client.timeout.
177+
178+
Returns:
179+
ErrorResponse | OperationEnvelopeDimensionResponse
180+
"""
181+
182+
return sync_detailed(
183+
graph_id=graph_id,
184+
client=client,
185+
body=body,
186+
idempotency_key=idempotency_key,
187+
).parsed
188+
189+
190+
async def asyncio_detailed(
191+
graph_id: str,
192+
*,
193+
client: AuthenticatedClient,
194+
body: CreateDimensionRequest,
195+
idempotency_key: None | str | Unset = UNSET,
196+
) -> Response[ErrorResponse | OperationEnvelopeDimensionResponse]:
197+
"""Create Dimension
198+
199+
Add a member to a management dimension: a department, class, location or project (or an axis of your
200+
own) that ledger lines can carry, one member per axis per line. `value` is the member's stable key
201+
within its axis, a slug of the name when omitted; a second member with the same key returns 409. Tag
202+
lines with its id through `dimension_ids` on a journal line, and read the income statement by it
203+
with `live-financial-statement`'s `dimension`.
204+
205+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
206+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
207+
208+
Args:
209+
graph_id (str):
210+
idempotency_key (None | str | Unset):
211+
body (CreateDimensionRequest): Add a member to a management dimension.
212+
213+
Raises:
214+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
215+
httpx.TimeoutException: If the request takes longer than Client.timeout.
216+
217+
Returns:
218+
Response[ErrorResponse | OperationEnvelopeDimensionResponse]
219+
"""
220+
221+
kwargs = _get_kwargs(
222+
graph_id=graph_id,
223+
body=body,
224+
idempotency_key=idempotency_key,
225+
)
226+
227+
response = await client.get_async_httpx_client().request(**kwargs)
228+
229+
return _build_response(client=client, response=response)
230+
231+
232+
async def asyncio(
233+
graph_id: str,
234+
*,
235+
client: AuthenticatedClient,
236+
body: CreateDimensionRequest,
237+
idempotency_key: None | str | Unset = UNSET,
238+
) -> ErrorResponse | OperationEnvelopeDimensionResponse | None:
239+
"""Create Dimension
240+
241+
Add a member to a management dimension: a department, class, location or project (or an axis of your
242+
own) that ledger lines can carry, one member per axis per line. `value` is the member's stable key
243+
within its axis, a slug of the name when omitted; a second member with the same key returns 409. Tag
244+
lines with its id through `dimension_ids` on a journal line, and read the income statement by it
245+
with `live-financial-statement`'s `dimension`.
246+
247+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
248+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
249+
250+
Args:
251+
graph_id (str):
252+
idempotency_key (None | str | Unset):
253+
body (CreateDimensionRequest): Add a member to a management dimension.
254+
255+
Raises:
256+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
257+
httpx.TimeoutException: If the request takes longer than Client.timeout.
258+
259+
Returns:
260+
ErrorResponse | OperationEnvelopeDimensionResponse
261+
"""
262+
263+
return (
264+
await asyncio_detailed(
265+
graph_id=graph_id,
266+
client=client,
267+
body=body,
268+
idempotency_key=idempotency_key,
269+
)
270+
).parsed

0 commit comments

Comments
 (0)