feat(wallet): serve customer balances and history from the wallet

GET /customer/wallet now reads the EnakPoint & EnakCoin wallet
(docs/prd-point-coin.md F6, PC-106): spendable point and coin balances, the
rupiah value of one EnakPoint and of the balance, the nearest day each
currency loses balance (grouped by Asia/Jakarta day), and recent ledger
rows. The fields of the pre-wallet response stay, filled from the wallet, so
app versions that read them keep working.

Adds GET /customer/wallet/transactions with pagination and filters for
currency, one or more types, and an inclusive date range. Each row shows
where the value came from (additions) or went to (deductions) as in §8.1,
and additions list their lots and earliest expiry. The counterparty id, the
admin and the metadata are left out; the description already carries the
masked name. A malformed query answers 400, a missing customer 404.

/customer/points and /customer/tokens keep their shape and now read the
wallet too, so customer_points_repository is no longer used for balances.

Balances are what the customer can spend: lots that have expired but that
the expiry job has not processed are not counted. The point value is read
from organization_settings (loyalty.point.value, default 1) through a small
repository that the typed settings reader in PC-109 will build on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
efrilm
2026-09-30 09:15:26 +07:00
co-authored by Claude Opus 5.5
parent 41b75810fd
commit e5db0325cc
13 changed files with 1199 additions and 130 deletions
+13
View File
@@ -109,7 +109,20 @@ type GetCustomerWalletResponse struct {
Data *GetCustomerWalletResponseData `json:"data,omitempty"`
}
// GetCustomerWalletResponseData is GET /customer/wallet (docs/prd-point-coin.md F6).
type GetCustomerWalletResponseData struct {
// Balances the customer can spend now.
PointBalance int64 `json:"point_balance"`
CoinBalance int64 `json:"coin_balance"`
// Rupiah value of one EnakPoint, and of the whole point balance. EnakPoint only
// ever pays for orders, so the app shows this as "setara potongan Rp …" (K7).
PointValue int64 `json:"point_value"`
PointDiscountValue int64 `json:"point_discount_value"`
NearestExpiring CustomerWalletNearestExpiring `json:"nearest_expiring"`
RecentTransactions []CustomerWalletTransaction `json:"recent_transactions"`
// Deprecated: the shape of this endpoint before the wallet, kept for app versions
// that still read it. Filled from the wallet like the fields above.
TotalPoints int64 `json:"total_points"`
TotalTokens int64 `json:"total_tokens"`
PointsHistory []PointsHistoryItem `json:"points_history,omitempty"`