@bash-app/bash-common 30.95.0 → 30.97.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.
Files changed (41) hide show
  1. package/dist/definitions.d.ts +3 -36
  2. package/dist/definitions.d.ts.map +1 -1
  3. package/dist/definitions.js +1 -45
  4. package/dist/definitions.js.map +1 -1
  5. package/dist/extendedSchemas.d.ts +82 -1
  6. package/dist/extendedSchemas.d.ts.map +1 -1
  7. package/dist/extendedSchemas.js +11 -0
  8. package/dist/extendedSchemas.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/membershipDefinitions.d.ts +138 -0
  14. package/dist/membershipDefinitions.d.ts.map +1 -1
  15. package/dist/membershipDefinitions.js +416 -0
  16. package/dist/membershipDefinitions.js.map +1 -1
  17. package/dist/utils/bashCashPaymentUtils.d.ts +72 -0
  18. package/dist/utils/bashCashPaymentUtils.d.ts.map +1 -0
  19. package/dist/utils/bashCashPaymentUtils.js +115 -0
  20. package/dist/utils/bashCashPaymentUtils.js.map +1 -0
  21. package/dist/utils/paymentUtils.d.ts +6 -2
  22. package/dist/utils/paymentUtils.d.ts.map +1 -1
  23. package/dist/utils/paymentUtils.js +27 -86
  24. package/dist/utils/paymentUtils.js.map +1 -1
  25. package/dist/utils/service/apiServiceBookingApiUtils.d.ts.map +1 -1
  26. package/dist/utils/service/apiServiceBookingApiUtils.js +1 -0
  27. package/dist/utils/service/apiServiceBookingApiUtils.js.map +1 -1
  28. package/dist/utils/service/frontendServiceBookingUtils.d.ts +2 -1
  29. package/dist/utils/service/frontendServiceBookingUtils.d.ts.map +1 -1
  30. package/dist/utils/service/frontendServiceBookingUtils.js +4 -3
  31. package/dist/utils/service/frontendServiceBookingUtils.js.map +1 -1
  32. package/package.json +1 -1
  33. package/prisma/schema.prisma +44 -5
  34. package/src/definitions.ts +3 -54
  35. package/src/extendedSchemas.ts +18 -0
  36. package/src/index.ts +1 -0
  37. package/src/membershipDefinitions.ts +549 -0
  38. package/src/utils/bashCashPaymentUtils.ts +146 -0
  39. package/src/utils/paymentUtils.ts +34 -124
  40. package/src/utils/service/apiServiceBookingApiUtils.ts +1 -0
  41. package/src/utils/service/frontendServiceBookingUtils.ts +5 -3
@@ -1,38 +1,10 @@
1
1
  import { BashEventPromoCode, MembershipTier, TicketTier, VenuePricingPlan as VenuePricingPlanOption } from "@prisma/client";
2
2
  import {
3
- BASH_FEE_PERCENTAGE,
4
- SERVICE_FEE_PERCENTAGE,
5
- PARTNER_FEE_PERCENTAGE,
6
- BASH_FEE_BASIC,
7
- BASH_FEE_PRO,
8
- BASH_FEE_CREATOR,
9
- BASH_FEE_ELITE,
10
- BASH_FEE_LEGEND,
11
- SERVICE_FEE_BASIC,
12
- SERVICE_FEE_PRO,
13
- SERVICE_FEE_CREATOR,
14
- SERVICE_FEE_ELITE,
15
- SERVICE_FEE_LEGEND,
16
- PARTNER_FEE_BASIC,
17
- PARTNER_FEE_PRO,
18
- PARTNER_FEE_CREATOR,
19
- PARTNER_FEE_ELITE,
20
- PARTNER_FEE_LEGEND,
21
- BASH_FEE_CAP_BASIC,
22
- BASH_FEE_CAP_PRO,
23
- BASH_FEE_CAP_CREATOR,
24
- BASH_FEE_CAP_ELITE,
25
- BASH_FEE_CAP_LEGEND,
26
- SERVICE_FEE_CAP_BASIC,
27
- SERVICE_FEE_CAP_PRO,
28
- SERVICE_FEE_CAP_CREATOR,
29
- SERVICE_FEE_CAP_ELITE,
30
- SERVICE_FEE_CAP_LEGEND,
31
- PARTNER_FEE_CAP_BASIC,
32
- PARTNER_FEE_CAP_PRO,
33
- PARTNER_FEE_CAP_CREATOR,
34
- PARTNER_FEE_CAP_ELITE,
35
- PARTNER_FEE_CAP_LEGEND,
3
+ BASH_EVENT_FEES,
4
+ SERVICE_BOOKING_FEES,
5
+ PARTNER_PAYMENT_FEES,
6
+ } from "../membershipDefinitions";
7
+ import {
36
8
  NumberOfTicketsForDate,
37
9
  PRICE_DOLLARS_AND_CENTS_RATIO,
38
10
  } from "../definitions";
