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>
71 lines
1.5 KiB
Python
71 lines
1.5 KiB
Python
# app/modules/loyalty/models/__init__.py
|
|
"""
|
|
Loyalty module database models.
|
|
|
|
This is the canonical location for loyalty models. Module models are automatically
|
|
discovered and registered with SQLAlchemy's Base.metadata at startup.
|
|
|
|
Usage:
|
|
from app.modules.loyalty.models import (
|
|
LoyaltyProgram,
|
|
LoyaltyCard,
|
|
LoyaltyTransaction,
|
|
StaffPin,
|
|
AppleDeviceRegistration,
|
|
MerchantLoyaltySettings,
|
|
LoyaltyType,
|
|
TransactionType,
|
|
StaffPinPolicy,
|
|
)
|
|
"""
|
|
|
|
from app.modules.loyalty.models.apple_device import (
|
|
# Model
|
|
AppleDeviceRegistration,
|
|
)
|
|
from app.modules.loyalty.models.loyalty_card import (
|
|
# Model
|
|
LoyaltyCard,
|
|
)
|
|
from app.modules.loyalty.models.loyalty_program import (
|
|
# Model
|
|
LoyaltyProgram,
|
|
# Enums
|
|
LoyaltyType,
|
|
)
|
|
from app.modules.loyalty.models.loyalty_transaction import (
|
|
# Model
|
|
LoyaltyTransaction,
|
|
# Enums
|
|
TransactionType,
|
|
)
|
|
from app.modules.loyalty.models.merchant_settings import (
|
|
# Model
|
|
MerchantLoyaltySettings,
|
|
# Enums
|
|
StaffPinPolicy,
|
|
)
|
|
from app.modules.loyalty.models.staff_pin import (
|
|
# Model
|
|
StaffPin,
|
|
)
|
|
from app.modules.loyalty.models.transaction_category import (
|
|
# Model
|
|
StoreTransactionCategory,
|
|
)
|
|
|
|
__all__ = [
|
|
# Enums
|
|
"LoyaltyType",
|
|
"TransactionType",
|
|
"StaffPinPolicy",
|
|
# Models
|
|
"LoyaltyProgram",
|
|
"LoyaltyCard",
|
|
"LoyaltyTransaction",
|
|
"StaffPin",
|
|
"AppleDeviceRegistration",
|
|
"MerchantLoyaltySettings",
|
|
"StoreTransactionCategory",
|
|
]
|