Show names in issue history, and record invoices the webhook attaches

The history showed the customer and estimate as id numbers. It now shows their names,
for existing entries too. When the QuickBooks webhook attaches an invoice to an issue,
the issue's history gets "Invoice 1042 added", linking to the invoice PDF.

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 159420fac1
commit d2cdd798cd
3 files changed
+83

No files matched your search

@@ -27,6 +27,7 @@ class InvoiceAttachmentService
unless issue.invoices.exists?(@invoice.id)
issue.invoices << @invoice
issue.save! if issue.changed?
journalize(issue)
log "Attached invoice ##{@invoice.id} to issue ##{issue.id}"
end
end
@@ -34,6 +35,18 @@ class InvoiceAttachmentService
private
# Records the new invoice in the issue's history (shown by RedmineQbo::Patches::IssuesHelperPatch).
# The webhook has no Redmine user, so the entry is by Anonymous. Saving the journal also sends
# Redmine's usual issue-updated emails.
def journalize(issue)
journal = Journal.new(journalized: issue, user: User.anonymous, notes: '')
journal.details << JournalDetail.new(property: 'invoice', prop_key: @invoice.id.to_s, value: @invoice.to_s.presence || @invoice.id.to_s)
journal.save
rescue => e
# The invoice is attached either way; a missing history entry shouldn't fail the sync
log "Couldn't add invoice ##{@invoice.id} to the history of issue ##{issue.id}: #{e.message}"
end
# Extract issue IDs from the invoice's private note and line descriptions
def extract_issue_ids
ids = []