diff --git a/app/models/finished_timer_session_validator.rb b/app/models/finished_timer_session_validator.rb index b69f8b5..3095ab4 100644 --- a/app/models/finished_timer_session_validator.rb +++ b/app/models/finished_timer_session_validator.rb @@ -41,16 +41,16 @@ def validate_minimal_duration end def validate_day_limit - return unless ( + return if ( @record.splittable_hours + TimerSession.created_by(@record.user) .recorded_on(@record.timer_start.to_date).sum(:hours) - ) > SettingsManager.max_hours_recorded_per_day.to_f + ) <= SettingsManager.max_hours_recorded_per_day.to_f @record.errors.add(:timer_start, :limit_reached_day) end def validate_session_limit - return unless @record.splittable_hours > SettingsManager.max_hours_recorded_per_session.to_f + return if @record.splittable_hours <= SettingsManager.max_hours_recorded_per_session.to_f @record.errors.add(:timer_start, :limit_reached_session) end diff --git a/app/models/unfinished_timer_session_validator.rb b/app/models/unfinished_timer_session_validator.rb index 5ddbb64..17e7a2e 100644 --- a/app/models/unfinished_timer_session_validator.rb +++ b/app/models/unfinished_timer_session_validator.rb @@ -8,7 +8,7 @@ def validate(record) end def validate_start_before_end_date - return if @record.timer_start.blank? || @record.timer_end.blank? + return if @record.timer_end.blank? return if @record.timer_end > @record.timer_start @record.errors.add(:timer_start, :after_end)