Skip to content

Commit 9e5a6ed

Browse files
jfrench9claude
andauthored
Add closing book structures and account rollups API support (#84)
## Summary Introduces new API endpoints, models, and field extensions to support closing book structures and account rollups in the robosystems client library. This feature adds the foundational client-side data layer needed for closing book workflows. ## Key Accomplishments ### New API Endpoints - **`get_account_rollups`** – New ledger API endpoint for retrieving account rollup data, enabling aggregated account views - **`get_closing_book_structures`** – New ledger API endpoint for fetching closing book structure definitions (categories and items) ### New Models - **`AccountRollupGroup`** – Represents a logical grouping of account rollup rows - **`AccountRollupRow`** – Represents an individual row within an account rollup group - **`AccountRollupsResponse`** – Response wrapper for the account rollups endpoint - **`ClosingBookCategory`** – Represents a category within a closing book structure - **`ClosingBookItem`** – Represents an individual item within a closing book category - **`ClosingBookStructuresResponse`** – Response wrapper for the closing book structures endpoint ### Model Enhancements - **`ClosingEntryResponse`** – Extended with additional fields to support closing entry workflows - **`EntryTemplateRequest`** – Added new fields to support richer template configuration - **`PeriodCloseItemResponse`** – Extended with new fields for period close tracking - **`SearchHit`** – Added new fields to enrich search result data ### Module Registration - All new models are properly exported via `models/__init__.py` ## Breaking Changes None expected. All changes are additive — new endpoints, new models, and new optional fields on existing models. ## Testing Notes - Verify new API endpoints return correctly deserialized response objects for both success and error cases - Validate that new model fields serialize/deserialize properly, especially nested structures (e.g., `ClosingBookCategory` containing `ClosingBookItem` lists, `AccountRollupGroup` containing `AccountRollupRow` lists) - Confirm that modifications to existing models (`ClosingEntryResponse`, `EntryTemplateRequest`, `PeriodCloseItemResponse`, `SearchHit`) are backward-compatible and do not break existing consumers - Test edge cases around empty/null collections in rollup groups and closing book categories ## Infrastructure Considerations - No new dependencies introduced - No configuration or environment changes required - New endpoints may require corresponding backend API availability for integration testing --- 🤖 Generated with [Claude Code](https://claude.ai/code) **Branch Info:** - Source: `feature/closing-book` - Target: `main` - Type: feature Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 29c057e + f6a31ab commit 9e5a6ed

30 files changed

Lines changed: 5394 additions & 15 deletions
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
import datetime
2+
from http import HTTPStatus
3+
from typing import Any
4+
from urllib.parse import quote
5+
6+
import httpx
7+
8+
from ... import errors
9+
from ...client import AuthenticatedClient, Client
10+
from ...models.account_rollups_response import AccountRollupsResponse
11+
from ...models.http_validation_error import HTTPValidationError
12+
from ...types import UNSET, Response, Unset
13+
14+
15+
def _get_kwargs(
16+
graph_id: str,
17+
*,
18+
mapping_id: None | str | Unset = UNSET,
19+
start_date: datetime.date | None | Unset = UNSET,
20+
end_date: datetime.date | None | Unset = UNSET,
21+
) -> dict[str, Any]:
22+
params: dict[str, Any] = {}
23+
24+
json_mapping_id: None | str | Unset
25+
if isinstance(mapping_id, Unset):
26+
json_mapping_id = UNSET
27+
else:
28+
json_mapping_id = mapping_id
29+
params["mapping_id"] = json_mapping_id
30+
31+
json_start_date: None | str | Unset
32+
if isinstance(start_date, Unset):
33+
json_start_date = UNSET
34+
elif isinstance(start_date, datetime.date):
35+
json_start_date = start_date.isoformat()
36+
else:
37+
json_start_date = start_date
38+
params["start_date"] = json_start_date
39+
40+
json_end_date: None | str | Unset
41+
if isinstance(end_date, Unset):
42+
json_end_date = UNSET
43+
elif isinstance(end_date, datetime.date):
44+
json_end_date = end_date.isoformat()
45+
else:
46+
json_end_date = end_date
47+
params["end_date"] = json_end_date
48+
49+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
50+
51+
_kwargs: dict[str, Any] = {
52+
"method": "get",
53+
"url": "/v1/ledger/{graph_id}/account-rollups".format(
54+
graph_id=quote(str(graph_id), safe=""),
55+
),
56+
"params": params,
57+
}
58+
59+
return _kwargs
60+
61+
62+
def _parse_response(
63+
*, client: AuthenticatedClient | Client, response: httpx.Response
64+
) -> AccountRollupsResponse | HTTPValidationError | None:
65+
if response.status_code == 200:
66+
response_200 = AccountRollupsResponse.from_dict(response.json())
67+
68+
return response_200
69+
70+
if response.status_code == 422:
71+
response_422 = HTTPValidationError.from_dict(response.json())
72+
73+
return response_422
74+
75+
if client.raise_on_unexpected_status:
76+
raise errors.UnexpectedStatus(response.status_code, response.content)
77+
else:
78+
return None
79+
80+
81+
def _build_response(
82+
*, client: AuthenticatedClient | Client, response: httpx.Response
83+
) -> Response[AccountRollupsResponse | HTTPValidationError]:
84+
return Response(
85+
status_code=HTTPStatus(response.status_code),
86+
content=response.content,
87+
headers=response.headers,
88+
parsed=_parse_response(client=client, response=response),
89+
)
90+
91+
92+
def sync_detailed(
93+
graph_id: str,
94+
*,
95+
client: AuthenticatedClient,
96+
mapping_id: None | str | Unset = UNSET,
97+
start_date: datetime.date | None | Unset = UNSET,
98+
end_date: datetime.date | None | Unset = UNSET,
99+
) -> Response[AccountRollupsResponse | HTTPValidationError]:
100+
"""Account Rollups
101+
102+
Account rollups — CoA accounts grouped by reporting element with balances.
103+
104+
Shows how company-specific accounts roll up to standardized reporting
105+
line items. Auto-discovers the mapping structure if mapping_id is not provided.
106+
107+
Args:
108+
graph_id (str):
109+
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
110+
start_date (datetime.date | None | Unset): Start date (inclusive)
111+
end_date (datetime.date | None | Unset): End date (inclusive)
112+
113+
Raises:
114+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
115+
httpx.TimeoutException: If the request takes longer than Client.timeout.
116+
117+
Returns:
118+
Response[AccountRollupsResponse | HTTPValidationError]
119+
"""
120+
121+
kwargs = _get_kwargs(
122+
graph_id=graph_id,
123+
mapping_id=mapping_id,
124+
start_date=start_date,
125+
end_date=end_date,
126+
)
127+
128+
response = client.get_httpx_client().request(
129+
**kwargs,
130+
)
131+
132+
return _build_response(client=client, response=response)
133+
134+
135+
def sync(
136+
graph_id: str,
137+
*,
138+
client: AuthenticatedClient,
139+
mapping_id: None | str | Unset = UNSET,
140+
start_date: datetime.date | None | Unset = UNSET,
141+
end_date: datetime.date | None | Unset = UNSET,
142+
) -> AccountRollupsResponse | HTTPValidationError | None:
143+
"""Account Rollups
144+
145+
Account rollups — CoA accounts grouped by reporting element with balances.
146+
147+
Shows how company-specific accounts roll up to standardized reporting
148+
line items. Auto-discovers the mapping structure if mapping_id is not provided.
149+
150+
Args:
151+
graph_id (str):
152+
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
153+
start_date (datetime.date | None | Unset): Start date (inclusive)
154+
end_date (datetime.date | None | Unset): End date (inclusive)
155+
156+
Raises:
157+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
158+
httpx.TimeoutException: If the request takes longer than Client.timeout.
159+
160+
Returns:
161+
AccountRollupsResponse | HTTPValidationError
162+
"""
163+
164+
return sync_detailed(
165+
graph_id=graph_id,
166+
client=client,
167+
mapping_id=mapping_id,
168+
start_date=start_date,
169+
end_date=end_date,
170+
).parsed
171+
172+
173+
async def asyncio_detailed(
174+
graph_id: str,
175+
*,
176+
client: AuthenticatedClient,
177+
mapping_id: None | str | Unset = UNSET,
178+
start_date: datetime.date | None | Unset = UNSET,
179+
end_date: datetime.date | None | Unset = UNSET,
180+
) -> Response[AccountRollupsResponse | HTTPValidationError]:
181+
"""Account Rollups
182+
183+
Account rollups — CoA accounts grouped by reporting element with balances.
184+
185+
Shows how company-specific accounts roll up to standardized reporting
186+
line items. Auto-discovers the mapping structure if mapping_id is not provided.
187+
188+
Args:
189+
graph_id (str):
190+
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
191+
start_date (datetime.date | None | Unset): Start date (inclusive)
192+
end_date (datetime.date | None | Unset): End date (inclusive)
193+
194+
Raises:
195+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
196+
httpx.TimeoutException: If the request takes longer than Client.timeout.
197+
198+
Returns:
199+
Response[AccountRollupsResponse | HTTPValidationError]
200+
"""
201+
202+
kwargs = _get_kwargs(
203+
graph_id=graph_id,
204+
mapping_id=mapping_id,
205+
start_date=start_date,
206+
end_date=end_date,
207+
)
208+
209+
response = await client.get_async_httpx_client().request(**kwargs)
210+
211+
return _build_response(client=client, response=response)
212+
213+
214+
async def asyncio(
215+
graph_id: str,
216+
*,
217+
client: AuthenticatedClient,
218+
mapping_id: None | str | Unset = UNSET,
219+
start_date: datetime.date | None | Unset = UNSET,
220+
end_date: datetime.date | None | Unset = UNSET,
221+
) -> AccountRollupsResponse | HTTPValidationError | None:
222+
"""Account Rollups
223+
224+
Account rollups — CoA accounts grouped by reporting element with balances.
225+
226+
Shows how company-specific accounts roll up to standardized reporting
227+
line items. Auto-discovers the mapping structure if mapping_id is not provided.
228+
229+
Args:
230+
graph_id (str):
231+
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
232+
start_date (datetime.date | None | Unset): Start date (inclusive)
233+
end_date (datetime.date | None | Unset): End date (inclusive)
234+
235+
Raises:
236+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
237+
httpx.TimeoutException: If the request takes longer than Client.timeout.
238+
239+
Returns:
240+
AccountRollupsResponse | HTTPValidationError
241+
"""
242+
243+
return (
244+
await asyncio_detailed(
245+
graph_id=graph_id,
246+
client=client,
247+
mapping_id=mapping_id,
248+
start_date=start_date,
249+
end_date=end_date,
250+
)
251+
).parsed

0 commit comments

Comments
 (0)