@@ -98,81 +70,13 @@ export function convertDollarsToCents(
98
70
  return price * PRICE_DOLLARS_AND_CENTS_RATIO;
99
71
  }
100
72
 
101
- export function calculateBashAppFee(total: number): number {
102
- return parseFloat((total * BASH_FEE_PERCENTAGE).toFixed(2));
103
- }
104
-
105
- /**
106
- * Bash ticket/donation fee percentages by membership tier
107
- * Imported from definitions.ts
108
- */
109
- const BASH_FEE_PERCENTAGES: Record<MembershipTier, number> = {
110
- Basic: BASH_FEE_BASIC,
111
- Pro: BASH_FEE_PRO,
112
- Creator: BASH_FEE_CREATOR,
113
- Elite: BASH_FEE_ELITE,
114
- Legend: BASH_FEE_LEGEND,
115
- };
116
-
117
- /**
118
- * Service booking fee percentages by membership tier (Allies, Patrons)
119
- * Imported from definitions.ts
120
- */
121
- const SERVICE_FEE_PERCENTAGES: Record<MembershipTier, number> = {
122
- Basic: SERVICE_FEE_BASIC,
123
- Pro: SERVICE_FEE_PRO,
124
- Creator: SERVICE_FEE_CREATOR,
125
- Elite: SERVICE_FEE_ELITE,
126
- Legend: SERVICE_FEE_LEGEND,
127
- };
128
-
129
- /**
130
- * Bash ticket/donation fee caps by membership tier (in cents)
131
- * Imported from definitions.ts
132
- */
133
- const BASH_FEE_CAPS: Record<MembershipTier, number> = {
134
- Basic: BASH_FEE_CAP_BASIC,
135
- Pro: BASH_FEE_CAP_PRO,
136
- Creator: BASH_FEE_CAP_CREATOR,
137
- Elite: BASH_FEE_CAP_ELITE,
138
- Legend: BASH_FEE_CAP_LEGEND,
139
- };
140
-
141
73
  /**
142
- * Service booking fee caps by membership tier (in cents)
143
- * Imported from definitions.ts
74
+ * Legacy function - calculates basic Bash fee without membership tier
75
+ * @deprecated Use calculateBashAppFeeWithMembershipDiscount instead
144
76
  */
145
- const SERVICE_FEE_CAPS: Record<MembershipTier, number> = {
146
- Basic: SERVICE_FEE_CAP_BASIC,
147
- Pro: SERVICE_FEE_CAP_PRO,
148
- Creator: SERVICE_FEE_CAP_CREATOR,
149
- Elite: SERVICE_FEE_CAP_ELITE,
150
- Legend: SERVICE_FEE_CAP_LEGEND,
151
- };
152
-
153
- /**
154
- * Partner payment fee percentages by membership tier (Vendors, Exhibitors, Sponsors)
155
- * Imported from definitions.ts
156
- */
157
- const PARTNER_FEE_PERCENTAGES: Record<MembershipTier, number> = {
158
- Basic: PARTNER_FEE_BASIC,
159
- Pro: PARTNER_FEE_PRO,
160
- Creator: PARTNER_FEE_CREATOR,
161
- Elite: PARTNER_FEE_ELITE,
162
- Legend: PARTNER_FEE_LEGEND,
163
- };
164
-
165
- /**
166
- * Partner payment fee caps by membership tier (in cents)
167
- * Imported from definitions.ts
168
- */
169
- const PARTNER_FEE_CAPS: Record<MembershipTier, number> = {
170
- Basic: PARTNER_FEE_CAP_BASIC,
171
- Pro: PARTNER_FEE_CAP_PRO,
172
- Creator: PARTNER_FEE_CAP_CREATOR,
173
- Elite: PARTNER_FEE_CAP_ELITE,
174
- Legend: PARTNER_FEE_CAP_LEGEND,
175
- };
77
+ export function calculateBashAppFee(total: number): number {
78
+ return parseFloat((total * BASH_EVENT_FEES.Basic.percent).toFixed(2));
79
+ }
176
80
 
