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

+12 -6
View File
@@ -50,12 +50,18 @@ module RedmineQboCommission
I18n.t("label_sales_commission_kind_#{kind}")
end
# The transaction's page in QuickBooks
def qbo_url
host = defined?(RedmineQbo) && RedmineQbo.respond_to?(:sandbox_mode?) && RedmineQbo.sandbox_mode? ? 'sandbox' : 'app'
page = { 'invoice' => 'invoice', 'sales_receipt' => 'salesreceipt', 'refund_receipt' => 'refundreceipt',
'credit_memo' => 'creditmemo' }[kind]
"https://#{host}.qbo.intuit.com/app/#{page}?txnId=#{txn_id}"
# The QuickBooks services that print the transactions Redmine has no page for
PDF_SERVICES = { 'sales_receipt' => 'SalesReceipt', 'refund_receipt' => 'RefundReceipt',
'credit_memo' => 'CreditMemo' }.freeze
# QuickBooks' PDF of a sales receipt, refund receipt or credit memo (an invoice opens in Redmine instead)
def self.pdf(kind, txn_id)
entity = PDF_SERVICES.fetch(kind.to_s)
qbo = QboConnectionService.current!
qbo.perform_authenticated_request do |access_token|
service = "Quickbooks::Service::#{entity}".constantize.new(company_id: qbo.realm_id, access_token: access_token)
service.pdf(Struct.new(:id).new(txn_id.to_s))
end
end
end
end