Adding CDPSM package.
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / MerchantAccount.py
blobc91a8fe82238b4af2e3e0c7817c41f195ae66253
1 # Copyright (C) 2010 Richard Lincoln
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
17 from CIM14.IEC61968.Common.Document import Document
19 class MerchantAccount(Document):
20 """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.
21 """
23 def __init__(self, provisionalBalance=0.0, currentBalance=0.0, VendorShifts=None, MerchantAgreement=None, Vendors=None, Transactors=None, *args, **kw_args):
24 """Initialises a new 'MerchantAccount' instance.
26 @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).
27 @param currentBalance: The current operating balance of this account.
28 @param VendorShifts: All vendor shifts that operate on this merchant account.
29 @param MerchantAgreement: Merchant agreement that instantiated this merchant account.
30 @param Vendors: All vendors selling tokens or receipt payments against this merchant account.
31 @param Transactors: All transactors this merchant account is registered with.
32 """
33 #: 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).
34 self.provisionalBalance = provisionalBalance
36 #: The current operating balance of this account.
37 self.currentBalance = currentBalance
39 self._VendorShifts = []
40 self.VendorShifts = [] if VendorShifts is None else VendorShifts
42 self._MerchantAgreement = None
43 self.MerchantAgreement = MerchantAgreement
45 self._Vendors = []
46 self.Vendors = [] if Vendors is None else Vendors
48 self._Transactors = []
49 self.Transactors = [] if Transactors is None else Transactors
51 super(MerchantAccount, self).__init__(*args, **kw_args)
53 _attrs = ["provisionalBalance", "currentBalance"]
54 _attr_types = {"provisionalBalance": float, "currentBalance": float}
55 _defaults = {"provisionalBalance": 0.0, "currentBalance": 0.0}
56 _enums = {}
57 _refs = ["VendorShifts", "MerchantAgreement", "Vendors", "Transactors"]
58 _many_refs = ["VendorShifts", "Vendors", "Transactors"]
60 def getVendorShifts(self):
61 """All vendor shifts that operate on this merchant account.
62 """
63 return self._VendorShifts
65 def setVendorShifts(self, value):
66 for x in self._VendorShifts:
67 x.MerchantAccount = None
68 for y in value:
69 y._MerchantAccount = self
70 self._VendorShifts = value
72 VendorShifts = property(getVendorShifts, setVendorShifts)
74 def addVendorShifts(self, *VendorShifts):
75 for obj in VendorShifts:
76 obj.MerchantAccount = self
78 def removeVendorShifts(self, *VendorShifts):
79 for obj in VendorShifts:
80 obj.MerchantAccount = None
82 def getMerchantAgreement(self):
83 """Merchant agreement that instantiated this merchant account.
84 """
85 return self._MerchantAgreement
87 def setMerchantAgreement(self, value):
88 if self._MerchantAgreement is not None:
89 filtered = [x for x in self.MerchantAgreement.MerchantAccounts if x != self]
90 self._MerchantAgreement._MerchantAccounts = filtered
92 self._MerchantAgreement = value
93 if self._MerchantAgreement is not None:
94 if self not in self._MerchantAgreement._MerchantAccounts:
95 self._MerchantAgreement._MerchantAccounts.append(self)
97 MerchantAgreement = property(getMerchantAgreement, setMerchantAgreement)
99 def getVendors(self):
100 """All vendors selling tokens or receipt payments against this merchant account.
102 return self._Vendors
104 def setVendors(self, value):
105 for x in self._Vendors:
106 x.MerchantAccount = None
107 for y in value:
108 y._MerchantAccount = self
109 self._Vendors = value
111 Vendors = property(getVendors, setVendors)
113 def addVendors(self, *Vendors):
114 for obj in Vendors:
115 obj.MerchantAccount = self
117 def removeVendors(self, *Vendors):
118 for obj in Vendors:
119 obj.MerchantAccount = None
121 def getTransactors(self):
122 """All transactors this merchant account is registered with.
124 return self._Transactors
126 def setTransactors(self, value):
127 for p in self._Transactors:
128 filtered = [q for q in p.MerchantAccounts if q != self]
129 self._Transactors._MerchantAccounts = filtered
130 for r in value:
131 if self not in r._MerchantAccounts:
132 r._MerchantAccounts.append(self)
133 self._Transactors = value
135 Transactors = property(getTransactors, setTransactors)
137 def addTransactors(self, *Transactors):
138 for obj in Transactors:
139 if self not in obj._MerchantAccounts:
140 obj._MerchantAccounts.append(self)
141 self._Transactors.append(obj)
143 def removeTransactors(self, *Transactors):
144 for obj in Transactors:
145 if self in obj._MerchantAccounts:
146 obj._MerchantAccounts.remove(self)
147 self._Transactors.remove(obj)