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 Vendor(IdentifiedObject
):
20 """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.
23 def __init__(self
, PointOfSales
=None, MerchantAccount
=None, Cashiers
=None, VendorShifts
=None, *args
, **kw_args
):
24 """Initialises a new 'Vendor' instance.
26 @param PointOfSales: All points of sale this Vendor controls.
27 @param MerchantAccount: Merchant account against which this vendor sells tokens or recept payments.
28 @param Cashiers: All Cachiers managed by this Vendor.
29 @param VendorShifts: All vendor shifts opened and owned by this vendor.
31 self
._PointOfSales
= []
32 self
.PointOfSales
= [] if PointOfSales
is None else PointOfSales
34 self
._MerchantAccount
= None
35 self
.MerchantAccount
= MerchantAccount
38 self
.Cashiers
= [] if Cashiers
is None else Cashiers
40 self
._VendorShifts
= []
41 self
.VendorShifts
= [] if VendorShifts
is None else VendorShifts
43 super(Vendor
, self
).__init
__(*args
, **kw_args
)
49 _refs
= ["PointOfSales", "MerchantAccount", "Cashiers", "VendorShifts"]
50 _many_refs
= ["PointOfSales", "Cashiers", "VendorShifts"]
52 def getPointOfSales(self
):
53 """All points of sale this Vendor controls.
55 return self
._PointOfSales
57 def setPointOfSales(self
, value
):
58 for x
in self
._PointOfSales
:
62 self
._PointOfSales
= value
64 PointOfSales
= property(getPointOfSales
, setPointOfSales
)
66 def addPointOfSales(self
, *PointOfSales
):
67 for obj
in PointOfSales
:
70 def removePointOfSales(self
, *PointOfSales
):
71 for obj
in PointOfSales
:
74 def getMerchantAccount(self
):
75 """Merchant account against which this vendor sells tokens or recept payments.
77 return self
._MerchantAccount
79 def setMerchantAccount(self
, value
):
80 if self
._MerchantAccount
is not None:
81 filtered
= [x
for x
in self
.MerchantAccount
.Vendors
if x
!= self
]
82 self
._MerchantAccount
._Vendors
= filtered
84 self
._MerchantAccount
= value
85 if self
._MerchantAccount
is not None:
86 if self
not in self
._MerchantAccount
._Vendors
:
87 self
._MerchantAccount
._Vendors
.append(self
)
89 MerchantAccount
= property(getMerchantAccount
, setMerchantAccount
)
91 def getCashiers(self
):
92 """All Cachiers managed by this Vendor.
96 def setCashiers(self
, value
):
97 for x
in self
._Cashiers
:
101 self
._Cashiers
= value
103 Cashiers
= property(getCashiers
, setCashiers
)
105 def addCashiers(self
, *Cashiers
):
109 def removeCashiers(self
, *Cashiers
):
113 def getVendorShifts(self
):
114 """All vendor shifts opened and owned by this vendor.
116 return self
._VendorShifts
118 def setVendorShifts(self
, value
):
119 for x
in self
._VendorShifts
:
123 self
._VendorShifts
= value
125 VendorShifts
= property(getVendorShifts
, setVendorShifts
)
127 def addVendorShifts(self
, *VendorShifts
):
128 for obj
in VendorShifts
:
131 def removeVendorShifts(self
, *VendorShifts
):
132 for obj
in VendorShifts
: