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 VendorShift(Shift
):
20 """The operating shift for a vendor during which he may transact against the merchant's account. It aggregates transactions and receipts during the shift and periodically debits a merchant account. The totals in VendorShift should always = sum of totals aggregated in all cashier shifts that were open under the particular vendor shift.
23 def __init__(self
, merchantDebitAmount
=0.0, posted
=False, MerchantAccount
=None, Transactions
=None, Receipts
=None, Vendor
=None, *args
, **kw_args
):
24 """Initialises a new 'VendorShift' instance.
26 @param merchantDebitAmount: The amount that is to be debited from the merchant account for this vendor shift. This amount reflects the sum(PaymentTransaction.transactionAmount).
27 @param posted: = true if merchantDebitAmount has been debited from MerchantAccount; typically happens at the end of VendorShift when it closes.
28 @param MerchantAccount: Merchant account this vendor shift periodically debits (based on aggregated transactions).
31 @param Vendor: Vendor that opens and owns this vendor shift.
33 #: The amount that is to be debited from the merchant account for this vendor shift. This amount reflects the sum(PaymentTransaction.transactionAmount).
34 self
.merchantDebitAmount
= merchantDebitAmount
36 #: = true if merchantDebitAmount has been debited from MerchantAccount; typically happens at the end of VendorShift when it closes.
39 self
._MerchantAccount
= None
40 self
.MerchantAccount
= MerchantAccount
42 self
._Transactions
= []
43 self
.Transactions
= [] if Transactions
is None else Transactions
46 self
.Receipts
= [] if Receipts
is None else Receipts
51 super(VendorShift
, self
).__init
__(*args
, **kw_args
)
53 _attrs
= ["merchantDebitAmount", "posted"]
54 _attr_types
= {"merchantDebitAmount": float, "posted": bool}
55 _defaults
= {"merchantDebitAmount": 0.0, "posted": False}
57 _refs
= ["MerchantAccount", "Transactions", "Receipts", "Vendor"]
58 _many_refs
= ["Transactions", "Receipts"]
60 def getMerchantAccount(self
):
61 """Merchant account this vendor shift periodically debits (based on aggregated transactions).
63 return self
._MerchantAccount
65 def setMerchantAccount(self
, value
):
66 if self
._MerchantAccount
is not None:
67 filtered
= [x
for x
in self
.MerchantAccount
.VendorShifts
if x
!= self
]
68 self
._MerchantAccount
._VendorShifts
= filtered
70 self
._MerchantAccount
= value
71 if self
._MerchantAccount
is not None:
72 if self
not in self
._MerchantAccount
._VendorShifts
:
73 self
._MerchantAccount
._VendorShifts
.append(self
)
75 MerchantAccount
= property(getMerchantAccount
, setMerchantAccount
)
77 def getTransactions(self
):
79 return self
._Transactions
81 def setTransactions(self
, value
):
82 for x
in self
._Transactions
:
86 self
._Transactions
= value
88 Transactions
= property(getTransactions
, setTransactions
)
90 def addTransactions(self
, *Transactions
):
91 for obj
in Transactions
:
92 obj
.VendorShift
= self
94 def removeTransactions(self
, *Transactions
):
95 for obj
in Transactions
:
96 obj
.VendorShift
= None
98 def getReceipts(self
):
100 return self
._Receipts
102 def setReceipts(self
, value
):
103 for x
in self
._Receipts
:
106 y
._VendorShift
= self
107 self
._Receipts
= value
109 Receipts
= property(getReceipts
, setReceipts
)
111 def addReceipts(self
, *Receipts
):
113 obj
.VendorShift
= self
115 def removeReceipts(self
, *Receipts
):
117 obj
.VendorShift
= None
120 """Vendor that opens and owns this vendor shift.
124 def setVendor(self
, value
):
125 if self
._Vendor
is not None:
126 filtered
= [x
for x
in self
.Vendor
.VendorShifts
if x
!= self
]
127 self
._Vendor
._VendorShifts
= filtered
130 if self
._Vendor
is not None:
131 if self
not in self
._Vendor
._VendorShifts
:
132 self
._Vendor
._VendorShifts
.append(self
)
134 Vendor
= property(getVendor
, setVendor
)