Files
redmine_qbo_commission/db/migrate/003_create_commission_lines.rb
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

31 lines
1.9 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.
class CreateCommissionLines < ActiveRecord::Migration[7.0]
def change
# A QuickBooks transaction as it counted toward an approved month
create_table :commission_lines do |t|
t.integer :commission_month_id, null: false
# invoice, sales_receipt, refund_receipt or credit_memo
t.string :kind, null: false
t.string :txn_id, null: false
t.string :doc_number
t.string :customer_name
# The day an invoice was paid in full, or the transaction's date
t.date :txn_date
t.decimal :total, precision: 15, scale: 2, null: false, default: 0
t.decimal :tax, precision: 15, scale: 2, null: false, default: 0
# Whether a deduction was ticked (sales always count)
t.boolean :included, null: false, default: true
end
add_index :commission_lines, :commission_month_id
end
end