# 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.output_transaction import OutputTransaction
from lusid.models.resource_id import ResourceId
from lusid.models.transaction_settlement_instruction import TransactionSettlementInstruction
[docs]
class SettlementActivity(BaseModel):
"""
SettlementActivity
"""
activity_id: StrictStr = Field(...,alias="activityId", description="A unique identifier for the settlement activity row, composed from the portfolio, activity type and the underlying transaction or settlement instruction.")
portfolio_id: ResourceId = Field(alias="portfolioId")
activity_type: StrictStr = Field(...,alias="activityType", description="The type of settlement activity: Expected for outstanding units that are due or overdue, or Settled for units that have settled. Available values: Expected, Settled.")
activity_basis: StrictStr = Field(...,alias="activityBasis", description="The basis on which the settlement activity arose: Inferred for outstanding units, Automatic for units settled per the portfolio's settlement configuration, or Instruction for units settled by a settlement instruction. Available values: Inferred, Automatic, Instruction.")
activity_date: datetime = Field(description="The date of the settlement activity. For Expected activity this is the query's end activity date; for Automatic settlement it is the contractual settlement date; for Instruction settlement it is the instruction's actual settlement date.", alias="activityDate")
settlement_category: StrictStr = Field(...,alias="settlementCategory", description="The settlement category of the underlying movements. Available values: StockSettlement, CashSettlement, DeferredCashReceipt, NotApplicable.")
transaction_id: Optional[StrictStr] = Field(None,alias="transactionId", description="The identifier of the transaction that gave rise to this settlement activity. Always populated for Expected and Settled activity.")
settlement_instruction_id: Optional[StrictStr] = Field(None,alias="settlementInstructionId", description="The identifier of the settlement instruction that settled the activity. Populated only for Instruction settlement; null for Inferred and Automatic activity.")
holding_ids: Optional[List[StrictInt]] = Field(default=None, description="The identifiers of the holdings whose movements contributed to this settlement activity.", alias="holdingIds")
lusid_instrument_id: StrictStr = Field(...,alias="lusidInstrumentId", description="The LUSID instrument identifier (LUID) of the instrument being settled.")
instrument_scope: StrictStr = Field(...,alias="instrumentScope", description="The scope in which the instrument is defined.")
contractual_settlement_date: datetime = Field(description="The contractual settlement date of the underlying movements.", alias="contractualSettlementDate")
custodian_account_id: Optional[ResourceId] = Field(default=None, alias="custodianAccountId")
custodian_account_number: Optional[StrictStr] = Field(None,alias="custodianAccountNumber", description="The account number of the associated custodian account, if any.")
custodian_account_name: Optional[StrictStr] = Field(None,alias="custodianAccountName", description="The name of the associated custodian account, if any.")
units: Union[StrictFloat, StrictInt] = Field(description="The signed number of units settled or expected to settle for this activity.")
direction: StrictStr = Field(...,alias="direction", description="The direction of the settlement from the portfolio's perspective. Available values: Debit, Credit.")
days_overdue: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The number of days the activity is overdue, calculated as the activity date minus the contractual settlement date. Zero for settled activity.", alias="daysOverdue")
transaction: Optional[OutputTransaction] = None
settlement_instruction: Optional[TransactionSettlementInstruction] = Field(default=None, alias="settlementInstruction")
__properties = ["activityId", "portfolioId", "activityType", "activityBasis", "activityDate", "settlementCategory", "transactionId", "settlementInstructionId", "holdingIds", "lusidInstrumentId", "instrumentScope", "contractualSettlementDate", "custodianAccountId", "custodianAccountNumber", "custodianAccountName", "units", "direction", "daysOverdue", "transaction", "settlementInstruction"]
[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) -> SettlementActivity:
"""Create an instance of SettlementActivity 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 portfolio_id
if self.portfolio_id:
_dict['portfolioId'] = self.portfolio_id.to_dict()
# override the default output from pydantic by calling `to_dict()` of custodian_account_id
if self.custodian_account_id:
_dict['custodianAccountId'] = self.custodian_account_id.to_dict()
# override the default output from pydantic by calling `to_dict()` of transaction
if self.transaction:
_dict['transaction'] = self.transaction.to_dict()
# override the default output from pydantic by calling `to_dict()` of settlement_instruction
if self.settlement_instruction:
_dict['settlementInstruction'] = self.settlement_instruction.to_dict()
# set to None if transaction_id (nullable) is None
# and __fields_set__ contains the field
if self.transaction_id is None and "transaction_id" in self.__fields_set__:
_dict['transactionId'] = None
# set to None if settlement_instruction_id (nullable) is None
# and __fields_set__ contains the field
if self.settlement_instruction_id is None and "settlement_instruction_id" in self.__fields_set__:
_dict['settlementInstructionId'] = None
# set to None if holding_ids (nullable) is None
# and __fields_set__ contains the field
if self.holding_ids is None and "holding_ids" in self.__fields_set__:
_dict['holdingIds'] = None
# set to None if custodian_account_number (nullable) is None
# and __fields_set__ contains the field
if self.custodian_account_number is None and "custodian_account_number" in self.__fields_set__:
_dict['custodianAccountNumber'] = None
# set to None if custodian_account_name (nullable) is None
# and __fields_set__ contains the field
if self.custodian_account_name is None and "custodian_account_name" in self.__fields_set__:
_dict['custodianAccountName'] = None
# set to None if days_overdue (nullable) is None
# and __fields_set__ contains the field
if self.days_overdue is None and "days_overdue" in self.__fields_set__:
_dict['daysOverdue'] = None
return _dict
[docs]
@classmethod
def from_dict(cls, obj: dict) -> SettlementActivity:
"""Create an instance of SettlementActivity from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return SettlementActivity.parse_obj(obj)
_obj = SettlementActivity.parse_obj({
"activity_id": obj.get("activityId"),
"portfolio_id": ResourceId.from_dict(obj.get("portfolioId")) if obj.get("portfolioId") is not None else None,
"activity_type": obj.get("activityType"),
"activity_basis": obj.get("activityBasis"),
"activity_date": obj.get("activityDate"),
"settlement_category": obj.get("settlementCategory"),
"transaction_id": obj.get("transactionId"),
"settlement_instruction_id": obj.get("settlementInstructionId"),
"holding_ids": obj.get("holdingIds"),
"lusid_instrument_id": obj.get("lusidInstrumentId"),
"instrument_scope": obj.get("instrumentScope"),
"contractual_settlement_date": obj.get("contractualSettlementDate"),
"custodian_account_id": ResourceId.from_dict(obj.get("custodianAccountId")) if obj.get("custodianAccountId") is not None else None,
"custodian_account_number": obj.get("custodianAccountNumber"),
"custodian_account_name": obj.get("custodianAccountName"),
"units": obj.get("units"),
"direction": obj.get("direction"),
"days_overdue": obj.get("daysOverdue"),
"transaction": OutputTransaction.from_dict(obj.get("transaction")) if obj.get("transaction") is not None else None,
"settlement_instruction": TransactionSettlementInstruction.from_dict(obj.get("settlementInstruction")) if obj.get("settlementInstruction") is not None else None
})
return _obj
SettlementActivity.update_forward_refs()