Implementing RDF/XML serialisation using meta-data attributes.
[PyCIM.git] / schemata / CIM14 / IEC61968 / PaymentMetering / VendorShift.py
blobbd18873d112f6b35b982a112b244f83fc7c45ec3
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.
21 """
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).
29 @param Transactions:
30 @param Receipts:
31 @param Vendor: Vendor that opens and owns this vendor shift.
32 """
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.
37 self.posted = posted
39 self._MerchantAccount = None
40 self.MerchantAccount = MerchantAccount
42 self._Transactions = []
43 self.Transactions = [] if Transactions is None else Transactions
45 self._Receipts = []
46 self.Receipts = [] if Receipts is None else Receipts
48 self._Vendor = None
49 self.Vendor = Vendor
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}
56 _enums = {}
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).
62 """
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 self._MerchantAccount._VendorShifts.append(self)
74 MerchantAccount = property(getMerchantAccount, setMerchantAccount)
76 def getTransactions(self):
78 return self._Transactions
80 def setTransactions(self, value):
81 for x in self._Transactions:
82 x._VendorShift = None
83 for y in value:
84 y._VendorShift = self
85 self._Transactions = value
87 Transactions = property(getTransactions, setTransactions)
89 def addTransactions(self, *Transactions):
90 for obj in Transactions:
91 obj._VendorShift = self
92 self._Transactions.append(obj)
94 def removeTransactions(self, *Transactions):
95 for obj in Transactions:
96 obj._VendorShift = None
97 self._Transactions.remove(obj)
99 def getReceipts(self):
101 return self._Receipts
103 def setReceipts(self, value):
104 for x in self._Receipts:
105 x._VendorShift = None
106 for y in value:
107 y._VendorShift = self
108 self._Receipts = value
110 Receipts = property(getReceipts, setReceipts)
112 def addReceipts(self, *Receipts):
113 for obj in Receipts:
114 obj._VendorShift = self
115 self._Receipts.append(obj)
117 def removeReceipts(self, *Receipts):
118 for obj in Receipts:
119 obj._VendorShift = None
120 self._Receipts.remove(obj)
122 def getVendor(self):
123 """Vendor that opens and owns this vendor shift.
125 return self._Vendor
127 def setVendor(self, value):
128 if self._Vendor is not None:
129 filtered = [x for x in self.Vendor.VendorShifts if x != self]
130 self._Vendor._VendorShifts = filtered
132 self._Vendor = value
133 if self._Vendor is not None:
134 self._Vendor._VendorShifts.append(self)
136 Vendor = property(getVendor, setVendor)