use crate::registry::prelude::*;

const ENERGY_BASED_PRICELIST_BASE: PriceListBuilder = PriceList::builder()
    .from_date(2025, 1, 1)
    .monthly_production_fee(Cost::Unverified)
    .feed_in_revenue(FeedInRevenue::Unverified)
    .transfer_fee(TransferFee::fixed_subunit(7.5))
    .power_tariff(PowerTariff::new(
        TariffCalculationMethod::AverageDays(3),
        CostPeriods::new_first(&[
            CostPeriod::builder()
                .load(High)
                // TODO: Handling of summer time counting as winter time
                //       See https://git.spotpilot.io/spotpilot/grid-tariffs/issues/195
                .hours(7, 20)
                .months(November, March)
                .exclude_weekends()
                .exclude_holidays(Country::SE)
                .fixed_cost(132, 0)
                .build(),
            CostPeriod::builder().load(Low).cost(Cost::None).build(),
        ]),
    ));

pub static GOTEBORG_ENERGI: GridOperator = GridOperator::builder()
    .name("Göteborg Energi")
    .vat_number("SE556379272901")
    .country(Country::SE)
    .main_fuses(MainFuseSizes::new_range(16, 63))
    .links(
        Links::builder()
            .fee_info(
                "https://www.goteborgenergi.se/privat/elnat/elnatsavgiften",
                "#prisvilla + *",
            )
            .eltariff_api("https://api.goteborgenergi.cloud/gridtariff/v0/tariffs")
            .build(),
    )
    .price_lists(&[
        PriceList::builder()
            .variant("Standard")
            .from_date(2025, 1, 1)
            .monthly_fee(Cost::fixed(185, 0))
            .monthly_production_fee(Cost::Unverified)
            .feed_in_revenue(FeedInRevenue::Unverified)
            .transfer_fee(TransferFee::fixed_subunit(25.))
            .power_tariff(PowerTariff::new(
                TariffCalculationMethod::AverageDays(3),
                CostPeriods::new_first(&[CostPeriod::builder()
                    .load(Base)
                    .fixed_cost(45, 0)
                    .build()]),
            ))
            .build(),
        ENERGY_BASED_PRICELIST_BASE
            .variant("Tidsbaserad, 6 kW")
            .monthly_fee(Cost::fixed(182, 50))
            .build(),
        ENERGY_BASED_PRICELIST_BASE
            .variant("Tidsbaserad, 14 kW")
            .monthly_fee(Cost::fixed(342, 50))
            .build(),
        ENERGY_BASED_PRICELIST_BASE
            .variant("Tidsbaserad, 43 kW")
            .monthly_fee(Cost::fixed(927, 50))
            .build(),
    ])
    .build();
