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
21 from CIM14
.IEC61968
.PaymentMetering
.Shift
import Shift
23 class CashierShift(Shift
):
24 """The operating shift for a cashier, during which he may transact against the CashierShift, subject to VendorShift being open.
27 def __init__(self
, cashFloat
=0.0, Receipts
=None, Transactions
=None, Cashier
=None, PointOfSale
=None, *args
, **kw_args
):
28 """Initialises a new 'CashierShift' instance.
30 @param cashFloat: The amount of cash that the cashier brings with him to start his shift and that he will take away at the end of his shift; i.e. the cash float does not get banked.
31 @param Receipts: All Receipts recorded for this Shift.
33 @param Cashier: Cashier operating this shift.
34 @param PointOfSale: Point of sale that is in operation during this shift.
36 #: The amount of cash that the cashier brings with him to start his shift and that he will take away at the end of his shift; i.e. the cash float does not get banked.
37 self
.cashFloat
= cashFloat
40 self
.Receipts
= [] if Receipts
is None else Receipts
42 self
._Transactions
= []
43 self
.Transactions
= [] if Transactions
is None else Transactions
46 self
.Cashier
= Cashier
48 self
._PointOfSale
= None
49 self
.PointOfSale
= PointOfSale
51 super(CashierShift
, self
).__init
__(*args
, **kw_args
)
53 _attrs
= ["cashFloat"]
54 _attr_types
= {"cashFloat": float}
55 _defaults
= {"cashFloat": 0.0}
57 _refs
= ["Receipts", "Transactions", "Cashier", "PointOfSale"]
58 _many_refs
= ["Receipts", "Transactions"]
60 def getReceipts(self
):
61 """All Receipts recorded for this Shift.
65 def setReceipts(self
, value
):
66 for x
in self
._Receipts
:
69 y
._CashierShift
= self
70 self
._Receipts
= value
72 Receipts
= property(getReceipts
, setReceipts
)
74 def addReceipts(self
, *Receipts
):
76 obj
.CashierShift
= self
78 def removeReceipts(self
, *Receipts
):
80 obj
.CashierShift
= None
82 def getTransactions(self
):
84 return self
._Transactions
86 def setTransactions(self
, value
):
87 for x
in self
._Transactions
:
90 y
._CashierShift
= self
91 self
._Transactions
= value
93 Transactions
= property(getTransactions
, setTransactions
)
95 def addTransactions(self
, *Transactions
):
96 for obj
in Transactions
:
97 obj
.CashierShift
= self
99 def removeTransactions(self
, *Transactions
):
100 for obj
in Transactions
:
101 obj
.CashierShift
= None
103 def getCashier(self
):
104 """Cashier operating this shift.
108 def setCashier(self
, value
):
109 if self
._Cashier
is not None:
110 filtered
= [x
for x
in self
.Cashier
.CashierShifts
if x
!= self
]
111 self
._Cashier
._CashierShifts
= filtered
113 self
._Cashier
= value
114 if self
._Cashier
is not None:
115 if self
not in self
._Cashier
._CashierShifts
:
116 self
._Cashier
._CashierShifts
.append(self
)
118 Cashier
= property(getCashier
, setCashier
)
120 def getPointOfSale(self
):
121 """Point of sale that is in operation during this shift.
123 return self
._PointOfSale
125 def setPointOfSale(self
, value
):
126 if self
._PointOfSale
is not None:
127 filtered
= [x
for x
in self
.PointOfSale
.CashierShifts
if x
!= self
]
128 self
._PointOfSale
._CashierShifts
= filtered
130 self
._PointOfSale
= value
131 if self
._PointOfSale
is not None:
132 if self
not in self
._PointOfSale
._CashierShifts
:
133 self
._PointOfSale
._CashierShifts
.append(self
)
135 PointOfSale
= property(getPointOfSale
, setPointOfSale
)