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
.Agreement
import Agreement
19 class AuxiliaryAgreement(Agreement
):
20 """An ad-hoc auxiliary account agreement associated with a customer agreement, not part of the customer's account, but typically subject to formal agreement between customer and supplier (utility). Typically this is used to collect revenue owing by the customer for other services or arrears accrued with the utility for other services. It is typically linked to a prepaid token purchase transaction, thus forcing the customer to make a payment towards settlement of the auxiliary account balance whenever he needs to purchase a prepaid token for electricity. The present status of AuxiliaryAgreement can be defined in the context of the utility's business rules, for example: enabled, disabled, pending, over recovered, under recovered, written off, etc.
23 def __init__(self
, arrearsInterest
=0.0, vendPortion
=0.0, minAmount
=0.0, auxPriorityCode
='', subCategory
='', auxRef
='', auxCycle
='', vendPortionArrear
=0.0, payCycle
='', fixedAmount
=0.0, AuxiliaryAccounts
=None, CustomerAgreement
=None, *args
, **kw_args
):
24 """Initialises a new 'AuxiliaryAgreement' instance.
26 @param arrearsInterest: The interest per annum to be charged prorata on AuxiliaryAccount.dueArrears at the end of each payCycle.
27 @param vendPortion: The percentage of the transaction amount that must be collected from each vending transaction towards settlement of this AuxiliaryAgreement when payments are not in arrears. Note that there may be multiple tokens vended per vending transaction, but this is not relevant.
28 @param minAmount: The minimum amount that must be paid at any transaction towards settling this AuxiliryAgreement or reducing the balance.
29 @param auxPriorityCode: The coded priority indicating the priority that this AuxiliaryAgreement has above other AuxiliaryAgreements (associated with the same customer agreement) when it comes to competing for settlement from a payment transaction or token purchase.
30 @param subCategory: Sub-category of this AuxiliaryAgreement as sub-classification of the inherited 'category'.
31 @param auxRef: A local reference to this AuxiliaryAgreement defined in the context of the implementation and not related to IdentifiedObject.mRID.
32 @param auxCycle: The frequency for automatically recurring auxiliary charges, where AuxiliaryAccount.initialCharge is recursively added to AuxiliaryAccount.dueCurrent at the start of each auxCycle. For example: on a specified date and time; hourly; daily; weekly; monthly; 3-monthly; 6-monthly; 12-monthly; etc.
33 @param vendPortionArrear: The percentage of the transaction amount that must be collected from each vending transaction towards settlement of this AuxiliaryAgreement when payments are in arrears. Note that there may be multiple tokens vended per vending transaction, but this is not relevant.
34 @param payCycle: The contractually expected payment frequency (by the customer). Examples are: ad-hoc; on specified date; hourly, daily, weekly, monthly. etc.
35 @param fixedAmount: The fixed amount that must be collected from each vending transaction towards settlement of this AuxiliaryAgreement. Note that there may be multiple tokens vended per vending transaction, but this is not relevant.
36 @param AuxiliaryAccounts: All auxiliary accounts regulated by this agreement.
37 @param CustomerAgreement: Customer agreement this (non-service related) auxiliary agreement refers to.
39 #: The interest per annum to be charged prorata on AuxiliaryAccount.dueArrears at the end of each payCycle.
40 self
.arrearsInterest
= arrearsInterest
42 #: The percentage of the transaction amount that must be collected from each vending transaction towards settlement of this AuxiliaryAgreement when payments are not in arrears. Note that there may be multiple tokens vended per vending transaction, but this is not relevant.
43 self
.vendPortion
= vendPortion
45 #: The minimum amount that must be paid at any transaction towards settling this AuxiliryAgreement or reducing the balance.
46 self
.minAmount
= minAmount
48 #: The coded priority indicating the priority that this AuxiliaryAgreement has above other AuxiliaryAgreements (associated with the same customer agreement) when it comes to competing for settlement from a payment transaction or token purchase.
49 self
.auxPriorityCode
= auxPriorityCode
51 #: Sub-category of this AuxiliaryAgreement as sub-classification of the inherited 'category'.
52 self
.subCategory
= subCategory
54 #: A local reference to this AuxiliaryAgreement defined in the context of the implementation and not related to IdentifiedObject.mRID.
57 #: The frequency for automatically recurring auxiliary charges, where AuxiliaryAccount.initialCharge is recursively added to AuxiliaryAccount.dueCurrent at the start of each auxCycle. For example: on a specified date and time; hourly; daily; weekly; monthly; 3-monthly; 6-monthly; 12-monthly; etc.
58 self
.auxCycle
= auxCycle
60 #: The percentage of the transaction amount that must be collected from each vending transaction towards settlement of this AuxiliaryAgreement when payments are in arrears. Note that there may be multiple tokens vended per vending transaction, but this is not relevant.
61 self
.vendPortionArrear
= vendPortionArrear
63 #: The contractually expected payment frequency (by the customer). Examples are: ad-hoc; on specified date; hourly, daily, weekly, monthly. etc.
64 self
.payCycle
= payCycle
66 #: The fixed amount that must be collected from each vending transaction towards settlement of this AuxiliaryAgreement. Note that there may be multiple tokens vended per vending transaction, but this is not relevant.
67 self
.fixedAmount
= fixedAmount
69 self
._AuxiliaryAccounts
= []
70 self
.AuxiliaryAccounts
= [] if AuxiliaryAccounts
is None else AuxiliaryAccounts
72 self
._CustomerAgreement
= None
73 self
.CustomerAgreement
= CustomerAgreement
75 super(AuxiliaryAgreement
, self
).__init
__(*args
, **kw_args
)
77 _attrs
= ["arrearsInterest", "vendPortion", "minAmount", "auxPriorityCode", "subCategory", "auxRef", "auxCycle", "vendPortionArrear", "payCycle", "fixedAmount"]
78 _attr_types
= {"arrearsInterest": float, "vendPortion": float, "minAmount": float, "auxPriorityCode": str, "subCategory": str, "auxRef": str, "auxCycle": str, "vendPortionArrear": float, "payCycle": str, "fixedAmount": float}
79 _defaults
= {"arrearsInterest": 0.0, "vendPortion": 0.0, "minAmount": 0.0, "auxPriorityCode": '', "subCategory": '', "auxRef": '', "auxCycle": '', "vendPortionArrear": 0.0, "payCycle": '', "fixedAmount": 0.0}
81 _refs
= ["AuxiliaryAccounts", "CustomerAgreement"]
82 _many_refs
= ["AuxiliaryAccounts"]
84 def getAuxiliaryAccounts(self
):
85 """All auxiliary accounts regulated by this agreement.
87 return self
._AuxiliaryAccounts
89 def setAuxiliaryAccounts(self
, value
):
90 for x
in self
._AuxiliaryAccounts
:
91 x
.AuxiliaryAgreement
= None
93 y
._AuxiliaryAgreement
= self
94 self
._AuxiliaryAccounts
= value
96 AuxiliaryAccounts
= property(getAuxiliaryAccounts
, setAuxiliaryAccounts
)
98 def addAuxiliaryAccounts(self
, *AuxiliaryAccounts
):
99 for obj
in AuxiliaryAccounts
:
100 obj
.AuxiliaryAgreement
= self
102 def removeAuxiliaryAccounts(self
, *AuxiliaryAccounts
):
103 for obj
in AuxiliaryAccounts
:
104 obj
.AuxiliaryAgreement
= None
106 def getCustomerAgreement(self
):
107 """Customer agreement this (non-service related) auxiliary agreement refers to.
109 return self
._CustomerAgreement
111 def setCustomerAgreement(self
, value
):
112 if self
._CustomerAgreement
is not None:
113 filtered
= [x
for x
in self
.CustomerAgreement
.AuxiliaryAgreements
if x
!= self
]
114 self
._CustomerAgreement
._AuxiliaryAgreements
= filtered
116 self
._CustomerAgreement
= value
117 if self
._CustomerAgreement
is not None:
118 if self
not in self
._CustomerAgreement
._AuxiliaryAgreements
:
119 self
._CustomerAgreement
._AuxiliaryAgreements
.append(self
)
121 CustomerAgreement
= property(getCustomerAgreement
, setCustomerAgreement
)