Top menu opens this week; weeks run are for Run tech bonuses
The Tech bonuses top menu now goes to /tech_bonuses/current, which redirects to the week containing today. The index (week picker and weeks run) is limited to Run tech bonuses: View tech bonuses only covers a week's page, whose title links to the index only for those who can run the bonus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d35d408ac6
commit
67a0bc62aa
6 files changed
+28
-11
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
|
||||
|
||||
**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;
|
||||
* each technician's hours and bonus, with an **Attended** box. Uncheck a technician who missed part of a scheduled shift;
|
||||
@@ -55,7 +55,7 @@ Restart Redmine, then:
|
||||
* Check the target and amounts.
|
||||
* 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.
|
||||
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 it (e.g. the Foreman). They're global permissions, so they apply 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.
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ class TechBonusesController < ApplicationController
|
||||
@week = RedmineQboBonus::Week.last_completed
|
||||
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
|
||||
@report = RedmineQboBonus::WeekReport.new(@week)
|
||||
@bonus_week = TechBonusWeek.for(@week)
|
||||
|
||||
@@ -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' %>
|
||||
</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="box">
|
||||
|
||||
@@ -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)
|
||||
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}/ }
|
||||
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
|
||||
|
||||
@@ -29,12 +29,12 @@ Redmine::Plugin.register :redmine_qbo_bonus do
|
||||
|
||||
settings default: RedmineQboBonus::Settings::DEFAULTS.dup, partial: 'settings/qbo_bonus'
|
||||
|
||||
# Seeing the weeks' hours and bonuses (e.g. the Foreman), without running them or opening the credit memos
|
||||
permission :view_tech_bonuses, { tech_bonuses: [:index, :show] }, global: true
|
||||
# Previewing a week's bonus, creating and emailing its credit memos
|
||||
permission :run_tech_bonuses, { tech_bonuses: [:index, :show, :create, :resend, :pdf] }, global: true
|
||||
# Seeing a week's hours and bonuses (e.g. the Foreman), without the weeks run, running them or opening the credit memos
|
||||
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,
|
||||
if: proc { RedmineQboBonus.visible? }
|
||||
|
||||
|
||||
@@ -31,7 +31,15 @@ class TechBonusesTest < Redmine::IntegrationTest
|
||||
Role.find(1).add_permission!(:run_tech_bonuses)
|
||||
get '/tech_bonuses'
|
||||
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
|
||||
@@ -43,10 +51,13 @@ class TechBonusesTest < Redmine::IntegrationTest
|
||||
reset!
|
||||
log_user('jsmith', 'jsmith')
|
||||
get '/tech_bonuses'
|
||||
assert_response :success
|
||||
assert_select '#top-menu a.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
|
||||
|
||||
Reference in new issue
Block a user