Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffaf37e55b | ||
|
|
67a0bc62aa | ||
|
|
d35d408ac6 | ||
|
|
07e79a3c00 |
No files matched your search
@@ -25,7 +25,7 @@ The tier line is only there when a tier was reached. Both lines use the product/
|
|||||||
|
|
||||||
## Running a week
|
## Running a week
|
||||||
|
|
||||||
**Tech bonuses** (top menu) lists the weeks run so far. Pick a week to see:
|
**Tech bonuses** (top menu) opens this week, so far. For those who run the bonus, its title links to the weeks run so far and a week picker. A week shows:
|
||||||
|
|
||||||
* the shop's hours, the goal, the tiers reached and the hours to the next tier;
|
* the shop's hours, the goal, the tiers reached and the hours to the next tier;
|
||||||
* each technician's hours and bonus, with an **Attended** box. Uncheck a technician who missed part of a scheduled shift;
|
* each technician's hours and bonus, with an **Attended** box. Uncheck a technician who missed part of a scheduled shift;
|
||||||
@@ -55,7 +55,9 @@ Restart Redmine, then:
|
|||||||
* Check the target and amounts.
|
* Check the target and amounts.
|
||||||
* Pick the product/service.
|
* Pick the product/service.
|
||||||
3. **Administration » Bonus technicians**: add each technician and the Foreman. Give each one their role, the QuickBooks customer account their bonus is credited to, and the last day of their probation if they're in it.
|
3. **Administration » Bonus technicians**: add each technician and the Foreman. Give each one their role, the QuickBooks customer account their bonus is credited to, and the last day of their probation if they're in it.
|
||||||
4. **Administration » Roles and permissions**: give **Run tech bonuses** to the roles that run the bonus. It's a global permission, so it applies to any role the user has in any project.
|
4. **Administration » Roles and permissions**: give **Run tech bonuses** to the roles that run the bonus, and **View tech bonuses** to those who only see a week's hours and bonuses (e.g. the Foreman), without the weeks run. They're global permissions, so they apply to any role the user has in any project.
|
||||||
|
|
||||||
|
**View tech bonuses** shows the weeks and each week's hours, tiers and bonuses, read-only. It doesn't show the technicians' customer accounts, the attendance boxes, or the credit memos' QuickBooks and PDF links, and it can't run a week or email a credit memo.
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,16 @@ class TechBonusesController < ApplicationController
|
|||||||
@week = RedmineQboBonus::Week.last_completed
|
@week = RedmineQboBonus::Week.last_completed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The top menu opens this week, so far
|
||||||
|
def current
|
||||||
|
redirect_to tech_bonus_week_path(RedmineQboBonus::Week.containing(Date.current).to_param)
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@report = RedmineQboBonus::WeekReport.new(@week)
|
@report = RedmineQboBonus::WeekReport.new(@week)
|
||||||
@bonus_week = TechBonusWeek.for(@week)
|
@bonus_week = TechBonusWeek.for(@week)
|
||||||
@credits = @bonus_week ? @bonus_week.credits.index_by(&:user_id) : {}
|
@credits = @bonus_week ? @bonus_week.credits.index_by(&:user_id) : {}
|
||||||
|
@can_run = RedmineQboBonus.allowed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
| <%= link_to sprite_icon('time', l(:label_tech_bonus_time_report)), report_time_entries_path(report.redmine_report_params), class: 'icon icon-time' %>
|
| <%= link_to sprite_icon('time', l(:label_tech_bonus_time_report)), report_time_entries_path(report.redmine_report_params), class: 'icon icon-time' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2><%= link_to l(:label_tech_bonus_plural), tech_bonuses_path %> » <%= bonus_week_title(@week) %></h2>
|
<h2><%= @can_run ? link_to(l(:label_tech_bonus_plural), tech_bonuses_path) : l(:label_tech_bonus_plural) %> » <%= bonus_week_title(@week) %></h2>
|
||||||
|
|
||||||
<div class="tech-bonus-summary">
|
<div class="tech-bonus-summary">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
@@ -69,13 +69,16 @@
|
|||||||
<% credit = @credits[tech.user_id] %>
|
<% credit = @credits[tech.user_id] %>
|
||||||
<% credited = credit&.credited? %>
|
<% credited = credit&.credited? %>
|
||||||
<tr class="<%= 'ineligible' unless line.eligible? %>">
|
<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 class="name">
|
||||||
|
<%= link_to_user tech.user %>
|
||||||
|
<% if @can_run %><br><small><%= tech.customer&.name || l(:text_tech_bonus_no_customer) %></small><% end %>
|
||||||
|
</td>
|
||||||
<td><%= tech.role_name %></td>
|
<td><%= tech.role_name %></td>
|
||||||
<td><%= bonus_hours(line.hours) %></td>
|
<td><%= bonus_hours(line.hours) %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if credited %>
|
<% if credited %>
|
||||||
<%= sprite_icon('checked', l(:general_text_Yes)) %>
|
<%= sprite_icon('checked', l(:general_text_Yes)) %>
|
||||||
<% elsif line.eligible? %>
|
<% elsif @can_run && line.eligible? %>
|
||||||
<%= check_box_tag 'attended[]', tech.user_id, credit.nil? || credit.message != l(:text_tech_bonus_missed_shift),
|
<%= 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? %>
|
id: "attended_#{tech.user_id}", disabled: !report.goal_met? %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -89,15 +92,15 @@
|
|||||||
<td><%= bonus_money(line.tier_amount) %></td>
|
<td><%= bonus_money(line.tier_amount) %></td>
|
||||||
<td><%= bonus_money(line.amount) %></td>
|
<td><%= bonus_money(line.amount) %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= credit_memo_link(credit) %></td>
|
<td><%= @can_run ? credit_memo_link(credit) : (credit&.doc_number.presence && "##{credit.doc_number}") %></td>
|
||||||
<td class="message">
|
<td class="message">
|
||||||
<%= bonus_status_tag(credit) %>
|
<%= bonus_status_tag(credit) %>
|
||||||
<% message = credit&.message.presence || line.ineligible_reason %>
|
<% message = credit&.message.presence || line.ineligible_reason %>
|
||||||
<% if credit&.emailed_to.present? %><br><small><%= credit.emailed_to %></small><% end %>
|
<% if @can_run && credit&.emailed_to.present? %><br><small><%= credit.emailed_to %></small><% end %>
|
||||||
<% if message %><br><small><%= message %></small><% end %>
|
<% if message %><br><small><%= message %></small><% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% if credited %>
|
<% if credited && @can_run %>
|
||||||
<%= link_to sprite_icon('email', l(:button_tech_bonus_resend)), resend_tech_bonus_credit_path(credit),
|
<%= link_to sprite_icon('email', l(:button_tech_bonus_resend)), resend_tech_bonus_credit_path(credit),
|
||||||
method: :post, class: 'icon icon-email',
|
method: :post, class: 'icon icon-email',
|
||||||
data: { confirm: l(:text_tech_bonus_resend_confirm) } %>
|
data: { confirm: l(:text_tech_bonus_resend_confirm) } %>
|
||||||
@@ -108,9 +111,11 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<% if @can_run %>
|
||||||
<p><em class="info"><%= l(:text_tech_bonus_attendance) %></em></p>
|
<p><em class="info"><%= l(:text_tech_bonus_attendance) %></em></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if @week.completed? %>
|
<% if @can_run && @week.completed? %>
|
||||||
<p>
|
<p>
|
||||||
<% label = report.goal_met? ? l(:button_tech_bonus_run) : l(:button_tech_bonus_record) %>
|
<% 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 } %>
|
<%= submit_tag label, data: { confirm: report.goal_met? ? l(:text_tech_bonus_run_confirm) : nil } %>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
en:
|
en:
|
||||||
permission_run_tech_bonuses: "Run tech bonuses"
|
permission_run_tech_bonuses: "Run tech bonuses"
|
||||||
|
permission_view_tech_bonuses: "View tech bonuses"
|
||||||
|
|
||||||
label_tech_bonus_plural: "Tech bonuses"
|
label_tech_bonus_plural: "Tech bonuses"
|
||||||
label_bonus_technician_plural: "Bonus technicians"
|
label_bonus_technician_plural: "Bonus technicians"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ RedmineApp::Application.routes.draw do
|
|||||||
|
|
||||||
# Weekly bonus: the weeks run, a week's hours and bonuses (by its Sunday, e.g. /tech_bonuses/2026-11-15)
|
# Weekly bonus: the weeks run, a week's hours and bonuses (by its Sunday, e.g. /tech_bonuses/2026-11-15)
|
||||||
get 'tech_bonuses', to: 'tech_bonuses#index', as: :tech_bonuses
|
get 'tech_bonuses', to: 'tech_bonuses#index', as: :tech_bonuses
|
||||||
|
get 'tech_bonuses/current', to: 'tech_bonuses#current', as: :current_tech_bonus_week
|
||||||
get 'tech_bonuses/:week', to: 'tech_bonuses#show', as: :tech_bonus_week, constraints: { week: /\d{4}-\d{2}-\d{2}/ }
|
get 'tech_bonuses/:week', to: 'tech_bonuses#show', as: :tech_bonus_week, constraints: { week: /\d{4}-\d{2}-\d{2}/ }
|
||||||
post 'tech_bonuses/:week', to: 'tech_bonuses#create', constraints: { week: /\d{4}-\d{2}-\d{2}/ }
|
post 'tech_bonuses/:week', to: 'tech_bonuses#create', constraints: { week: /\d{4}-\d{2}-\d{2}/ }
|
||||||
get 'tech_bonuses/credits/:id/pdf', to: 'tech_bonuses#pdf', as: :tech_bonus_credit_pdf
|
get 'tech_bonuses/credits/:id/pdf', to: 'tech_bonuses#pdf', as: :tech_bonus_credit_pdf
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Redmine::Plugin.register :redmine_qbo_bonus do
|
|||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'Weekly billable hours bonus for technicians (SOP-OPS-012): totals the shop\'s billable hours for a week, ' \
|
description 'Weekly billable hours bonus for technicians (SOP-OPS-012): totals the shop\'s billable hours for a week, ' \
|
||||||
'and credits each qualifying technician\'s QuickBooks customer account with an emailed credit memo'
|
'and credits each qualifying technician\'s QuickBooks customer account with an emailed credit memo'
|
||||||
version '2026.11.0'
|
version '2026.11.2'
|
||||||
url 'https://gitea.rickbarrette.org/ricky/redmine_qbo_bonus'
|
url 'https://gitea.rickbarrette.org/ricky/redmine_qbo_bonus'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine version_or_higher: '7.0.0'
|
requires_redmine version_or_higher: '7.0.0'
|
||||||
@@ -29,12 +29,14 @@ Redmine::Plugin.register :redmine_qbo_bonus do
|
|||||||
|
|
||||||
settings default: RedmineQboBonus::Settings::DEFAULTS.dup, partial: 'settings/qbo_bonus'
|
settings default: RedmineQboBonus::Settings::DEFAULTS.dup, partial: 'settings/qbo_bonus'
|
||||||
|
|
||||||
# Previewing a week's bonus, creating and emailing its credit memos
|
# Seeing a week's hours and bonuses (e.g. the Foreman), without the weeks run, running them or opening the credit memos
|
||||||
permission :run_tech_bonuses, { tech_bonuses: [:index, :show, :create, :resend, :pdf] }, global: true
|
permission :view_tech_bonuses, { tech_bonuses: [:current, :show] }, global: true
|
||||||
|
# The weeks run, previewing a week's bonus, creating and emailing its credit memos
|
||||||
|
permission :run_tech_bonuses, { tech_bonuses: [:index, :current, :show, :create, :resend, :pdf] }, global: true
|
||||||
|
|
||||||
menu :top_menu, :tech_bonuses, { controller: 'tech_bonuses', action: 'index' },
|
menu :top_menu, :tech_bonuses, { controller: 'tech_bonuses', action: 'current' },
|
||||||
caption: :label_tech_bonus_plural, after: :my_page,
|
caption: :label_tech_bonus_plural, after: :my_page,
|
||||||
if: proc { User.current.allowed_to?(:run_tech_bonuses, nil, global: true) }
|
if: proc { RedmineQboBonus.visible? }
|
||||||
|
|
||||||
# The technicians who earn the bonus and their QuickBooks customer accounts
|
# The technicians who earn the bonus and their QuickBooks customer accounts
|
||||||
menu :admin_menu, :bonus_technicians, { controller: 'bonus_technicians', action: 'index' },
|
menu :admin_menu, :bonus_technicians, { controller: 'bonus_technicians', action: 'index' },
|
||||||
|
|||||||
@@ -12,10 +12,16 @@ module RedmineQboBonus
|
|||||||
|
|
||||||
def self.setup; end
|
def self.setup; end
|
||||||
|
|
||||||
|
# May run the bonus (create and email credit memos)
|
||||||
def self.allowed?(user = User.current)
|
def self.allowed?(user = User.current)
|
||||||
user.allowed_to?(:run_tech_bonuses, nil, global: true)
|
user.allowed_to?(:run_tech_bonuses, nil, global: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# May see the bonus pages (run them, or only view them)
|
||||||
|
def self.visible?(user = User.current)
|
||||||
|
allowed?(user) || user.allowed_to?(:view_tech_bonuses, nil, global: true)
|
||||||
|
end
|
||||||
|
|
||||||
# 95.5 => "95.5", 110.0 => "110", 87.583 => "87.58"
|
# 95.5 => "95.5", 110.0 => "110", 87.583 => "87.58"
|
||||||
def self.format_hours(hours)
|
def self.format_hours(hours)
|
||||||
rounded = hours.to_d.round(2)
|
rounded = hours.to_d.round(2)
|
||||||
|
|||||||
@@ -31,7 +31,50 @@ class TechBonusesTest < Redmine::IntegrationTest
|
|||||||
Role.find(1).add_permission!(:run_tech_bonuses)
|
Role.find(1).add_permission!(:run_tech_bonuses)
|
||||||
get '/tech_bonuses'
|
get '/tech_bonuses'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select '#top-menu a.tech-bonuses'
|
assert_select '#top-menu a.tech-bonuses[href=?]', '/tech_bonuses/current'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_menu_opens_this_week
|
||||||
|
log_user('admin', 'admin')
|
||||||
|
travel_to Date.new(2026, 11, 18) do
|
||||||
|
get '/tech_bonuses/current'
|
||||||
|
assert_redirected_to '/tech_bonuses/2026-11-15'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_view_only
|
||||||
|
log_user('admin', 'admin')
|
||||||
|
post '/tech_bonuses/2026-11-08', params: { attended: ['2'] }
|
||||||
|
credit = TechBonusCredit.find_by(user_id: 2)
|
||||||
|
|
||||||
|
Role.find(1).add_permission!(:view_tech_bonuses)
|
||||||
|
reset!
|
||||||
|
log_user('jsmith', 'jsmith')
|
||||||
|
get '/tech_bonuses'
|
||||||
|
assert_response :forbidden
|
||||||
|
get '/tech_bonuses/current'
|
||||||
|
assert_response :redirect
|
||||||
|
get '/tech_bonuses/2026-11-08'
|
||||||
|
assert_response :success
|
||||||
|
assert_select '#top-menu a.tech-bonuses[href=?]', '/tech_bonuses/current'
|
||||||
|
assert_select 'h2 a[href=?]', '/tech_bonuses', count: 0
|
||||||
|
assert_select 'td', text: '$100.00'
|
||||||
|
assert_select 'td', text: '#1042'
|
||||||
|
assert_select 'input[name=?]', 'attended[]', count: 0
|
||||||
|
assert_select '#tech-bonus-run input[type=submit]', count: 0
|
||||||
|
assert_select 'a[href*="creditmemo"]', count: 0
|
||||||
|
assert_select 'a[href*="/pdf"]', count: 0
|
||||||
|
assert_select 'a[href*="/resend"]', count: 0
|
||||||
|
assert_not_includes response.body, 'tech@example.com'
|
||||||
|
|
||||||
|
assert_no_difference 'TechBonusCredit.count' do
|
||||||
|
post '/tech_bonuses/2026-11-15', params: { attended: ['2'] }
|
||||||
|
end
|
||||||
|
assert_response :forbidden
|
||||||
|
post "/tech_bonuses/credits/#{credit.id}/resend"
|
||||||
|
assert_response :forbidden
|
||||||
|
get "/tech_bonuses/credits/#{credit.id}/pdf"
|
||||||
|
assert_response :forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_week_preview
|
def test_week_preview
|
||||||
|
|||||||
Reference in new issue
Block a user