Skip to content

Commit f3d1f42

Browse files
authored
feat(ledger): list_unmapped_elements names the concept a contra nets against (#316)
## Summary `LedgerClient.list_unmapped_elements` now returns `nets_against` on each unmapped element. For a contra-asset account (accumulated amortization, an allowance), it names the reporting concept the gross sibling under the same parent already maps to, which is the concept the contra should map to. It is absent when the parent has no such sibling, has more than one, or the sibling is not yet mapped. The field comes from robosystems#2141, released in robosystems **v1.24.6**. The query selects it, so `list_unmapped_elements` needs a server on v1.24.6 or later. TypeScript twin: RoboFinSystems/robosystems-typescript-client#337. ## Changes - **Operation** (`graphql/operations/ledger/ListLedgerUnmappedElements.graphql`): selects `netsAgainst { elementId qname name confidence }`. - **Schema** (`graphql/schema.graphql`): refreshed from the API. The only drift is the new `UnmappedElement.netsAgainst: SuggestedTarget` field, nullable. Regenerating the OpenAPI produced no change. - **Generated models** (`graphql/generated/`): regenerated. Net effect: `ListLedgerUnmappedElementsUnmappedElements.nets_against` (optional) and the new `ListLedgerUnmappedElementsUnmappedElementsNetsAgainst` model, exported from `graphql.generated`. - **Tests** (`tests/test_ledger_client.py`): the existing test asserts `nets_against is None` for an ordinary account; a new test reads the concept for a contra. ## Compatibility ADDITIVE: a new optional field on a generated model, plus a new generated model export. No facade signature changes. The facade query selects a field that servers before robosystems v1.24.6 do not have, so `list_unmapped_elements` fails schema validation against an older server. The v1.24.6 production deploy is in progress. ## Testing - `just generate-sdk` against the local stack, current with robosystems `main` at v1.24.6, then `just generate-graphql`. - `just test-all`: 761 passed, 17 skipped; format, lint and typecheck clean. - Not run against a live API. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents d7b7fbe + 0386f3a commit f3d1f42

6 files changed

Lines changed: 54 additions & 0 deletions

File tree

‎robosystems_client/graphql/generated/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@
401401
from .list_ledger_unmapped_elements import (
402402
ListLedgerUnmappedElements,
403403
ListLedgerUnmappedElementsUnmappedElements,
404+
ListLedgerUnmappedElementsUnmappedElementsNetsAgainst,
404405
ListLedgerUnmappedElementsUnmappedElementsSuggestedTargets,
405406
)
406407
from .list_library_elements import (
@@ -872,6 +873,7 @@
872873
"ListLedgerTransactionsTransactionsTransactions",
873874
"ListLedgerUnmappedElements",
874875
"ListLedgerUnmappedElementsUnmappedElements",
876+
"ListLedgerUnmappedElementsUnmappedElementsNetsAgainst",
875877
"ListLedgerUnmappedElementsUnmappedElementsSuggestedTargets",
876878
"ListLibraryElements",
877879
"ListLibraryElementsLibraryElements",

‎robosystems_client/graphql/generated/list_ledger_unmapped_elements.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ListLedgerUnmappedElementsUnmappedElements(BaseModel):
2121
suggested_targets: list[
2222
"ListLedgerUnmappedElementsUnmappedElementsSuggestedTargets"
2323
] = Field(alias="suggestedTargets")
24+
nets_against: Optional["ListLedgerUnmappedElementsUnmappedElementsNetsAgainst"] = (
25+
Field(alias="netsAgainst")
26+
)
2427

2528

2629
class ListLedgerUnmappedElementsUnmappedElementsSuggestedTargets(BaseModel):
@@ -30,5 +33,12 @@ class ListLedgerUnmappedElementsUnmappedElementsSuggestedTargets(BaseModel):
3033
confidence: Optional[float]
3134

3235

36+
class ListLedgerUnmappedElementsUnmappedElementsNetsAgainst(BaseModel):
37+
element_id: str = Field(alias="elementId")
38+
qname: str
39+
name: str
40+
confidence: Optional[float]
41+
42+
3343
ListLedgerUnmappedElements.model_rebuild()
3444
ListLedgerUnmappedElementsUnmappedElements.model_rebuild()

‎robosystems_client/graphql/generated/operations.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,6 +2460,12 @@
24602460
name
24612461
confidence
24622462
}
2463+
netsAgainst {
2464+
elementId
2465+
qname
2466+
name
2467+
confidence
2468+
}
24632469
}
24642470
}
24652471
"""

‎robosystems_client/graphql/operations/ledger/ListLedgerUnmappedElements.graphql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ query ListLedgerUnmappedElements($mappingId: String) {
22
unmappedElements(mappingId: $mappingId) {
33
id code name trait balanceType externalSource
44
suggestedTargets { elementId qname name confidence }
5+
netsAgainst { elementId qname name confidence }
56
}
67
}

‎robosystems_client/graphql/schema.graphql‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3238,6 +3238,11 @@ type UnmappedElement {
32383238
balanceType: String!
32393239
externalSource: String
32403240
suggestedTargets: [SuggestedTarget!]!
3241+
3242+
"""
3243+
For a contra-asset account: the reporting concept its gross sibling maps to, the one asset account under the same parent, already mapped. A contra nets against the balance it reduces, so it maps to the same concept. Absent when the parent has no such sibling, more than one, or one not yet mapped.
3244+
"""
3245+
netsAgainst: SuggestedTarget
32413246
}
32423247

32433248
"""A suggested mapping target from the reporting taxonomy."""

‎tests/test_ledger_client.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ def test_list_unmapped_elements(self, mock_execute, mock_config, graph_id):
18981898
"confidence": 0.9,
18991899
}
19001900
],
1901+
"netsAgainst": None,
19011902
}
19021903
]
19031904
}
@@ -1906,9 +1907,38 @@ def test_list_unmapped_elements(self, mock_execute, mock_config, graph_id):
19061907
assert len(result) == 1
19071908
assert result[0].code == "4500"
19081909
assert result[0].suggested_targets[0].confidence == 0.9
1910+
assert result[0].nets_against is None
19091911
variables = mock_execute.call_args[0][2]
19101912
assert variables["mappingId"] == "map_1"
19111913

1914+
@patch("robosystems_client.graphql.client.GraphQLClient.execute")
1915+
def test_list_unmapped_elements_names_the_concept_a_contra_nets_against(
1916+
self, mock_execute, mock_config, graph_id
1917+
):
1918+
mock_execute.return_value = {
1919+
"unmappedElements": [
1920+
{
1921+
"id": "elem_3",
1922+
"code": "1420",
1923+
"name": "Accumulated Amortization",
1924+
"trait": "contraAsset",
1925+
"balanceType": "credit",
1926+
"externalSource": "qb",
1927+
"suggestedTargets": [],
1928+
"netsAgainst": {
1929+
"elementId": "elem_intangibles",
1930+
"qname": "rs-gaap:IntangibleAssetsNetExcludingGoodwill",
1931+
"name": "Intangible Assets, Net (Excluding Goodwill)",
1932+
"confidence": None,
1933+
},
1934+
}
1935+
]
1936+
}
1937+
client = LedgerClient(mock_config)
1938+
(contra,) = client.list_unmapped_elements(graph_id)
1939+
assert contra.nets_against is not None
1940+
assert contra.nets_against.qname == "rs-gaap:IntangibleAssetsNetExcludingGoodwill"
1941+
19121942
@patch("robosystems_client.graphql.client.GraphQLClient.execute")
19131943
def test_list_structures(self, mock_execute, mock_config, graph_id):
19141944
mock_execute.return_value = {

0 commit comments

Comments
 (0)