From c0f3f310952fddbf67c60a1ca665833a9bf5c711 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Fri, 22 Jul 2022 12:39:50 +0200 Subject: [PATCH] total sums for duration and rate in invoice and export preview (#3431) --- templates/export/index.html.twig | 16 ++++++++++++++++ templates/invoice/index.html.twig | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/templates/export/index.html.twig b/templates/export/index.html.twig index f36feb2a..ce85e93b 100644 --- a/templates/export/index.html.twig +++ b/templates/export/index.html.twig @@ -66,10 +66,26 @@ {% if entries is empty %} {{ widgets.nothing_found() }} {% else %} + {% set totalDuration = 0 %} + {% set totalRates = {} %} + + {% for row in by_customer %} + {% set totalDuration = totalDuration + row.duration %} + {% set customerCurrency = row.customer.currency %} + {% if totalRates[customerCurrency] is not defined %} + {% set totalRates = totalRates|merge({(customerCurrency): 0.00}) %} + {% endif %} + {% set totalRates = totalRates|merge({(customerCurrency): totalRates[customerCurrency] + row.rate}) %} + {% endfor %} + {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} {% import "macros/widgets.html.twig" as widgets %} {% block box_title %} {{ 'button.preview'|trans }}: {{ 'export.title'|trans }} + {{ widgets.label(totalDuration|duration, 'gray') }} + {% for totalCurrency, totalRate in totalRates %} + {{ widgets.label(totalRate|money(totalCurrency), 'gray') }} + {% endfor %} {% endblock %} {% block box_body_class %}no-padding{% endblock %} {% block box_footer %} diff --git a/templates/invoice/index.html.twig b/templates/invoice/index.html.twig index 4aa000e3..44ed0b33 100644 --- a/templates/invoice/index.html.twig +++ b/templates/invoice/index.html.twig @@ -66,12 +66,21 @@ {{ widgets.callout('danger', 'http_error_403.suggestion'|trans({}, 'exceptions')) }} {% endif %} + {% set totalDuration = 0 %} + {% set totalRates = {} %} + {% if searched %} {% set showEmpty = true %} {% for model in models %} {% if showEmpty %} {% set showEmpty = model.calculator is empty or model.calculator.entries is empty %} {% endif %} + {% set totalDuration = totalDuration + model.calculator.timeWorked %} + {% set customerCurrency = model.customer.currency %} + {% if totalRates[customerCurrency] is not defined %} + {% set totalRates = totalRates|merge({(customerCurrency): 0.00}) %} + {% endif %} + {% set totalRates = totalRates|merge({(customerCurrency): totalRates[customerCurrency] + model.calculator.total}) %} {% endfor %} {% if showEmpty %} {{ widgets.nothing_found() }} @@ -84,6 +93,10 @@ {% import '@AdminLTE/Macros/buttons.html.twig' as button %} {% block box_title %} {{ 'button.preview'|trans }}: {{ 'invoices'|trans }} + {{ widgets.label(totalDuration|duration, 'gray') }} + {% for totalCurrency, totalRate in totalRates %} + {{ widgets.label(totalRate|money(totalCurrency), 'gray') }} + {% endfor %} {% endblock %} {% block box_body_class %}no-padding{% endblock %} {% block box_footer %}