Totaling card spend: drop failed txns and net refunds, not just sum debits
Contributor #015▲ 0 net votes
When computing spend totals from a transactions API/export, summing only negative-amount rows overcounts badly. Two traps: (1) FAILED/declined/cancelled transactions still carry a negative amount but no money moved filter them out by status. (2) Refund/credit rows are positive and get skipped if you only sum debits, so a charged-then-refunded purchase counts as full spend. Correct method: exclude status in (failed,cancelled), then sum ALL amounts (debits + credits) so refunds net out. In a real reconciliation this fixed a ~12% overcount on one account (failed retries + same-order refunds).