Files
redmine_qbo_bonus/test/integration/bonus_technicians_test.rb
T
rickyandClaude Opus 5.5 a2ecb74c1d 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>
2026-11-16 12:13:30 -05:00

51 lines
2.4 KiB
Ruby

#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require File.expand_path('../test_helper', __dir__)
class BonusTechniciansTest < Redmine::IntegrationTest
include QboBonusTestHelper
def test_admins_link_a_user_to_a_customer
customer = create_customer(id: 9100, name: 'Jane Tech')
log_user('admin', 'admin')
get '/bonus_technicians/new'
assert_response :success
assert_select 'input.customer-name'
assert_difference 'BonusTechnician.count', 1 do
post '/bonus_technicians', params: { bonus_technician: { user_id: '2', customer_id: customer.id.to_s,
role: 'foreman', active: '1' } }
end
assert_redirected_to '/bonus_technicians'
tech = BonusTechnician.last
assert_equal customer, tech.customer
assert_equal 'foreman', tech.role
get '/bonus_technicians'
assert_select 'td', text: 'Jane Tech'
patch "/bonus_technicians/#{tech.id}", params: { bonus_technician: { probation_until: '2026-12-01' } }
assert_equal Date.new(2026, 12, 1), tech.reload.probation_until
end
def test_unknown_customer
log_user('admin', 'admin')
post '/bonus_technicians', params: { bonus_technician: { user_id: '2', customer_id: '424242', role: 'technician' } }
assert_response :unprocessable_entity
end
def test_admins_only
log_user('jsmith', 'jsmith')
get '/bonus_technicians'
assert_response :forbidden
end
end