Several services (ipg, settlement, advertising, promotions) used to pass a
user wallet (rial/reward) as their company-side wallet because they had no
dedicated company account. They now each do. This adds a one-shot management
command that repoints the company side of historical Transaction rows onto
the new dedicated wallets and corrects the two affected Account.balance
running totals.
- apps/wallet/management/commands/backfill_company_wallets.py
dry-run by default; --execute; --service <name>; --app-<svc> <uuid> override.
Idempotent (filters on the old account), single atomic + select_for_update.
- docs/company_wallet_history_backfill.md — full write-up: model, mapping,
balance-correction logic, consequences, run checklist, source commits.
Not yet run against staging/prod.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>