Cash on Delivery looks simple from the outside: customer gets the package, customer pays the driver, order is "paid." Most systems model it exactly that way β a boolean on the order row flips from false to true and everyone moves on.
That's wrong, and it took a support ticket to notice why.
The money the driver collected isn't actually ours yet. It's sitting with the carrier until they run their settlement cycle and transfer it over β which, depending on the carrier, can be days or weeks later. During that whole window, "paid: true" is a lie. The order is fulfilled, sure. The cash isn't.
So we stopped treating it as a flag and started treating it as what it actually is: a receivable. An order moves from placed β COD pending (an open receivable on our books) β carrier payout β reconciled, and it's only "settled" once we've matched an actual payout from the carrier against that specific order's expected amount.β¦