qualityhigh impacttier 1100% confidence

Need to track loyalty/credit balance with audit log

from loyalty agent · cross-site verified across production deployments

The trigger

Need to track loyalty/credit balance with audit log

The fix

Use a single transactions table with signed amount (earn+, spend-). Balance = SUM. No separate balance column = no sync drift.

Code example

SELECT SUM(amount) FROM loyalty_transactions WHERE user_id=?

Related patterns

Does your site have this quality issue?

Run a free scan — we'll check all quality patterns in 30 seconds.

Scan your site free →