Metrics → Customers: only customers who have spent more than $0
A customer counts when their paid invoices' amount_paid, less refunds, is above zero. Trials ($0 invoices), fully discounted invoices, only-open invoices and payments refunded in full no longer put someone on the list. Also ticks the Market Fetch check in TEST.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,7 +116,7 @@ func TestCustomersPage(t *testing.T) {
|
||||
s.DB.Exec(`INSERT INTO crm_records (entity, espo_id, name, email, domain, data, synced_at) VALUES ('Account', 'a1', 'Acme', '', 'acme.example', '{}', '')`)
|
||||
s.DB.Exec(`INSERT INTO stripe_objects (kind, id, customer, data) VALUES ('customer', 'cus_x', 'cus_x', '{"name":"Xco","email":"x@xco.example"}'),
|
||||
('customer', 'cus_a', 'cus_a', '{"name":"Acme Ltd","email":"pay@acme.example"}')`)
|
||||
s.DB.Exec(`INSERT INTO stripe_objects (kind, id, customer, status, currency, data) VALUES ('invoice', 'in_1', 'cus_x', 'paid', 'usd', '{}'), ('invoice', 'in_2', 'cus_a', 'paid', 'usd', '{}')`)
|
||||
s.DB.Exec(`INSERT INTO stripe_objects (kind, id, customer, status, currency, data) VALUES ('invoice', 'in_1', 'cus_x', 'paid', 'usd', '{"amount_paid":1000}'), ('invoice', 'in_2', 'cus_a', 'paid', 'usd', '{"amount_paid":1000}')`)
|
||||
body := do(h, http.MethodGet, "/metrics/customers", nil, nil).Body.String()
|
||||
if !strings.Contains(body, "Xco") || strings.Contains(body, "Acme Ltd") {
|
||||
t.Fatal("the to-fix list should hold only the unmatched customer")
|
||||
|
||||
Reference in New Issue
Block a user