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
.IEC61970
.Core
.IdentifiedObject
import IdentifiedObject
23 class Vendor(IdentifiedObject
):
24 """The entity that owns PointOfSale and contracts with Cashier to receipt payments and vend tokens using the payment system. Vendor has a private contract with and is managed by Merchant who is a type of Organisation. Vendor is accountable to Merchant for revenue collected, who is in turn accountable to Supplier.
27 def __init__(self
, PointOfSales
=None, MerchantAccount
=None, Cashiers
=None, VendorShifts
=None, *args
, **kw_args
):
28 """Initialises a new 'Vendor' instance.
30 @param PointOfSales: All points of sale this Vendor controls.
31 @param MerchantAccount: Merchant account against which this vendor sells tokens or recept payments.
32 @param Cashiers: All Cachiers managed by this Vendor.
33 @param VendorShifts: All vendor shifts opened and owned by this vendor.
35 self
._PointOfSales
= []
36 self
.PointOfSales
= [] if PointOfSales
is None else PointOfSales
38 self
._MerchantAccount
= None
39 self
.MerchantAccount
= MerchantAccount
42 self
.Cashiers
= [] if Cashiers
is None else Cashiers
44 self
._VendorShifts
= []
45 self
.VendorShifts
= [] if VendorShifts
is None else VendorShifts
47 super(Vendor
, self
).__init
__(*args
, **kw_args
)
53 _refs
= ["PointOfSales", "MerchantAccount", "Cashiers", "VendorShifts"]
54 _many_refs
= ["PointOfSales", "Cashiers", "VendorShifts"]
56 def getPointOfSales(self
):
57 """All points of sale this Vendor controls.
59 return self
._PointOfSales
61 def setPointOfSales(self
, value
):
62 for x
in self
._PointOfSales
:
66 self
._PointOfSales
= value
68 PointOfSales
= property(getPointOfSales
, setPointOfSales
)
70 def addPointOfSales(self
, *PointOfSales
):
71 for obj
in PointOfSales
:
74 def removePointOfSales(self
, *PointOfSales
):
75 for obj
in PointOfSales
:
78 def getMerchantAccount(self
):
79 """Merchant account against which this vendor sells tokens or recept payments.
81 return self
._MerchantAccount
83 def setMerchantAccount(self
, value
):
84 if self
._MerchantAccount
is not None:
85 filtered
= [x
for x
in self
.MerchantAccount
.Vendors
if x
!= self
]
86 self
._MerchantAccount
._Vendors
= filtered
88 self
._MerchantAccount
= value
89 if self
._MerchantAccount
is not None:
90 if self
not in self
._MerchantAccount
._Vendors
:
91 self
._MerchantAccount
._Vendors
.append(self
)
93 MerchantAccount
= property(getMerchantAccount
, setMerchantAccount
)
95 def getCashiers(self
):
96 """All Cachiers managed by this Vendor.
100 def setCashiers(self
, value
):
101 for x
in self
._Cashiers
:
105 self
._Cashiers
= value
107 Cashiers
= property(getCashiers
, setCashiers
)
109 def addCashiers(self
, *Cashiers
):
113 def removeCashiers(self
, *Cashiers
):
117 def getVendorShifts(self
):
118 """All vendor shifts opened and owned by this vendor.
120 return self
._VendorShifts
122 def setVendorShifts(self
, value
):
123 for x
in self
._VendorShifts
:
127 self
._VendorShifts
= value
129 VendorShifts
= property(getVendorShifts
, setVendorShifts
)
131 def addVendorShifts(self
, *VendorShifts
):
132 for obj
in VendorShifts
:
135 def removeVendorShifts(self
, *VendorShifts
):
136 for obj
in VendorShifts
: