Update README.rst
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / Receipt.py
blob1d8617e190e55cfda808ffb40f48ad49ede1c7f4
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 Receipt(IdentifiedObject):
24 """Record of total receipted payment from customer.
25 """
27 def __init__(self, isBankable=False, CashierShift=None, Tenders=None, VendorShift=None, Transactions=None, line=None, *args, **kw_args):
28 """Initialises a new 'Receipt' instance.
30 @param isBankable: True if this receipted payment is manually bankable, otherwise it is an electronic funds transfer.
31 @param CashierShift: Cashier shift during which this receipt was recorded.
32 @param Tenders: All payments received in the form of tenders recorded by this receipt.
33 @param VendorShift: Vendor shift during which this receipt was recorded.
34 @param Transactions: All transactions recorded for this receipted payment.
35 @param line: Receipted amount with rounding, date and note.
36 """
37 #: True if this receipted payment is manually bankable, otherwise it is an electronic funds transfer.
38 self.isBankable = isBankable
40 self._CashierShift = None
41 self.CashierShift = CashierShift
43 self._Tenders = []
44 self.Tenders = [] if Tenders is None else Tenders
46 self._VendorShift = None
47 self.VendorShift = VendorShift
49 self._Transactions = []
50 self.Transactions = [] if Transactions is None else Transactions
52 self.line = line
54 super(Receipt, self).__init__(*args, **kw_args)
56 _attrs = ["isBankable"]
57 _attr_types = {"isBankable": bool}
58 _defaults = {"isBankable": False}
59 _enums = {}
60 _refs = ["CashierShift", "Tenders", "VendorShift", "Transactions", "line"]
61 _many_refs = ["Tenders", "Transactions"]
63 def getCashierShift(self):
64 """Cashier shift during which this receipt was recorded.
65 """
66 return self._CashierShift
68 def setCashierShift(self, value):
69 if self._CashierShift is not None:
70 filtered = [x for x in self.CashierShift.Receipts if x != self]
71 self._CashierShift._Receipts = filtered
73 self._CashierShift = value
74 if self._CashierShift is not None:
75 if self not in self._CashierShift._Receipts:
76 self._CashierShift._Receipts.append(self)
78 CashierShift = property(getCashierShift, setCashierShift)
80 def getTenders(self):
81 """All payments received in the form of tenders recorded by this receipt.
82 """
83 return self._Tenders
85 def setTenders(self, value):
86 for x in self._Tenders:
87 x.Receipt = None
88 for y in value:
89 y._Receipt = self
90 self._Tenders = value
92 Tenders = property(getTenders, setTenders)
94 def addTenders(self, *Tenders):
95 for obj in Tenders:
96 obj.Receipt = self
98 def removeTenders(self, *Tenders):
99 for obj in Tenders:
100 obj.Receipt = None
102 def getVendorShift(self):
103 """Vendor shift during which this receipt was recorded.
105 return self._VendorShift
107 def setVendorShift(self, value):
108 if self._VendorShift is not None:
109 filtered = [x for x in self.VendorShift.Receipts if x != self]
110 self._VendorShift._Receipts = filtered
112 self._VendorShift = value
113 if self._VendorShift is not None:
114 if self not in self._VendorShift._Receipts:
115 self._VendorShift._Receipts.append(self)
117 VendorShift = property(getVendorShift, setVendorShift)
119 def getTransactions(self):
120 """All transactions recorded for this receipted payment.
122 return self._Transactions
124 def setTransactions(self, value):
125 for x in self._Transactions:
126 x.Receipt = None
127 for y in value:
128 y._Receipt = self
129 self._Transactions = value
131 Transactions = property(getTransactions, setTransactions)
133 def addTransactions(self, *Transactions):
134 for obj in Transactions:
135 obj.Receipt = self
137 def removeTransactions(self, *Transactions):
138 for obj in Transactions:
139 obj.Receipt = None
141 # Receipted amount with rounding, date and note.
142 line = None