Fix permissions, holiday, hours, visibility and scheduling bugs

- customer_options is now covered by the add/edit permissions, so
  non-admin staff get the vehicle/estimate dropdowns
- create_issues is now a POST member route with its own permission,
  checks add_issues on the target project, no longer redirects to a
  missing route, and has a button on the appointment page
- "Last" week-of-month holidays (e.g. Memorial Day) now match every year
- Cancelled and Call Out appointments no longer count toward hours
- Calendar only shows appointments to users with View customer
  appointments, and only loads those near the displayed month
- due_date skips weekends and holidays, matching the calendar layout
- Subjects keep their casing; only the first letter is capitalized

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-28 17:14:13 -04:00
1 parent 21538ad95b
commit 73115da2b9
10 files changed
+130 -17

No files matched your search

+9 -1
View File
@@ -15,6 +15,9 @@ class Holiday < ApplicationRecord
dynamic
]
# Value saved by the holiday form for "Last" in the week-of-month select
LAST_WEEK = 5
validates :recurrence_type, inclusion: { in: TYPES }, allow_blank: true
def occurs_on?(target_date)
@@ -23,6 +26,7 @@ class Holiday < ApplicationRecord
end
if recurrence_type == 'fixed'
return false if exact_date.nil?
return target_date.month == exact_date.month && target_date.day == exact_date.day
end
@@ -30,7 +34,11 @@ class Holiday < ApplicationRecord
# Check if month and day of week match
return false unless target_date.month == month && target_date.wday == day_of_week
# Calculate if it's the correct week of the month (1st, 2nd, 3rd, etc.)
# Week 5 means "Last": the final occurrence of that weekday in the month
# (e.g. Memorial Day, which falls in week 4 in some years and week 5 in others)
return (target_date + 7).month != target_date.month if week_of_month == LAST_WEEK
# Otherwise the Nth occurrence (1st, 2nd, 3rd, 4th)
week_in_month = ((target_date.day - 1) / 7) + 1
return week_in_month == week_of_month
end