From e988deaf2501032a3f492129e33f72d227f31b9b Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Apr 2026 08:50:43 +0200 Subject: [PATCH] Ostrom: add SimplyDynamic_V2 contract type (#28726) --- tariff/ostrom.go | 28 +++++++++++++++++++++------- tariff/ostrom/api.go | 9 +++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tariff/ostrom.go b/tariff/ostrom.go index 256e11bd0..4f4e582a2 100644 --- a/tariff/ostrom.go +++ b/tariff/ostrom.go @@ -100,8 +100,13 @@ func NewOstromFromConfig(other map[string]any) (api.Tariff, error) { t.contractType = contract.Product t.zip = contract.Address.Zip + tariffType, err := t.tariffType() + if err != nil { + return nil, err + } + done := make(chan error) - if t.Type() == api.TariffTypePriceStatic { + if tariffType == api.TariffTypePriceStatic { t.cityId, err = t.getCityId() if err != nil { return nil, err @@ -253,14 +258,23 @@ func (t *Ostrom) Rates() (api.Rates, error) { return res, err } -// Type implements the api.Tariff interface -func (t *Ostrom) Type() api.TariffType { +// tariffType returns the tariff type for the current contract, or an error for unknown contract types. +func (t *Ostrom) tariffType() (api.TariffType, error) { switch t.contractType { - case ostrom.PRODUCT_DYNAMIC: - return api.TariffTypePriceForecast + case ostrom.PRODUCT_DYNAMIC, ostrom.PRODUCT_DYNAMIC_V2: + return api.TariffTypePriceForecast, nil case ostrom.PRODUCT_FAIR, ostrom.PRODUCT_FAIR_CAP: - return api.TariffTypePriceStatic + return api.TariffTypePriceStatic, nil default: - panic("invalid contract type: " + t.contractType) + return 0, fmt.Errorf("invalid contract type: %s", t.contractType) } } + +// Type implements the api.Tariff interface +func (t *Ostrom) Type() api.TariffType { + tariffType, err := t.tariffType() + if err != nil { + panic(err.Error()) + } + return tariffType +} diff --git a/tariff/ostrom/api.go b/tariff/ostrom/api.go index a56cf3f36..02dfa1813 100644 --- a/tariff/ostrom/api.go +++ b/tariff/ostrom/api.go @@ -19,10 +19,11 @@ const ( ) const ( - PRODUCT_FAIR = "SIMPLY_FAIR" - PRODUCT_FAIR_CAP = "SIMPLY_FAIR_WITH_PRICE_CAP" - PRODUCT_DYNAMIC = "SIMPLY_DYNAMIC" - PRODUCT_BASIC = "basisProdukt" + PRODUCT_FAIR = "SIMPLY_FAIR" + PRODUCT_FAIR_CAP = "SIMPLY_FAIR_WITH_PRICE_CAP" + PRODUCT_DYNAMIC = "SIMPLY_DYNAMIC" + PRODUCT_DYNAMIC_V2 = "SimplyDynamic_V2" + PRODUCT_BASIC = "basisProdukt" ) type Prices struct {