Receipts and credit memos open QuickBooks' PDF through Redmine

Sales receipts, refund receipts and credit memos on the commission
page link to their QuickBooks PDF, fetched by Redmine (approvers only),
so nothing on the page opens QuickBooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-17 07:07:24 -05:00
1 parent 9501216525
commit e76bd12b7f
7 files changed
+57 -15

No files matched your search

@@ -16,7 +16,7 @@ class SalesCommissionsController < ApplicationController
menu_item :sales_commissions
before_action :authorize_global
before_action :find_month, except: [:index, :current]
before_action :find_month, except: [:index, :current, :txn_pdf]
before_action :find_open_record, only: [:update, :add_adjustment, :remove_adjustment]
helper :sales_commissions
@@ -120,6 +120,19 @@ class SalesCommissionsController < ApplicationController
render_404
end
# QuickBooks' PDF of a sales receipt, refund receipt or credit memo, shown in the browser
def txn_pdf
pdf = RedmineQboCommission::Txn.pdf(params[:kind], params[:txn_id])
send_data pdf, type: 'application/pdf', disposition: 'inline',
filename: "#{params[:kind].to_s.dasherize}-#{params[:txn_id].to_i}.pdf"
rescue KeyError
render_404
rescue StandardError => e
Rails.logger.error "[redmine_qbo_commission] PDF of #{params[:kind]} #{params[:txn_id]}: #{e.message}"
flash[:error] = l(:error_sales_commission_qbo, error: e.message)
redirect_back_or_default sales_commissions_path
end
private
def find_month
+4 -3
View File
@@ -17,8 +17,9 @@ module SalesCommissionsHelper
RedmineQboCommission.format_rate(rate)
end
# 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
# The transaction's number, linked for those who approve: an invoice opens its page in Redmine (or its PDF
# without the Write invoices permission); a sales receipt, refund receipt or credit memo, which Redmine has no
# page for, opens QuickBooks' PDF of it
def commission_txn_link(txn, can_approve)
label = txn.doc_number.present? ? "##{txn.doc_number}" : txn.kind_name
return label unless can_approve
@@ -26,7 +27,7 @@ module SalesCommissionsHelper
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')
link_to(label, sales_commission_txn_pdf_path(txn.kind, txn.txn_id), target: '_blank', rel: 'noopener')
end
end