Update README.rst
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / Transaction.py
blobd9948a8a782814b73e95073fd9a958f73dd510f0
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.IEC61970.Core.IdentifiedObject import IdentifiedObject
23 class Transaction(IdentifiedObject):
24 """The record of details of payment for service or token sale.
25 """
27 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):
28 """Initialises a new 'Transaction' instance.
30 @param kind: Kind of transaction. Values are: "diversePayment", "tokenSalePayment", "serviceChargePayment", "other", "transactionReversal", "taxChargePayment", "meterConfigurationToken", "accountPayment", "tokenFreeIssue", "tokenExchange", "tokenCancellation", "tokenGrant", "auxiliaryChargePayment"
31 @param serviceUnitsEnergy: Actual amount of service units that is being paid for.
32 @param diverseReference: Formal reference for use with diverse payment (traffic fine for example).
33 @param receiverReference: Reference to the entity that is the recipient of 'amount' (for example, supplier for service charge payment; or tax receiver for VAT).
34 @param donorReference: Reference to the entity that is the source of 'amount' (for example: customer for token purchase; or supplier for free issue token).
35 @param serviceUnitsError: Number of service units not reflected in 'serviceUnitsEnergy' due to process rounding or truncating errors.
36 @param reversedId: (if 'kind' is transactionReversal) Reference to the original transaction that is being reversed by this transaction.
37 @param PricingStructure: Pricing structure applicable for this transaction.
38 @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.
39 @param CustomerAccount: Customer account for this payment transaction.
40 @param CashierShift: Cashier shift during which this transaction was recorded.
41 @param VendorShift: Vendor shift during which this transaction was recorded.
42 @param MeterAsset: Meter asset for this vending transaction.
43 @param AuxiliaryAccount: Auxiliary account for this payment transaction.
44 @param line: Transaction amount, rounding, date and note for this transaction line.
45 @param Receipt: The receipted payment for which this transaction has been recorded.
46 """
47 #: Kind of transaction. Values are: "diversePayment", "tokenSalePayment", "serviceChargePayment", "other", "transactionReversal", "taxChargePayment", "meterConfigurationToken", "accountPayment", "tokenFreeIssue", "tokenExchange", "tokenCancellation", "tokenGrant", "auxiliaryChargePayment"
48 self.kind = kind
50 #: Actual amount of service units that is being paid for.
51 self.serviceUnitsEnergy = serviceUnitsEnergy
53 #: Formal reference for use with diverse payment (traffic fine for example).
54 self.diverseReference = diverseReference
56 #: Reference to the entity that is the recipient of 'amount' (for example, supplier for service charge payment; or tax receiver for VAT).
57 self.receiverReference = receiverReference
59 #: Reference to the entity that is the source of 'amount' (for example: customer for token purchase; or supplier for free issue token).
60 self.donorReference = donorReference
62 #: Number of service units not reflected in 'serviceUnitsEnergy' due to process rounding or truncating errors.
63 self.serviceUnitsError = serviceUnitsError
65 #: (if 'kind' is transactionReversal) Reference to the original transaction that is being reversed by this transaction.
66 self.reversedId = reversedId
68 self._PricingStructure = None
69 self.PricingStructure = PricingStructure
71 self._UserAttributes = []
72 self.UserAttributes = [] if UserAttributes is None else UserAttributes
74 self._CustomerAccount = None
75 self.CustomerAccount = CustomerAccount
77 self._CashierShift = None
78 self.CashierShift = CashierShift
80 self._VendorShift = None
81 self.VendorShift = VendorShift
83 self._MeterAsset = None
84 self.MeterAsset = MeterAsset
86 self._AuxiliaryAccount = None
87 self.AuxiliaryAccount = AuxiliaryAccount
89 self.line = line
91 self._Receipt = None
92 self.Receipt = Receipt
94 super(Transaction, self).__init__(*args, **kw_args)
96 _attrs = ["kind", "serviceUnitsEnergy", "diverseReference", "receiverReference", "donorReference", "serviceUnitsError", "reversedId"]
97 _attr_types = {"kind": str, "serviceUnitsEnergy": float, "diverseReference": str, "receiverReference": str, "donorReference": str, "serviceUnitsError": float, "reversedId": str}
98 _defaults = {"kind": "diversePayment", "serviceUnitsEnergy": 0.0, "diverseReference": '', "receiverReference": '', "donorReference": '', "serviceUnitsError": 0.0, "reversedId": ''}
99 _enums = {"kind": "TransactionKind"}
100 _refs = ["PricingStructure", "UserAttributes", "CustomerAccount", "CashierShift", "VendorShift", "MeterAsset", "AuxiliaryAccount", "line", "Receipt"]
101 _many_refs = ["UserAttributes"]
103 def getPricingStructure(self):
104 """Pricing structure applicable for this transaction.
106 return self._PricingStructure
108 def setPricingStructure(self, value):
109 if self._PricingStructure is not None:
110 filtered = [x for x in self.PricingStructure.Transactions if x != self]
111 self._PricingStructure._Transactions = filtered
113 self._PricingStructure = value
114 if self._PricingStructure is not None:
115 if self not in self._PricingStructure._Transactions:
116 self._PricingStructure._Transactions.append(self)
118 PricingStructure = property(getPricingStructure, setPricingStructure)
120 def getUserAttributes(self):
121 """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.
123 return self._UserAttributes
125 def setUserAttributes(self, value):
126 for x in self._UserAttributes:
127 x.Transaction = None
128 for y in value:
129 y._Transaction = self
130 self._UserAttributes = value
132 UserAttributes = property(getUserAttributes, setUserAttributes)
134 def addUserAttributes(self, *UserAttributes):
135 for obj in UserAttributes:
136 obj.Transaction = self
138 def removeUserAttributes(self, *UserAttributes):
139 for obj in UserAttributes:
140 obj.Transaction = None
142 def getCustomerAccount(self):
143 """Customer account for this payment transaction.
145 return self._CustomerAccount
147 def setCustomerAccount(self, value):
148 if self._CustomerAccount is not None:
149 filtered = [x for x in self.CustomerAccount.PaymentTransactions if x != self]
150 self._CustomerAccount._PaymentTransactions = filtered
152 self._CustomerAccount = value
153 if self._CustomerAccount is not None:
154 if self not in self._CustomerAccount._PaymentTransactions:
155 self._CustomerAccount._PaymentTransactions.append(self)
157 CustomerAccount = property(getCustomerAccount, setCustomerAccount)
159 def getCashierShift(self):
160 """Cashier shift during which this transaction was recorded.
162 return self._CashierShift
164 def setCashierShift(self, value):
165 if self._CashierShift is not None:
166 filtered = [x for x in self.CashierShift.Transactions if x != self]
167 self._CashierShift._Transactions = filtered
169 self._CashierShift = value
170 if self._CashierShift is not None:
171 if self not in self._CashierShift._Transactions:
172 self._CashierShift._Transactions.append(self)
174 CashierShift = property(getCashierShift, setCashierShift)
176 def getVendorShift(self):
177 """Vendor shift during which this transaction was recorded.
179 return self._VendorShift
181 def setVendorShift(self, value):
182 if self._VendorShift is not None:
183 filtered = [x for x in self.VendorShift.Transactions if x != self]
184 self._VendorShift._Transactions = filtered
186 self._VendorShift = value
187 if self._VendorShift is not None:
188 if self not in self._VendorShift._Transactions:
189 self._VendorShift._Transactions.append(self)
191 VendorShift = property(getVendorShift, setVendorShift)
193 def getMeterAsset(self):
194 """Meter asset for this vending transaction.
196 return self._MeterAsset
198 def setMeterAsset(self, value):
199 if self._MeterAsset is not None:
200 filtered = [x for x in self.MeterAsset.VendingTransactions if x != self]
201 self._MeterAsset._VendingTransactions = filtered
203 self._MeterAsset = value
204 if self._MeterAsset is not None:
205 if self not in self._MeterAsset._VendingTransactions:
206 self._MeterAsset._VendingTransactions.append(self)
208 MeterAsset = property(getMeterAsset, setMeterAsset)
210 def getAuxiliaryAccount(self):
211 """Auxiliary account for this payment transaction.
213 return self._AuxiliaryAccount
215 def setAuxiliaryAccount(self, value):
216 if self._AuxiliaryAccount is not None:
217 filtered = [x for x in self.AuxiliaryAccount.PaymentTransactions if x != self]
218 self._AuxiliaryAccount._PaymentTransactions = filtered
220 self._AuxiliaryAccount = value
221 if self._AuxiliaryAccount is not None:
222 if self not in self._AuxiliaryAccount._PaymentTransactions:
223 self._AuxiliaryAccount._PaymentTransactions.append(self)
225 AuxiliaryAccount = property(getAuxiliaryAccount, setAuxiliaryAccount)
227 # Transaction amount, rounding, date and note for this transaction line.
228 line = None
230 def getReceipt(self):
231 """The receipted payment for which this transaction has been recorded.
233 return self._Receipt
235 def setReceipt(self, value):
236 if self._Receipt is not None:
237 filtered = [x for x in self.Receipt.Transactions if x != self]
238 self._Receipt._Transactions = filtered
240 self._Receipt = value
241 if self._Receipt is not None:
242 if self not in self._Receipt._Transactions:
243 self._Receipt._Transactions.append(self)
245 Receipt = property(getReceipt, setReceipt)