From bcdb177244a94a4fc6f47926463880c5a99f5c01 Mon Sep 17 00:00:00 2001 From: Krao Hasanee Date: Thu, 2 Jul 2026 10:17:19 -0400 Subject: [PATCH] fix: report billing counts only sent/paid invoices as Invoiced MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Draft invoices and orphaned invoice line items (invoice deleted → null) no longer count as Invoiced on the billing report, matching what the Finances page shows as issued. Not-invoiced/invoiced/paid buckets still sum to total version rows. No-op on current data (no drafts/orphans); guards future drafts. Co-Authored-By: Claude Opus 4.8 --- src/pages/team/TeamReports.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/team/TeamReports.jsx b/src/pages/team/TeamReports.jsx index 4e25faf..1ea2725 100644 --- a/src/pages/team/TeamReports.jsx +++ b/src/pages/team/TeamReports.jsx @@ -15,8 +15,12 @@ function fmtVersion(versionNumber) { } function billingStatusFromInvoices(items = []) { - if (!items.length) return 'not_started'; - if (items.some((item) => item.invoice?.status === 'paid')) return 'paid'; + // Only a sent or paid invoice counts as billed. Draft invoices and orphaned + // line items (invoice deleted → invoice null) are treated as Not Invoiced, + // matching what the Finances page actually shows as issued. + const issued = items.filter((item) => item.invoice?.status === 'sent' || item.invoice?.status === 'paid'); + if (!issued.length) return 'not_started'; + if (issued.some((item) => item.invoice?.status === 'paid')) return 'paid'; return 'invoiced'; }