feat(loyalty): translatable categories + mandatory on earn points
Some checks failed
CI / pytest (push) Failing after 2h47m45s
CI / validate (push) Successful in 39s
CI / dependency-scanning (push) Successful in 47s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped
CI / ruff (push) Successful in 21s

- Add name_translations JSON column to StoreTransactionCategory
  (migration loyalty_008). Stores {"en": "Men", "fr": "Hommes", ...}.
  Model has get_translated_name(lang) helper.
- Admin CRUD form now has FR/DE/LB translation inputs alongside the
  default name.
- Points earn: category_id is now mandatory when the store has
  active categories configured. Returns CATEGORY_REQUIRED error.
- Stamps: category remains optional (quick tap workflow).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-19 14:12:55 +02:00
parent ab2daf99bd
commit eafa086c73
6 changed files with 101 additions and 9 deletions

View File

@@ -10,6 +10,10 @@ class CategoryCreate(BaseModel):
"""Schema for creating a transaction category."""
name: str = Field(..., min_length=1, max_length=100)
name_translations: dict[str, str] | None = Field(
None,
description='Translations keyed by language: {"en": "Men", "fr": "Hommes"}',
)
display_order: int = Field(default=0, ge=0)
@@ -17,6 +21,7 @@ class CategoryUpdate(BaseModel):
"""Schema for updating a transaction category."""
name: str | None = Field(None, min_length=1, max_length=100)
name_translations: dict[str, str] | None = None
display_order: int | None = Field(None, ge=0)
is_active: bool | None = None
@@ -29,6 +34,7 @@ class CategoryResponse(BaseModel):
id: int
store_id: int
name: str
name_translations: dict[str, str] | None = None
display_order: int
is_active: bool
created_at: datetime