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

@@ -0,0 +1,32 @@
<%= error_messages_for @technician %>
<% taken = BonusTechnician.where.not(id: @technician.id).pluck(:user_id) %>
<% users = User.active.sorted.where.not(id: taken).to_a %>
<% users << @technician.user if @technician.user && !users.include?(@technician.user) %>
<div class="box tabular">
<p>
<%= f.select :user_id, users.map { |user| [user.name, user.id] }, { include_blank: true, required: true, label: :field_user },
{ disabled: @technician.persisted? } %>
</p>
<p>
<label for="bonus_technician_customer_name"><%= l(:label_bonus_technician_customer) %></label>
<%= text_field_tag 'customer_name', @technician.customer&.name, id: 'bonus_technician_customer_name',
class: 'customer-name', autocomplete: 'off', size: 40, placeholder: l(:label_choose_a_customer),
data: { autocomplete_url: '/customers/autocomplete' } %>
<%= f.hidden_field :customer_id, id: 'customer_id' %>
<em class="info"><%= l(:text_bonus_technician_customer) %></em>
</p>
<p><%= f.select :role, BonusTechnician.role_options, required: true %></p>
<p>
<%= f.date_field :probation_until, label: :field_bonus_technician_probation_until %>
<em class="info"><%= l(:text_bonus_technician_probation) %></em>
</p>
<p><%= f.check_box :active %></p>
</div>
<%= javascript_tag do %>
$(function() {
if (window.initCustomerAutocomplete) { window.initCustomerAutocomplete(document); }
$('#bonus_technician_customer_name').on('input', function() {
if (!$(this).val()) { $('#customer_id').val(''); }
});
});
<% end %>
@@ -0,0 +1,8 @@
<h2><%= link_to l(:label_bonus_technician_plural), bonus_technicians_path %> » <%= @technician.name %></h2>
<%= labelled_form_for @technician, url: bonus_technician_path(@technician), method: :patch do |f| %>
<%= render partial: 'bonus_technicians/form', locals: { f: f } %>
<%= submit_tag l(:button_save) %>
<% end %>
<% html_title @technician.name %>
@@ -0,0 +1,45 @@
<div class="contextual">
<%= link_to sprite_icon('add', l(:label_bonus_technician_new)), new_bonus_technician_path, class: 'icon icon-add' %>
<%= link_to sprite_icon('settings', l(:label_settings)), plugin_settings_path('redmine_qbo_bonus'), class: 'icon icon-settings' %>
</div>
<h2><%= l(:label_bonus_technician_plural) %></h2>
<p><em class="info"><%= l(:text_bonus_technicians) %></em></p>
<% if @technicians.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<div class="autoscroll">
<table class="list">
<thead>
<tr>
<th><%= l(:label_user) %></th>
<th><%= l(:field_role) %></th>
<th><%= l(:label_bonus_technician_customer) %></th>
<th><%= l(:field_bonus_technician_probation_until) %></th>
<th><%= l(:field_active) %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @technicians.each do |tech| %>
<tr>
<td class="name"><%= link_to_user tech.user %></td>
<td><%= tech.role_name %></td>
<td><%= tech.customer ? link_to(tech.customer.name, customer_path(tech.customer)) : content_tag(:span, l(:text_tech_bonus_no_customer), class: 'tech-bonus-error') %></td>
<td><%= format_date(tech.probation_until) %></td>
<td><%= checked_image tech.active? %></td>
<td class="buttons">
<%= link_to sprite_icon('edit', l(:button_edit)), edit_bonus_technician_path(tech), class: 'icon icon-edit' %>
<%= link_to sprite_icon('del', l(:button_delete)), bonus_technician_path(tech), method: :delete,
data: { confirm: l(:text_are_you_sure) }, class: 'icon icon-del' %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
<% html_title l(:label_bonus_technician_plural) %>
+8
View File
@@ -0,0 +1,8 @@
<h2><%= link_to l(:label_bonus_technician_plural), bonus_technicians_path %> » <%= l(:label_bonus_technician_new) %></h2>
<%= labelled_form_for @technician, url: bonus_technicians_path do |f| %>
<%= render partial: 'bonus_technicians/form', locals: { f: f } %>
<%= submit_tag l(:button_create) %>
<% end %>
<% html_title l(:label_bonus_technician_new) %>