Show estimate, invoice and payment activity on the activity page

Each type appears only on the overall activity page, and only for users who may see it:
estimates need View customers or Write estimates, invoices View customers or Write invoices,
and payments View or Receive payments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-03 21:53:13 -05:00
1 parent dbee228cdf
commit 159420fac1
10 files changed
+185

No files matched your search

+15
View File
@@ -17,11 +17,26 @@ class Invoice < QboBaseModel
self.primary_key = :id
qbo_sync push: false
include QboActivity
qbo_activity 'qbo_invoices', icon: 'qbo-invoice', permissions: %i[view_customers write_invoices],
title: ->(i) { I18n.t(:label_activity_invoice, number: i.doc_number, customer: i.activity_customer) },
description: ->(i) { i.activity_description },
url: ->(i) { { controller: 'invoices', action: 'show', id: i.id } }
# Return the invoice's document number as its string representation
def to_s
doc_number
end
# Amount and where it stands, e.g. "$1,250.00 · Partially paid ($400.00 owed)"
def activity_description
state = status
owed = activity_money(self[:balance]) if state && self[:balance].to_d.positive?
[activity_money(self[:total_amount]),
(I18n.t(:"label_invoice_status_#{state}", default: state.to_s.humanize) if state),
(I18n.t(:text_activity_invoice_owed, amount: owed) if owed && state != :open && state != :overdue)].compact.join(' · ')
end
# Paid, partially paid, overdue, open or voided, from the cached total, balance and due date
# (RedmineQboBilling::InvoiceStatus); nil when the balance isn't cached
def status(today: User.current.today)