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>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-16 18:53:25 -05:00
commit 6fcd5f9b64
44 files changed
+2661

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
en:
permission_view_sales_commission: "View sales commission"
permission_approve_sales_commission: "Approve sales commission"
label_sales_commission: "Sales commission"
label_commission_rep_plural: "Commission reps"
label_commission_rep_new: "New commission rep"
field_commission_rep_probation_until: "Probation until"
field_probation_until: "Probation until"
label_sales_commission_month: "Month"
label_sales_commission_history: "Months"
label_sales_commission_status_open: "Open"
label_sales_commission_status_approved: "Approved"
label_sales_commission_approved_by: "Approved by"
label_sales_commission_gross_sales: "Paid sales"
label_sales_commission_deductions: "Deductions"
label_sales_commission_net_sales: "Commission sales"
label_sales_commission_threshold: "Threshold"
label_sales_commission_short_of_threshold: "Short of threshold"
label_sales_commission_pool: "Commission"
label_sales_commission_payouts: "Payouts"
label_sales_commission_payouts_total: "Paid out"
label_sales_commission_paid: "Paid"
label_sales_commission_reason: "Why not"
label_sales_commission_amount: "Amount"
label_sales_commission_bracket: "Bracket"
label_sales_commission_rate: "Rate"
label_sales_commission_bracket_sales: "Sales in bracket"
label_sales_commission_deducted: "Deduct"
label_sales_commission_number: "No."
label_sales_commission_customer: "Customer"
label_sales_commission_total: "Total"
label_sales_commission_tax: "Tax"
label_sales_commission_paid_on: "Paid in full"
label_sales_commission_sales: "Paid sales"
label_sales_commission_adjustment: "Adjustment"
label_sales_commission_add_adjustment: "Add an adjustment"
label_sales_commission_payroll_csv: "Payroll CSV"
label_sales_commission_kind_invoice: "Invoice"
label_sales_commission_kind_sales_receipt: "Sales receipt"
label_sales_commission_kind_refund_receipt: "Refund receipt"
label_sales_commission_kind_credit_memo: "Credit memo"
label_sales_commission_rates: "Threshold and rates"
label_sales_commission_base_rate: "Base rate"
label_sales_commission_step_rate: "Step-up rate"
label_sales_commission_top_rate: "Top rate"
label_sales_commission_up_to: "of sales up to"
label_sales_commission_above: "of sales above that"
label_sales_commission_counted: "What counts"
label_sales_commission_include_sales_receipts: "Count sales receipts"
label_sales_commission_deduct_refund_receipts: "Deduct refund receipts"
label_sales_commission_deduct_credit_memos: "Deduct credit memos"
label_sales_commission_excluded_items: "Not returns"
button_sales_commission_show: "Show"
button_sales_commission_refresh: "Read from QuickBooks"
button_sales_commission_approve: "Approve for payroll"
button_sales_commission_reopen: "Reopen"
notice_sales_commission_approved: "%{month} is approved for payroll."
notice_sales_commission_reopened: "%{month} is open again."
error_sales_commission_month_not_over: "The month isn't over yet."
error_sales_commission_already_approved: "This month is approved. Reopen it to change it."
error_sales_commission_qbo: "Couldn't read QuickBooks: %{error}"
text_sales_commission_month_in_progress: "This month isn't over until %{date}, so its sales can still change. It can be approved once it's over."
text_sales_commission_read_at: "Read from QuickBooks at %{time}. It's read again every 15 minutes."
text_sales_commission_approved_by: "Approved for payroll by %{user} on %{time}."
text_sales_commission_threshold_met: "reached"
text_sales_commission_threshold_of: "to reach %{amount}"
text_sales_commission_each_rep: "for each rep"
text_sales_commission_no_reps: "No commission reps yet."
text_sales_commission_eligible: "Untick a rep who shouldn't be paid for this month."
text_sales_commission_unticked: "Unticked when approving"
text_sales_commission_inactive: "Not active"
text_sales_commission_probation: "On probation until %{date}"
text_sales_commission_adjustment: "Deducted from the month's sales, e.g. a return refunded by company check. A negative amount adds sales back."
text_sales_commission_sales: "Invoices count in the month they're paid in full, and sales receipts on their date. Amounts are without sales tax."
text_sales_commission_approve_confirm: "Read the month from QuickBooks one last time and approve it for payroll?"
text_sales_commission_reopen_confirm: "Reopen this month? It goes back to being worked out from QuickBooks as it stands."
text_commission_reps: "The sales reps, service advisors and counter sales staff who earn the monthly sales commission (SOP-OPS-013). Each eligible rep is paid the whole commission."
text_commission_rep_probation: "The last day of their 90-day probation. Months that start on or before this day pay no commission."
text_sales_commission_setting_threshold: "No commission for a month below this (SOP-OPS-013: $100,000). At or above it, the whole month counts from the first dollar."
text_sales_commission_setting_brackets: "Each rate applies only to the sales inside its bracket (SOP-OPS-013: 0.5% up to $125,000, 0.75% up to $150,000, 1% above)."
text_sales_commission_setting_sales_receipts: "Counter sales paid on the spot count on their date."
text_sales_commission_setting_excluded_items: "Credit memos made only of these products/services aren't returns and aren't deducted. The tech bonus product/service (redmine_qbo_bonus) is always left out."
+31
View File
@@ -0,0 +1,31 @@
#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.
RedmineApp::Application.routes.draw do
# Monthly commission: the months, a month's sales, pool and payouts (by its year and month, e.g. /sales_commission/2026-11)
month = { month: /\d{4}-\d{2}/ }
get 'sales_commission', to: 'sales_commissions#index', as: :sales_commissions
get 'sales_commission/current', to: 'sales_commissions#current', as: :current_sales_commission_month
get 'sales_commission/:month', to: 'sales_commissions#show', as: :sales_commission_month, constraints: month
post 'sales_commission/:month', to: 'sales_commissions#update', constraints: month
post 'sales_commission/:month/refresh', to: 'sales_commissions#refresh', as: :refresh_sales_commission_month,
constraints: month
post 'sales_commission/:month/reopen', to: 'sales_commissions#reopen', as: :reopen_sales_commission_month,
constraints: month
post 'sales_commission/:month/adjustments', to: 'sales_commissions#add_adjustment',
as: :sales_commission_adjustments, constraints: month
delete 'sales_commission/:month/adjustments/:id', to: 'sales_commissions#remove_adjustment',
as: :sales_commission_adjustment, constraints: month
# Administration » Commission reps
resources :commission_reps, except: [:show]
end