The /eskaera/load-draft endpoint was returning previous-cycle drafts when group_order.cutoff_date was still in the future but group_order.pickup_date had not yet been recomputed (its compute only depends on pickup_day and start_date). Both the stale group_order.pickup_date and the old draft's pickup_date held the same past value, so the exact-pickup-date filter in _find_recent_draft_order matched the stale draft and the cart was repopulated with old products immediately after being cleared. Replace the pickup_date exact-match + current-week fallback with a single cutoff-anchored window: create_date in [cutoff_date - 6 days, cutoff_date]. Drafts created outside that window belong to a previous cycle and must not be reused. The change applies to all four callers (load-draft, clear-cart, save-order, confirm) so the merge/confirm paths also stop attaching to stale drafts. Covered by a new regression test that mirrors the production setup (matching pickup_date, draft create_date backdated 10 days). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| exceptions.py | ||
| portal.py | ||
| website_sale.py | ||
| website_sale_i18n.py | ||
| website_sale_pickup.py | ||
| website_sale_pricing.py | ||
| website_sale_products.py | ||
| website_sale_utils.py | ||
| website_sale_validators.py | ||