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>
39 lines
2.2 KiB
Ruby
39 lines
2.2 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 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
|
|
|
|
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, sales_commission_txn_pdf_path(txn.kind, txn.txn_id), 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
|