feat(loyalty): transaction categories (what was sold)
Some checks failed
Some checks failed
Merchants can configure per-store product categories (e.g., Men,
Women, Accessories, Kids) that sellers select when entering loyalty
transactions. Enables per-category sales analytics.
Backend:
- New model: StoreTransactionCategory (store-scoped, max 10 per store)
- Migration loyalty_007: creates table + adds category_id FK on
loyalty_transactions
- New category_service.py with CRUD + validation
- New schemas/category.py (Create, Update, Response, ListResponse)
- Admin CRUD: GET/POST/PATCH/DELETE /admin/loyalty/stores/{id}/categories
- Store CRUD: GET/POST/PATCH/DELETE /store/loyalty/categories
- Stamp/Points request schemas accept optional category_id
- Stamp/Points services pass category_id to transaction creation
- TransactionResponse includes category_id + category_name
342 tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,12 @@ class LoyaltyTransaction(Base, TimestampMixin):
|
||||
index=True,
|
||||
comment="Staff PIN used for this operation",
|
||||
)
|
||||
category_id = Column(
|
||||
Integer,
|
||||
ForeignKey("store_transaction_categories.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
comment="Product category (e.g., Men, Women, Accessories)",
|
||||
)
|
||||
|
||||
# Related transaction (for voids/returns)
|
||||
related_transaction_id = Column(
|
||||
|
||||
Reference in New Issue
Block a user