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

+15
View File
@@ -0,0 +1,15 @@
<%= error_messages_for @rep %>
<% taken = CommissionRep.where.not(id: @rep.id).pluck(:user_id) %>
<% users = User.active.sorted.where.not(id: taken).to_a %>
<% users << @rep.user if @rep.user && !users.include?(@rep.user) %>
<div class="box tabular">
<p>
<%= f.select :user_id, users.map { |user| [user.name, user.id] }, { include_blank: true, required: true, label: :field_user },
{ disabled: @rep.persisted? } %>
</p>
<p>
<%= f.date_field :probation_until, label: :field_commission_rep_probation_until %>
<em class="info"><%= l(:text_commission_rep_probation) %></em>
</p>
<p><%= f.check_box :active %></p>
</div>
+8
View File
@@ -0,0 +1,8 @@
<h2><%= link_to l(:label_commission_rep_plural), commission_reps_path %> » <%= @rep.name %></h2>
<%= labelled_form_for @rep, url: commission_rep_path(@rep), method: :patch do |f| %>
<%= render partial: 'commission_reps/form', locals: { f: f } %>
<%= submit_tag l(:button_save) %>
<% end %>
<% html_title @rep.name %>
+41
View File
@@ -0,0 +1,41 @@
<div class="contextual">
<%= link_to sprite_icon('add', l(:label_commission_rep_new)), new_commission_rep_path, class: 'icon icon-add' %>
<%= link_to sprite_icon('settings', l(:label_settings)), plugin_settings_path('redmine_qbo_commission'), class: 'icon icon-settings' %>
</div>
<h2><%= l(:label_commission_rep_plural) %></h2>
<p><em class="info"><%= l(:text_commission_reps) %></em></p>
<% if @reps.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<div class="autoscroll">
<table class="list">
<thead>
<tr>
<th><%= l(:label_user) %></th>
<th><%= l(:field_commission_rep_probation_until) %></th>
<th><%= l(:field_active) %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @reps.each do |rep| %>
<tr>
<td class="name"><%= link_to_user rep.user %></td>
<td><%= format_date(rep.probation_until) %></td>
<td><%= checked_image rep.active? %></td>
<td class="buttons">
<%= link_to sprite_icon('edit', l(:button_edit)), edit_commission_rep_path(rep), class: 'icon icon-edit' %>
<%= link_to sprite_icon('del', l(:button_delete)), commission_rep_path(rep), method: :delete,
data: { confirm: l(:text_are_you_sure) }, class: 'icon icon-del' %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
<% html_title l(:label_commission_rep_plural) %>
+8
View File
@@ -0,0 +1,8 @@
<h2><%= link_to l(:label_commission_rep_plural), commission_reps_path %> » <%= l(:label_commission_rep_new) %></h2>
<%= labelled_form_for @rep, url: commission_reps_path do |f| %>
<%= render partial: 'commission_reps/form', locals: { f: f } %>
<%= submit_tag l(:button_create) %>
<% end %>
<% html_title l(:label_commission_rep_new) %>