From 73e643a6f973a814577cfd73fdb7c1d18368f77c Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Tue, 17 Nov 2026 07:00:28 -0500 Subject: [PATCH] Invoices on the commission page open in Redmine Paid sales invoices link to their Redmine invoice page (or PDF without the Write invoices permission) instead of QuickBooks. Sales receipts, refund receipts and credit memos, which Redmine has no page for, still open in QuickBooks. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- app/helpers/sales_commissions_helper.rb | 11 +++++++++-- test/integration/sales_commissions_test.rb | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 391b878..1fe6190 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Returns, canceled orders and refunded deposits are deducted from the month's sal Once the month is over, **Approve for payroll** reads QuickBooks one last time. It records the sales, deductions, threshold, rates and payouts, so the month no longer changes with QuickBooks or the settings. **Payroll CSV** downloads each rep's payout. **Reopen** puts an approved month back to being worked out from QuickBooks; the unticked items, adjustments and notes are kept. -Approvers see each transaction linked to QuickBooks, and the list of months with the month picker. +Approvers see each invoice linked to its page in Redmine (or its PDF without the Write invoices permission), the sales receipts, refund receipts and credit memos linked to QuickBooks, and the list of months with the month picker. ## Requirements diff --git a/app/helpers/sales_commissions_helper.rb b/app/helpers/sales_commissions_helper.rb index f85152a..33abde2 100644 --- a/app/helpers/sales_commissions_helper.rb +++ b/app/helpers/sales_commissions_helper.rb @@ -17,10 +17,17 @@ module SalesCommissionsHelper RedmineQboCommission.format_rate(rate) end - # The transaction's number, linked to it in QuickBooks for those who approve + # The transaction's number, linked for those who approve: an invoice opens in Redmine (its invoice page, or its + # PDF without the Write invoices permission); the others, which Redmine has no page for, open in QuickBooks def commission_txn_link(txn, can_approve) label = txn.doc_number.present? ? "##{txn.doc_number}" : txn.kind_name - can_approve ? link_to(label, txn.qbo_url, target: '_blank', rel: 'noopener') : label + return label unless can_approve + + if txn.kind == 'invoice' + link_to(label, RedmineQboBilling.invoice_writer? ? edit_qbo_invoice_path(txn.txn_id) : invoice_path(txn.txn_id)) + else + link_to(label, txn.qbo_url, target: '_blank', rel: 'noopener') + end end # "Approved by Jane Smith on 12/03/2026 09:15 AM" diff --git a/test/integration/sales_commissions_test.rb b/test/integration/sales_commissions_test.rb index 445119f..bc9e1b9 100644 --- a/test/integration/sales_commissions_test.rb +++ b/test/integration/sales_commissions_test.rb @@ -57,6 +57,10 @@ class SalesCommissionsTest < Redmine::IntegrationTest assert_select 'input[name=?][value=?][checked]', 'included[]', 'refund_receipt:3' assert_select 'input[name=?][value="2"][checked]', 'eligible[]' assert_select 'input[name=approve]' + # Invoices open in Redmine, the refund receipt (no Redmine page) in QuickBooks + assert_select '#sales-commission-sales a[href=?]', '/qbo_invoices/1/edit' + assert_select '#sales-commission-sales a[href*="qbo.intuit.com"]', count: 0 + assert_select '#sales-commission-deductions a[href*="qbo.intuit.com/app/refundreceipt?txnId=3"]' end def test_view_only