Files
redmine_qbo_commission/app/controllers/commission_reps_controller.rb
T
rickyandClaude Opus 5.5 6fcd5f9b64 New plugin: monthly sales commission (SOP-OPS-013)
Reads the month's paid sales from QuickBooks Online (invoices paid in
full that month, sales receipts), deducts refund receipts, credit memos
and adjustments, works out the commission pool with the threshold and
marginal brackets, and records each sales rep's payout once the month
is approved for payroll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 18:53:25 -05:00

67 lines
2.3 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.
# Administration » Commission reps: who earns the monthly sales commission
class CommissionRepsController < ApplicationController
layout 'admin'
self.main_menu = false
menu_item :commission_reps
before_action :require_admin
before_action :find_rep, only: [:edit, :update, :destroy]
def index
@reps = CommissionRep.sorted.to_a
end
def new
@rep = CommissionRep.new
end
def create
@rep = CommissionRep.new(rep_params)
if @rep.save
flash[:notice] = l(:notice_successful_create)
redirect_to commission_reps_path
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @rep.update(rep_params.except(:user_id))
flash[:notice] = l(:notice_successful_update)
redirect_to commission_reps_path
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@rep.destroy
flash[:notice] = l(:notice_successful_delete)
redirect_to commission_reps_path
end
private
def find_rep
@rep = CommissionRep.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
def rep_params
params.require(:commission_rep).permit(:user_id, :probation_until, :active)
end
end