fix(loyalty): fix runtime bugs in storefront routes, point expiration, and enforce settings

- Add total_points_voided column to LoyaltyCard with migration (loyalty_002)
- Fix storefront self_enroll to use correct service method signature and schema fields
- Fix get_my_card/get_my_transactions to use get_card_by_customer_and_merchant
- Fix transaction history field reference (balance_after -> points_balance_after)
- Fix point_expiration task: wrong field names and manual balance update -> card.expire_points()
- Register storefront_router in definition.py and export all routers from __init__.py
- Enforce MerchantLoyaltySettings in storefront enrollment, points, and stamp void operations
- Fix test fixture using non-existent balance_after column
- Suppress intentional architecture validator warnings in templates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 14:20:18 +01:00
parent c3d26e9aa4
commit 82585b1363
14 changed files with 120 additions and 34 deletions

View File

@@ -0,0 +1,30 @@
"""add total_points_voided to loyalty_cards
Revision ID: loyalty_002
Revises: loyalty_001
Create Date: 2026-02-08
"""
from alembic import op
import sqlalchemy as sa
revision = "loyalty_002"
down_revision = "loyalty_001"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
"loyalty_cards",
sa.Column(
"total_points_voided",
sa.Integer(),
nullable=False,
server_default="0",
comment="Lifetime points voided (returns + expirations)",
),
)
def downgrade() -> None:
op.drop_column("loyalty_cards", "total_points_voided")