Adding class meta-data attributes.
[PyCIM.git] / schemata / CIM14 / IEC61968 / PaymentMetering / MerchantAccount.py
blob29c50ec8a55112c3ae051daba0bebc31f1c999ec
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
77 self._VendorShifts.append(obj)
79 def removeVendorShifts(self, *VendorShifts):
80 for obj in VendorShifts:
81 obj._MerchantAccount = None
82 self._VendorShifts.remove(obj)
84 def getMerchantAgreement(self):
85 """Merchant agreement that instantiated this merchant account.
86 """
87 return self._MerchantAgreement
89 def setMerchantAgreement(self, value):
90 if self._MerchantAgreement is not None:
91 filtered = [x for x in self.MerchantAgreement.MerchantAccounts if x != self]
92 self._MerchantAgreement._MerchantAccounts = filtered
94 self._MerchantAgreement = value
95 if self._MerchantAgreement is not None:
96 self._MerchantAgreement._MerchantAccounts.append(self)
98 MerchantAgreement = property(getMerchantAgreement, setMerchantAgreement)
100 def getVendors(self):
101 """All vendors selling tokens or receipt payments against this merchant account.
103 return self._Vendors
105 def setVendors(self, value):
106 for x in self._Vendors:
107 x._MerchantAccount = None
108 for y in value:
109 y._MerchantAccount = self
110 self._Vendors = value
112 Vendors = property(getVendors, setVendors)
114 def addVendors(self, *Vendors):
115 for obj in Vendors:
116 obj._MerchantAccount = self
117 self._Vendors.append(obj)
119 def removeVendors(self, *Vendors):
120 for obj in Vendors:
121 obj._MerchantAccount = None
122 self._Vendors.remove(obj)
124 def getTransactors(self):
125 """All transactors this merchant account is registered with.
127 return self._Transactors
129 def setTransactors(self, value):
130 for p in self._Transactors:
131 filtered = [q for q in p.MerchantAccounts if q != self]
132 self._Transactors._MerchantAccounts = filtered
133 for r in value:
134 if self not in r._MerchantAccounts:
135 r._MerchantAccounts.append(self)
136 self._Transactors = value
138 Transactors = property(getTransactors, setTransactors)
140 def addTransactors(self, *Transactors):
141 for obj in Transactors:
142 if self not in obj._MerchantAccounts:
143 obj._MerchantAccounts.append(self)
144 self._Transactors.append(obj)
146 def removeTransactors(self, *Transactors):
147 for obj in Transactors:
148 if self in obj._MerchantAccounts:
149 obj._MerchantAccounts.remove(self)
150 self._Transactors.remove(obj)