diff --git a/src/gsy_e/models/area/scm_dataclasses.py b/src/gsy_e/models/area/scm_dataclasses.py index 257f0f134..16f06be9e 100644 --- a/src/gsy_e/models/area/scm_dataclasses.py +++ b/src/gsy_e/models/area/scm_dataclasses.py @@ -265,9 +265,11 @@ class AreaFees: def prices_as_dict(self) -> Dict: """Return all prices (accumulated values) for the fees in a dictionary.""" - return { - name: fee.price for name, fee in {**self.per_kWh_fees, **self.monthly_fees}.items() - } + # monthly fees are not accumulated but already set for the market slot, + # hence we only report the value of the FeeContainer here + monthly_prices = {name: fee.value for name, fee in self.monthly_fees.items()} + per_kwh_prices = {name: fee.price for name, fee in self.per_kWh_fees.items()} + return {**monthly_prices, **per_kwh_prices} @property def total_per_kWh_fee_price(self): diff --git a/tests/area/test_scm_data_classes.py b/tests/area/test_scm_data_classes.py new file mode 100644 index 000000000..eb0ece12c --- /dev/null +++ b/tests/area/test_scm_data_classes.py @@ -0,0 +1,32 @@ +from gsy_e.models.area.scm_dataclasses import AreaFees, FeeContainer + + +class TestAreaFees: + # pylint: disable=attribute-defined-outside-init + + def setup_method(self): + self.area_fees = AreaFees( + grid_import_fee_const=0.2, + grid_export_fee_const=0.1, + grid_fees_reduction=0.0, + per_kWh_fees={ + "taxes_surcharges": FeeContainer(value=0.01), + "other_fee": FeeContainer(value=0.001), + }, + monthly_fees={ + "monthly_fee": FeeContainer(value=0.002), + "other_monthly_fee": FeeContainer(value=0.0002), + }, + ) + + def test_price_as_dict_returns_correct_values(self): + for fee in self.area_fees.per_kWh_fees.values(): + fee.price = 0.1 + for fee in self.area_fees.monthly_fees.values(): + fee.price = 0.1 + assert self.area_fees.prices_as_dict() == { + "taxes_surcharges": 0.1, + "other_fee": 0.1, + "monthly_fee": 0.002, + "other_monthly_fee": 0.0002, + }