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
.Document
import Document
19 class Tariff(Document
):
20 """Document, approved by the responsible regulatory agency, listing the terms and conditions, including a schedule of prices, under which utility services will be provided. It has a unique number within the state or province. For Rate Schedules it is frequently allocated by the affiliated Public Utilities Commission.
23 def __init__(self
, startDate
='', endDate
='', TariffProfiles
=None, PricingStructures
=None, *args
, **kw_args
):
24 """Initialises a new 'Tariff' instance.
26 @param startDate: Date tariff was activated.
27 @param endDate: (if tariff became inactive) Date tariff was terminated.
28 @param TariffProfiles: All tariff profiles using this tariff.
29 @param PricingStructures: All pricing structures using this tariff.
31 #: Date tariff was activated.
32 self
.startDate
= startDate
34 #: (if tariff became inactive) Date tariff was terminated.
35 self
.endDate
= endDate
37 self
._TariffProfiles
= []
38 self
.TariffProfiles
= [] if TariffProfiles
is None else TariffProfiles
40 self
._PricingStructures
= []
41 self
.PricingStructures
= [] if PricingStructures
is None else PricingStructures
43 super(Tariff
, self
).__init
__(*args
, **kw_args
)
45 _attrs
= ["startDate", "endDate"]
46 _attr_types
= {"startDate": str, "endDate": str}
47 _defaults
= {"startDate": '', "endDate": ''}
49 _refs
= ["TariffProfiles", "PricingStructures"]
50 _many_refs
= ["TariffProfiles", "PricingStructures"]
52 def getTariffProfiles(self
):
53 """All tariff profiles using this tariff.
55 return self
._TariffProfiles
57 def setTariffProfiles(self
, value
):
58 for p
in self
._TariffProfiles
:
59 filtered
= [q
for q
in p
.Tariffs
if q
!= self
]
60 self
._TariffProfiles
._Tariffs
= filtered
62 if self
not in r
._Tariffs
:
63 r
._Tariffs
.append(self
)
64 self
._TariffProfiles
= value
66 TariffProfiles
= property(getTariffProfiles
, setTariffProfiles
)
68 def addTariffProfiles(self
, *TariffProfiles
):
69 for obj
in TariffProfiles
:
70 if self
not in obj
._Tariffs
:
71 obj
._Tariffs
.append(self
)
72 self
._TariffProfiles
.append(obj
)
74 def removeTariffProfiles(self
, *TariffProfiles
):
75 for obj
in TariffProfiles
:
76 if self
in obj
._Tariffs
:
77 obj
._Tariffs
.remove(self
)
78 self
._TariffProfiles
.remove(obj
)
80 def getPricingStructures(self
):
81 """All pricing structures using this tariff.
83 return self
._PricingStructures
85 def setPricingStructures(self
, value
):
86 for p
in self
._PricingStructures
:
87 filtered
= [q
for q
in p
.Tariffs
if q
!= self
]
88 self
._PricingStructures
._Tariffs
= filtered
90 if self
not in r
._Tariffs
:
91 r
._Tariffs
.append(self
)
92 self
._PricingStructures
= value
94 PricingStructures
= property(getPricingStructures
, setPricingStructures
)
96 def addPricingStructures(self
, *PricingStructures
):
97 for obj
in PricingStructures
:
98 if self
not in obj
._Tariffs
:
99 obj
._Tariffs
.append(self
)
100 self
._PricingStructures
.append(obj
)
102 def removePricingStructures(self
, *PricingStructures
):
103 for obj
in PricingStructures
:
104 if self
in obj
._Tariffs
:
105 obj
._Tariffs
.remove(self
)
106 self
._PricingStructures
.remove(obj
)