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
.IEC61968
.PaymentMetering
.Shift
import Shift
19 class CashierShift(Shift
):
20 """The operating shift for a cashier, during which he may transact against the CashierShift, subject to VendorShift being open.
23 def __init__(self
, cashFloat
=0.0, Receipts
=None, Transactions
=None, Cashier
=None, PointOfSale
=None, *args
, **kw_args
):
24 """Initialises a new 'CashierShift' instance.
26 @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.
27 @param Receipts: All Receipts recorded for this Shift.
29 @param Cashier: Cashier operating this shift.
30 @param PointOfSale: Point of sale that is in operation during this shift.
32 #: 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.
33 self
.cashFloat
= cashFloat
36 self
.Receipts
= [] if Receipts
is None else Receipts
38 self
._Transactions
= []
39 self
.Transactions
= [] if Transactions
is None else Transactions
42 self
.Cashier
= Cashier
44 self
._PointOfSale
= None
45 self
.PointOfSale
= PointOfSale
47 super(CashierShift
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["cashFloat"]
50 _attr_types
= {"cashFloat": float}
51 _defaults
= {"cashFloat": 0.0}
53 _refs
= ["Receipts", "Transactions", "Cashier", "PointOfSale"]
54 _many_refs
= ["Receipts", "Transactions"]
56 def getReceipts(self
):
57 """All Receipts recorded for this Shift.
61 def setReceipts(self
, value
):
62 for x
in self
._Receipts
:
63 x
._CashierShift
= None
65 y
._CashierShift
= self
66 self
._Receipts
= value
68 Receipts
= property(getReceipts
, setReceipts
)
70 def addReceipts(self
, *Receipts
):
72 obj
._CashierShift
= self
73 self
._Receipts
.append(obj
)
75 def removeReceipts(self
, *Receipts
):
77 obj
._CashierShift
= None
78 self
._Receipts
.remove(obj
)
80 def getTransactions(self
):
82 return self
._Transactions
84 def setTransactions(self
, value
):
85 for x
in self
._Transactions
:
86 x
._CashierShift
= None
88 y
._CashierShift
= self
89 self
._Transactions
= value
91 Transactions
= property(getTransactions
, setTransactions
)
93 def addTransactions(self
, *Transactions
):
94 for obj
in Transactions
:
95 obj
._CashierShift
= self
96 self
._Transactions
.append(obj
)
98 def removeTransactions(self
, *Transactions
):
99 for obj
in Transactions
:
100 obj
._CashierShift
= None
101 self
._Transactions
.remove(obj
)
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 self
._Cashier
._CashierShifts
.append(self
)
117 Cashier
= property(getCashier
, setCashier
)
119 def getPointOfSale(self
):
120 """Point of sale that is in operation during this shift.
122 return self
._PointOfSale
124 def setPointOfSale(self
, value
):
125 if self
._PointOfSale
is not None:
126 filtered
= [x
for x
in self
.PointOfSale
.CashierShifts
if x
!= self
]
127 self
._PointOfSale
._CashierShifts
= filtered
129 self
._PointOfSale
= value
130 if self
._PointOfSale
is not None:
131 self
._PointOfSale
._CashierShifts
.append(self
)
133 PointOfSale
= property(getPointOfSale
, setPointOfSale
)