Totals the shop's billable hours for a Sunday-Saturday week (picked projects, trackers and users) against the SOP-OPS-012 target, and credits each qualifying technician's QuickBooks customer account with a credit memo: a "Tech Bonus <week> <total>/<goal> hours (total/goal)" line, plus a separate tier line for every full 15 hours over the goal. Credit memos are emailed through QuickBooks. - Bonus technicians (admin): user, QuickBooks customer, role (technician/foreman), probation end - Tech bonuses (global "Run tech bonuses" permission): week preview, attendance check, run, PDF and email again; re-running a week never credits anyone twice Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.6 KiB
Ruby
69 lines
2.6 KiB
Ruby
#The MIT License (MIT)
|
|
#
|
|
#Copyright (c) 2026 rick barrette
|
|
#
|
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
#
|
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
#
|
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
# Administration » Bonus technicians: who earns the weekly bonus, their role and their QuickBooks customer account
|
|
class BonusTechniciansController < ApplicationController
|
|
layout 'admin'
|
|
self.main_menu = false
|
|
menu_item :bonus_technicians
|
|
|
|
before_action :require_admin
|
|
before_action :find_technician, only: [:edit, :update, :destroy]
|
|
|
|
def index
|
|
@technicians = BonusTechnician.sorted.includes(:customer).to_a
|
|
end
|
|
|
|
def new
|
|
@technician = BonusTechnician.new
|
|
end
|
|
|
|
def create
|
|
@technician = BonusTechnician.new(technician_params)
|
|
if @technician.save
|
|
flash[:notice] = l(:notice_successful_create)
|
|
redirect_to bonus_technicians_path
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
if @technician.update(technician_params)
|
|
flash[:notice] = l(:notice_successful_update)
|
|
redirect_to bonus_technicians_path
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@technician.destroy
|
|
flash[:notice] = l(:notice_successful_delete)
|
|
redirect_to bonus_technicians_path
|
|
end
|
|
|
|
private
|
|
|
|
def find_technician
|
|
@technician = BonusTechnician.find(params[:id])
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
|
|
def technician_params
|
|
permitted = params.require(:bonus_technician).permit(:user_id, :customer_id, :role, :probation_until, :active)
|
|
permitted[:customer_id] = permitted[:customer_id].presence if permitted.key?(:customer_id)
|
|
permitted
|
|
end
|
|
end
|