Files
apskel-pos-backend/internal/models
efrilmandClaude Opus 5.5 39e47ff0e6 feat(loyalty): typed loyalty settings with change history
Adds LoyaltySettingsProcessor (docs/prd-point-coin.md F1, F2, F12, PC-109).

Reading returns typed settings for an outlet (earning per currency, paying
with EnakPoint) and for an organization (point value, exchange rate,
transfers, and the expiry settings awaiting note N4). A key that was never
set takes the PRD default. A stored value that is unusable, such as an
earn_per_amount of 0 that would divide by zero, also falls back to the
default and is logged, so a bad row never reaches a calculation.

Writing takes the whole settings struct, validates every rule in the PRD
before touching the database, and stores and records in
loyalty_setting_changes only the keys whose effective value changes: old
value (NULL while it was on its default), new value, and who changed it.
Clearing a limit deletes the stored value. Each save runs in one
transaction under an advisory lock per outlet or organization, so two saves
at once cannot both compute their change from the same old value. The
outlet must belong to the caller's organization.

Every key is described once (key, default, valid range, bound field), and
reading, validating and diffing all use that description.

GET /customer/wallet now reads the point value through this processor; the
minimal organization settings repository from PC-106 is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 10:23:08 +07:00
..
2026-06-08 12:30:39 +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-18 01:32:01 +07:00
2025-09-18 12:42:07 +07:00
2025-09-17 19:30:17 +07:00
2026-06-08 12:30:39 +07:00
2026-08-13 14:38:28 +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
2025-08-14 01:35:19 +07:00
2025-09-12 01:12:11 +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
…
2026-06-08 12:30:39 +07:00
2026-06-08 12:30:39 +07:00
2026-06-08 12:29:59 +07:00
2026-08-13 14:38:28 +07:00
2025-09-17 23:55:11 +07:00
2025-09-18 13:39:37 +07:00
…
2025-09-17 19:30:17 +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