New plugin: weekly technician bonus credit memos (SOP-OPS-012)

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>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-16 12:13:30 -05:00
commit a2ecb74c1d
37 files changed
+2274

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
<%= render partial: 'tech_bonuses/styles' %>
<div class="contextual">
<% if User.current.admin? %>
<%= link_to sprite_icon('user', l(:label_bonus_technician_plural)), bonus_technicians_path, class: 'icon icon-user' %>
<%= link_to sprite_icon('settings', l(:label_settings)), plugin_settings_path('redmine_qbo_bonus'), class: 'icon icon-settings' %>
<% end %>
</div>
<h2><%= l(:label_tech_bonus_plural) %></h2>
<%= form_tag(tech_bonuses_path, method: :get, id: 'tech-bonus-week-picker', class: 'tech-bonus-picker') do %>
<label for="tech_bonus_week"><%= l(:label_tech_bonus_week) %></label>
<%= select_tag 'week', options_for_select(@weeks.map { |week| [bonus_week_title(week), week.to_param] }, @week.to_param),
id: 'tech_bonus_week' %>
<%= submit_tag l(:button_tech_bonus_preview), name: nil %>
<% end %>
<h3><%= l(:label_tech_bonus_history) %></h3>
<% if @bonus_weeks.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<div class="autoscroll">
<table class="list tech-bonus-weeks">
<thead>
<tr>
<th><%= l(:label_tech_bonus_week) %></th>
<th><%= l(:label_tech_bonus_hours_total_goal) %></th>
<th><%= l(:label_tech_bonus_tiers) %></th>
<th><%= l(:label_tech_bonus_credits) %></th>
<th><%= l(:label_tech_bonus_amount) %></th>
<th><%= l(:label_tech_bonus_run_by) %></th>
</tr>
</thead>
<tbody>
<% @bonus_weeks.each do |bonus_week| %>
<tr>
<td><%= link_to bonus_week_title(bonus_week.week), tech_bonus_week_path(bonus_week.week.to_param) %></td>
<td class="<%= bonus_week.goal_met? ? 'tech-bonus-ok' : 'tech-bonus-miss' %>">
<%= bonus_hours(bonus_week.total_hours) %>/<%= bonus_hours(bonus_week.goal_hours) %>
</td>
<td><%= bonus_week.tiers %></td>
<td>
<%= bonus_week.credits.count(&:credited?) %>
<% failed = bonus_week.credits.count { |credit| credit.status == 'failed' } %>
<% if failed.positive? %><span class="tech-bonus-error">(<%= l(:label_tech_bonus_failed_count, count: failed) %>)</span><% end %>
</td>
<td><%= bonus_money(bonus_week.credited_total) %></td>
<td><%= bonus_week.run_by ? link_to_user(bonus_week.run_by) : '' %> <%= format_time(bonus_week.updated_at) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
<% html_title l(:label_tech_bonus_plural) %>