diff --git a/.changes/unreleased/Fixed-20260112-103411.yaml b/.changes/unreleased/Fixed-20260112-103411.yaml new file mode 100644 index 000000000..57ff00ab2 --- /dev/null +++ b/.changes/unreleased/Fixed-20260112-103411.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix the calculation of budget balance to only take into account resources and charges that are still actual +time: 2026-01-12T10:34:11.032115897+01:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index a1fee19ce..22e80fb3a 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -72,14 +72,20 @@ {% macro table_results(actualCharges, actualResources, results) %} +{% set now = date() %} + {% set totalCharges = 0 %} {% for c in actualCharges %} - {% set totalCharges = totalCharges + c.amount %} + {% if c.startDate <= now and (c.endDate is null or c.endDate >= now) %} + {% set totalCharges = totalCharges + c.amount %} + {% endif %} {% endfor %} {% set totalResources = 0 %} {% for r in actualResources %} - {% set totalResources = totalResources + r.amount %} + {% if r.startDate <= now and (r.endDate is null or r.endDate >= now) %} + {% set totalResources = totalResources + r.amount %} + {% endif %} {% endfor %} {% set result = (totalResources - totalCharges) %}