Metrics: MRR and cohorts count only paid invoices

Open (unpaid) invoices no longer count toward MRR, so they don't put a
customer in a cohort either; an invoice counts once it's paid. This
matches the customer count, which takes only those who have spent more
than $0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 12:47:30 -07:00
co-authored by Claude Opus 5.5
parent 739f85fde1
commit fab349d166
3 changed files with 7 additions and 5 deletions
+3 -3
View File
@@ -46,11 +46,11 @@ func (l line) monthly() float64 {
return float64(l.amount) / months
}
// loadLines reads the recurring lines of billed invoices (paid or open; not
// void, not uncollectible) in the main currency.
// loadLines reads the recurring lines of paid invoices (not open, void or
// uncollectible) in the main currency.
func loadLines(d *db.DB, currency string) ([]line, error) {
rows, err := d.Query(`SELECT customer, amount, period_start, period_end, interval, interval_count, proration, product
FROM stripe_invoice_lines WHERE recurring = 1 AND status IN ('paid', 'open') AND currency = ? AND customer != ''
FROM stripe_invoice_lines WHERE recurring = 1 AND status = 'paid' AND currency = ? AND customer != ''
AND period_end > period_start ORDER BY invoice, id`, currency) // a fixed order: float sums come out the same everywhere
if err != nil {
return nil, err