@bash-app/bash-common 30.431.0 → 30.433.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/bashSectionTitleForBashType.test.js +2 -0
- package/dist/__tests__/bashSectionTitleForBashType.test.js.map +1 -1
- package/dist/__tests__/discoveryScope.test.js +9 -1
- package/dist/__tests__/discoveryScope.test.js.map +1 -1
- package/dist/__tests__/promoCartEngine.test.d.ts +2 -0
- package/dist/__tests__/promoCartEngine.test.d.ts.map +1 -0
- package/dist/__tests__/promoCartEngine.test.js +174 -0
- package/dist/__tests__/promoCartEngine.test.js.map +1 -0
- package/dist/__tests__/promoCodeRedemption.test.d.ts +2 -0
- package/dist/__tests__/promoCodeRedemption.test.d.ts.map +1 -0
- package/dist/__tests__/promoCodeRedemption.test.js +103 -0
- package/dist/__tests__/promoCodeRedemption.test.js.map +1 -0
- package/dist/__tests__/promoCodeScope.test.d.ts +2 -0
- package/dist/__tests__/promoCodeScope.test.d.ts.map +1 -0
- package/dist/__tests__/promoCodeScope.test.js +77 -0
- package/dist/__tests__/promoCodeScope.test.js.map +1 -0
- package/dist/definitions.d.ts +3 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +4 -2
- package/dist/definitions.js.map +1 -1
- package/dist/discoveryScope.d.ts +6 -6
- package/dist/discoveryScope.d.ts.map +1 -1
- package/dist/discoveryScope.js +25 -16
- package/dist/discoveryScope.js.map +1 -1
- package/dist/extendedSchemas.d.ts +1 -0
- package/dist/extendedSchemas.d.ts.map +1 -1
- package/dist/extendedSchemas.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/promoCartEngine.d.ts +55 -0
- package/dist/promoCartEngine.d.ts.map +1 -0
- package/dist/promoCartEngine.js +135 -0
- package/dist/promoCartEngine.js.map +1 -0
- package/dist/promoCodeRedemption.d.ts +44 -0
- package/dist/promoCodeRedemption.d.ts.map +1 -0
- package/dist/promoCodeRedemption.js +81 -0
- package/dist/promoCodeRedemption.js.map +1 -0
- package/dist/promoCodeScope.d.ts +85 -0
- package/dist/promoCodeScope.d.ts.map +1 -0
- package/dist/promoCodeScope.js +93 -0
- package/dist/promoCodeScope.js.map +1 -0
- package/dist/utils/__tests__/discountEngine/discountCalculator.test.js +8 -1
- package/dist/utils/__tests__/discountEngine/discountCalculator.test.js.map +1 -1
- package/dist/utils/__tests__/paymentUtils.test.js +87 -4
- package/dist/utils/__tests__/paymentUtils.test.js.map +1 -1
- package/dist/utils/paymentUtils.d.ts +30 -5
- package/dist/utils/paymentUtils.d.ts.map +1 -1
- package/dist/utils/paymentUtils.js +43 -11
- package/dist/utils/paymentUtils.js.map +1 -1
- package/package.json +7 -3
- package/prisma/schema.prisma +106 -4
- package/src/__tests__/bashSectionTitleForBashType.test.ts +4 -0
- package/src/__tests__/discoveryScope.test.ts +22 -1
- package/src/__tests__/promoCartEngine.test.ts +201 -0
- package/src/__tests__/promoCodeRedemption.test.ts +134 -0
- package/src/__tests__/promoCodeScope.test.ts +106 -0
- package/src/definitions.ts +4 -2
- package/src/discoveryScope.ts +30 -20
- package/src/extendedSchemas.ts +1 -0
- package/src/index.ts +3 -0
- package/src/promoCartEngine.ts +193 -0
- package/src/promoCodeRedemption.ts +123 -0
- package/src/promoCodeScope.ts +164 -0
- package/src/utils/__tests__/discountEngine/discountCalculator.test.ts +8 -0
- package/src/utils/__tests__/paymentUtils.test.ts +100 -6
- package/src/utils/paymentUtils.ts +56 -13
|
@@ -448,12 +448,35 @@ export function lowestGuestAllInPriceCents(
|
|
|
448
448
|
return min;
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
/**
|
|
452
|
-
export const MAX_TICKET_COMMISSION_BPS =
|
|
451
|
+
/** A host can assign up to 100% of eligible net ticket proceeds to a promoter. */
|
|
452
|
+
export const MAX_TICKET_COMMISSION_BPS = 10_000;
|
|
453
453
|
|
|
454
454
|
/**
|
|
455
|
-
*
|
|
456
|
-
*
|
|
455
|
+
* Cents left on the host transfer when withholding commission. Stripe test mode
|
|
456
|
+
* accepted application_fee_amount equal to the charge (check 4b, 2026-10-14),
|
|
457
|
+
* so a $0 host transfer is allowed and this stays 0. This is not a host share.
|
|
458
|
+
*/
|
|
459
|
+
export const TEMPORARY_SETTLEMENT_SAFETY_REMAINDER_CENTS = 0;
|
|
460
|
+
|
|
461
|
+
/** Error message for an out-of-range rate, or null when 0-100% (0-10000 bps). */
|
|
462
|
+
export function ticketCommissionBpsError(
|
|
463
|
+
commissionBps: number | null | undefined
|
|
464
|
+
): string | null {
|
|
465
|
+
if (commissionBps == null) return null;
|
|
466
|
+
if (!Number.isInteger(commissionBps)) {
|
|
467
|
+
return "Commission must be a whole number of basis points.";
|
|
468
|
+
}
|
|
469
|
+
if (commissionBps < 0 || commissionBps > MAX_TICKET_COMMISSION_BPS) {
|
|
470
|
+
return "Commission must be between 0% and 100% of eligible net ticket proceeds.";
|
|
471
|
+
}
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Floor cents owed to a promoter: `commissionBps` of `basisCents`, where the basis
|
|
477
|
+
* is eligible net ticket proceeds. Guest price is unchanged; the amount is
|
|
478
|
+
* withheld from the host via application_fee. Rates are validated when written;
|
|
479
|
+
* this never pays more than 100% of the basis.
|
|
457
480
|
*/
|
|
458
481
|
export function ticketCommissionCents(
|
|
459
482
|
basisCents: number,
|
|
@@ -462,16 +485,34 @@ export function ticketCommissionCents(
|
|
|
462
485
|
if (basisCents <= 0) return 0;
|
|
463
486
|
const bps = Math.floor(Number(commissionBps) || 0);
|
|
464
487
|
if (bps <= 0) return 0;
|
|
465
|
-
|
|
466
|
-
return Math.floor((basisCents * clamped) / 10_000);
|
|
488
|
+
return Math.floor((basisCents * Math.min(MAX_TICKET_COMMISSION_BPS, bps)) / 10_000);
|
|
467
489
|
}
|
|
468
490
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
491
|
+
/**
|
|
492
|
+
* What the host would otherwise receive for the eligible ticket lines: the
|
|
493
|
+
* eligible discounted subtotal, less its share of the Bash platform fee and the
|
|
494
|
+
* Stripe processing estimate that no guest fee line pays. Tax, guest fee lines,
|
|
495
|
+
* coat check, and delivery are never part of it. Floored at 0.
|
|
496
|
+
*/
|
|
497
|
+
export function eligibleNetTicketProceedsCents(args: {
|
|
498
|
+
/** Discounted subtotal of the lines the code applies to. */
|
|
499
|
+
eligibleSubtotalCents: number;
|
|
500
|
+
/** Discounted ticket subtotal of the whole cart (the fee basis). */
|
|
501
|
+
discountedSubtotalCents: number;
|
|
502
|
+
bashPlatformTotalCents: number;
|
|
503
|
+
guestPlatformLineCents: number;
|
|
504
|
+
stripeProcessingCents: number;
|
|
505
|
+
guestProcessingLineCents: number;
|
|
506
|
+
}): number {
|
|
507
|
+
const eligible = Math.max(0, Math.floor(args.eligibleSubtotalCents));
|
|
508
|
+
const cart = Math.max(0, Math.floor(args.discountedSubtotalCents));
|
|
509
|
+
if (eligible <= 0 || cart <= 0) return 0;
|
|
510
|
+
const share = Math.min(1, eligible / cart);
|
|
511
|
+
const hostPlatform = Math.max(0, args.bashPlatformTotalCents - args.guestPlatformLineCents);
|
|
512
|
+
const hostProcessing = Math.max(0, args.stripeProcessingCents - args.guestProcessingLineCents);
|
|
513
|
+
const net =
|
|
514
|
+
eligible - Math.ceil(hostPlatform * share) - Math.ceil(hostProcessing * share);
|
|
515
|
+
return Math.max(0, net);
|
|
475
516
|
}
|
|
476
517
|
|
|
477
518
|
/**
|
|
@@ -528,7 +569,9 @@ export function computeTicketApplicationFeeAmountCents(args: {
|
|
|
528
569
|
);
|
|
529
570
|
const maxWithhold = Math.max(
|
|
530
571
|
0,
|
|
531
|
-
breakdown.totalDueCents -
|
|
572
|
+
breakdown.totalDueCents -
|
|
573
|
+
breakdown.applicationFeeAmountCents -
|
|
574
|
+
TEMPORARY_SETTLEMENT_SAFETY_REMAINDER_CENTS
|
|
532
575
|
);
|
|
533
576
|
const withheld = Math.min(performerCommissionCents, maxWithhold);
|
|
534
577
|
return {
|