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 Receipt(IdentifiedObject
):
20 """Record of total receipted payment from customer.
23 def __init__(self
, isBankable
=False, CashierShift
=None, Tenders
=None, VendorShift
=None, Transactions
=None, line
=None, *args
, **kw_args
):
24 """Initialises a new 'Receipt' instance.
26 @param isBankable: True if this receipted payment is manually bankable, otherwise it is an electronic funds transfer.
27 @param CashierShift: Cashier shift during which this receipt was recorded.
28 @param Tenders: All payments received in the form of tenders recorded by this receipt.
29 @param VendorShift: Vendor shift during which this receipt was recorded.
30 @param Transactions: All transactions recorded for this receipted payment.
31 @param line: Receipted amount with rounding, date and note.
33 #: True if this receipted payment is manually bankable, otherwise it is an electronic funds transfer.
34 self
.isBankable
= isBankable
36 self
._CashierShift
= None
37 self
.CashierShift
= CashierShift
40 self
.Tenders
= [] if Tenders
is None else Tenders
42 self
._VendorShift
= None
43 self
.VendorShift
= VendorShift
45 self
._Transactions
= []
46 self
.Transactions
= [] if Transactions
is None else Transactions
50 super(Receipt
, self
).__init
__(*args
, **kw_args
)
52 _attrs
= ["isBankable"]
53 _attr_types
= {"isBankable": bool}
54 _defaults
= {"isBankable": False}
56 _refs
= ["CashierShift", "Tenders", "VendorShift", "Transactions", "line"]
57 _many_refs
= ["Tenders", "Transactions"]
59 def getCashierShift(self
):
60 """Cashier shift during which this receipt was recorded.
62 return self
._CashierShift
64 def setCashierShift(self
, value
):
65 if self
._CashierShift
is not None:
66 filtered
= [x
for x
in self
.CashierShift
.Receipts
if x
!= self
]
67 self
._CashierShift
._Receipts
= filtered
69 self
._CashierShift
= value
70 if self
._CashierShift
is not None:
71 if self
not in self
._CashierShift
._Receipts
:
72 self
._CashierShift
._Receipts
.append(self
)
74 CashierShift
= property(getCashierShift
, setCashierShift
)
77 """All payments received in the form of tenders recorded by this receipt.
81 def setTenders(self
, value
):
82 for x
in self
._Tenders
:
88 Tenders
= property(getTenders
, setTenders
)
90 def addTenders(self
, *Tenders
):
94 def removeTenders(self
, *Tenders
):
98 def getVendorShift(self
):
99 """Vendor shift during which this receipt was recorded.
101 return self
._VendorShift
103 def setVendorShift(self
, value
):
104 if self
._VendorShift
is not None:
105 filtered
= [x
for x
in self
.VendorShift
.Receipts
if x
!= self
]
106 self
._VendorShift
._Receipts
= filtered
108 self
._VendorShift
= value
109 if self
._VendorShift
is not None:
110 if self
not in self
._VendorShift
._Receipts
:
111 self
._VendorShift
._Receipts
.append(self
)
113 VendorShift
= property(getVendorShift
, setVendorShift
)
115 def getTransactions(self
):
116 """All transactions recorded for this receipted payment.
118 return self
._Transactions
120 def setTransactions(self
, value
):
121 for x
in self
._Transactions
:
125 self
._Transactions
= value
127 Transactions
= property(getTransactions
, setTransactions
)
129 def addTransactions(self
, *Transactions
):
130 for obj
in Transactions
:
133 def removeTransactions(self
, *Transactions
):
134 for obj
in Transactions
:
137 # Receipted amount with rounding, date and note.