Files
apskel-pos-backend/internal/entities
efrilmandClaude Opus 5.5 fc5eecb68a feat(wallet): add wallet entities and repository
Entities for the four wallet tables and a WalletRepository that the wallet
processor will build on (PC-103).

Every method goes through the caller's transaction, and writes and locks
refuse to run without one: outside a transaction a lock is released as soon
as it is taken and a balance could move without its ledger row.

- LockWallet creates the wallet on first use, taking the organization from
  the customer, then locks it with SELECT ... FOR UPDATE.
- LockWallets always locks in customer_id order so opposite transfers
  cannot deadlock.
- AddBalance and ConsumeLot are conditional updates that return an error
  when they would overdraw, instead of tripping the CHECK constraint.
- ListActiveLots returns unexpired lots with balance in K9 spending order.

The tests need a real Postgres and run only when TEST_DATABASE_URL points at
a migrated database. Both the lock and the lock ordering were checked by
removing them and watching the tests fail (lost update, deadlock detected).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 01:01:03 +07:00
..
2025-09-12 01:12:11 +07:00
2025-09-18 17:21:58 +07:00
2026-08-13 14:38:28 +07:00
2026-08-05 19:28:38 +07:00
2025-09-12 16:37:16 +07:00
2025-09-17 19:30:17 +07:00
2025-09-17 19:30:17 +07:00
2025-09-18 01:32:01 +07:00
2026-08-13 14:38:28 +07:00
2025-07-18 20:10:29 +07:00
2025-09-17 19:30:17 +07:00
2025-09-18 12:01:20 +07:00
2025-09-17 19:30:17 +07:00
2026-06-08 12:30:39 +07:00
2025-07-18 20:10:29 +07:00
2026-05-10 10:57:38 +07:00
2025-09-17 19:30:17 +07:00
2026-06-08 12:30:39 +07:00
2025-07-18 20:10:29 +07:00
2025-08-07 22:45:02 +07:00
2025-07-18 20:10:29 +07:00
2025-09-18 12:01:20 +07:00
2025-07-18 20:10:29 +07:00
2025-07-18 20:10:29 +07:00
2025-08-08 22:33:08 +07:00
2025-08-07 22:45:02 +07:00
2026-06-08 12:30:39 +07:00
2026-06-08 12:30:39 +07:00
2026-08-13 14:38:28 +07:00
2025-09-18 01:38:03 +07:00
2025-09-17 19:30:17 +07:00
2025-08-08 00:22:28 +07:00
2026-05-10 10:42:09 +07:00
2026-06-19 13:31:33 +07:00
2025-09-12 01:12:11 +07:00