Hi All
This is my first attempt at coding in Jinja, so please bare with me
Where I live, my net provider is N1 and they are constantly changing their prices depending on the month and time of day. On top of that, the tax to the government is also changing twice next year, and then the following years, it changes once a year.
Is there anyone who is willing to take a look on what I’ve made, to sort out any bugs or you are also more then welcome to use it yourself
So. This year, the overall prices changes at 1. October 2022. On top of that, from October to April (including) from 17.00 to 20.00 the prices are even higher.
In 2023, the tax the first 6 month is lower, then the rest of the year, but then again, from October to April, the price from 17.00 to 20.00 is higher.
Then from 2024 an onwards, the tax changes once a year, but again from October to April between 17.00 to 20.00 the price is higher.
I have looked it over again and again and again, but my language of choice is php, so I had to read up on Jinja to be sure I’ve made it the right way.
lavlast_rabat_XXX = low prices discount
spidslast_rabat_XXX = high prices discount
nettarif_lavlast_XX_2022 = low cost kWh for the specific month in 2022
nettarif_spidslast_XX_2022 = high cost kWh for the specific month in 2022
elafgift_2022 = tax 2022
elafgift_H1_2023 = tax first half of 2023
elafgift_H2_2023 = tax second half of 2023
elafgift_202X = tax for the following years
balancering = an additionel tax
additional_costs: '{% set s = {
"lavlast_rabat_2022": 0.1299,
"lavlast_rabat_2023": 0,
"spidslast_rabat_2022": 0.1605,
"spidslast_rabat_2023": 0,
"nettarif_lavlast_10_2022": 0.3942,
"nettarif_lavlast_11_2022": 0.5096,
"nettarif_lavlast_12_2022": 0.5096,
"nettarif_lavlast_2023": 0.5403,
"nettarif_spidslast_10_2022": 1.027,
"nettarif_spidslast_11_2022": 1.2699,
"nettarif_spidslast_12_2022": 1.2699,
"nettarif_spidslast_2023": 1.3202,
"elafgift_2022": 0.95375,
"elafgift_H1_2023": 0.01,
"elafgift_H2_2023": 0.87125,
"elafgift_2024": 0.8875,
"elafgift_2025": 0.81,
"elafgift_2026": 0.81,
"elafgift_2027": 0.81,
"elafgift_2028": 0.79,
"elafgift_2029": 0.77125,
"elafgift_2030": 0.70125,
"balancering": 0.008
}
%}
{% if now().year == 2022 %}
Year 2022 <-- Lines like this was just for "debugging" and should be removed.
{% if now().month >= 10 or now().month <= 4 %}
Month 10 to 4
{% if now().hour <= 20 and now().hour >= 17 %}
Hour 17 to 20
{{(s["elafgift_" ~ now().year]+s.balancering+s["nettarif_spidslast_" ~ now().month ~ "_" ~ now().year])-s["spidslast_rabat_" ~ now().year]|float}}
{% else %}
Not hour 17 to 20
{{(s["elafgift_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ now().month ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% else %}
Not month 10 to 4
{{(s["elafgift_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ now().month ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% elif now().year == 2023 %}
Year 2023
{% if now().month >= 1 and now().month <= 6 %}
Month 1 to 6
{% if now().month >= 10 or now().month <= 4 %}
Month 10 to 4
{% if now().hour <= 20 and now().hour >= 17 %}
Hour 17 to 20
{{(s["elafgift_H1_" ~ now().year]+s.balancering+s["nettarif_spidslast_" ~ "_" ~ now().year])-s["spidslast_rabat_" ~ now().year]|float}}
{% else %}
Not hour 17 to 20
{{(s["elafgift_H1_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% else %}
{{(s["elafgift_H1_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% else %}
{% if now().month >= 10 or now().month <= 4 %}
Month 10 to 4
{% if now().hour <= 20 and now().hour >= 17 %}
Hour 17 to 20
{{(s["elafgift_H2_" ~ now().year]+s.balancering+s["nettarif_spidslast_" ~ "_" ~ now().year])-s["spidslast_rabat_" ~ now().year]|float}}
{% else %}
Not hour 17 to 20
{{(s["elafgift_H2_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% else %}
{{(s["elafgift_H2_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% endif %}
{% else %}
Not year 2022 or 2023
{% if now().month >= 10 or now().month <= 4 %}
Month 10 to 4
{% if now().hour <= 20 and now().hour >= 17 %}
Hour 17 to 20
{{(s["elafgift_" ~ now().year]+s.balancering+s["nettarif_spidslast_" ~ now().month ~ "_" ~ now().year])-s["spidslast_rabat_" ~ now().year]|float}}
{% else %}
Not hour 17 to 20
{{(s["elafgift_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ now().month ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% else %}
{{(s["elafgift_" ~ now().year]+s.balancering+s["nettarif_lavlast_" ~ now().month ~ "_" ~ now().year])-s["lavlast_rabat_" ~ now().year]|float}}
{% endif %}
{% endif %}'