Source code for sdk.lusid.models.fund_cash_statement_row

# coding: utf-8

"""
    LUSID API

    FINBOURNE Technology  # noqa: E501

    Contact: info@finbourne.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import List, Dict, Optional, Any, Union, TYPE_CHECKING
from typing_extensions import Annotated
from pydantic.v1 import BaseModel, StrictStr, StrictInt, StrictBool, StrictFloat, StrictBytes, Field, validator, ValidationError, conlist, constr
from datetime import datetime
from lusid.models.currency_and_amount import CurrencyAndAmount
from lusid.models.link import Link
from lusid.models.model_property import ModelProperty
from lusid.models.perpetual_property import PerpetualProperty
from lusid.models.resource_id import ResourceId

[docs] class FundCashStatementRow(BaseModel): """ A single row in a Fund Cash Statement report. Each row represents a settled cash movement with running balance, cost basis, average rate, and realised FX PnL. # noqa: E501 """ group_by_id: Optional[StrictInt] = Field(default=None, description="The groupBy subHoldings and currency.", alias="groupById") sequence_number: Optional[StrictInt] = Field(default=None, description="Sequence number determining the order of the cash flow records.", alias="sequenceNumber") sub_holding_keys: Optional[Dict[str, PerpetualProperty]] = Field(default=None, description="The sub-holding properties which identify the holding. Each property will be from the 'Transaction' domain. These are configured on a transaction portfolio.", alias="subHoldingKeys") source_id: Optional[StrictStr] = Field(None,alias="sourceId", description="The transaction ID that sourced this cash movement.") cash_statement_action_type: Optional[StrictStr] = Field(None,alias="cashStatementActionType", description="The action type: Default, Reversal, TrueUp, AvgRateCorrection, Opening, or Closing.") accounting_date: Optional[datetime] = Field(default=None, description="The accounting date of the cash movement.", alias="accountingDate") activity_date: Optional[datetime] = Field(default=None, description="The activity date (trade/settlement date) of the cash movement.", alias="activityDate") movement_name: Optional[StrictStr] = Field(None,alias="movementName", description="The movement type (e.g. Receivable_Cash_Trade, Payable_Cash_Trade).") portfolio_id: Optional[ResourceId] = Field(default=None, alias="portfolioId") instruction_type: Optional[StrictStr] = Field(None,alias="instructionType", description="The settlement instruction type: Automatic, Instructed_Complete, Instructed - Cancel Automatic.") diary_entry_code: Optional[StrictStr] = Field(None,alias="diaryEntryCode", description="The diary entry code of the valuation point this row belongs to.") origin_diary_entry_code: Optional[StrictStr] = Field(None,alias="originDiaryEntryCode", description="For Reversal/TrueUp rows: the diary entry code of the period the original row belonged to.") cashflow_local: Optional[CurrencyAndAmount] = Field(default=None, alias="cashflowLocal") balance_local: Optional[CurrencyAndAmount] = Field(default=None, alias="balanceLocal") cashflow_base: Optional[CurrencyAndAmount] = Field(default=None, alias="cashflowBase") realised_fx_pnl: Optional[CurrencyAndAmount] = Field(default=None, alias="realisedFxPnl") cost_basis_base: Optional[CurrencyAndAmount] = Field(default=None, alias="costBasisBase") avg_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weighted average FX rate (costBasisBase / balanceLocal). Null when balance is zero.", alias="avgRate") fx_rate_movement: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="FX rate for this specific movement (CashflowBase / CashFlowLocal). Null when localAmount is zero.", alias="fxRateMovement") properties: Optional[Dict[str, ModelProperty]] = Field(default=None, description="The requested properties decorated onto the cash statement row.") links: Optional[List[Link]] = None __properties = ["groupById", "sequenceNumber", "subHoldingKeys", "sourceId", "cashStatementActionType", "accountingDate", "activityDate", "movementName", "portfolioId", "instructionType", "diaryEntryCode", "originDiaryEntryCode", "cashflowLocal", "balanceLocal", "cashflowBase", "realisedFxPnl", "costBasisBase", "avgRate", "fxRateMovement", "properties", "links"]
[docs] class Config: """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True
def __str__(self): """For `print` and `pprint`""" return pprint.pformat(self.dict(by_alias=False)) def __repr__(self): """For `print` and `pprint`""" return self.to_str()
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.dict(by_alias=True))
[docs] def to_json(self) -> str: """Returns the JSON representation of the model using alias""" return json.dumps(self.to_dict())
[docs] @classmethod def from_json(cls, json_str: str) -> FundCashStatementRow: """Create an instance of FundCashStatementRow from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] def to_dict(self): """Returns the dictionary representation of the model using alias""" _dict = self.dict(by_alias=True, exclude={ }, exclude_none=True) # override the default output from pydantic by calling `to_dict()` of each value in sub_holding_keys (dict) _field_dict = {} if self.sub_holding_keys: for _key in self.sub_holding_keys: if self.sub_holding_keys[_key]: _field_dict[_key] = self.sub_holding_keys[_key].to_dict() _dict['subHoldingKeys'] = _field_dict # override the default output from pydantic by calling `to_dict()` of portfolio_id if self.portfolio_id: _dict['portfolioId'] = self.portfolio_id.to_dict() # override the default output from pydantic by calling `to_dict()` of cashflow_local if self.cashflow_local: _dict['cashflowLocal'] = self.cashflow_local.to_dict() # override the default output from pydantic by calling `to_dict()` of balance_local if self.balance_local: _dict['balanceLocal'] = self.balance_local.to_dict() # override the default output from pydantic by calling `to_dict()` of cashflow_base if self.cashflow_base: _dict['cashflowBase'] = self.cashflow_base.to_dict() # override the default output from pydantic by calling `to_dict()` of realised_fx_pnl if self.realised_fx_pnl: _dict['realisedFxPnl'] = self.realised_fx_pnl.to_dict() # override the default output from pydantic by calling `to_dict()` of cost_basis_base if self.cost_basis_base: _dict['costBasisBase'] = self.cost_basis_base.to_dict() # override the default output from pydantic by calling `to_dict()` of each value in properties (dict) _field_dict = {} if self.properties: for _key in self.properties: if self.properties[_key]: _field_dict[_key] = self.properties[_key].to_dict() _dict['properties'] = _field_dict # override the default output from pydantic by calling `to_dict()` of each item in links (list) _items = [] if self.links: for _item in self.links: if _item: _items.append(_item.to_dict()) _dict['links'] = _items # set to None if sub_holding_keys (nullable) is None # and __fields_set__ contains the field if self.sub_holding_keys is None and "sub_holding_keys" in self.__fields_set__: _dict['subHoldingKeys'] = None # set to None if source_id (nullable) is None # and __fields_set__ contains the field if self.source_id is None and "source_id" in self.__fields_set__: _dict['sourceId'] = None # set to None if cash_statement_action_type (nullable) is None # and __fields_set__ contains the field if self.cash_statement_action_type is None and "cash_statement_action_type" in self.__fields_set__: _dict['cashStatementActionType'] = None # set to None if movement_name (nullable) is None # and __fields_set__ contains the field if self.movement_name is None and "movement_name" in self.__fields_set__: _dict['movementName'] = None # set to None if instruction_type (nullable) is None # and __fields_set__ contains the field if self.instruction_type is None and "instruction_type" in self.__fields_set__: _dict['instructionType'] = None # set to None if diary_entry_code (nullable) is None # and __fields_set__ contains the field if self.diary_entry_code is None and "diary_entry_code" in self.__fields_set__: _dict['diaryEntryCode'] = None # set to None if origin_diary_entry_code (nullable) is None # and __fields_set__ contains the field if self.origin_diary_entry_code is None and "origin_diary_entry_code" in self.__fields_set__: _dict['originDiaryEntryCode'] = None # set to None if avg_rate (nullable) is None # and __fields_set__ contains the field if self.avg_rate is None and "avg_rate" in self.__fields_set__: _dict['avgRate'] = None # set to None if fx_rate_movement (nullable) is None # and __fields_set__ contains the field if self.fx_rate_movement is None and "fx_rate_movement" in self.__fields_set__: _dict['fxRateMovement'] = None # set to None if properties (nullable) is None # and __fields_set__ contains the field if self.properties is None and "properties" in self.__fields_set__: _dict['properties'] = None # set to None if links (nullable) is None # and __fields_set__ contains the field if self.links is None and "links" in self.__fields_set__: _dict['links'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> FundCashStatementRow: """Create an instance of FundCashStatementRow from a dict""" if obj is None: return None if not isinstance(obj, dict): return FundCashStatementRow.parse_obj(obj) _obj = FundCashStatementRow.parse_obj({ "group_by_id": obj.get("groupById"), "sequence_number": obj.get("sequenceNumber"), "sub_holding_keys": dict( (_k, PerpetualProperty.from_dict(_v)) for _k, _v in obj.get("subHoldingKeys").items() ) if obj.get("subHoldingKeys") is not None else None, "source_id": obj.get("sourceId"), "cash_statement_action_type": obj.get("cashStatementActionType"), "accounting_date": obj.get("accountingDate"), "activity_date": obj.get("activityDate"), "movement_name": obj.get("movementName"), "portfolio_id": ResourceId.from_dict(obj.get("portfolioId")) if obj.get("portfolioId") is not None else None, "instruction_type": obj.get("instructionType"), "diary_entry_code": obj.get("diaryEntryCode"), "origin_diary_entry_code": obj.get("originDiaryEntryCode"), "cashflow_local": CurrencyAndAmount.from_dict(obj.get("cashflowLocal")) if obj.get("cashflowLocal") is not None else None, "balance_local": CurrencyAndAmount.from_dict(obj.get("balanceLocal")) if obj.get("balanceLocal") is not None else None, "cashflow_base": CurrencyAndAmount.from_dict(obj.get("cashflowBase")) if obj.get("cashflowBase") is not None else None, "realised_fx_pnl": CurrencyAndAmount.from_dict(obj.get("realisedFxPnl")) if obj.get("realisedFxPnl") is not None else None, "cost_basis_base": CurrencyAndAmount.from_dict(obj.get("costBasisBase")) if obj.get("costBasisBase") is not None else None, "avg_rate": obj.get("avgRate"), "fx_rate_movement": obj.get("fxRateMovement"), "properties": dict( (_k, ModelProperty.from_dict(_v)) for _k, _v in obj.get("properties").items() ) if obj.get("properties") is not None else None, "links": [Link.from_dict(_item) for _item in obj.get("links")] if obj.get("links") is not None else None }) return _obj
FundCashStatementRow.update_forward_refs()