Update README.rst
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / AuxiliaryAgreement.py
bloba63498c987c88ec707f507487aded691c63828d2
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.Agreement import Agreement
23 class AuxiliaryAgreement(Agreement):
24 """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.
25 """
27 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):
28 """Initialises a new 'AuxiliaryAgreement' instance.
30 @param arrearsInterest: The interest per annum to be charged prorata on AuxiliaryAccount.dueArrears at the end of each payCycle.
31 @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.
32 @param minAmount: The minimum amount that must be paid at any transaction towards settling this AuxiliryAgreement or reducing the balance.
33 @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.
34 @param subCategory: Sub-category of this AuxiliaryAgreement as sub-classification of the inherited 'category'.
35 @param auxRef: A local reference to this AuxiliaryAgreement defined in the context of the implementation and not related to IdentifiedObject.mRID.
36 @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.
37 @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.
38 @param payCycle: The contractually expected payment frequency (by the customer). Examples are: ad-hoc; on specified date; hourly, daily, weekly, monthly. etc.
39 @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.
40 @param AuxiliaryAccounts: All auxiliary accounts regulated by this agreement.
41 @param CustomerAgreement: Customer agreement this (non-service related) auxiliary agreement refers to.
42 """
43 #: The interest per annum to be charged prorata on AuxiliaryAccount.dueArrears at the end of each payCycle.
44 self.arrearsInterest = arrearsInterest
46 #: 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.
47 self.vendPortion = vendPortion
49 #: The minimum amount that must be paid at any transaction towards settling this AuxiliryAgreement or reducing the balance.
50 self.minAmount = minAmount
52 #: 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.
53 self.auxPriorityCode = auxPriorityCode
55 #: Sub-category of this AuxiliaryAgreement as sub-classification of the inherited 'category'.
56 self.subCategory = subCategory
58 #: A local reference to this AuxiliaryAgreement defined in the context of the implementation and not related to IdentifiedObject.mRID.
59 self.auxRef = auxRef
61 #: 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.
62 self.auxCycle = auxCycle
64 #: 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.
65 self.vendPortionArrear = vendPortionArrear
67 #: The contractually expected payment frequency (by the customer). Examples are: ad-hoc; on specified date; hourly, daily, weekly, monthly. etc.
68 self.payCycle = payCycle
70 #: 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.
71 self.fixedAmount = fixedAmount
73 self._AuxiliaryAccounts = []
74 self.AuxiliaryAccounts = [] if AuxiliaryAccounts is None else AuxiliaryAccounts
76 self._CustomerAgreement = None
77 self.CustomerAgreement = CustomerAgreement
79 super(AuxiliaryAgreement, self).__init__(*args, **kw_args)
81 _attrs = ["arrearsInterest", "vendPortion", "minAmount", "auxPriorityCode", "subCategory", "auxRef", "auxCycle", "vendPortionArrear", "payCycle", "fixedAmount"]
82 _attr_types = {"arrearsInterest": float, "vendPortion": float, "minAmount": float, "auxPriorityCode": str, "subCategory": str, "auxRef": str, "auxCycle": str, "vendPortionArrear": float, "payCycle": str, "fixedAmount": float}
83 _defaults = {"arrearsInterest": 0.0, "vendPortion": 0.0, "minAmount": 0.0, "auxPriorityCode": '', "subCategory": '', "auxRef": '', "auxCycle": '', "vendPortionArrear": 0.0, "payCycle": '', "fixedAmount": 0.0}
84 _enums = {}
85 _refs = ["AuxiliaryAccounts", "CustomerAgreement"]
86 _many_refs = ["AuxiliaryAccounts"]
88 def getAuxiliaryAccounts(self):
89 """All auxiliary accounts regulated by this agreement.
90 """
91 return self._AuxiliaryAccounts
93 def setAuxiliaryAccounts(self, value):
94 for x in self._AuxiliaryAccounts:
95 x.AuxiliaryAgreement = None
96 for y in value:
97 y._AuxiliaryAgreement = self
98 self._AuxiliaryAccounts = value
100 AuxiliaryAccounts = property(getAuxiliaryAccounts, setAuxiliaryAccounts)
102 def addAuxiliaryAccounts(self, *AuxiliaryAccounts):
103 for obj in AuxiliaryAccounts:
104 obj.AuxiliaryAgreement = self
106 def removeAuxiliaryAccounts(self, *AuxiliaryAccounts):
107 for obj in AuxiliaryAccounts:
108 obj.AuxiliaryAgreement = None
110 def getCustomerAgreement(self):
111 """Customer agreement this (non-service related) auxiliary agreement refers to.
113 return self._CustomerAgreement
115 def setCustomerAgreement(self, value):
116 if self._CustomerAgreement is not None:
117 filtered = [x for x in self.CustomerAgreement.AuxiliaryAgreements if x != self]
118 self._CustomerAgreement._AuxiliaryAgreements = filtered
120 self._CustomerAgreement = value
121 if self._CustomerAgreement is not None:
122 if self not in self._CustomerAgreement._AuxiliaryAgreements:
123 self._CustomerAgreement._AuxiliaryAgreements.append(self)
125 CustomerAgreement = property(getCustomerAgreement, setCustomerAgreement)