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
.Common
.Agreement
import Agreement
19 class CustomerAgreement(Agreement
):
20 """Agreement between the Customer and the ServiceSupplier to pay for service at a specific ServiceLocation. It records certain billing information about the type of service provided at the ServiceLocation and is used during charge creation to determine the type of service.
23 def __init__(self
, loadMgmt
='', budgetBill
='', billingCycle
='', DemandResponseProgram
=None, ServiceSupplier
=None, PricingStructures
=None, ServiceLocations
=None, ServiceCategory
=None, MeterReadings
=None, CustomerAccount
=None, AuxiliaryAgreements
=None, EndDeviceControls
=None, Customer
=None, ServiceDeliveryPoints
=None, Equipments
=None, *args
, **kw_args
):
24 """Initialises a new 'CustomerAgreement' instance.
26 @param loadMgmt: Load management code.
27 @param budgetBill: Budget bill code.
28 @param billingCycle: Cycle day on which the associated customer account will normally be billed, used to determine when to produce the billing.
29 @param DemandResponseProgram: Demand response program for this customer agreement.
30 @param ServiceSupplier: Service supplier for this customer agreement.
31 @param PricingStructures: All pricing structures applicable to this customer agreement.
32 @param ServiceLocations: All service locations regulated by this customer agreement.
33 @param ServiceCategory:
34 @param MeterReadings: (could be deprecated in the future) All meter readings for this customer agreement.
35 @param CustomerAccount: Customer account owning this agreement.
36 @param AuxiliaryAgreements: All (non-service related) auxiliary agreements that refer to this customer agreement.
37 @param EndDeviceControls: Could be deprecated in the future.
38 @param Customer: Customer for this agreement.
39 @param ServiceDeliveryPoints: All service delivery points regulated by this customer agreement.
42 #: Load management code.
43 self
.loadMgmt
= loadMgmt
46 self
.budgetBill
= budgetBill
48 #: Cycle day on which the associated customer account will normally be billed, used to determine when to produce the billing.
49 self
.billingCycle
= billingCycle
51 self
._DemandResponseProgram
= None
52 self
.DemandResponseProgram
= DemandResponseProgram
54 self
._ServiceSupplier
= None
55 self
.ServiceSupplier
= ServiceSupplier
57 self
._PricingStructures
= []
58 self
.PricingStructures
= [] if PricingStructures
is None else PricingStructures
60 self
._ServiceLocations
= []
61 self
.ServiceLocations
= [] if ServiceLocations
is None else ServiceLocations
63 self
._ServiceCategory
= None
64 self
.ServiceCategory
= ServiceCategory
66 self
._MeterReadings
= []
67 self
.MeterReadings
= [] if MeterReadings
is None else MeterReadings
69 self
._CustomerAccount
= None
70 self
.CustomerAccount
= CustomerAccount
72 self
._AuxiliaryAgreements
= []
73 self
.AuxiliaryAgreements
= [] if AuxiliaryAgreements
is None else AuxiliaryAgreements
75 self
._EndDeviceControls
= []
76 self
.EndDeviceControls
= [] if EndDeviceControls
is None else EndDeviceControls
79 self
.Customer
= Customer
81 self
._ServiceDeliveryPoints
= []
82 self
.ServiceDeliveryPoints
= [] if ServiceDeliveryPoints
is None else ServiceDeliveryPoints
85 self
.Equipments
= [] if Equipments
is None else Equipments
87 super(CustomerAgreement
, self
).__init
__(*args
, **kw_args
)
89 _attrs
= ["loadMgmt", "budgetBill", "billingCycle"]
90 _attr_types
= {"loadMgmt": str, "budgetBill": str, "billingCycle": str}
91 _defaults
= {"loadMgmt": '', "budgetBill": '', "billingCycle": ''}
93 _refs
= ["DemandResponseProgram", "ServiceSupplier", "PricingStructures", "ServiceLocations", "ServiceCategory", "MeterReadings", "CustomerAccount", "AuxiliaryAgreements", "EndDeviceControls", "Customer", "ServiceDeliveryPoints", "Equipments"]
94 _many_refs
= ["PricingStructures", "ServiceLocations", "MeterReadings", "AuxiliaryAgreements", "EndDeviceControls", "ServiceDeliveryPoints", "Equipments"]
96 def getDemandResponseProgram(self
):
97 """Demand response program for this customer agreement.
99 return self
._DemandResponseProgram
101 def setDemandResponseProgram(self
, value
):
102 if self
._DemandResponseProgram
is not None:
103 filtered
= [x
for x
in self
.DemandResponseProgram
.CustomerAgreements
if x
!= self
]
104 self
._DemandResponseProgram
._CustomerAgreements
= filtered
106 self
._DemandResponseProgram
= value
107 if self
._DemandResponseProgram
is not None:
108 if self
not in self
._DemandResponseProgram
._CustomerAgreements
:
109 self
._DemandResponseProgram
._CustomerAgreements
.append(self
)
111 DemandResponseProgram
= property(getDemandResponseProgram
, setDemandResponseProgram
)
113 def getServiceSupplier(self
):
114 """Service supplier for this customer agreement.
116 return self
._ServiceSupplier
118 def setServiceSupplier(self
, value
):
119 if self
._ServiceSupplier
is not None:
120 filtered
= [x
for x
in self
.ServiceSupplier
.CustomerAgreements
if x
!= self
]
121 self
._ServiceSupplier
._CustomerAgreements
= filtered
123 self
._ServiceSupplier
= value
124 if self
._ServiceSupplier
is not None:
125 if self
not in self
._ServiceSupplier
._CustomerAgreements
:
126 self
._ServiceSupplier
._CustomerAgreements
.append(self
)
128 ServiceSupplier
= property(getServiceSupplier
, setServiceSupplier
)
130 def getPricingStructures(self
):
131 """All pricing structures applicable to this customer agreement.
133 return self
._PricingStructures
135 def setPricingStructures(self
, value
):
136 for p
in self
._PricingStructures
:
137 filtered
= [q
for q
in p
.CustomerAgreements
if q
!= self
]
138 self
._PricingStructures
._CustomerAgreements
= filtered
140 if self
not in r
._CustomerAgreements
:
141 r
._CustomerAgreements
.append(self
)
142 self
._PricingStructures
= value
144 PricingStructures
= property(getPricingStructures
, setPricingStructures
)
146 def addPricingStructures(self
, *PricingStructures
):
147 for obj
in PricingStructures
:
148 if self
not in obj
._CustomerAgreements
:
149 obj
._CustomerAgreements
.append(self
)
150 self
._PricingStructures
.append(obj
)
152 def removePricingStructures(self
, *PricingStructures
):
153 for obj
in PricingStructures
:
154 if self
in obj
._CustomerAgreements
:
155 obj
._CustomerAgreements
.remove(self
)
156 self
._PricingStructures
.remove(obj
)
158 def getServiceLocations(self
):
159 """All service locations regulated by this customer agreement.
161 return self
._ServiceLocations
163 def setServiceLocations(self
, value
):
164 for p
in self
._ServiceLocations
:
165 filtered
= [q
for q
in p
.CustomerAgreements
if q
!= self
]
166 self
._ServiceLocations
._CustomerAgreements
= filtered
168 if self
not in r
._CustomerAgreements
:
169 r
._CustomerAgreements
.append(self
)
170 self
._ServiceLocations
= value
172 ServiceLocations
= property(getServiceLocations
, setServiceLocations
)
174 def addServiceLocations(self
, *ServiceLocations
):
175 for obj
in ServiceLocations
:
176 if self
not in obj
._CustomerAgreements
:
177 obj
._CustomerAgreements
.append(self
)
178 self
._ServiceLocations
.append(obj
)
180 def removeServiceLocations(self
, *ServiceLocations
):
181 for obj
in ServiceLocations
:
182 if self
in obj
._CustomerAgreements
:
183 obj
._CustomerAgreements
.remove(self
)
184 self
._ServiceLocations
.remove(obj
)
186 def getServiceCategory(self
):
188 return self
._ServiceCategory
190 def setServiceCategory(self
, value
):
191 if self
._ServiceCategory
is not None:
192 filtered
= [x
for x
in self
.ServiceCategory
.CustomerAgreements
if x
!= self
]
193 self
._ServiceCategory
._CustomerAgreements
= filtered
195 self
._ServiceCategory
= value
196 if self
._ServiceCategory
is not None:
197 if self
not in self
._ServiceCategory
._CustomerAgreements
:
198 self
._ServiceCategory
._CustomerAgreements
.append(self
)
200 ServiceCategory
= property(getServiceCategory
, setServiceCategory
)
202 def getMeterReadings(self
):
203 """(could be deprecated in the future) All meter readings for this customer agreement.
205 return self
._MeterReadings
207 def setMeterReadings(self
, value
):
208 for x
in self
._MeterReadings
:
209 x
.CustomerAgreement
= None
211 y
._CustomerAgreement
= self
212 self
._MeterReadings
= value
214 MeterReadings
= property(getMeterReadings
, setMeterReadings
)
216 def addMeterReadings(self
, *MeterReadings
):
217 for obj
in MeterReadings
:
218 obj
.CustomerAgreement
= self
220 def removeMeterReadings(self
, *MeterReadings
):
221 for obj
in MeterReadings
:
222 obj
.CustomerAgreement
= None
224 def getCustomerAccount(self
):
225 """Customer account owning this agreement.
227 return self
._CustomerAccount
229 def setCustomerAccount(self
, value
):
230 if self
._CustomerAccount
is not None:
231 filtered
= [x
for x
in self
.CustomerAccount
.CustomerAgreements
if x
!= self
]
232 self
._CustomerAccount
._CustomerAgreements
= filtered
234 self
._CustomerAccount
= value
235 if self
._CustomerAccount
is not None:
236 if self
not in self
._CustomerAccount
._CustomerAgreements
:
237 self
._CustomerAccount
._CustomerAgreements
.append(self
)
239 CustomerAccount
= property(getCustomerAccount
, setCustomerAccount
)
241 def getAuxiliaryAgreements(self
):
242 """All (non-service related) auxiliary agreements that refer to this customer agreement.
244 return self
._AuxiliaryAgreements
246 def setAuxiliaryAgreements(self
, value
):
247 for x
in self
._AuxiliaryAgreements
:
248 x
.CustomerAgreement
= None
250 y
._CustomerAgreement
= self
251 self
._AuxiliaryAgreements
= value
253 AuxiliaryAgreements
= property(getAuxiliaryAgreements
, setAuxiliaryAgreements
)
255 def addAuxiliaryAgreements(self
, *AuxiliaryAgreements
):
256 for obj
in AuxiliaryAgreements
:
257 obj
.CustomerAgreement
= self
259 def removeAuxiliaryAgreements(self
, *AuxiliaryAgreements
):
260 for obj
in AuxiliaryAgreements
:
261 obj
.CustomerAgreement
= None
263 def getEndDeviceControls(self
):
264 """Could be deprecated in the future.
266 return self
._EndDeviceControls
268 def setEndDeviceControls(self
, value
):
269 for x
in self
._EndDeviceControls
:
270 x
.CustomerAgreement
= None
272 y
._CustomerAgreement
= self
273 self
._EndDeviceControls
= value
275 EndDeviceControls
= property(getEndDeviceControls
, setEndDeviceControls
)
277 def addEndDeviceControls(self
, *EndDeviceControls
):
278 for obj
in EndDeviceControls
:
279 obj
.CustomerAgreement
= self
281 def removeEndDeviceControls(self
, *EndDeviceControls
):
282 for obj
in EndDeviceControls
:
283 obj
.CustomerAgreement
= None
285 def getCustomer(self
):
286 """Customer for this agreement.
288 return self
._Customer
290 def setCustomer(self
, value
):
291 if self
._Customer
is not None:
292 filtered
= [x
for x
in self
.Customer
.CustomerAgreements
if x
!= self
]
293 self
._Customer
._CustomerAgreements
= filtered
295 self
._Customer
= value
296 if self
._Customer
is not None:
297 if self
not in self
._Customer
._CustomerAgreements
:
298 self
._Customer
._CustomerAgreements
.append(self
)
300 Customer
= property(getCustomer
, setCustomer
)
302 def getServiceDeliveryPoints(self
):
303 """All service delivery points regulated by this customer agreement.
305 return self
._ServiceDeliveryPoints
307 def setServiceDeliveryPoints(self
, value
):
308 for x
in self
._ServiceDeliveryPoints
:
309 x
.CustomerAgreement
= None
311 y
._CustomerAgreement
= self
312 self
._ServiceDeliveryPoints
= value
314 ServiceDeliveryPoints
= property(getServiceDeliveryPoints
, setServiceDeliveryPoints
)
316 def addServiceDeliveryPoints(self
, *ServiceDeliveryPoints
):
317 for obj
in ServiceDeliveryPoints
:
318 obj
.CustomerAgreement
= self
320 def removeServiceDeliveryPoints(self
, *ServiceDeliveryPoints
):
321 for obj
in ServiceDeliveryPoints
:
322 obj
.CustomerAgreement
= None
324 def getEquipments(self
):
326 return self
._Equipments
328 def setEquipments(self
, value
):
329 for p
in self
._Equipments
:
330 filtered
= [q
for q
in p
.CustomerAgreements
if q
!= self
]
331 self
._Equipments
._CustomerAgreements
= filtered
333 if self
not in r
._CustomerAgreements
:
334 r
._CustomerAgreements
.append(self
)
335 self
._Equipments
= value
337 Equipments
= property(getEquipments
, setEquipments
)
339 def addEquipments(self
, *Equipments
):
340 for obj
in Equipments
:
341 if self
not in obj
._CustomerAgreements
:
342 obj
._CustomerAgreements
.append(self
)
343 self
._Equipments
.append(obj
)
345 def removeEquipments(self
, *Equipments
):
346 for obj
in Equipments
:
347 if self
in obj
._CustomerAgreements
:
348 obj
._CustomerAgreements
.remove(self
)
349 self
._Equipments
.remove(obj
)