Skip to content

feat(OUT-3539): extract findOrMapInvoiceFromQBO helper for invoice sync resilience#216

Draft
SandipBajracharya wants to merge 1 commit intomasterfrom
OUT-3539
Draft

feat(OUT-3539): extract findOrMapInvoiceFromQBO helper for invoice sync resilience#216
SandipBajracharya wants to merge 1 commit intomasterfrom
OUT-3539

Conversation

@SandipBajracharya
Copy link
Copy Markdown
Collaborator

Summary

  • Adds findOrMapInvoiceFromQBO() helper that queries QBO by invoice number, resolves/creates the customer mapping, and inserts a qb_invoice_sync row when found
  • Integrates the helper into all 4 webhook handlers (created, paid, voided, deleted) as a fallback when no local mapping exists
  • Refactors checkIfInvoiceExistsInQBO() to delegate to the new helper, so existing callers (syncMissedInvoices, backfillTimedOutInvoices) automatically gain mapping creation

Problem

When an invoice is manually created in QBO, our app tries to create the same invoice and fails. Subsequent invoice.paid, invoice.void, and invoice.delete events also silently skip because no qb_invoice_sync mapping row exists in our database.

Test plan

  • Invoice exists in QBO but not in local DB → created webhook maps it and skips creation
  • paid / voided / deleted webhooks with unmapped invoice → maps from QBO and proceeds
  • Invoice already mapped locally → handlers continue as before (no extra QBO API call)
  • Invoice not in QBO at all → handlers silently return as before
  • Calling findOrMapInvoiceFromQBO twice for the same invoice does not create duplicates

🤖 Generated with Claude Code

…nc resilience

When an invoice is manually created in QBO, subsequent webhook events
(paid, void, delete) silently failed because no qb_invoice_sync mapping
existed. The new findOrMapInvoiceFromQBO helper queries QBO by invoice
number, resolves/creates the customer mapping, and inserts the
qb_invoice_sync row so downstream handlers can proceed normally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear bot commented Apr 9, 2026

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickbooks-sync (dev) Ready Ready Preview, Comment Apr 9, 2026 11:03am
quickbooks-sync Ready Ready Preview, Comment Apr 9, 2026 11:03am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant