Update README.rst
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / AuxiliaryAccount.py
blob2fbbad55021f6166b74e283d5e2cb0ef3f4de39b
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
19 # IN THE SOFTWARE.
21 from CIM14.IEC61968.Common.Document import Document
23 class AuxiliaryAccount(Document):
24 """Variable and dynamic part of AuxiliaryAgreement, generally representing the current state of the account related to the outstanding balance defined in AuxiliaryAgreement.
25 """
27 def __init__(self, balance=0.0, principleAmount=0.0, Charges=None, AuxiliaryAgreement=None, PaymentTransactions=None, lastDebit=None, lastCredit=None, due=None, *args, **kw_args):
28 """Initialises a new 'AuxiliaryAccount' instance.
30 @param balance: The total amount currently remaining on this account that is required to be paid in order to settle the account to zero. This excludes any due amounts not yet paid.
31 @param principleAmount: The initial principle amount, with which this account was instantiated.
32 @param Charges: All charges levied on this account.
33 @param AuxiliaryAgreement: Auxiliary agreement regulating this account.
34 @param PaymentTransactions: All payments against this account.
35 @param lastDebit: Details of the last debit transaction performed on this account.
36 @param lastCredit: Details of the last credit transaction performed on this account.
37 @param due: Current amounts now due for payment on this account.
38 """
39 #: The total amount currently remaining on this account that is required to be paid in order to settle the account to zero. This excludes any due amounts not yet paid.
40 self.balance = balance
42 #: The initial principle amount, with which this account was instantiated.
43 self.principleAmount = principleAmount
45 self._Charges = []
46 self.Charges = [] if Charges is None else Charges
48 self._AuxiliaryAgreement = None
49 self.AuxiliaryAgreement = AuxiliaryAgreement
51 self._PaymentTransactions = []
52 self.PaymentTransactions = [] if PaymentTransactions is None else PaymentTransactions
54 self.lastDebit = lastDebit
56 self.lastCredit = lastCredit
58 self.due = due
60 super(AuxiliaryAccount, self).__init__(*args, **kw_args)
62 _attrs = ["balance", "principleAmount"]
63 _attr_types = {"balance": float, "principleAmount": float}
64 _defaults = {"balance": 0.0, "principleAmount": 0.0}
65 _enums = {}
66 _refs = ["Charges", "AuxiliaryAgreement", "PaymentTransactions", "lastDebit", "lastCredit", "due"]
67 _many_refs = ["Charges", "PaymentTransactions"]
69 def getCharges(self):
70 """All charges levied on this account.
71 """
72 return self._Charges
74 def setCharges(self, value):
75 for p in self._Charges:
76 filtered = [q for q in p.AuxiliaryAccounts if q != self]
77 self._Charges._AuxiliaryAccounts = filtered
78 for r in value:
79 if self not in r._AuxiliaryAccounts:
80 r._AuxiliaryAccounts.append(self)
81 self._Charges = value
83 Charges = property(getCharges, setCharges)
85 def addCharges(self, *Charges):
86 for obj in Charges:
87 if self not in obj._AuxiliaryAccounts:
88 obj._AuxiliaryAccounts.append(self)
89 self._Charges.append(obj)
91 def removeCharges(self, *Charges):
92 for obj in Charges:
93 if self in obj._AuxiliaryAccounts:
94 obj._AuxiliaryAccounts.remove(self)
95 self._Charges.remove(obj)
97 def getAuxiliaryAgreement(self):
98 """Auxiliary agreement regulating this account.
99 """
100 return self._AuxiliaryAgreement
102 def setAuxiliaryAgreement(self, value):
103 if self._AuxiliaryAgreement is not None:
104 filtered = [x for x in self.AuxiliaryAgreement.AuxiliaryAccounts if x != self]
105 self._AuxiliaryAgreement._AuxiliaryAccounts = filtered
107 self._AuxiliaryAgreement = value
108 if self._AuxiliaryAgreement is not None:
109 if self not in self._AuxiliaryAgreement._AuxiliaryAccounts:
110 self._AuxiliaryAgreement._AuxiliaryAccounts.append(self)
112 AuxiliaryAgreement = property(getAuxiliaryAgreement, setAuxiliaryAgreement)
114 def getPaymentTransactions(self):
115 """All payments against this account.
117 return self._PaymentTransactions
119 def setPaymentTransactions(self, value):
120 for x in self._PaymentTransactions:
121 x.AuxiliaryAccount = None
122 for y in value:
123 y._AuxiliaryAccount = self
124 self._PaymentTransactions = value
126 PaymentTransactions = property(getPaymentTransactions, setPaymentTransactions)
128 def addPaymentTransactions(self, *PaymentTransactions):
129 for obj in PaymentTransactions:
130 obj.AuxiliaryAccount = self
132 def removePaymentTransactions(self, *PaymentTransactions):
133 for obj in PaymentTransactions:
134 obj.AuxiliaryAccount = None
136 # Details of the last debit transaction performed on this account.
137 lastDebit = None
139 # Details of the last credit transaction performed on this account.
140 lastCredit = None
142 # Current amounts now due for payment on this account.
143 due = None