def emails(self, emails): if not isinstance(emails, dict): raise ValueError(ERROR_LOOKUP.get('email_invalid') % (str(emails), self.party_id, self.asset_manager_id)) primary = [email.email_primary for email in emails.values() if email.email_primary] # If emails are present, one of them must be primary if len(emails) and len(primary) != 1: raise ValueError(ERROR_LOOKUP.get('email_primary') % (self.party_id, self.asset_manager_id)) self._emails = emails
def addresses(self, addresses): if not isinstance(addresses, dict): raise ValueError(ERROR_LOOKUP.get('address_invalid') % (str(addresses), self.party_id, self.asset_manager_id)) primary = [address.address_primary for address in addresses.values() if address.address_primary] # If addresses are present, one of them must be primary if len(addresses) and len(primary) != 1: raise ValueError(ERROR_LOOKUP.get('address_primary') % (self.party_id, self.asset_manager_id)) self._addresses = addresses
def remove_link(self, link_type, linked_transaction_id): link_set = self.links.get(link_type) if not link_set: raise KeyError(ERROR_LOOKUP.get('transaction_link_not_found')) if isinstance(link_set, Link): if link_set.linked_transaction_id == linked_transaction_id: link_set = None else: raise KeyError(ERROR_LOOKUP.get('transaction_link_not_found')) else: output = [link for link in link_set if link.linked_transaction_id == linked_transaction_id] if output: link_set.remove(output[0]) else: raise KeyError(ERROR_LOOKUP.get('transaction_link_not_found')) self.upsert_link_set(link_type=link_type, link_set=link_set)
def account_type(self, account_type): if account_type: if account_type in ACCOUNT_TYPES: self._account_type = account_type else: raise ValueError( ERROR_LOOKUP.get('am_account_type_invalid') % (account_type, self.asset_manager_id))
def asset_manager_type(self, asset_manager_type): if asset_manager_type: if asset_manager_type in ASSET_MANAGER_TYPES: self._asset_manager_type = asset_manager_type else: raise ValueError( ERROR_LOOKUP.get('am_type_invalid') % (asset_manager_type, self.asset_manager_id))
def book_type(self, book_type): """ :param book_type: The type of book that we are creating - e.g. Trading, Wash :return: """ if book_type not in BOOK_TYPES: raise ValueError(ERROR_LOOKUP.get('book_type_invalid') % (book_type, self.book_id, self.asset_manager_id)) else: self._book_type = book_type
def party_status(self, party_status): """ :param transaction_status: The status of the transaction - e.g. Active, Inactive :return: """ if party_status not in PARTY_STATUSES: raise ValueError(ERROR_LOOKUP.get('party_status_invalid') % (party_status, self.party_id, self.asset_manager_id)) else: self._party_status = party_status
def transaction_type(self, transaction_type): """ :param transaction_type: The type of transaction that we are recording - e.g. Trade, Payment, Coupon :return: """ if transaction_type not in TRANSACTION_TYPES: raise ValueError(ERROR_LOOKUP.get('transaction_type_invalid') % (transaction_type, self.transaction_id, self.asset_manager_id)) else: self._transaction_type = transaction_type
def transaction_status(self, transaction_status): """ :param transaction_status: The status of the transaction - e.g. New, Netted :return: """ if transaction_status not in TRANSACTION_STATUSES: raise ValueError(ERROR_LOOKUP.get('transaction_status_invalid') % (transaction_status, self.transaction_id, self.asset_manager_id)) else: self._transaction_status = transaction_status
def transaction_action(self, transaction_action): """ :param transaction_action: The action that this transaction is recording - e.g. Buy, Deliver :return: """ if transaction_action not in TRANSACTION_ACTIONS: raise ValueError(ERROR_LOOKUP.get('transaction_action_invalid') % (transaction_action, self.transaction_id, self.asset_manager_id)) else: self._transaction_action = transaction_action
def email(self, email): # Validate email addresses if not re.match('[^@]+@[^@]+\.[^@]+', email): raise ValueError(ERROR_LOOKUP.get('email_address_invalid') % email) self._email = email
def country_id(self, country_id): if country_id: if len(country_id) != 3: raise ValueError( ERROR_LOOKUP.get('country_id_invalid') % country_id) self._country_id = country_id