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

@@ -0,0 +1,65 @@
<%# Settings for redmine_qbo_commission (Administration » Plugins » Configure) %>
<% s = RedmineQboCommission::Settings %>
<% field = ->(key) { "settings[#{key}]" } %>
<% plain = ->(number) { number.to_d == number.to_d.to_i ? number.to_d.to_i.to_s : number.to_d.to_s('F') } %>
<% brackets = s.brackets %>
<p>
<%= link_to sprite_icon('user', l(:label_commission_rep_plural)), commission_reps_path, class: 'icon icon-user' %>
<%= link_to sprite_icon('stats', l(:label_sales_commission)), sales_commissions_path, class: 'icon icon-stats' %>
</p>
<fieldset class="box tabular">
<legend><%= l(:label_sales_commission_rates) %></legend>
<p>
<label for="qbo_commission_threshold"><%= l(:label_sales_commission_threshold) %></label>
$<%= number_field_tag field.call('threshold'), plain.call(s.threshold), id: 'qbo_commission_threshold', min: 0, step: 0.01, style: 'width: 9em' %>
<em class="info"><%= l(:text_sales_commission_setting_threshold) %></em>
</p>
<p>
<label for="qbo_commission_base_rate"><%= l(:label_sales_commission_base_rate) %></label>
<%= number_field_tag field.call('base_rate'), plain.call(brackets[0][1]), id: 'qbo_commission_base_rate', min: 0, step: 0.01, style: 'width: 5em' %>%
<%= l(:label_sales_commission_up_to) %>
$<%= number_field_tag field.call('base_limit'), plain.call(brackets[0][0]), id: 'qbo_commission_base_limit', min: 0, step: 0.01, style: 'width: 9em' %>
</p>
<p>
<label for="qbo_commission_step_rate"><%= l(:label_sales_commission_step_rate) %></label>
<%= number_field_tag field.call('step_rate'), plain.call(brackets[1][1]), id: 'qbo_commission_step_rate', min: 0, step: 0.01, style: 'width: 5em' %>%
<%= l(:label_sales_commission_up_to) %>
$<%= number_field_tag field.call('step_limit'), plain.call(brackets[1][0]), id: 'qbo_commission_step_limit', min: 0, step: 0.01, style: 'width: 9em' %>
</p>
<p>
<label for="qbo_commission_top_rate"><%= l(:label_sales_commission_top_rate) %></label>
<%= number_field_tag field.call('top_rate'), plain.call(brackets[2][1]), id: 'qbo_commission_top_rate', min: 0, step: 0.01, style: 'width: 5em' %>%
<%= l(:label_sales_commission_above) %>
</p>
<p><em class="info"><%= l(:text_sales_commission_setting_brackets) %></em></p>
</fieldset>
<fieldset class="box tabular">
<legend><%= l(:label_sales_commission_counted) %></legend>
<p>
<label for="qbo_commission_sales_receipts"><%= l(:label_sales_commission_include_sales_receipts) %></label>
<%= hidden_field_tag field.call('include_sales_receipts'), '0', id: nil %>
<%= check_box_tag field.call('include_sales_receipts'), '1', s.include_sales_receipts?, id: 'qbo_commission_sales_receipts' %>
<em class="info"><%= l(:text_sales_commission_setting_sales_receipts) %></em>
</p>
<p>
<label for="qbo_commission_refund_receipts"><%= l(:label_sales_commission_deduct_refund_receipts) %></label>
<%= hidden_field_tag field.call('deduct_refund_receipts'), '0', id: nil %>
<%= check_box_tag field.call('deduct_refund_receipts'), '1', s.deduct_refund_receipts?, id: 'qbo_commission_refund_receipts' %>
</p>
<p>
<label for="qbo_commission_credit_memos"><%= l(:label_sales_commission_deduct_credit_memos) %></label>
<%= hidden_field_tag field.call('deduct_credit_memos'), '0', id: nil %>
<%= check_box_tag field.call('deduct_credit_memos'), '1', s.deduct_credit_memos?, id: 'qbo_commission_credit_memos' %>
</p>
<p>
<label for="qbo_commission_items"><%= l(:label_sales_commission_excluded_items) %></label>
<%= hidden_field_tag "#{field.call('excluded_item_ids')}[]", '', id: nil %>
<%= select_tag "#{field.call('excluded_item_ids')}[]",
options_from_collection_for_select(Item.order(:name), :id, :name, Array(s.values['excluded_item_ids']).map(&:to_s)),
multiple: true, size: 8, id: 'qbo_commission_items' %>
<em class="info"><%= l(:text_sales_commission_setting_excluded_items) %></em>
</p>
</fieldset>