Add bundle deals

Sell a set of tickets together for one price (e.g. 5 Adult + 3 Child for R500).
Bundles apply automatically, as many times as a registration's tickets allow, and
only when cheaper than the prices actually charged. Coupons come off afterwards.

- EventBundle/EventBundleItem/RegistrationBundle models and Registration.bundleDiscount
- Supervisor "Bundle deals" page, quote endpoint, bundle lines on invoices,
  receipts, emails, WhatsApp and Yoco checkout, Discounts report rows
- Register form shows started bundles with "Complete bundle" and "+" buttons
- Demo: Family Fun Day sells a Family deal bundle instead of the Family pass ticket

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 15:14:53 +02:00
co-authored by Claude Opus 5.5
parent 8f92a8c3e9
commit 763b66ff56
35 changed files with 1766 additions and 149 deletions
+39 -1
View File
@@ -141,6 +141,8 @@ export type Event = {
eventOptions?: EventOption[];
attachments?: EventAttachment[];
form?: EventForm | null;
// Bundle deals on sale now (single-event responses only).
bundles?: PublicBundle[];
createdAt?: string;
updatedAt?: string;
cashupStatus?: "open" | "closed";
@@ -150,6 +152,39 @@ export type Event = {
reopenedById?: string | null;
};
export type BundleItem = { id?: string; eventOptionId: string; variantId?: string | null; quantity: number; eventOption?: { id: string; name: string; price?: number } | null; variant?: { id: string; name: string } | null };
// A bundle deal as shown to buyers on the event page.
export type PublicBundle = {
id: string;
name: string;
description?: string | null;
price: number;
validUntil?: string | null;
summary: string;
// What the items cost separately at the standard price.
standardValue: number;
items: BundleItem[];
};
// A bundle deal as supervisors manage it.
export type EventBundle = PublicBundle & {
eventId: string;
isActive: boolean;
validFrom?: string | null;
order: number;
available: boolean;
uses?: number;
registrations?: number;
totalDiscount?: number;
createdAt?: string;
};
// One bundle applied to a basket or registration.
export type BundleApplication = { id?: string; bundleId: string; name?: string; count: number; discount: number; bundle?: { id: string; name: string } | null };
export type BundleQuote = { subtotal: number; bundleDiscount: number; bundles: BundleApplication[]; total: number };
export type EventCostType = "once_off" | "per_item";
export type CashupMethod = "cash" | "card" | "eft" | "other";
@@ -301,7 +336,7 @@ export type EventFinancials = {
totalWriteOffs: number;
pendingOutstandingTotal: number;
netProfit: number;
// Coupon discounts given on the event's registrations.
// Bundle and coupon discounts given on the event's registrations.
discountsTotal?: number;
unallocatedDonations: Payment[];
unallocatedDonationsTotal: number;
@@ -349,7 +384,10 @@ export type Registration = {
userId: string;
eventId: string;
status: RegistrationStatus;
// All discounts: bundle deals (bundleDiscount) plus the coupon.
discountTotal?: number;
bundleDiscount?: number;
bundleApplications?: BundleApplication[];
ticketDelivery?: "payer" | "each";
createdAt: string;
updatedAt?: string;