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

@@ -11,7 +11,7 @@
class CustomerAppointmentsController < ApplicationController
before_action :require_login
before_action :find_project, except: [:index]
before_action :find_appointment, only: [ :show, :edit, :update, :destroy ]
before_action :find_appointment, only: [ :show, :edit, :update, :destroy, :create_issues ]
# This tells Redmine to check global permissions for the current controller/action
before_action :authorize_global
@@ -26,17 +26,22 @@ class CustomerAppointmentsController < ApplicationController
}
end
# Creates one issue per "Labor" line on the appointment's QBO estimate.
def create_issues
@appointment = CustomerAppointment.find(params[:id])
created_issues = @appointment.create_issues_from_labor_lines(project: @project, author: User.current)
# Same fallback order as CustomerAppointment#create_issues_from_labor_lines
target_project = @project || @appointment.project || Project.first
# The user must also be allowed to add issues to the project they'll be created in
return deny_access unless target_project && User.current.allowed_to?(:add_issues, target_project)
created_issues = @appointment.create_issues_from_labor_lines(project: target_project, author: User.current)
if created_issues.any?
flash[:notice] = l(:notice_successful_create)
redirect_to project_customer_appointments_path(@project)
flash[:notice] = l(:notice_appointment_issues_created, count: created_issues.size)
else
flash[:error] = l(:error_no_labor_lines_found)
redirect_to customer_appointment_path(@appointment)
end
redirect_to customer_appointment_path(@appointment)
end
def index