CapBank derivates from CapCollection and add a method iter_transfer_recipients
This commit is contained in:
parent
0061d598e0
commit
7b29d2dc80
1 changed files with 27 additions and 7 deletions
|
|
@ -20,10 +20,11 @@
|
||||||
|
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
|
|
||||||
from .base import IBaseCap, CapBaseObject
|
from .base import CapBaseObject
|
||||||
|
from .collection import ICapCollection, CollectionNotFound
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank',
|
__all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank',
|
||||||
'Operation']
|
'Operation']
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -36,10 +37,14 @@ class AccountNotFound(Exception):
|
||||||
class TransferError(Exception):
|
class TransferError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Account(CapBaseObject):
|
class Recipient(CapBaseObject):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
CapBaseObject.__init__(self, 0)
|
CapBaseObject.__init__(self, 0)
|
||||||
self.add_field('label', basestring)
|
self.add_field('label', basestring)
|
||||||
|
|
||||||
|
class Account(Recipient):
|
||||||
|
def __init__(self):
|
||||||
|
Recipient.__init__(self)
|
||||||
self.add_field('balance', float)
|
self.add_field('balance', float)
|
||||||
self.add_field('coming', float)
|
self.add_field('coming', float)
|
||||||
self.link_id = None
|
self.link_id = None
|
||||||
|
|
@ -56,7 +61,7 @@ class Operation(CapBaseObject):
|
||||||
self.add_field('amount', float)
|
self.add_field('amount', float)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Operation date='%s' label='%s' amount=%s>" % (self.date,
|
return "<Operation date='%s' label='%s' amount=%s>" % (self.date,
|
||||||
self.label, self.amount)
|
self.label, self.amount)
|
||||||
|
|
||||||
class Transfer(CapBaseObject):
|
class Transfer(CapBaseObject):
|
||||||
|
|
@ -67,7 +72,13 @@ class Transfer(CapBaseObject):
|
||||||
self.add_field('origin', (int, long, basestring))
|
self.add_field('origin', (int, long, basestring))
|
||||||
self.add_field('recipient', (int, long, basestring))
|
self.add_field('recipient', (int, long, basestring))
|
||||||
|
|
||||||
class ICapBank(IBaseCap):
|
class ICapBank(ICapCollection):
|
||||||
|
def iter_resources(self, splited_path):
|
||||||
|
if len(splited_path) > 0:
|
||||||
|
raise CollectionNotFound()
|
||||||
|
|
||||||
|
return self.iter_accounts()
|
||||||
|
|
||||||
def iter_accounts(self):
|
def iter_accounts(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
@ -80,12 +91,21 @@ class ICapBank(IBaseCap):
|
||||||
def iter_history(self, account):
|
def iter_history(self, account):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def transfer(self, account, to, amount, reason=None):
|
def iter_transfer_recipients(self, account):
|
||||||
|
"""
|
||||||
|
Iter recipients availables for a transfer from a specific account.
|
||||||
|
|
||||||
|
@param account [Account] account which initiate the transfer
|
||||||
|
@return [iter(Recipient)]
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def transfer(self, account, recipient, amount, reason=None):
|
||||||
"""
|
"""
|
||||||
Make a transfer from an account to a recipient.
|
Make a transfer from an account to a recipient.
|
||||||
|
|
||||||
@param account [Account] account to take money
|
@param account [Account] account to take money
|
||||||
@param to [Account] account to send money
|
@param recipient [Recipient] account to send money
|
||||||
@param amount [float] amount
|
@param amount [float] amount
|
||||||
@param reason [str] reason of transfer
|
@param reason [str] reason of transfer
|
||||||
@return [Transfer] a Transfer object
|
@return [Transfer] a Transfer object
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue