/** Shared commerce numbers so cart, checkout and orders stay consistent. */ export const DELIVERY_FEE = 80; export const DEMO_VOUCHER = "GISHEN10"; export const DEMO_VOUCHER_PCT = 0.1; export const DEMO_OTP = "1234"; /** Short branch-counter code guests show to fulfill pickup at any location. */ export function generatePickupCode() { const alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; let body = ""; for (let i = 0; i < 4; i += 1) { body += alphabet[Math.floor(Math.random() * alphabet.length)]; } return `GSH-${body}`; } export function voucherDiscount(subtotal: number, code: string | null | undefined) { if (!code) return 0; if (code.trim().toUpperCase() === DEMO_VOUCHER) { return Math.round(subtotal * DEMO_VOUCHER_PCT); } return 0; } export function orderSubtotalTotal(input: { subtotal: number; deliveryFee: number; discount?: number; }) { return Math.max(0, input.subtotal + input.deliveryFee - (input.discount ?? 0)); }