Created
April 18, 2013 05:06
-
-
Save amolpujari/5410272 to your computer and use it in GitHub Desktop.
Trial Plan DSL sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from calc import Calc | |
from plan import Plan | |
from datetime import datetime | |
.... | |
class OurTrialPlan(Plan): | |
def __init__(self, start_date, end_date, usage, extra=None): | |
super(OurTrialPlan, self).__init__() | |
self.calc = Calc(start_date, usage) | |
self._extra = extra if type(extra)==dict else {} | |
def calculate(self): | |
.... | |
add(10, 'customer charges') | |
# OFF-PEAK | |
usage = for_month_of(['Jan', 'Feb', 'Oct']) | |
cost, tier_rate = slab_wise_tariff( usage, no_change_rates) | |
add( cost, 'no_change', rate=tier_rate) | |
# KU OFF-PEAK | |
usage = for_month_of(['Mar', 'Apr', 'May', 'Nov', 'Dec']) and during('10pm','6am') | |
add( usage*0.0265, 'ke_flat_rate', rate=0.0265) | |
# KU ON-PEAK | |
usage = for_month_of(['Mar', 'Apr', 'May', 'Nov', 'Dec']) and during('6am','10pm') | |
cost, tier_rate = slab_wise_tariff( usage, ke_base_rates) | |
add( cost, 'ke_base_rates', rate=tier_rate) | |
cost, tier_rate = slab_tariff( usage, ke_surcharge) | |
add( cost, 'ke_surcharge', rate=tier_rate) | |
..... | |
return tariff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment