diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 10131a4..2807f86 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -251,7 +251,9 @@ class EntriesController < ApplicationController :distance_km, :beschreibung, :kosten, - :zaehlt_als_fortbildung + :zaehlt_als_fortbildung, + :start_time, + :end_time ) end diff --git a/app/models/entry.rb b/app/models/entry.rb index 396e259..cd1d350 100644 --- a/app/models/entry.rb +++ b/app/models/entry.rb @@ -137,11 +137,17 @@ class Entry < ApplicationRecord private def normalize_time - - self.minutes ||= 0 - self.hours ||= 0 - - self.hours += minutes / 60 - self.minutes = minutes % 60 + if (hours.to_i + minutes.to_i) == 0 && start_time.present? && end_time.present? + total_minutes_worked = total_minutes_including_break + if total_minutes_worked + self.hours = total_minutes_worked / 60 + self.minutes = total_minutes_worked % 60 + end + else + self.minutes ||= 0 + self.hours ||= 0 + self.hours += minutes / 60 + self.minutes = minutes % 60 + end end end