Repository navigation
fix(db): release discount use by code id - #498
Merged
Merged
Conversation
… display Paid vendors (Pro or a running Event Pass) create, switch off and delete percent or fixed codes with an optional last day and use cap. Customers enter a code at checkout; place_order re-validates and redeems it atomically so the client total is never trusted and a total never goes below zero. The order page and the live board card show the code and amount taken off. Also adds the service-role-only qkit.issue_reward_code(...) for loopkit, idempotent on source_ref. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… free cart Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Vendors set an optional minimum per item. The cart starts the item at the minimum, removes it when decremented below, and the DB refuses customer orders below it (migration 0130, ORDER_BELOW_MIN). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
place_order refuses any line above 20, so a larger minimum could never be ordered. The editor, save validation and cart now treat it as invalid or unreachable, and the editor flags a minimum above the booth's per-order cap. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Checkout gets an unticked opt-in checkbox and email field. The address lives in service-role-only qkit.order_ready_emails (migration 0131), kept off orders because that table is in the Realtime publication. Mark Ready claims the row and sends one Resend email; a send failure never blocks it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Insert instead of upsert and ignore 23505, look up only unfinished orders, mark ready-email.ts server-only, drop the vendor-controlled booth name from the subject, and extend the pgTAP test with service_role insert and delete returning. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
DELETE ... RETURNING is not valid inside a subquery. Run the service_role insert and delete before asserting, and assert after reset role. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #497 (feat/order-ready-email), on #494, on #487. Merge #487, #494, #497, then this.
Migration 0132 adds
orders.discount_code_id(FK ON DELETE SET NULL), stores it inplace_order, and releases a cancelled order's use by id instead of code text, so a deleted-and-recreated code with the same text is not decremented. A NULL id releases nothing. Backfill only where the text matches exactly one code.The owner applies migration 0132 by hand after merging.
pgTAP cases added to discount-codes.test.sql (not run locally, no supabase CLI; CI runs db).
🤖 Generated with Claude Code