Browse Source

fix calc off gesamtkosten

main
Christoph Marzell 4 weeks ago
parent
commit
94599cd688
  1. 1
      app/controllers/entries_controller.rb
  2. 14
      app/models/entry.rb
  3. 4
      app/views/entries/index.html.erb

1
app/controllers/entries_controller.rb

@ -76,6 +76,7 @@ class EntriesController < ApplicationController
@selbstsupervision_by_year = Entry.total_supervision_by_year(current_user)
@selbsterfahrungskosten_by_year = Entry.total_selbsterfahrungskosten_by_year(current_user)
@allekosten_by_year = Entry.total_semesterkosten_by_year(current_user)
@gesamtkosten_by_year = Entry.total_gesamtkosten_by_year(current_user)
# Voraussichtliches Ende je Kombination basierend auf weekly_target_matrix
#

14
app/models/entry.rb

@ -102,6 +102,20 @@ class Entry < ApplicationRecord
.to_h
end
def self.total_gesamtkosten_by_year(user)
semester_by_year = total_semesterkosten_by_year(user)
km_by_year = total_kilometer_cost_by_year(user)
years = (semester_by_year.keys + km_by_year.keys).uniq.sort.reverse
years.each_with_object({}) do |year, out|
semester = (semester_by_year[year] || 0).to_d
km = (km_by_year[year] || 0).to_d
out[year] = (semester + km).round(2)
end
end
def jahr
date.year
end

4
app/views/entries/index.html.erb

@ -163,8 +163,8 @@
</div>
<div class="col rounded border shadow-sm p-3">
<h5>📊 Gesamtkosten (Werbungskosten)</h5>
<% @allekosten_by_year.each do |year, sum| %>
<h5>🧾 Gesamtkosten (Weiterbildungskosten + Kilometergeld)</h5>
<% @gesamtkosten_by_year.each do |year, sum| %>
<p><strong><%= year %>:</strong>
<%= number_to_currency(sum, unit: "€", separator: ",", delimiter: ".", precision: 2) %>
</p>

Loading…
Cancel
Save