Skip to content

Commit 9b5fd4c

Browse files
committed
feat(ledger): a journal entry line's cash flow row, and the in-place re-tag
Regenerated against robosystems #1812. UpdateJournalEntryRequest gains line_flows; the line input and response carry flow_qname; the journal list selects flowQname.
1 parent 7b38ddd commit 9b5fd4c

12 files changed

Lines changed: 276 additions & 32 deletions

‎robosystems_client/api/robo_ledger_ledger_events/update_journal_entry.py‎

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,25 @@ def sync_detailed(
113113
) -> Response[ErrorResponse | OperationEnvelopeJournalEntryResponse]:
114114
"""Update Journal Entry
115115
116-
Update a draft journal entry. Posted entries are immutable and must be corrected via `create-event-
117-
block(event_type='journal_entry_reversed')`. If line_items is provided, existing line items are
118-
replaced atomically, the new set must balance, and a line on a retired (`is_active=false`) account
119-
is refused.
116+
Update a draft journal entry, or re-tag any entry's flows. If line_items is provided, existing line
117+
items are replaced atomically, the new set must balance, and a line on a retired (`is_active=false`)
118+
account is refused. `line_flows` sets the cash flow row of the named lines in place, on a posted
119+
entry too, closed month included, since a flow moves no balance; the lines on the other side of the
120+
entry follow when that side carries one flow. Posted entries accept nothing else and are corrected
121+
via `create-event-block(event_type='journal_entry_reversed')`.
120122
121123
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
122124
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
123125
124126
Args:
125127
graph_id (str):
126128
idempotency_key (None | str | Unset):
127-
body (UpdateJournalEntryRequest): Update a draft journal entry. Posted entries cannot be
128-
updated —
129-
create a reversal and a corrected entry instead.
129+
body (UpdateJournalEntryRequest): Update a draft journal entry, or re-tag any entry's
130+
flows.
131+
132+
Posted entries accept only `line_flows`: a flow moves no balance, so it
133+
changes in place, closed month or not. Anything else on a posted entry is
134+
a reversal and a corrected entry.
130135
131136
Omitted fields are left unchanged. If `line_items` is provided, the
132137
existing line items are replaced entirely (atomic delete + insert)
@@ -163,20 +168,25 @@ def sync(
163168
) -> ErrorResponse | OperationEnvelopeJournalEntryResponse | None:
164169
"""Update Journal Entry
165170
166-
Update a draft journal entry. Posted entries are immutable and must be corrected via `create-event-
167-
block(event_type='journal_entry_reversed')`. If line_items is provided, existing line items are
168-
replaced atomically, the new set must balance, and a line on a retired (`is_active=false`) account
169-
is refused.
171+
Update a draft journal entry, or re-tag any entry's flows. If line_items is provided, existing line
172+
items are replaced atomically, the new set must balance, and a line on a retired (`is_active=false`)
173+
account is refused. `line_flows` sets the cash flow row of the named lines in place, on a posted
174+
entry too, closed month included, since a flow moves no balance; the lines on the other side of the
175+
entry follow when that side carries one flow. Posted entries accept nothing else and are corrected
176+
via `create-event-block(event_type='journal_entry_reversed')`.
170177
171178
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
172179
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
173180
174181
Args:
175182
graph_id (str):
176183
idempotency_key (None | str | Unset):
177-
body (UpdateJournalEntryRequest): Update a draft journal entry. Posted entries cannot be
178-
updated —
179-
create a reversal and a corrected entry instead.
184+
body (UpdateJournalEntryRequest): Update a draft journal entry, or re-tag any entry's
185+
flows.
186+
187+
Posted entries accept only `line_flows`: a flow moves no balance, so it
188+
changes in place, closed month or not. Anything else on a posted entry is
189+
a reversal and a corrected entry.
180190
181191
Omitted fields are left unchanged. If `line_items` is provided, the
182192
existing line items are replaced entirely (atomic delete + insert)
@@ -208,20 +218,25 @@ async def asyncio_detailed(
208218
) -> Response[ErrorResponse | OperationEnvelopeJournalEntryResponse]:
209219
"""Update Journal Entry
210220
211-
Update a draft journal entry. Posted entries are immutable and must be corrected via `create-event-
212-
block(event_type='journal_entry_reversed')`. If line_items is provided, existing line items are
213-
replaced atomically, the new set must balance, and a line on a retired (`is_active=false`) account
214-
is refused.
221+
Update a draft journal entry, or re-tag any entry's flows. If line_items is provided, existing line
222+
items are replaced atomically, the new set must balance, and a line on a retired (`is_active=false`)
223+
account is refused. `line_flows` sets the cash flow row of the named lines in place, on a posted
224+
entry too, closed month included, since a flow moves no balance; the lines on the other side of the
225+
entry follow when that side carries one flow. Posted entries accept nothing else and are corrected
226+
via `create-event-block(event_type='journal_entry_reversed')`.
215227
216228
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
217229
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
218230
219231
Args:
220232
graph_id (str):
221233
idempotency_key (None | str | Unset):
222-
body (UpdateJournalEntryRequest): Update a draft journal entry. Posted entries cannot be
223-
updated —
224-
create a reversal and a corrected entry instead.
234+
body (UpdateJournalEntryRequest): Update a draft journal entry, or re-tag any entry's
235+
flows.
236+
237+
Posted entries accept only `line_flows`: a flow moves no balance, so it
238+
changes in place, closed month or not. Anything else on a posted entry is
239+
a reversal and a corrected entry.
225240
226241
Omitted fields are left unchanged. If `line_items` is provided, the
227242
existing line items are replaced entirely (atomic delete + insert)
@@ -256,20 +271,25 @@ async def asyncio(
256271
) -> ErrorResponse | OperationEnvelopeJournalEntryResponse | None:
257272
"""Update Journal Entry
258273
259-
Update a draft journal entry. Posted entries are immutable and must be corrected via `create-event-
260-
block(event_type='journal_entry_reversed')`. If line_items is provided, existing line items are
261-
replaced atomically, the new set must balance, and a line on a retired (`is_active=false`) account
262-
is refused.
274+
Update a draft journal entry, or re-tag any entry's flows. If line_items is provided, existing line
275+
items are replaced atomically, the new set must balance, and a line on a retired (`is_active=false`)
276+
account is refused. `line_flows` sets the cash flow row of the named lines in place, on a posted
277+
entry too, closed month included, since a flow moves no balance; the lines on the other side of the
278+
entry follow when that side carries one flow. Posted entries accept nothing else and are corrected
279+
via `create-event-block(event_type='journal_entry_reversed')`.
263280
264281
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
265282
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
266283
267284
Args:
268285
graph_id (str):
269286
idempotency_key (None | str | Unset):
270-
body (UpdateJournalEntryRequest): Update a draft journal entry. Posted entries cannot be
271-
updated —
272-
create a reversal and a corrected entry instead.
287+
body (UpdateJournalEntryRequest): Update a draft journal entry, or re-tag any entry's
288+
flows.
289+
290+
Posted entries accept only `line_flows`: a flow moves no balance, so it
291+
changes in place, closed month or not. Anything else on a posted entry is
292+
a reversal and a corrected entry.
273293
274294
Omitted fields are left unchanged. If `line_items` is provided, the
275295
existing line items are replaced entirely (atomic delete + insert)

