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>
154 lines
6.3 KiB
ERB
154 lines
6.3 KiB
ERB
<%= render partial: 'tech_bonuses/styles' %>
|
|
<% report = @report %>
|
|
<% previous_week = @week - 1 %>
|
|
<% next_week = @week + 1 %>
|
|
|
|
<div class="contextual">
|
|
<%= link_to "« #{previous_week.label}", tech_bonus_week_path(previous_week.to_param) %>
|
|
<% if next_week.start_date <= Date.current %>
|
|
| <%= link_to "#{next_week.label} »", tech_bonus_week_path(next_week.to_param) %>
|
|
<% end %>
|
|
| <%= link_to sprite_icon('time', l(:label_tech_bonus_time_report)), report_time_entries_path(report.redmine_report_params), class: 'icon icon-time' %>
|
|
</div>
|
|
|
|
<h2><%= link_to l(:label_tech_bonus_plural), tech_bonuses_path %> » <%= bonus_week_title(@week) %></h2>
|
|
|
|
<div class="tech-bonus-summary">
|
|
<div class="box">
|
|
<%= l(:label_tech_bonus_total_hours) %>
|
|
<span class="value <%= report.goal_met? ? 'tech-bonus-ok' : 'tech-bonus-miss' %>"><%= bonus_hours(report.total_hours) %></span>
|
|
</div>
|
|
<div class="box">
|
|
<%= l(:label_tech_bonus_goal_hours) %>
|
|
<span class="value"><%= bonus_hours(report.goal_hours) %></span>
|
|
</div>
|
|
<div class="box">
|
|
<%= l(:label_tech_bonus_tiers) %>
|
|
<span class="value"><%= report.tiers %></span>
|
|
<%= l(:text_tech_bonus_tier_every, hours: bonus_hours(report.tier_hours)) %>
|
|
</div>
|
|
<div class="box">
|
|
<% if report.goal_met? %>
|
|
<%= l(:label_tech_bonus_next_tier) %>
|
|
<% else %>
|
|
<%= l(:label_tech_bonus_short_of_goal) %>
|
|
<% end %>
|
|
<span class="value"><%= bonus_hours(report.hours_to_next_tier) %></span>
|
|
</div>
|
|
</div>
|
|
|
|
<% unless @week.completed? %>
|
|
<p class="warning"><%= l(:text_tech_bonus_week_in_progress, date: format_date(@week.end_date)) %></p>
|
|
<% end %>
|
|
|
|
<h3><%= l(:label_tech_bonus_technicians) %></h3>
|
|
<% if report.lines.empty? %>
|
|
<p class="nodata"><%= l(:text_tech_bonus_no_technicians) %>
|
|
<% if User.current.admin? %><%= link_to l(:label_bonus_technician_new), new_bonus_technician_path %><% end %></p>
|
|
<% else %>
|
|
<%= form_tag tech_bonus_week_path(@week.to_param), method: :post, id: 'tech-bonus-run' do %>
|
|
<div class="autoscroll">
|
|
<table class="list tech-bonus-table">
|
|
<thead>
|
|
<tr>
|
|
<th><%= l(:label_user) %></th>
|
|
<th><%= l(:field_role) %></th>
|
|
<th><%= l(:label_tech_bonus_hours) %></th>
|
|
<th title="<%= l(:text_tech_bonus_attendance) %>"><%= l(:label_tech_bonus_attended) %></th>
|
|
<th><%= l(:label_tech_bonus_base) %></th>
|
|
<th><%= l(:label_tech_bonus_tier_bonus) %></th>
|
|
<th><%= l(:label_tech_bonus_amount) %></th>
|
|
<th><%= l(:label_tech_bonus_credit_memo) %></th>
|
|
<th><%= l(:field_status) %></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% report.lines.each do |line| %>
|
|
<% tech = line.technician %>
|
|
<% credit = @credits[tech.user_id] %>
|
|
<% credited = credit&.credited? %>
|
|
<tr class="<%= 'ineligible' unless line.eligible? %>">
|
|
<td class="name"><%= link_to_user tech.user %><br><small><%= tech.customer&.name || l(:text_tech_bonus_no_customer) %></small></td>
|
|
<td><%= tech.role_name %></td>
|
|
<td><%= bonus_hours(line.hours) %></td>
|
|
<td>
|
|
<% if credited %>
|
|
<%= sprite_icon('checked', l(:general_text_Yes)) %>
|
|
<% elsif line.eligible? %>
|
|
<%= check_box_tag 'attended[]', tech.user_id, credit.nil? || credit.message != l(:text_tech_bonus_missed_shift),
|
|
id: "attended_#{tech.user_id}", disabled: !report.goal_met? %>
|
|
<% end %>
|
|
</td>
|
|
<% if credited %>
|
|
<td><%= bonus_money(credit.base_amount) %></td>
|
|
<td><%= bonus_money(credit.tier_amount) %></td>
|
|
<td><%= bonus_money(credit.amount) %></td>
|
|
<% else %>
|
|
<td><%= bonus_money(line.base_amount) %></td>
|
|
<td><%= bonus_money(line.tier_amount) %></td>
|
|
<td><%= bonus_money(line.amount) %></td>
|
|
<% end %>
|
|
<td><%= credit_memo_link(credit) %></td>
|
|
<td class="message">
|
|
<%= bonus_status_tag(credit) %>
|
|
<% message = credit&.message.presence || line.ineligible_reason %>
|
|
<% if credit&.emailed_to.present? %><br><small><%= credit.emailed_to %></small><% end %>
|
|
<% if message %><br><small><%= message %></small><% end %>
|
|
</td>
|
|
<td>
|
|
<% if credited %>
|
|
<%= link_to sprite_icon('email', l(:button_tech_bonus_resend)), resend_tech_bonus_credit_path(credit),
|
|
method: :post, class: 'icon icon-email',
|
|
data: { confirm: l(:text_tech_bonus_resend_confirm) } %>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p><em class="info"><%= l(:text_tech_bonus_attendance) %></em></p>
|
|
|
|
<% if @week.completed? %>
|
|
<p>
|
|
<% label = report.goal_met? ? l(:button_tech_bonus_run) : l(:button_tech_bonus_record) %>
|
|
<%= submit_tag label, data: { confirm: report.goal_met? ? l(:text_tech_bonus_run_confirm) : nil } %>
|
|
<% if @bonus_week %>
|
|
<em class="info"><%= l(:text_tech_bonus_already_run, user: @bonus_week.run_by&.name, time: format_time(@bonus_week.updated_at)) %></em>
|
|
<% end %>
|
|
</p>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<h3><%= l(:label_tech_bonus_shop_hours) %></h3>
|
|
<% if report.hours_by_user.empty? %>
|
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
|
<% else %>
|
|
<% tech_ids = report.technicians.map(&:user_id) %>
|
|
<div class="autoscroll">
|
|
<table class="list tech-bonus-table">
|
|
<thead>
|
|
<tr><th><%= l(:label_user) %></th><th><%= l(:label_tech_bonus_hours) %></th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<% report.hours_by_user.each do |user_id, hours| %>
|
|
<tr>
|
|
<td class="name">
|
|
<%= report.users[user_id] ? link_to_user(report.users[user_id]) : "##{user_id}" %>
|
|
<% unless tech_ids.include?(user_id) %><small>(<%= l(:text_tech_bonus_helping) %>)</small><% end %>
|
|
</td>
|
|
<td><%= bonus_hours(hours) %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
<tfoot>
|
|
<tr><td class="name"><%= l(:label_total_time) %></td><td><%= bonus_hours(report.total_hours) %></td></tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% html_title "#{l(:label_tech_bonus_plural)} #{@week.label}" %>
|