Bumping version for release.
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / AuxiliaryAccount.py
blobd98cd66e3dc6618dabdd032e980de271b83358ea
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 AuxiliaryAccount(Document):
20 """Variable and dynamic part of AuxiliaryAgreement, generally representing the current state of the account related to the outstanding balance defined in AuxiliaryAgreement.
21 """
23 def __init__(self, balance=0.0, principleAmount=0.0, Charges=None, AuxiliaryAgreement=None, PaymentTransactions=None, lastDebit=None, lastCredit=None, due=None, *args, **kw_args):
24 """Initialises a new 'AuxiliaryAccount' instance.
26 @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.
27 @param principleAmount: The initial principle amount, with which this account was instantiated.
28 @param Charges: All charges levied on this account.
29 @param AuxiliaryAgreement: Auxiliary agreement regulating this account.
30 @param PaymentTransactions: All payments against this account.
31 @param lastDebit: Details of the last debit transaction performed on this account.
32 @param lastCredit: Details of the last credit transaction performed on this account.
33 @param due: Current amounts now due for payment on this account.
34 """
35 #: 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.
36 self.balance = balance
38 #: The initial principle amount, with which this account was instantiated.
39 self.principleAmount = principleAmount
41 self._Charges = []
42 self.Charges = [] if Charges is None else Charges
44 self._AuxiliaryAgreement = None
45 self.AuxiliaryAgreement = AuxiliaryAgreement
47 self._PaymentTransactions = []
48 self.PaymentTransactions = [] if PaymentTransactions is None else PaymentTransactions
50 self.lastDebit = lastDebit
52 self.lastCredit = lastCredit
54 self.due = due
56 super(AuxiliaryAccount, self).__init__(*args, **kw_args)
58 _attrs = ["balance", "principleAmount"]
59 _attr_types = {"balance": float, "principleAmount": float}
60 _defaults = {"balance": 0.0, "principleAmount": 0.0}
61 _enums = {}
62 _refs = ["Charges", "AuxiliaryAgreement", "PaymentTransactions", "lastDebit", "lastCredit", "due"]
63 _many_refs = ["Charges", "PaymentTransactions"]
65 def getCharges(self):
66 """All charges levied on this account.
67 """
68 return self._Charges
70 def setCharges(self, value):
71 for p in self._Charges:
72 filtered = [q for q in p.AuxiliaryAccounts if q != self]
73 self._Charges._AuxiliaryAccounts = filtered
74 for r in value:
75 if self not in r._AuxiliaryAccounts:
76 r._AuxiliaryAccounts.append(self)
77 self._Charges = value
79 Charges = property(getCharges, setCharges)
81 def addCharges(self, *Charges):
82 for obj in Charges:
83 if self not in obj._AuxiliaryAccounts:
84 obj._AuxiliaryAccounts.append(self)
85 self._Charges.append(obj)
87 def removeCharges(self, *Charges):
88 for obj in Charges:
89 if self in obj._AuxiliaryAccounts:
90 obj._AuxiliaryAccounts.remove(self)
91 self._Charges.remove(obj)
93 def getAuxiliaryAgreement(self):
94 """Auxiliary agreement regulating this account.
95 """
96 return self._AuxiliaryAgreement
98 def setAuxiliaryAgreement(self, value):
99 if self._AuxiliaryAgreement is not None:
100 filtered = [x for x in self.AuxiliaryAgreement.AuxiliaryAccounts if x != self]
101 self._AuxiliaryAgreement._AuxiliaryAccounts = filtered
103 self._AuxiliaryAgreement = value
104 if self._AuxiliaryAgreement is not None:
105 if self not in self._AuxiliaryAgreement._AuxiliaryAccounts:
106 self._AuxiliaryAgreement._AuxiliaryAccounts.append(self)
108 AuxiliaryAgreement = property(getAuxiliaryAgreement, setAuxiliaryAgreement)
110 def getPaymentTransactions(self):
111 """All payments against this account.
113 return self._PaymentTransactions
115 def setPaymentTransactions(self, value):
116 for x in self._PaymentTransactions:
117 x.AuxiliaryAccount = None
118 for y in value:
119 y._AuxiliaryAccount = self
120 self._PaymentTransactions = value
122 PaymentTransactions = property(getPaymentTransactions, setPaymentTransactions)
124 def addPaymentTransactions(self, *PaymentTransactions):
125 for obj in PaymentTransactions:
126 obj.AuxiliaryAccount = self
128 def removePaymentTransactions(self, *PaymentTransactions):
129 for obj in PaymentTransactions:
130 obj.AuxiliaryAccount = None
132 # Details of the last debit transaction performed on this account.
133 lastDebit = None
135 # Details of the last credit transaction performed on this account.
136 lastCredit = None
138 # Current amounts now due for payment on this account.
139 due = None