‎robosystems_client/clients/ledger_client.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,12 @@ def create_journal_entry(
19921992
``entity_id`` names the entity whose books the entry goes into; omitted,
19931993
the group parent's.
19941994
1995+
A line dict may carry ``flow_qname``, the cash flow row its cash belongs
1996+
to (a ``qname`` from ``get_flow_candidates``): only for a loan drawn or
1997+
repaid, capital put in or taken out, an asset bought or sold. A flow on
1998+
one side of the entry tags the untagged lines on the other; one that is
1999+
not a row of the entity's statement is refused.
2000+
19952001
Returns the EventBlockEnvelope (event row fields).
19962002
"""
19972003
metadata: dict[str, Any] = {
@@ -2024,7 +2030,13 @@ def create_journal_entry(
20242030
def update_journal_entry(
20252031
self, graph_id: str, body: dict[str, Any]
20262032
) -> JournalEntryResponse:
2027-
"""Update a draft journal entry. Posted entries are immutable."""
2033+
"""Update a draft journal entry, or re-tag any entry's flows.
2034+
2035+
``line_flows`` (``[{"line_id", "flow_qname"}]``) sets the cash flow row
2036+
of the named lines in place, on a posted entry too, closed month
2037+
included, since a flow moves no balance; the lines on the other side of
2038+
the entry follow. It is the only change a posted entry accepts.
2039+
"""
20282040
request = UpdateJournalEntryRequest.from_dict(body)
20292041
response = op_update_journal_entry(
20302042
graph_id=graph_id, body=request, client=self._get_client()

‎robosystems_client/graphql/generated/list_ledger_journal_entries.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class ListLedgerJournalEntriesJournalEntriesEntriesLineItems(BaseModel):
4747
credit_amount: float = Field(alias="creditAmount")
4848
description: Optional[str]
4949
line_order: int = Field(alias="lineOrder")
50+
flow_qname: Optional[str] = Field(alias="flowQname")
5051

5152

5253
class ListLedgerJournalEntriesJournalEntriesPagination(BaseModel):

‎robosystems_client/graphql/generated/operations.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,7 @@
16591659
creditAmount
16601660
description
16611661
lineOrder
1662+
flowQname
16621663
}
16631664
}
16641665
pagination {

‎robosystems_client/graphql/operations/ledger/ListLedgerJournalEntries.graphql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ query ListLedgerJournalEntries(
2727
totalDebit totalCredit balanced
2828
lineItems {
2929
id accountId accountName accountCode
30-
debitAmount creditAmount description lineOrder
30+
debitAmount creditAmount description lineOrder flowQname
3131
}
3232
}
3333
pagination { total limit offset hasMore }

‎robosystems_client/graphql/schema.graphql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,7 @@ type LedgerLineItem {
22572257
creditAmount: Float!
22582258
description: String
22592259
lineOrder: Int!
2260+
flowQname: String
22602261
}
22612262

22622263
"""

‎robosystems_client/models/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@
375375
from .invoice import Invoice
376376
from .invoice_line_item import InvoiceLineItem
377377
from .invoices_response import InvoicesResponse
378+
from .journal_entry_line_flow import JournalEntryLineFlow
378379
from .journal_entry_line_item_input import JournalEntryLineItemInput
379380
from .journal_entry_line_item_input_metadata_type_0 import (
380381
JournalEntryLineItemInputMetadataType0,
@@ -1460,6 +1461,7 @@
14601461
"Invoice",
14611462
"InvoiceLineItem",
14621463
"InvoicesResponse",
1464+
"JournalEntryLineFlow",
14631465
"JournalEntryLineItemInput",
14641466
"JournalEntryLineItemInputMetadataType0",
14651467
"JournalEntryLineItemResponse",
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
from __future__ import annotations
2+
3+
from collections.abc import Mapping
4+
from typing import Any, TypeVar, cast
5+
6+
from attrs import define as _attrs_define
7+
from attrs import field as _attrs_field
8+
9+
from ..types import UNSET, Unset
10+
11+
T = TypeVar("T", bound="JournalEntryLineFlow")
12+
13+
14+
@_attrs_define
15+
class JournalEntryLineFlow:
16+
"""A line's cash flow row, set in place.
17+
18+
Attributes:
19+
line_id (str): The line to re-tag, by id.
20+
flow_qname (None | str | Unset): The rs-gaap flow qname the line takes; null clears it, back to the account's
21+
default flow.
22+
"""
23+
24+
line_id: str
25+
flow_qname: None | str | Unset = UNSET
26+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
27+
28+
def to_dict(self) -> dict[str, Any]:
29+
line_id = self.line_id
30+
31+
flow_qname: None | str | Unset
32+
if isinstance(self.flow_qname, Unset):
33+
flow_qname = UNSET
34+
else:
35+
flow_qname = self.flow_qname
36+
37+
field_dict: dict[str, Any] = {}
38+
field_dict.update(self.additional_properties)
39+
field_dict.update(
40+
{
41+
"line_id": line_id,
42+
}
43+
)
44+
if flow_qname is not UNSET:
45+
field_dict["flow_qname"] = flow_qname
46+
47+
return field_dict
48+
49+
@classmethod
50+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
51+
d = dict(src_dict)
52+
line_id = d.pop("line_id")
53+
54+
def _parse_flow_qname(data: object) -> None | str | Unset:
55+
if data is None:
56+
return data
57+
if isinstance(data, Unset):
58+
return data
59+
return cast(None | str | Unset, data)
60+
61+
flow_qname = _parse_flow_qname(d.pop("flow_qname", UNSET))
62+
63+
journal_entry_line_flow = cls(
64+
line_id=line_id,
65+
flow_qname=flow_qname,
66+
)
67+
68+
journal_entry_line_flow.additional_properties = d
69+
return journal_entry_line_flow
70+
71+
@property
72+
def additional_keys(self) -> list[str]:
73+
return list(self.additional_properties.keys())
74+
75+
def __getitem__(self, key: str) -> Any:
76+
return self.additional_properties[key]
77+
78+
def __setitem__(self, key: str, value: Any) -> None:
79+
self.additional_properties[key] = value
80+
81+
def __delitem__(self, key: str) -> None:
82+
del self.additional_properties[key]
83+
84+
def __contains__(self, key: str) -> bool:
85+
return key in self.additional_properties

‎robosystems_client/models/journal_entry_line_item_input.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class JournalEntryLineItemInput:
2929
debit_amount (int | Unset): Debit amount in cents. Must be 0 if `credit_amount` > 0. Default: 0.
3030
credit_amount (int | Unset): Credit amount in cents. Must be 0 if `debit_amount` > 0. Default: 0.
3131
description (None | str | Unset): Per-line memo (overrides the entry-level memo on this line).
32+
flow_qname (None | str | Unset): The cash flow row this line's cash belongs to, an rs-gaap flow qname
33+
(`flowCandidates(entityId)` lists the rows this company's statement offers). Only for a loan drawn or repaid,
34+
capital put in or taken out, an asset bought or sold; omitted, the account's default flow applies. A flow set on
35+
one side of the entry tags the untagged lines on the other: the cash flow statement reads the cash line and the
36+
roll-forwards read the account line. Refused when it is not a row of the entity's cash flow statement.
3237
metadata (JournalEntryLineItemInputMetadataType0 | None | Unset): Optional per-line metadata stamped on
3338
`LineItem.metadata_`. Used to carry source-system fields the standard columns don't cover — e.g. an external
3439
flow-tag code that drives rollforward attribution (`transaction_description_code`), an external memo, or a cost-
@@ -40,6 +45,7 @@ class JournalEntryLineItemInput:
4045
debit_amount: int | Unset = 0
4146
credit_amount: int | Unset = 0
4247
description: None | str | Unset = UNSET
48+
flow_qname: None | str | Unset = UNSET
4349
metadata: JournalEntryLineItemInputMetadataType0 | None | Unset = UNSET
4450
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
4551

@@ -60,6 +66,12 @@ def to_dict(self) -> dict[str, Any]:
6066
else:
6167
description = self.description
6268

69+
flow_qname: None | str | Unset
70+
if isinstance(self.flow_qname, Unset):
71+
flow_qname = UNSET
72+
else:
73+
flow_qname = self.flow_qname
74+
6375
metadata: dict[str, Any] | None | Unset
6476
if isinstance(self.metadata, Unset):
6577
metadata = UNSET
@@ -81,6 +93,8 @@ def to_dict(self) -> dict[str, Any]:
8193
field_dict["credit_amount"] = credit_amount
8294
if description is not UNSET:
8395
field_dict["description"] = description
96+
if flow_qname is not UNSET:
97+
field_dict["flow_qname"] = flow_qname
8498
if metadata is not UNSET:
8599
field_dict["metadata"] = metadata
86100

@@ -108,6 +122,15 @@ def _parse_description(data: object) -> None | str | Unset:
108122

109123
description = _parse_description(d.pop("description", UNSET))
110124

125+
def _parse_flow_qname(data: object) -> None | str | Unset:
126+
if data is None:
127+
return data
128+
if isinstance(data, Unset):
129+
return data
130+
return cast(None | str | Unset, data)
131+
132+
flow_qname = _parse_flow_qname(d.pop("flow_qname", UNSET))
133+
111134
def _parse_metadata(
112135
data: object,
113136
) -> JournalEntryLineItemInputMetadataType0 | None | Unset:
@@ -132,6 +155,7 @@ def _parse_metadata(
132155
debit_amount=debit_amount,
133156
credit_amount=credit_amount,
134157
description=description,
158+
flow_qname=flow_qname,
135159
metadata=metadata,
136160
)
137161

0 commit comments

Comments
 (0)