Source code for sdk.lusid.models.transaction_configuration_movement_data_request

# 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.perpetual_property import PerpetualProperty
from lusid.models.transaction_property_mapping_request import TransactionPropertyMappingRequest

[docs] class TransactionConfigurationMovementDataRequest(BaseModel): """ TransactionConfigurationMovementDataRequest """ movement_types: StrictStr = Field(...,alias="movementTypes", description="The movement types. Available values: Settlement, Traded, StockMovement, FutureCash, Commitment, Receivable, CashSettlement, CashForward, CashCommitment, CashReceivable, Accrual, CashAccrual, ForwardFx, CashFxForward, Carry, CarryAsPnl, VariationMargin, Capital, Fee, LimitAdjustment, BalanceAdjustment, Deferred, CashDeferred.") side: StrictStr = Field(...,alias="side", description="The movement side") direction: StrictInt = Field(description="The movement direction") properties: Optional[Dict[str, PerpetualProperty]] = Field(default=None, description="The properties associated with the underlying Movement.") mappings: Optional[List[TransactionPropertyMappingRequest]] = Field(default=None, description="This allows you to map a transaction property to a property on the underlying holding.") name: Optional[StrictStr] = Field(None,alias="name", description="The movement name (optional)") movement_options: Optional[List[StrictStr]] = Field(default=None, description="Allows extra specifications for the movement. The options currently available are 'DirectAdjustment', 'IncludesTradedInterest', 'Virtual', 'Income' and 'Expense'. A movement type of 'StockMovement' with an option of 'DirectAdjusment' will allow you to adjust the units of a holding without affecting its cost base. You will, therefore, be able to reflect the impact of a stock split by loading a Transaction. A movement type of 'Carry' with the option as 'Expense' will not impact the interest accrual for cash-type holdings such loans, loan facilities and deposits.", alias="movementOptions") __properties = ["movementTypes", "side", "direction", "properties", "mappings", "name", "movementOptions"]
[docs] @validator('movement_types') def movement_types_validate_enum(cls, value): """Validates the enum""" # Finbourne have removed enum validation on all models, except for this use case: # Workflow and notification application SDK use the property name 'type' as the discriminator on a number of classes. # During instantiation, the value of 'type' is checked against the enum values, # check it's a class that uses the 'type' property as a discriminator # list of classes can be found by searching for 'actual_instance: Union[' in the generated code if 'TransactionConfigurationMovementDataRequest' not in [ # For notification application classes 'AmazonSqsNotificationType', 'AmazonSqsNotificationTypeResponse', 'AmazonSqsPrincipalAuthNotificationType', 'AmazonSqsPrincipalAuthNotificationTypeResponse', 'AzureServiceBusTypeResponse', 'AzureServiceBusNotificationType', 'EmailNotificationType', 'EmailNotificationTypeResponse', 'SmsNotificationType', 'SmsNotificationTypeResponse', 'WebhookNotificationType', 'WebhookNotificationTypeResponse', # For workflow application classes 'CreateChildTasksAction', 'RunWorkerAction', 'TriggerParentTaskAction', 'CreateChildTasksActionResponse', 'RunWorkerActionResponse', 'TriggerChildTasksAction', 'TriggerChildTasksActionResponse', 'TriggerParentTaskActionResponse', 'CreateNewTaskActivity', 'UpdateMatchingTasksActivity', 'CreateNewTaskActivityResponse', 'UpdateMatchingTasksActivityResponse', 'Fail', 'GroupReconciliation', 'HealthCheck', 'LuminesceView', 'SchedulerJob', 'Sleep', 'FailResponse', 'GroupReconciliationResponse', 'HealthCheckResponse', 'LuminesceViewResponse', 'SchedulerJobResponse', 'SleepResponse', 'Library', 'LibraryResponse', 'DayRegularity', 'RelativeMonthRegularity', 'SpecificMonthRegularity', 'WeekRegularity', 'YearRegularity', 'LusidEntityDataQualityCheck', 'LusidEntityDataQualityCheckResponse', 'TriggerChildTasksActionResponse']: return value # Only validate the 'type' property of the class if "movement_types" != "type": return value if value not in ['Settlement', 'Traded', 'StockMovement', 'FutureCash', 'Commitment', 'Receivable', 'CashSettlement', 'CashForward', 'CashCommitment', 'CashReceivable', 'Accrual', 'CashAccrual', 'ForwardFx', 'CashFxForward', 'Carry', 'CarryAsPnl', 'VariationMargin', 'Capital', 'Fee', 'LimitAdjustment', 'BalanceAdjustment', 'Deferred', 'CashDeferred']: raise ValueError("must be one of enum values ('Settlement', 'Traded', 'StockMovement', 'FutureCash', 'Commitment', 'Receivable', 'CashSettlement', 'CashForward', 'CashCommitment', 'CashReceivable', 'Accrual', 'CashAccrual', 'ForwardFx', 'CashFxForward', 'Carry', 'CarryAsPnl', 'VariationMargin', 'Capital', 'Fee', 'LimitAdjustment', 'BalanceAdjustment', 'Deferred', 'CashDeferred')") return value
[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) -> TransactionConfigurationMovementDataRequest: """Create an instance of TransactionConfigurationMovementDataRequest 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 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 mappings (list) _items = [] if self.mappings: for _item in self.mappings: if _item: _items.append(_item.to_dict()) _dict['mappings'] = _items # 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 mappings (nullable) is None # and __fields_set__ contains the field if self.mappings is None and "mappings" in self.__fields_set__: _dict['mappings'] = None # set to None if name (nullable) is None # and __fields_set__ contains the field if self.name is None and "name" in self.__fields_set__: _dict['name'] = None # set to None if movement_options (nullable) is None # and __fields_set__ contains the field if self.movement_options is None and "movement_options" in self.__fields_set__: _dict['movementOptions'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> TransactionConfigurationMovementDataRequest: """Create an instance of TransactionConfigurationMovementDataRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): return TransactionConfigurationMovementDataRequest.parse_obj(obj) _obj = TransactionConfigurationMovementDataRequest.parse_obj({ "movement_types": obj.get("movementTypes"), "side": obj.get("side"), "direction": obj.get("direction"), "properties": dict( (_k, PerpetualProperty.from_dict(_v)) for _k, _v in obj.get("properties").items() ) if obj.get("properties") is not None else None, "mappings": [TransactionPropertyMappingRequest.from_dict(_item) for _item in obj.get("mappings")] if obj.get("mappings") is not None else None, "name": obj.get("name"), "movement_options": obj.get("movementOptions") }) return _obj
TransactionConfigurationMovementDataRequest.update_forward_refs()