Files
redmine_qbo_commission/app/helpers/sales_commissions_helper.rb
T
rickyandClaude Opus 5.5 73e643a6f9 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 <noreply@anthropic.com>
2026-11-17 07:00:28 -05:00

38 lines
2.1 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.
module SalesCommissionsHelper
def commission_money(amount)
RedmineQboCommission.format_money(amount)
end
def commission_rate(rate)
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
def commission_txn_link(txn, can_approve)
label = txn.doc_number.present? ? "##{txn.doc_number}" : txn.kind_name
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"
def commission_approved_text(record)
l(:text_sales_commission_approved_by, user: record.approved_by&.name.to_s, time: format_time(record.approved_at))
end
end