def serialise(self) -> Dict[str, Any]: global_unit_id = None custom_unit_id = None if isinstance(self._denomination, GlobalUnit): global_unit_id = self._denomination.id_ else: assert isinstance(self._denomination, CustomUnit) custom_unit_id = self._denomination.id_ start_time = None if self._start_time: start_time = AmatinoTime(self._start_time).serialise() end_time = None if self._end_time: end_time = AmatinoTime(self._end_time).serialise() data = { 'account_id': self._account.id_, 'start_time': start_time, 'end_time': end_time, 'page': self._page, 'global_unit_denomination': global_unit_id, 'custom_unit_denomination': custom_unit_id, 'order_oldest_first': self._order.value } return data
def __init__( self, start_time: datetime, end_time: datetime, denomination: Denomination, depth: Optional[int] = None ) -> None: if not isinstance(start_time, datetime): raise TypeError('start_time must be of type `datetime`') if not isinstance(end_time, datetime): raise TypeError('end_time must be of type `datetime`') if not isinstance(denomination, Denomination): raise TypeError('denomination must be of type `Denomination`') if depth is not None and not isinstance(depth, int): raise TypeError( 'If supplied, depth must be of type `int`' ) self._start_time = AmatinoTime(start_time) self._end_time = AmatinoTime(end_time) self._denomination = denomination self._depth = depth return
def __init__(self, account: Account, balance_time: Optional[datetime] = None, denomination: Optional[Denomination] = None) -> None: if not isinstance(account, Account): raise TypeError('account must be of type Account') if (balance_time is not None and not isinstance(balance_time, datetime)): raise TypeError( 'balance_time must be of type `datetime or None') if (denomination is not None and not isinstance(denomination, Denomination)): raise TypeError('denomination must conform to `Denomination`') if denomination is None: denomination = account.denomination self._account = account self._balance_time = None if balance_time: self._balance_time = AmatinoTime(balance_time) self._denomination = denomination
def __init__(self, account: Account, order: LedgerOrder = LedgerOrder.YOUNGEST_FIRST, page: int = 1, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None, denomination: Optional[Denomination] = None) -> None: if not isinstance(account, Account): raise TypeError('account must be of type `Account`') if not isinstance(order, LedgerOrder): raise TypeError('order must beof type `LedgerOrder`') if not isinstance(page, int): raise TypeError('page must be of type `int`') if start_time and not isinstance(start_time, datetime): raise TypeError( 'start_time must be of type `datetime` or None') if end_time and not isinstance(end_time, datetime): raise TypeError('end_time must be of type `datetime` or None') if denomination and not isinstance(denomination, Denomination): raise TypeError( 'denomination must be of type `Denomination` or None') if denomination is None: denomination = account.denomination self._account = account self._order = order self._page = page self._start_time = None if start_time: self._start_time = AmatinoTime(start_time) self._end_time = None if end_time: self._end_time = AmatinoTime(end_time) self._denomination = denomination
def __init__(self, transaction: T, time: Optional[datetime] = None, entries: Optional[List[Entry]] = None, denomination: Optional[Denomination] = None, description: Optional[str] = None) -> None: if not isinstance(transaction, Transaction): raise TypeError('transaction must be of type `Transaction`') self._transaction_id = transaction.id_ if time: if not isinstance(time, datetime): raise TypeError('time must be of type `datetime`') self._time = AmatinoTime(time) else: self._time = AmatinoTime(transaction.time) if entries: self._entries = Transaction._Entries(entries) else: self._entries = Transaction._Entries(transaction.entries) if denomination: if not isinstance(denomination, Denomination): raise TypeError( 'demomination must be of type `Denomination`') self._denomination = denomination else: self._denomination = transaction.denomination if description: self._description = Transaction._Description(description) else: self._description = Transaction._Description( transaction.description) return
def __init__( self, balance_time: datetime, denomination: Denomination ) -> None: if not isinstance(balance_time, datetime): raise TypeError('balance_time must be of type `datetime`') if not isinstance(denomination, Denomination): raise TypeError('denomination must be of type `denomination`') self._balance_time = AmatinoTime(balance_time) self._denomination = denomination
def __init__( self, time: datetime, entries: List[Entry], denomination: Denomination, description: Optional[str] = None, ) -> None: if not isinstance(time, datetime): raise TypeError('time must be of type `datetime.datetime`') if not isinstance(denomination, Denomination): raise TypeError('denomination must be of type `Denomination`') self._time = AmatinoTime(time) self._denomination = denomination self._entries = Transaction._Entries(entries) self._description = Transaction._Description(description) return