Beispiel #1
0
        private static UsageCost CostForTariff(Tariff tariff, Kwh <Power>?powerUsage, Kwh <Gas>?gasUsage)
        {
            var g = tariff.GasRate * gasUsage + tariff.StandingCharge * 12;
            var p = tariff.PowerRate * powerUsage + tariff.StandingCharge * 12;

            var total = TaxedValue.FromPreTaxValue((g ?? 0) + (p ?? 0), TaxHelper.ApplyTax);

            return(new UsageCost(tariff, g, p, total));
        }
Beispiel #2
0
 public static IEnumerable <UsageCost> CostsPerTariff(IEnumerable <Tariff> tariffs, Kwh <Power>?powerUsage, Kwh <Gas>?gasUsage) =>
 // we take care as either the tariffs could only have partial fuel coverage, and or the customer usage might be partial
 tariffs
 .Where(t => ((powerUsage.HasValue && t.PowerRate.HasValue) || !powerUsage.HasValue) &&
        ((gasUsage.HasValue && t.GasRate.HasValue) || !gasUsage.HasValue))              // only include compatible tariffs
 .Select(t => CostForTariff(t, powerUsage, gasUsage))
 .OrderBy(costs => costs.Total.PostTax);