1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 from CIM14
.IEC61968
.Common
.Document
import Document
23 class MerchantAccount(Document
):
24 """The operating account controlled by MerchantAgreement, against which Vendor may vend tokens or receipt payments. Transactions via VendorShift debit the account and bank deposits via BankStatement credit the account.
27 def __init__(self
, provisionalBalance
=0.0, currentBalance
=0.0, VendorShifts
=None, MerchantAgreement
=None, Vendors
=None, Transactors
=None, *args
, **kw_args
):
28 """Initialises a new 'MerchantAccount' instance.
30 @param provisionalBalance: The balance of this account after taking into account any pending debits from VendorShift.merchantDebitAmount and pending credits from BankStatement.merchantCreditAmount or credits (see also BankStatement attributes and VendorShift attributes).
31 @param currentBalance: The current operating balance of this account.
32 @param VendorShifts: All vendor shifts that operate on this merchant account.
33 @param MerchantAgreement: Merchant agreement that instantiated this merchant account.
34 @param Vendors: All vendors selling tokens or receipt payments against this merchant account.
35 @param Transactors: All transactors this merchant account is registered with.
37 #: The balance of this account after taking into account any pending debits from VendorShift.merchantDebitAmount and pending credits from BankStatement.merchantCreditAmount or credits (see also BankStatement attributes and VendorShift attributes).
38 self
.provisionalBalance
= provisionalBalance
40 #: The current operating balance of this account.
41 self
.currentBalance
= currentBalance
43 self
._VendorShifts
= []
44 self
.VendorShifts
= [] if VendorShifts
is None else VendorShifts
46 self
._MerchantAgreement
= None
47 self
.MerchantAgreement
= MerchantAgreement
50 self
.Vendors
= [] if Vendors
is None else Vendors
52 self
._Transactors
= []
53 self
.Transactors
= [] if Transactors
is None else Transactors
55 super(MerchantAccount
, self
).__init
__(*args
, **kw_args
)
57 _attrs
= ["provisionalBalance", "currentBalance"]
58 _attr_types
= {"provisionalBalance": float, "currentBalance": float}
59 _defaults
= {"provisionalBalance": 0.0, "currentBalance": 0.0}
61 _refs
= ["VendorShifts", "MerchantAgreement", "Vendors", "Transactors"]
62 _many_refs
= ["VendorShifts", "Vendors", "Transactors"]
64 def getVendorShifts(self
):
65 """All vendor shifts that operate on this merchant account.
67 return self
._VendorShifts
69 def setVendorShifts(self
, value
):
70 for x
in self
._VendorShifts
:
71 x
.MerchantAccount
= None
73 y
._MerchantAccount
= self
74 self
._VendorShifts
= value
76 VendorShifts
= property(getVendorShifts
, setVendorShifts
)
78 def addVendorShifts(self
, *VendorShifts
):
79 for obj
in VendorShifts
:
80 obj
.MerchantAccount
= self
82 def removeVendorShifts(self
, *VendorShifts
):
83 for obj
in VendorShifts
:
84 obj
.MerchantAccount
= None
86 def getMerchantAgreement(self
):
87 """Merchant agreement that instantiated this merchant account.
89 return self
._MerchantAgreement
91 def setMerchantAgreement(self
, value
):
92 if self
._MerchantAgreement
is not None:
93 filtered
= [x
for x
in self
.MerchantAgreement
.MerchantAccounts
if x
!= self
]
94 self
._MerchantAgreement
._MerchantAccounts
= filtered
96 self
._MerchantAgreement
= value
97 if self
._MerchantAgreement
is not None:
98 if self
not in self
._MerchantAgreement
._MerchantAccounts
:
99 self
._MerchantAgreement
._MerchantAccounts
.append(self
)
101 MerchantAgreement
= property(getMerchantAgreement
, setMerchantAgreement
)
103 def getVendors(self
):
104 """All vendors selling tokens or receipt payments against this merchant account.
108 def setVendors(self
, value
):
109 for x
in self
._Vendors
:
110 x
.MerchantAccount
= None
112 y
._MerchantAccount
= self
113 self
._Vendors
= value
115 Vendors
= property(getVendors
, setVendors
)
117 def addVendors(self
, *Vendors
):
119 obj
.MerchantAccount
= self
121 def removeVendors(self
, *Vendors
):
123 obj
.MerchantAccount
= None
125 def getTransactors(self
):
126 """All transactors this merchant account is registered with.
128 return self
._Transactors
130 def setTransactors(self
, value
):
131 for p
in self
._Transactors
:
132 filtered
= [q
for q
in p
.MerchantAccounts
if q
!= self
]
133 self
._Transactors
._MerchantAccounts
= filtered
135 if self
not in r
._MerchantAccounts
:
136 r
._MerchantAccounts
.append(self
)
137 self
._Transactors
= value
139 Transactors
= property(getTransactors
, setTransactors
)
141 def addTransactors(self
, *Transactors
):
142 for obj
in Transactors
:
143 if self
not in obj
._MerchantAccounts
:
144 obj
._MerchantAccounts
.append(self
)
145 self
._Transactors
.append(obj
)
147 def removeTransactors(self
, *Transactors
):
148 for obj
in Transactors
:
149 if self
in obj
._MerchantAccounts
:
150 obj
._MerchantAccounts
.remove(self
)
151 self
._Transactors
.remove(obj
)