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
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error_response import ErrorResponse
from ...models.operation_envelope_deconsolidation_response import (
OperationEnvelopeDeconsolidationResponse,
)
from ...models.record_deconsolidation_request import RecordDeconsolidationRequest
from ...types import UNSET, Response, Unset


def _get_kwargs(
graph_id: str,
*,
body: RecordDeconsolidationRequest,
idempotency_key: None | str | Unset = UNSET,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
if not isinstance(idempotency_key, Unset):
headers["Idempotency-Key"] = idempotency_key

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/extensions/roboledger/{graph_id}/operations/record-deconsolidation".format(
graph_id=quote(str(graph_id), safe=""),
),
}

_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | OperationEnvelopeDeconsolidationResponse | None:
if response.status_code == 200:
response_200 = OperationEnvelopeDeconsolidationResponse.from_dict(response.json())

return response_200

if response.status_code == 400:
response_400 = ErrorResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = ErrorResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = ErrorResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = ErrorResponse.from_dict(response.json())

return response_404

if response.status_code == 409:
response_409 = ErrorResponse.from_dict(response.json())

return response_409

if response.status_code == 422:
response_422 = ErrorResponse.from_dict(response.json())

return response_422

if response.status_code == 429:
response_429 = ErrorResponse.from_dict(response.json())

return response_429

if response.status_code == 500:
response_500 = ErrorResponse.from_dict(response.json())

return response_500

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[ErrorResponse | OperationEnvelopeDeconsolidationResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: RecordDeconsolidationRequest,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelopeDeconsolidationResponse]:
"""Record Deconsolidation

Record a member's leaving the group, once `left_on` is set on it: what the parent received for its
shares in cents (0 for a dissolution) and the basis. It writes a draft in the consolidation entity,
dated the first day of the month after the member's last, that its close posts: what the
consolidation entity still holds for the member on its balance-sheet accounts and as the outside
owners' interest is taken off (goodwill, step-ups, the price above book of the investment, the
outside owners' accumulated share), a member in full has the results it earned in the group put back
into the group's equity as they leave with its books, and the difference is the gain or loss on its
leaving: the group's adjustment to the gain the parent's own books took, so the consolidated gain is
the consideration less the carrying amount of what left (ASC 810). The investment and intercompany
eliminations go back on their own in that month's proposals. The parent's own sale entry stays on
its books. Recording again replaces the draft; a posted deconsolidation is reversed first. A
retained interest is not supported yet.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (RecordDeconsolidationRequest): A member has left the group (`left_on` set): what the
parent received
for its shares, and the basis. The entry derecognizes what the
consolidation entity still holds for the member and takes the gain or
loss on its leaving; the parent's own sale entry stays on its books.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | OperationEnvelopeDeconsolidationResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
idempotency_key=idempotency_key,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
body: RecordDeconsolidationRequest,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelopeDeconsolidationResponse | None:
"""Record Deconsolidation

Record a member's leaving the group, once `left_on` is set on it: what the parent received for its
shares in cents (0 for a dissolution) and the basis. It writes a draft in the consolidation entity,
dated the first day of the month after the member's last, that its close posts: what the
consolidation entity still holds for the member on its balance-sheet accounts and as the outside
owners' interest is taken off (goodwill, step-ups, the price above book of the investment, the
outside owners' accumulated share), a member in full has the results it earned in the group put back
into the group's equity as they leave with its books, and the difference is the gain or loss on its
leaving: the group's adjustment to the gain the parent's own books took, so the consolidated gain is
the consideration less the carrying amount of what left (ASC 810). The investment and intercompany
eliminations go back on their own in that month's proposals. The parent's own sale entry stays on
its books. Recording again replaces the draft; a posted deconsolidation is reversed first. A
retained interest is not supported yet.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (RecordDeconsolidationRequest): A member has left the group (`left_on` set): what the
parent received
for its shares, and the basis. The entry derecognizes what the
consolidation entity still holds for the member and takes the gain or
loss on its leaving; the parent's own sale entry stays on its books.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | OperationEnvelopeDeconsolidationResponse
"""

return sync_detailed(
graph_id=graph_id,
client=client,
body=body,
idempotency_key=idempotency_key,
).parsed


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: RecordDeconsolidationRequest,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelopeDeconsolidationResponse]:
"""Record Deconsolidation

Record a member's leaving the group, once `left_on` is set on it: what the parent received for its
shares in cents (0 for a dissolution) and the basis. It writes a draft in the consolidation entity,
dated the first day of the month after the member's last, that its close posts: what the
consolidation entity still holds for the member on its balance-sheet accounts and as the outside
owners' interest is taken off (goodwill, step-ups, the price above book of the investment, the
outside owners' accumulated share), a member in full has the results it earned in the group put back
into the group's equity as they leave with its books, and the difference is the gain or loss on its
leaving: the group's adjustment to the gain the parent's own books took, so the consolidated gain is
the consideration less the carrying amount of what left (ASC 810). The investment and intercompany
eliminations go back on their own in that month's proposals. The parent's own sale entry stays on
its books. Recording again replaces the draft; a posted deconsolidation is reversed first. A
retained interest is not supported yet.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (RecordDeconsolidationRequest): A member has left the group (`left_on` set): what the
parent received
for its shares, and the basis. The entry derecognizes what the
consolidation entity still holds for the member and takes the gain or
loss on its leaving; the parent's own sale entry stays on its books.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | OperationEnvelopeDeconsolidationResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
idempotency_key=idempotency_key,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
body: RecordDeconsolidationRequest,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelopeDeconsolidationResponse | None:
"""Record Deconsolidation

Record a member's leaving the group, once `left_on` is set on it: what the parent received for its
shares in cents (0 for a dissolution) and the basis. It writes a draft in the consolidation entity,
dated the first day of the month after the member's last, that its close posts: what the
consolidation entity still holds for the member on its balance-sheet accounts and as the outside
owners' interest is taken off (goodwill, step-ups, the price above book of the investment, the
outside owners' accumulated share), a member in full has the results it earned in the group put back
into the group's equity as they leave with its books, and the difference is the gain or loss on its
leaving: the group's adjustment to the gain the parent's own books took, so the consolidated gain is
the consideration less the carrying amount of what left (ASC 810). The investment and intercompany
eliminations go back on their own in that month's proposals. The parent's own sale entry stays on
its books. Recording again replaces the draft; a posted deconsolidation is reversed first. A
retained interest is not supported yet.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (RecordDeconsolidationRequest): A member has left the group (`left_on` set): what the
parent received
for its shares, and the basis. The entry derecognizes what the
consolidation entity still holds for the member and takes the gain or
loss on its leaving; the parent's own sale entry stays on its books.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | OperationEnvelopeDeconsolidationResponse
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
body=body,
idempotency_key=idempotency_key,
)
).parsed
5 changes: 5 additions & 0 deletions robosystems_client/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,11 @@ type LedgerEntity {
"""
leftOn: Date

"""
True once the month this entity left the group is over: its months in the group are history, readable under it, and it is no longer current. False for a member still in, and through the month it leaves.
"""
isFormer: Boolean!

"""Provenance: 'native' | 'sec' | 'quickbooks' | 'xero' | 'plaid'."""
source: String!

Expand Down
14 changes: 14 additions & 0 deletions robosystems_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
from .database_health_response import DatabaseHealthResponse
from .database_info_response import DatabaseInfoResponse
from .database_storage_entry import DatabaseStorageEntry
from .deconsolidation_response import DeconsolidationResponse
from .delete_connection_disposition import DeleteConnectionDisposition
from .delete_document_op import DeleteDocumentOp
from .delete_file_op import DeleteFileOp
Expand All @@ -202,6 +203,7 @@
from .delete_subgraph_op import DeleteSubgraphOp
from .delete_taxonomy_block_request import DeleteTaxonomyBlockRequest
from .delete_taxonomy_block_response import DeleteTaxonomyBlockResponse
from .derecognized_balance import DerecognizedBalance
from .describe_filing_request import DescribeFilingRequest
from .describe_filing_response import DescribeFilingResponse
from .describe_filing_response_counts_type_0 import DescribeFilingResponseCountsType0
Expand Down Expand Up @@ -552,6 +554,12 @@
from .operation_envelope_consolidation_worksheet_response_status import (
OperationEnvelopeConsolidationWorksheetResponseStatus,
)
from .operation_envelope_deconsolidation_response import (
OperationEnvelopeDeconsolidationResponse,
)
from .operation_envelope_deconsolidation_response_status import (
OperationEnvelopeDeconsolidationResponseStatus,
)
from .operation_envelope_delete_information_block_response import (
OperationEnvelopeDeleteInformationBlockResponse,
)
Expand Down Expand Up @@ -961,6 +969,7 @@
)
from .reconciling_item_regenerated import ReconcilingItemRegenerated
from .record_acquisition_request import RecordAcquisitionRequest
from .record_deconsolidation_request import RecordDeconsolidationRequest
from .record_opening_balance_request import RecordOpeningBalanceRequest
from .record_ownership_change_request import RecordOwnershipChangeRequest
from .record_statement_balance_request import RecordStatementBalanceRequest
Expand Down Expand Up @@ -1388,6 +1397,7 @@
"DatabaseHealthResponse",
"DatabaseInfoResponse",
"DatabaseStorageEntry",
"DeconsolidationResponse",
"DeleteConnectionDisposition",
"DeleteDocumentOp",
"DeleteFileOp",
Expand All @@ -1411,6 +1421,7 @@
"DeleteSubgraphOp",
"DeleteTaxonomyBlockRequest",
"DeleteTaxonomyBlockResponse",
"DerecognizedBalance",
"DescribeFilingRequest",
"DescribeFilingResponse",
"DescribeFilingResponseCountsType0",
Expand Down Expand Up @@ -1647,6 +1658,8 @@
"OperationEnvelopeComputeMetricsResponseStatus",
"OperationEnvelopeConsolidationWorksheetResponse",
"OperationEnvelopeConsolidationWorksheetResponseStatus",
"OperationEnvelopeDeconsolidationResponse",
"OperationEnvelopeDeconsolidationResponseStatus",
"OperationEnvelopeDeleteInformationBlockResponse",
"OperationEnvelopeDeleteInformationBlockResponseStatus",
"OperationEnvelopeDeletePortfolioBlockResponse",
Expand Down Expand Up @@ -1858,6 +1871,7 @@
"ReconcilingItemPlanDefaultDisposition",
"ReconcilingItemRegenerated",
"RecordAcquisitionRequest",
"RecordDeconsolidationRequest",
"RecordOpeningBalanceRequest",
"RecordOwnershipChangeRequest",
"RecordStatementBalanceRequest",
Expand Down
Loading
Loading