def datum_beginning_20(ds, hh): bill = ds.supplier_bill tariff = None for k, tf in ds.hh_rate( ds.dno_contract.id, hh['start-date'], 'tariffs').iteritems(): if ds.llfc_code in [cd.strip() for cd in k.split(',')]: tariff = tf if tariff is None: raise UserException( "The tariff for the LLFC " + ds.llfc_code + " cannot be found for the DNO 20 at " + utils.hh_format(hh['start-date']) + ".") lafs = ds.hh_rate( ds.dno_contract.id, hh['start-date'], 'lafs')[ds.voltage_level_code.lower()] day_rate = tariff['day-gbp-per-kwh'] if 'night-gbp-per-kwh' in tariff: night_rate = tariff['night-gbp-per-kwh'] if 0 < hh['ct-decimal-hour'] <= 7: bill['duos-night-kwh'] += hh['msp-kwh'] bill['duos-night-gbp'] += hh['msp-kwh'] * night_rate else: bill['duos-day-kwh'] += hh['msp-kwh'] bill['duos-day-gbp'] += hh['msp-kwh'] * day_rate else: bill['duos-day-kwh'] += hh['msp-kwh'] bill['duos-day-gbp'] += hh['msp-kwh'] * day_rate if 0 < hh['ct-decimal-hour'] <= 7: slot_name = 'night' elif hh['ct-day-of-week'] < 5 and \ 16 < hh['ct-decimal-hour'] <= 19 and \ (hh['ct-month'] > 10 or hh['ct-month'] < 3): slot_name = 'peak' elif 7 > hh['ct-day-of-week'] > 1 and ( 7 < hh['ct-decimal-hour'] < 15 or 18.5 < hh['ct-decimal-hour'] < 19) and \ (hh['ct-month'] > 11 or hh['ct-month'] < 4): slot_name = 'winter-weekday' else: slot_name = 'other' hh['laf'] = lafs[slot_name] hh['gsp-kwh'] = hh['laf'] * hh['msp-kwh'] hh['gsp-kw'] = hh['gsp-kwh'] * 2
def hh_time_beginning_20(ds, hh): bill = ds.supplier_bill if hh['utc-is-month-end']: tariff = None for k, tf in ds.hh_rate( ds.dno_contract.id, hh['start-date'], 'tariffs').iteritems(): if ds.llfc_code in map(str.strip, k.split(',')): tariff = tf break if tariff is None: raise UserException( "The tariff for the LLFC " + ds.llfc_code + " cannot be found for the DNO 20 at " + utils.hh_format(hh['start-date']) + ".") if not ds.is_displaced: year_md_kva_095 = year_md_095(ds, ds.finish_date) bill['duos-excess-availability-kva'] = max( year_md_kva_095 - ds.sc, 0) billed_avail = max(ds.sc, year_md_kva_095) bill['duos-availability-kva'] = ds.sc for threshold, block in [ (15, 15), (100, 5), (250, 10), (500, 25), (1000, 50), (None, 100)]: if threshold is None or billed_avail < threshold: if billed_avail % block > 0: billed_avail = (int(billed_avail / block) + 1) * block break le_200_avail_rate = tariff['capacity-<=200-gbp-per-kva-per-month'] bill['duos-availability-gbp'] += min(200, billed_avail) * \ le_200_avail_rate if billed_avail > 200: gt_200_avail_rate = \ tariff['capacity->200-gbp-per-kva-per-month'] bill['duos-availability-gbp'] += (billed_avail - 200) * \ gt_200_avail_rate if 'fixed-gbp-per-month' in tariff: bill['duos-standing-gbp'] += tariff['fixed-gbp-per-month'] else: bill['duos-standing-gbp'] += tariff['fixed-gbp-per-day'] * \ hh['utc-day']