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
.IEC61970
.Core
.IdentifiedObject
import IdentifiedObject
19 class Transaction(IdentifiedObject
):
20 """The record of details of payment for service or token sale.
23 def __init__(self
, kind
="diversePayment", serviceUnitsEnergy
=0.0, diverseReference
='', receiverReference
='', donorReference
='', serviceUnitsError
=0.0, reversedId
='', PricingStructure
=None, UserAttributes
=None, CustomerAccount
=None, CashierShift
=None, VendorShift
=None, MeterAsset
=None, AuxiliaryAccount
=None, line
=None, Receipt
=None, *args
, **kw_args
):
24 """Initialises a new 'Transaction' instance.
26 @param kind: Kind of transaction. Values are: "diversePayment", "tokenSalePayment", "serviceChargePayment", "other", "transactionReversal", "taxChargePayment", "meterConfigurationToken", "accountPayment", "tokenFreeIssue", "tokenExchange", "tokenCancellation", "tokenGrant", "auxiliaryChargePayment"
27 @param serviceUnitsEnergy: Actual amount of service units that is being paid for.
28 @param diverseReference: Formal reference for use with diverse payment (traffic fine for example).
29 @param receiverReference: Reference to the entity that is the recipient of 'amount' (for example, supplier for service charge payment; or tax receiver for VAT).
30 @param donorReference: Reference to the entity that is the source of 'amount' (for example: customer for token purchase; or supplier for free issue token).
31 @param serviceUnitsError: Number of service units not reflected in 'serviceUnitsEnergy' due to process rounding or truncating errors.
32 @param reversedId: (if 'kind' is transactionReversal) Reference to the original transaction that is being reversed by this transaction.
33 @param PricingStructure: Pricing structure applicable for this transaction.
34 @param UserAttributes: All snapshots of meter parameters recorded at the time of this transaction. Use 'name' and 'value.value' attributes to specify name and value of a parameter from meter.
35 @param CustomerAccount: Customer account for this payment transaction.
36 @param CashierShift: Cashier shift during which this transaction was recorded.
37 @param VendorShift: Vendor shift during which this transaction was recorded.
38 @param MeterAsset: Meter asset for this vending transaction.
39 @param AuxiliaryAccount: Auxiliary account for this payment transaction.
40 @param line: Transaction amount, rounding, date and note for this transaction line.
41 @param Receipt: The receipted payment for which this transaction has been recorded.
43 #: Kind of transaction. Values are: "diversePayment", "tokenSalePayment", "serviceChargePayment", "other", "transactionReversal", "taxChargePayment", "meterConfigurationToken", "accountPayment", "tokenFreeIssue", "tokenExchange", "tokenCancellation", "tokenGrant", "auxiliaryChargePayment"
46 #: Actual amount of service units that is being paid for.
47 self
.serviceUnitsEnergy
= serviceUnitsEnergy
49 #: Formal reference for use with diverse payment (traffic fine for example).
50 self
.diverseReference
= diverseReference
52 #: Reference to the entity that is the recipient of 'amount' (for example, supplier for service charge payment; or tax receiver for VAT).
53 self
.receiverReference
= receiverReference
55 #: Reference to the entity that is the source of 'amount' (for example: customer for token purchase; or supplier for free issue token).
56 self
.donorReference
= donorReference
58 #: Number of service units not reflected in 'serviceUnitsEnergy' due to process rounding or truncating errors.
59 self
.serviceUnitsError
= serviceUnitsError
61 #: (if 'kind' is transactionReversal) Reference to the original transaction that is being reversed by this transaction.
62 self
.reversedId
= reversedId
64 self
._PricingStructure
= None
65 self
.PricingStructure
= PricingStructure
67 self
._UserAttributes
= []
68 self
.UserAttributes
= [] if UserAttributes
is None else UserAttributes
70 self
._CustomerAccount
= None
71 self
.CustomerAccount
= CustomerAccount
73 self
._CashierShift
= None
74 self
.CashierShift
= CashierShift
76 self
._VendorShift
= None
77 self
.VendorShift
= VendorShift
79 self
._MeterAsset
= None
80 self
.MeterAsset
= MeterAsset
82 self
._AuxiliaryAccount
= None
83 self
.AuxiliaryAccount
= AuxiliaryAccount
88 self
.Receipt
= Receipt
90 super(Transaction
, self
).__init
__(*args
, **kw_args
)
92 _attrs
= ["kind", "serviceUnitsEnergy", "diverseReference", "receiverReference", "donorReference", "serviceUnitsError", "reversedId"]
93 _attr_types
= {"kind": str, "serviceUnitsEnergy": float, "diverseReference": str, "receiverReference": str, "donorReference": str, "serviceUnitsError": float, "reversedId": str}
94 _defaults
= {"kind": "diversePayment", "serviceUnitsEnergy": 0.0, "diverseReference": '', "receiverReference": '', "donorReference": '', "serviceUnitsError": 0.0, "reversedId": ''}
95 _enums
= {"kind": "TransactionKind"}
96 _refs
= ["PricingStructure", "UserAttributes", "CustomerAccount", "CashierShift", "VendorShift", "MeterAsset", "AuxiliaryAccount", "line", "Receipt"]
97 _many_refs
= ["UserAttributes"]
99 def getPricingStructure(self
):
100 """Pricing structure applicable for this transaction.
102 return self
._PricingStructure
104 def setPricingStructure(self
, value
):
105 if self
._PricingStructure
is not None:
106 filtered
= [x
for x
in self
.PricingStructure
.Transactions
if x
!= self
]
107 self
._PricingStructure
._Transactions
= filtered
109 self
._PricingStructure
= value
110 if self
._PricingStructure
is not None:
111 if self
not in self
._PricingStructure
._Transactions
:
112 self
._PricingStructure
._Transactions
.append(self
)
114 PricingStructure
= property(getPricingStructure
, setPricingStructure
)
116 def getUserAttributes(self
):
117 """All snapshots of meter parameters recorded at the time of this transaction. Use 'name' and 'value.value' attributes to specify name and value of a parameter from meter.
119 return self
._UserAttributes
121 def setUserAttributes(self
, value
):
122 for x
in self
._UserAttributes
:
125 y
._Transaction
= self
126 self
._UserAttributes
= value
128 UserAttributes
= property(getUserAttributes
, setUserAttributes
)
130 def addUserAttributes(self
, *UserAttributes
):
131 for obj
in UserAttributes
:
132 obj
.Transaction
= self
134 def removeUserAttributes(self
, *UserAttributes
):
135 for obj
in UserAttributes
:
136 obj
.Transaction
= None
138 def getCustomerAccount(self
):
139 """Customer account for this payment transaction.
141 return self
._CustomerAccount
143 def setCustomerAccount(self
, value
):
144 if self
._CustomerAccount
is not None:
145 filtered
= [x
for x
in self
.CustomerAccount
.PaymentTransactions
if x
!= self
]
146 self
._CustomerAccount
._PaymentTransactions
= filtered
148 self
._CustomerAccount
= value
149 if self
._CustomerAccount
is not None:
150 if self
not in self
._CustomerAccount
._PaymentTransactions
:
151 self
._CustomerAccount
._PaymentTransactions
.append(self
)
153 CustomerAccount
= property(getCustomerAccount
, setCustomerAccount
)
155 def getCashierShift(self
):
156 """Cashier shift during which this transaction was recorded.
158 return self
._CashierShift
160 def setCashierShift(self
, value
):
161 if self
._CashierShift
is not None:
162 filtered
= [x
for x
in self
.CashierShift
.Transactions
if x
!= self
]
163 self
._CashierShift
._Transactions
= filtered
165 self
._CashierShift
= value
166 if self
._CashierShift
is not None:
167 if self
not in self
._CashierShift
._Transactions
:
168 self
._CashierShift
._Transactions
.append(self
)
170 CashierShift
= property(getCashierShift
, setCashierShift
)
172 def getVendorShift(self
):
173 """Vendor shift during which this transaction was recorded.
175 return self
._VendorShift
177 def setVendorShift(self
, value
):
178 if self
._VendorShift
is not None:
179 filtered
= [x
for x
in self
.VendorShift
.Transactions
if x
!= self
]
180 self
._VendorShift
._Transactions
= filtered
182 self
._VendorShift
= value
183 if self
._VendorShift
is not None:
184 if self
not in self
._VendorShift
._Transactions
:
185 self
._VendorShift
._Transactions
.append(self
)
187 VendorShift
= property(getVendorShift
, setVendorShift
)
189 def getMeterAsset(self
):
190 """Meter asset for this vending transaction.
192 return self
._MeterAsset
194 def setMeterAsset(self
, value
):
195 if self
._MeterAsset
is not None:
196 filtered
= [x
for x
in self
.MeterAsset
.VendingTransactions
if x
!= self
]
197 self
._MeterAsset
._VendingTransactions
= filtered
199 self
._MeterAsset
= value
200 if self
._MeterAsset
is not None:
201 if self
not in self
._MeterAsset
._VendingTransactions
:
202 self
._MeterAsset
._VendingTransactions
.append(self
)
204 MeterAsset
= property(getMeterAsset
, setMeterAsset
)
206 def getAuxiliaryAccount(self
):
207 """Auxiliary account for this payment transaction.
209 return self
._AuxiliaryAccount
211 def setAuxiliaryAccount(self
, value
):
212 if self
._AuxiliaryAccount
is not None:
213 filtered
= [x
for x
in self
.AuxiliaryAccount
.PaymentTransactions
if x
!= self
]
214 self
._AuxiliaryAccount
._PaymentTransactions
= filtered
216 self
._AuxiliaryAccount
= value
217 if self
._AuxiliaryAccount
is not None:
218 if self
not in self
._AuxiliaryAccount
._PaymentTransactions
:
219 self
._AuxiliaryAccount
._PaymentTransactions
.append(self
)
221 AuxiliaryAccount
= property(getAuxiliaryAccount
, setAuxiliaryAccount
)
223 # Transaction amount, rounding, date and note for this transaction line.
226 def getReceipt(self
):
227 """The receipted payment for which this transaction has been recorded.
231 def setReceipt(self
, value
):
232 if self
._Receipt
is not None:
233 filtered
= [x
for x
in self
.Receipt
.Transactions
if x
!= self
]
234 self
._Receipt
._Transactions
= filtered
236 self
._Receipt
= value
237 if self
._Receipt
is not None:
238 if self
not in self
._Receipt
._Transactions
:
239 self
._Receipt
._Transactions
.append(self
)
241 Receipt
= property(getReceipt
, setReceipt
)