177
81
  /**
178
82
  * Calculate platform fee for bash tickets/donations with membership tier discounts and caps
@@ -187,16 +91,20 @@ export function calculateBashAppFeeWithMembershipDiscount(
187
91
  // Default to Basic tier if no membership provided
188
92
  const tier = membershipTier || 'Basic';
189
93
 
94
+ // Get fee config for this tier
95
+ const config = BASH_EVENT_FEES[tier];
96
+
190
97
  // Calculate fee based on membership tier percentage
191
- const feePercentage = BASH_FEE_PERCENTAGES[tier] || BASH_FEE_PERCENTAGE;
192
- const calculatedFee = total * feePercentage;
98
+ let calculatedFee = total * config.percent;
99
+
100
+ // Apply minimum fee
101
+ calculatedFee = Math.max(calculatedFee, config.minimumCents);
193
102
 
194
103
  // Apply cap for the membership tier
195
- const feeCap = BASH_FEE_CAPS[tier] || BASH_FEE_CAPS.Basic;
196
- const cappedFee = Math.min(calculatedFee, feeCap);
104
+ calculatedFee = Math.min(calculatedFee, config.capCents);
197
105
 
198
106
  // Round to 2 decimal places (cents precision)
199
- return parseFloat(cappedFee.toFixed(2));
107
+ return parseFloat(calculatedFee.toFixed(2));
200
108
  }
201
109
 
202
110
  /**
@@ -212,16 +120,17 @@ export function calculateServiceFeeWithMembershipDiscount(
212
120
  // Default to Basic tier if no membership provided
213
121
  const tier = membershipTier || 'Basic';
214
122
 
123
+ // Get fee config for this tier
124
+ const config = SERVICE_BOOKING_FEES[tier];
125
+
215
126
  // Calculate fee based on membership tier percentage
216
- const feePercentage = SERVICE_FEE_PERCENTAGES[tier] || SERVICE_FEE_PERCENTAGE;
217
- const calculatedFee = total * feePercentage;
127
+ let calculatedFee = total * config.percent;
218
128
 
219
129
  // Apply cap for the membership tier
220
- const feeCap = SERVICE_FEE_CAPS[tier] || SERVICE_FEE_CAPS.Basic;
221
- const cappedFee = Math.min(calculatedFee, feeCap);
130
+ calculatedFee = Math.min(calculatedFee, config.capCents);
222
131
 
223
132
  // Round to 2 decimal places (cents precision)
224
- return parseFloat(cappedFee.toFixed(2));
133
+ return parseFloat(calculatedFee.toFixed(2));
225
134
  }
226
135
 
227
136
  /**
@@ -238,16 +147,17 @@ export function calculatePartnerFeeWithMembershipDiscount(
238
147
  // Default to Basic tier if no membership provided
239
148
  const tier = membershipTier || 'Basic';
240
149
 
150
+ // Get fee config for this tier
151
+ const config = PARTNER_PAYMENT_FEES[tier];
152
+
241
153
  // Calculate fee based on membership tier percentage
242
- const feePercentage = PARTNER_FEE_PERCENTAGES[tier] || PARTNER_FEE_PERCENTAGE;
243
- const calculatedFee = total * feePercentage;
154
+ let calculatedFee = total * config.percent;
244
155
 
245
156
  // Apply cap for the membership tier
246
- const feeCap = PARTNER_FEE_CAPS[tier] || PARTNER_FEE_CAPS.Basic;
247
- const cappedFee = Math.min(calculatedFee, feeCap);
157
+ calculatedFee = Math.min(calculatedFee, config.capCents);
248
158
 
249
159
  // Round to 2 decimal places (cents precision)
250
- return parseFloat(cappedFee.toFixed(2));
160
+ return parseFloat(calculatedFee.toFixed(2));
251
161
  }
252
162
 
253
163
  // ============================================
@@ -270,14 +180,14 @@ export type VenuePricingPlanMap = {
270
180
  * Venue pricing plan options
271
181
  * Moved from venueUtils.ts for centralization
272
182
  *
273
- * Note: Uses SERVICE_FEE_PERCENTAGE (15% base rate) for percentage-based plan.
274
- * Actual fees may be lower based on membership tier (see SERVICE_FEE_BASIC, SERVICE_FEE_PRO, etc.)
183
+ * Note: Uses Basic tier service booking fee (15%) for percentage-based plan.
184
+ * Actual fees may be lower based on membership tier (see SERVICE_BOOKING_FEES)
275
185
  */
