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.
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.
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
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
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}
62 _refs
= ["Charges", "AuxiliaryAgreement", "PaymentTransactions", "lastDebit", "lastCredit", "due"]
63 _many_refs
= ["Charges", "PaymentTransactions"]
66 """All charges levied on this account.
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
75 if self
not in r
._AuxiliaryAccounts
:
76 r
._AuxiliaryAccounts
.append(self
)
79 Charges
= property(getCharges
, setCharges
)
81 def addCharges(self
, *Charges
):
83 if self
not in obj
._AuxiliaryAccounts
:
84 obj
._AuxiliaryAccounts
.append(self
)
85 self
._Charges
.append(obj
)
87 def removeCharges(self
, *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.
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
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.
135 # Details of the last credit transaction performed on this account.
138 # Current amounts now due for payment on this account.