Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion robosystems_client/clients/ledger_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,11 @@ def list_structures(
return page.structures if page else []

def list_mappings(self, graph_id: str) -> list[ListLedgerMappingsMappingsStructures]:
"""List active CoA→reporting mapping structures."""
"""List active CoA→reporting mapping structures, the book mapping first.

Each carries ``framework``: the reporting framework it maps the chart
into. A chart holds one mapping per framework.
"""
data = self._query(graph_id, LIST_LEDGER_MAPPINGS_GQL)
page = ListLedgerMappings.model_validate(data).mappings
return page.structures if page else []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ListLedgerMappingsMappingsStructures(BaseModel):
block_type: str = Field(alias="blockType")
taxonomy_id: str = Field(alias="taxonomyId")
is_active: bool = Field(alias="isActive")
framework: Optional[str]


ListLedgerMappings.model_rebuild()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ListLedgerStructuresStructuresStructures(BaseModel):
block_type: str = Field(alias="blockType")
taxonomy_id: str = Field(alias="taxonomyId")
is_active: bool = Field(alias="isActive")
framework: Optional[str]


ListLedgerStructures.model_rebuild()
Expand Down
2 changes: 2 additions & 0 deletions robosystems_client/graphql/generated/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@
blockType
taxonomyId
isActive
framework
}
}
}
Expand Down Expand Up @@ -1637,6 +1638,7 @@
blockType
taxonomyId
isActive
framework
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
query ListLedgerMappings {
mappings {
structures {
id name description blockType taxonomyId isActive
id name description blockType taxonomyId isActive framework
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
query ListLedgerStructures($taxonomyId: String, $blockType: String) {
structures(taxonomyId: $taxonomyId, blockType: $blockType) {
structures {
id name description blockType taxonomyId isActive
id name description blockType taxonomyId isActive framework
}
}
}
5 changes: 5 additions & 0 deletions robosystems_client/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,11 @@ type Structure {
blockType: String!
taxonomyId: String!
isActive: Boolean!

"""
`coa_mapping` only: the reporting framework the mapping maps the chart into (e.g. `rs-gaap`). A chart holds one mapping per framework.
"""
framework: String
}

"""A mapping structure with all its associations."""
Expand Down
20 changes: 20 additions & 0 deletions robosystems_client/models/taxonomy_block_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class TaxonomyBlockStructure:
block_type (str):
description (None | str | Unset):
role_uri (None | str | Unset):
target_framework (None | str | Unset): `coa_mapping` only: the framework the mapping maps into.
"""

id: str
name: str
block_type: str
description: None | str | Unset = UNSET
role_uri: None | str | Unset = UNSET
target_framework: None | str | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
Expand All @@ -49,6 +51,12 @@ def to_dict(self) -> dict[str, Any]:
else:
role_uri = self.role_uri

target_framework: None | str | Unset
if isinstance(self.target_framework, Unset):
target_framework = UNSET
else:
target_framework = self.target_framework

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
Expand All @@ -62,6 +70,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["description"] = description
if role_uri is not UNSET:
field_dict["role_uri"] = role_uri
if target_framework is not UNSET:
field_dict["target_framework"] = target_framework

return field_dict

Expand Down Expand Up @@ -92,12 +102,22 @@ def _parse_role_uri(data: object) -> None | str | Unset:

role_uri = _parse_role_uri(d.pop("role_uri", UNSET))

def _parse_target_framework(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)

target_framework = _parse_target_framework(d.pop("target_framework", UNSET))

taxonomy_block_structure = cls(
id=id,
name=name,
block_type=block_type,
description=description,
role_uri=role_uri,
target_framework=target_framework,
)

taxonomy_block_structure.additional_properties = d
Expand Down
21 changes: 21 additions & 0 deletions robosystems_client/models/taxonomy_block_structure_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class TaxonomyBlockStructureRequest:
vocabulary). A disclosure note footing members to a total is `roll_up`. Null leaves the pattern unset.
description (None | str | Unset):
role_uri (None | str | Unset):
target_framework (None | str | Unset): `coa_mapping` only: the framework this mapping maps the chart into, e.g.
`rs-gaap`. Omitted means the graph's book framework. A chart holds one mapping per framework.
metadata (TaxonomyBlockStructureRequestMetadata | Unset):
"""

Expand All @@ -47,6 +49,7 @@ class TaxonomyBlockStructureRequest:
) = UNSET
description: None | str | Unset = UNSET
role_uri: None | str | Unset = UNSET
target_framework: None | str | Unset = UNSET
metadata: TaxonomyBlockStructureRequestMetadata | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

Expand Down Expand Up @@ -77,6 +80,12 @@ def to_dict(self) -> dict[str, Any]:
else:
role_uri = self.role_uri

target_framework: None | str | Unset
if isinstance(self.target_framework, Unset):
target_framework = UNSET
else:
target_framework = self.target_framework

metadata: dict[str, Any] | Unset = UNSET
if not isinstance(self.metadata, Unset):
metadata = self.metadata.to_dict()
Expand All @@ -95,6 +104,8 @@ def to_dict(self) -> dict[str, Any]:
field_dict["description"] = description
if role_uri is not UNSET:
field_dict["role_uri"] = role_uri
if target_framework is not UNSET:
field_dict["target_framework"] = target_framework
if metadata is not UNSET:
field_dict["metadata"] = metadata

Expand Down Expand Up @@ -154,6 +165,15 @@ def _parse_role_uri(data: object) -> None | str | Unset:

role_uri = _parse_role_uri(d.pop("role_uri", UNSET))

def _parse_target_framework(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)

target_framework = _parse_target_framework(d.pop("target_framework", UNSET))

_metadata = d.pop("metadata", UNSET)
metadata: TaxonomyBlockStructureRequestMetadata | Unset
if isinstance(_metadata, Unset):
Expand All @@ -167,6 +187,7 @@ def _parse_role_uri(data: object) -> None | str | Unset:
concept_arrangement=concept_arrangement,
description=description,
role_uri=role_uri,
target_framework=target_framework,
metadata=metadata,
)

Expand Down
5 changes: 4 additions & 1 deletion tests/test_ledger_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ def test_list_mappings_unwraps_structures(self, mock_execute, mock_config, graph
"name": "CoA → GAAP",
"description": None,
"blockType": "coa_mapping",
"taxonomyId": "tax_usgaap",
"taxonomyId": "tax_map_gaap",
"isActive": True,
"framework": "rs-gaap",
}
]
}
Expand All @@ -265,6 +266,7 @@ def test_list_mappings_unwraps_structures(self, mock_execute, mock_config, graph
mappings = client.list_mappings(graph_id)
assert len(mappings) == 1
assert mappings[0].block_type == "coa_mapping"
assert mappings[0].framework == "rs-gaap"

@patch("robosystems_client.graphql.client.GraphQLClient.execute")
def test_get_fiscal_calendar(self, mock_execute, mock_config, graph_id):
Expand Down Expand Up @@ -1272,6 +1274,7 @@ def test_list_structures(self, mock_execute, mock_config, graph_id):
"blockType": "income_statement",
"taxonomyId": "tax_usgaap",
"isActive": True,
"framework": None,
}
]
}
Expand Down
Loading