feat(loyalty): multi-select categories on transactions
Some checks failed
CI / ruff (push) Successful in 24s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / pytest (push) Has been cancelled

Switch from single category_id to category_ids JSON array on
transactions. Sellers can now select multiple categories (e.g.,
Men + Accessories) when entering stamp/points transactions.

- Migration loyalty_009: drop category_id FK, add category_ids JSON
- Schemas: category_id → category_ids (list[int] | None)
- Services: stamp_service + points_service accept category_ids
- Terminal UI: pills are now multi-select (toggle on/off)
- Transaction response: category_names (list[str]) resolved from IDs
- Recent transactions table: new Category column showing comma-
  separated names

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-19 21:36:49 +02:00
parent 220f7e3a08
commit 29593f4c61
11 changed files with 81 additions and 32 deletions

View File

@@ -31,7 +31,7 @@ function storeLoyaltyTerminal() {
// Transaction inputs
earnAmount: null,
selectedReward: '',
selectedCategory: null,
selectedCategories: [],
categories: [],
// PIN entry
@@ -300,7 +300,7 @@ function storeLoyaltyTerminal() {
await apiClient.post('/store/loyalty/stamp', {
card_id: this.selectedCard.id,
staff_pin: this.pinDigits,
category_id: this.selectedCategory || undefined,
category_ids: this.selectedCategories.length > 0 ? this.selectedCategories : undefined,
});
Utils.showToast(I18n.t('loyalty.store.terminal.stamp_added'), 'success');
@@ -326,7 +326,7 @@ function storeLoyaltyTerminal() {
card_id: this.selectedCard.id,
purchase_amount_cents: Math.round(this.earnAmount * 100),
staff_pin: this.pinDigits,
category_id: this.selectedCategory || undefined,
category_ids: this.selectedCategories.length > 0 ? this.selectedCategories : undefined,
});
const pointsEarned = response.points_earned || Math.floor(this.earnAmount * (this.program?.points_per_euro || 1));