diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 029df8a..170cefe 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -30,6 +30,12 @@ class EntriesController < ApplicationController end end + @total_kilometer_costs_by_year = current_user.entries + .group_by { |e| e.date.year } + .transform_values do |entries| + entries.sum(&:kilometer_pauschale) + end + # Voraussichtliches Ende je Kombination basierend auf weekly_target_matrix @estimated_end_by_typ_art = {} @remaining_minutes_matrix.each do |typ, arts| diff --git a/app/views/entries/index.html.erb b/app/views/entries/index.html.erb index f9d5289..5d9052f 100644 --- a/app/views/entries/index.html.erb +++ b/app/views/entries/index.html.erb @@ -6,10 +6,15 @@
+ + +
🚗 Fahrtkosten (Kilometergeld)
+ <% @total_kilometer_costs_by_year.each do |year, sum| %> +

<%= year %>: <%= number_to_currency(sum, unit: "€", separator: ",", delimiter: ".", precision: 2) %>

+ <% end %> +

Gesamtzeit: <%= @total_minutes / 60 %> h <%= @total_minutes % 60 %> min

-

Fahrtkosten gesamt: - <%= number_to_currency(@total_kilometer_pauschale, unit: "€", separator: ",", delimiter: ".") %> -

+