276
186
  export const VENUE_PRICING_PLAN_DATA: VenuePricingPlanMap = {
277
187
  [VenuePricingPlanOption.Percentage]: {
278
188
  name: "Pay per booking",
279
189
  description: "15% of each booking goes to Bash.",
280
- percentageFee: SERVICE_FEE_PERCENTAGE, // Use centralized constant (15%)
190
+ percentageFee: SERVICE_BOOKING_FEES.Basic.percent, // Use centralized constant (15%)
281
191
  monthlyFee: 0.0,
282
192
  flatFee: 0.0,
283
193
  },
@@ -167,6 +167,7 @@ export function serviceGetPriceToBookFromBooking(
167
167
  daysTotalBeforeTaxesCents: booking.daysTotalATBCents,
168
168
  subtotalBeforeTaxesCents: booking.subtotalATBCents,
169
169
  totalBeforeTaxesCents: booking.totalATBCents,
170
+ totalWithFees: booking.totalATBCents, // Same as totalATBCents
170
171
  } as FrontendServiceGetPriceToBookResult;
171
172
  }
172
173
 
@@ -33,12 +33,12 @@ import {
33
33
  ServiceBookingAddOnBase,
34
34
  } from "./serviceBookingTypes";
35
35
  import { convertDollarsToCents } from "../paymentUtils";
36
- import { SERVICE_FEE_PERCENTAGE } from "../../definitions";
36
+ import { SERVICE_BOOKING_FEES } from "../../membershipDefinitions";
37
37
 
38
38
  // Use centralized service fee percentage (15% base rate for Basic tier)
39
39
  // Note: This is the DEFAULT processing fee. Actual fees may be lower based on membership tier.
40
- // See definitions.ts for SERVICE_FEE_BASIC, SERVICE_FEE_PRO, etc.
41
- export const SERVICE_BOOKING_PROCESSING_FEE_PERCENT = SERVICE_FEE_PERCENTAGE;
40
+ // See SERVICE_BOOKING_FEES in membershipDefinitions.ts for all tier-based fees.
41
+ export const SERVICE_BOOKING_PROCESSING_FEE_PERCENT = SERVICE_BOOKING_FEES.Basic.percent;
42
42
 
43
43
  export interface ServiceAddonInput extends ServiceAddon {
44
44
  chosenQuantity?: number;
@@ -77,6 +77,7 @@ export interface FrontendServiceGetPriceToBookResult {
77
77
  daysTotalBeforeTaxesCents: number;
78
78
  subtotalBeforeTaxesCents: number; //sum of all daysTotalBeforeTaxesCents, plus addOns/packages
79
79
  totalBeforeTaxesCents: number;
80
+ totalWithFees: number; // Total including all fees (same as totalBeforeTaxesCents, kept for compatibility)
80
81
 
81
82
  minimumTimeBlockHours?: number; //only valid on generalRate
82
83
  }
@@ -317,6 +318,7 @@ export function frontendServiceGetPriceToBookFees(
317
318
  daysTotalBeforeTaxesCents: daysTotalBeforeTaxesCents,
318
319
  subtotalBeforeTaxesCents: subtotalBeforeTaxesCents,
319
320
  totalBeforeTaxesCents: totalBeforeTaxesCents,
321
+ totalWithFees: totalBeforeTaxesCents, // Same as totalBeforeTaxesCents
320
322
  additionalFees: allAdditionalFees,
321
323
  addOns: usedAddons,
322
324
  minimumTimeBlockHours: minimumTimeBlockHours,