Why every balance on DevMall is derived, not stored
A seller balance column is a bug waiting for a concurrent refund. Here is what we do instead.
The first version of nearly every marketplace has a column called balance on the seller row, and an UPDATE sellers SET balance = balance + ? somewhere in the checkout path. It works until two things happen at once, and then it works incorrectly and silently.
DevMall does not have that column. Seller balances are derived from double-entry postings: a sale credits SELLER_PENDING, settlement moves it to SELLER_AVAILABLE, a payout debits it. The database enforces that every entry balances, with a deferred constraint trigger that refuses to commit an entry whose debits and credits disagree.
The cost is one join and a small amount of arithmetic on every dashboard load. The benefit is that "how much do we owe this seller" has exactly one answer, and that answer can be replayed from the beginning of time and audited line by line.
More from the blog
Six licences, not sixty
Sellers wanted custom licence text. We said no, and buyer disputes fell.
What we check before a listing goes live
Eight automated stages, then a human. Here is what each one is actually looking for.
How to price a licence ladder that people actually climb
Extended should be a multiple of Commercial, not a surcharge on it. Here is why.