Update README.rst
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / Vendor.py
blobb29dceeaa69046622f047370e1f962acdf68d064
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
19 # IN THE SOFTWARE.
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.
25 """
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.
34 """
35 self._PointOfSales = []
36 self.PointOfSales = [] if PointOfSales is None else PointOfSales
38 self._MerchantAccount = None
39 self.MerchantAccount = MerchantAccount
41 self._Cashiers = []
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)
49 _attrs = []
50 _attr_types = {}
51 _defaults = {}
52 _enums = {}
53 _refs = ["PointOfSales", "MerchantAccount", "Cashiers", "VendorShifts"]
54 _many_refs = ["PointOfSales", "Cashiers", "VendorShifts"]
56 def getPointOfSales(self):
57 """All points of sale this Vendor controls.
58 """
59 return self._PointOfSales
61 def setPointOfSales(self, value):
62 for x in self._PointOfSales:
63 x.Vendor = None
64 for y in value:
65 y._Vendor = self
66 self._PointOfSales = value
68 PointOfSales = property(getPointOfSales, setPointOfSales)
70 def addPointOfSales(self, *PointOfSales):
71 for obj in PointOfSales:
72 obj.Vendor = self
74 def removePointOfSales(self, *PointOfSales):
75 for obj in PointOfSales:
76 obj.Vendor = None
78 def getMerchantAccount(self):
79 """Merchant account against which this vendor sells tokens or recept payments.
80 """
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.
97 """
98 return self._Cashiers
100 def setCashiers(self, value):
101 for x in self._Cashiers:
102 x.Vendor = None
103 for y in value:
104 y._Vendor = self
105 self._Cashiers = value
107 Cashiers = property(getCashiers, setCashiers)
109 def addCashiers(self, *Cashiers):
110 for obj in Cashiers:
111 obj.Vendor = self
113 def removeCashiers(self, *Cashiers):
114 for obj in Cashiers:
115 obj.Vendor = None
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:
124 x.Vendor = None
125 for y in value:
126 y._Vendor = self
127 self._VendorShifts = value
129 VendorShifts = property(getVendorShifts, setVendorShifts)
131 def addVendorShifts(self, *VendorShifts):
132 for obj in VendorShifts:
133 obj.Vendor = self
135 def removeVendorShifts(self, *VendorShifts):
136 for obj in VendorShifts:
137 obj.Vendor = None