@@ -147,13 +147,14 @@ class Charge(odin.Resource):
147
147
season = odin .ObjectAs (Season , null = True )
148
148
type = odin .StringField (choices = CHARGE_TYPE_CHOICES , null = True , default = 'consumption' ,
149
149
use_default_if_not_provided = True )
150
+ meter = odin .StringField (null = True )
150
151
151
152
@odin .calculated_field
152
153
def name (self ):
153
154
season = self .season .name if self .season else None
154
155
time = self .time .name if self .time else None
155
156
scheduled = 'scheduled' if self .rate_schedule else None
156
- return str (self .code ) + str (self .type or '' ) + str (season or '' ) + str (time or '' ) + str (scheduled or '' )
157
+ return str (self .code or '' ) + str (self .type or '' ) + str (season or '' ) + str (time or '' ) + str (scheduled or '' )
157
158
158
159
159
160
class Times (odin .Resource ):
@@ -225,14 +226,14 @@ def charge_types(self):
225
226
226
227
def calc_charge (self , name , row , charge , cost_items , block_accum_dict ):
227
228
if charge .rate :
228
- cost_items [name ]['cost' ] += charge .rate * float (row [charge .type ])
229
+ cost_items [name ]['cost' ] += charge .rate * float (row [charge .meter or charge . type ])
229
230
if charge .rate_bands :
230
231
charge_time_step = float ()
231
232
for rate_band_index , rate_band in enumerate (charge .rate_bands ):
232
233
if block_accum_dict [name ] > rate_band .limit :
233
234
continue
234
235
block_usage = max ((min (
235
- (rate_band .limit - block_accum_dict [name ], row [charge .type ] - block_accum_dict [name ])), 0.0 ))
236
+ (rate_band .limit - block_accum_dict [name ], row [charge .meter or charge . type ] - block_accum_dict [name ])), 0.0 ))
236
237
charge_time_step += rate_band .rate * block_usage
237
238
block_accum_dict [name ] += block_usage
238
239
cost_items [name ]['cost' ] += charge_time_step
0 commit comments