Module: TimeOffPlannedWorkDayHelper

Included in:
Crm::TimeOffsHelper, DailyFocus::Prompt, EmployeeTimeOffsHelper
Defined in:
app/helpers/time_off_planned_work_day_helper.rb

Overview

Planned work window for partial-day PTO (TimeOffRequestDate#planned_work_day JSON).
Used by CRM UI and InternalMailer PTO notifications.

Instance Method Summary collapse

Instance Method Details

#time_off_planned_work_day_summary(planned_work_day) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/time_off_planned_work_day_helper.rb', line 6

def time_off_planned_work_day_summary(planned_work_day)
  return if planned_work_day.blank?

  h = planned_work_day.with_indifferent_access
  planned = h[:planned]
  return if planned.blank?

  p = planned.with_indifferent_access
  parts = []
  if p[:start_time].present? && p[:end_time].present?
    parts << "#{format_planned_time_ampm(p[:start_time])}#{format_planned_time_ampm(p[:end_time])} work"
  end
  if ActiveModel::Type::Boolean.new.cast(p[:skip_lunch])
    parts << 'no lunch'
  elsif p[:lunch_start].present? && p[:lunch_end].present?
    parts << "lunch #{format_planned_time_ampm(p[:lunch_start])}#{format_planned_time_ampm(p[:lunch_end])}"
  end
  parts.presence&.join(' · ')
end