feat(loyalty): multi-select categories on transactions
Some checks failed
Some checks failed
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:
@@ -836,8 +836,8 @@ class CardService:
|
||||
"transaction_at": tx.transaction_at.isoformat() if tx.transaction_at else None,
|
||||
"notes": tx.notes,
|
||||
"store_name": None,
|
||||
"category_id": tx.category_id,
|
||||
"category_name": None,
|
||||
"category_ids": tx.category_ids,
|
||||
"category_names": None,
|
||||
}
|
||||
|
||||
if tx.store_id:
|
||||
@@ -845,15 +845,19 @@ class CardService:
|
||||
if store_obj:
|
||||
tx_data["store_name"] = store_obj.name
|
||||
|
||||
if tx.category_id:
|
||||
if tx.category_ids and isinstance(tx.category_ids, list):
|
||||
from app.modules.loyalty.services.category_service import (
|
||||
category_service,
|
||||
)
|
||||
|
||||
cat_name = category_service.validate_category_for_store(
|
||||
db, tx.category_id, tx.store_id or 0
|
||||
)
|
||||
tx_data["category_name"] = cat_name
|
||||
names = []
|
||||
for cid in tx.category_ids:
|
||||
name = category_service.validate_category_for_store(
|
||||
db, cid, tx.store_id or 0
|
||||
)
|
||||
if name:
|
||||
names.append(name)
|
||||
tx_data["category_names"] = names if names else None
|
||||
|
||||
tx_responses.append(tx_data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user