@sellout/models 0.0.233 → 0.0.237
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/graphql/fragments/event.fragment.js +2 -0
- package/.dist/graphql/fragments/event.fragment.js.map +1 -1
- package/.dist/graphql/fragments/order.fragment.d.ts +1 -0
- package/.dist/graphql/fragments/order.fragment.js +23 -0
- package/.dist/graphql/fragments/order.fragment.js.map +1 -1
- package/.dist/graphql/mutations/createOrder.mutation.js +1 -0
- package/.dist/graphql/mutations/createOrder.mutation.js.map +1 -1
- package/.dist/graphql/queries/discountCodeVerify.query.d.ts +2 -0
- package/.dist/graphql/queries/discountCodeVerify.query.js +34 -0
- package/.dist/graphql/queries/discountCodeVerify.query.js.map +1 -0
- package/.dist/graphql/queries/order.query.js +4 -0
- package/.dist/graphql/queries/order.query.js.map +1 -1
- package/.dist/interfaces/IAnalytics.d.ts +3 -0
- package/.dist/interfaces/IAnalytics.js +3 -0
- package/.dist/interfaces/IAnalytics.js.map +1 -1
- package/.dist/interfaces/ICreateOrderParams.d.ts +3 -0
- package/.dist/interfaces/IEventPromotion.d.ts +5 -0
- package/.dist/interfaces/IEventPromotion.js +6 -1
- package/.dist/interfaces/IEventPromotion.js.map +1 -1
- package/.dist/interfaces/IFee.d.ts +3 -8
- package/.dist/interfaces/IFee.js +4 -10
- package/.dist/interfaces/IFee.js.map +1 -1
- package/.dist/interfaces/IOrder.d.ts +2 -0
- package/.dist/interfaces/IOrder.js.map +1 -1
- package/.dist/interfaces/IOrderSummary.d.ts +1 -0
- package/.dist/interfaces/IOrderTicket.d.ts +1 -0
- package/.dist/interfaces/IPayment.d.ts +2 -0
- package/.dist/schemas/Event.d.ts +4 -0
- package/.dist/schemas/Event.js +4 -0
- package/.dist/schemas/Event.js.map +1 -1
- package/.dist/schemas/Order.d.ts +21 -0
- package/.dist/schemas/Order.js +21 -0
- package/.dist/schemas/Order.js.map +1 -1
- package/.dist/sellout-proto.js +705 -6
- package/.dist/utils/AnalyticsUtil.d.ts +2 -0
- package/.dist/utils/AnalyticsUtil.js +72 -0
- package/.dist/utils/AnalyticsUtil.js.map +1 -1
- package/.dist/utils/OrderUtil.js +1 -1
- package/.dist/utils/OrderUtil.js.map +1 -1
- package/.dist/utils/PaymentUtil.d.ts +2 -0
- package/.dist/utils/PaymentUtil.js +382 -33
- package/.dist/utils/PaymentUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/graphql/fragments/event.fragment.ts +2 -0
- package/src/graphql/fragments/order.fragment.ts +24 -0
- package/src/graphql/mutations/createOrder.mutation.ts +1 -0
- package/src/graphql/queries/discountCodeVerify.query.ts +30 -0
- package/src/graphql/queries/order.query.ts +4 -0
- package/src/interfaces/IAnalytics.ts +3 -0
- package/src/interfaces/ICreateOrderParams.ts +4 -0
- package/src/interfaces/IEventPromotion.ts +7 -0
- package/src/interfaces/IFee.ts +3 -10
- package/src/interfaces/IOrder.ts +2 -0
- package/src/interfaces/IOrderSummary.ts +1 -0
- package/src/interfaces/IOrderTicket.ts +1 -0
- package/src/interfaces/IPayment.ts +3 -1
- package/src/proto/email.proto +1 -0
- package/src/proto/event.proto +18 -1
- package/src/proto/order.proto +15 -0
- package/src/schemas/Event.ts +4 -0
- package/src/schemas/Order.ts +21 -0
- package/src/utils/AnalyticsUtil.ts +123 -2
- package/src/utils/OrderUtil.ts +2 -1
- package/src/utils/PaymentUtil.ts +595 -96
package/src/utils/PaymentUtil.ts
CHANGED
|
@@ -11,6 +11,11 @@ import IFee, {
|
|
|
11
11
|
// FeePaymentMethodEnum
|
|
12
12
|
} from "../interfaces/IFee";
|
|
13
13
|
import { PaymentMethodTypeEnum } from "../enums/PaymentMethodTypeEnum";
|
|
14
|
+
import IEventPromotion, {
|
|
15
|
+
EventPromotionAppliesToEnum,
|
|
16
|
+
EventPromotionDiscountTypeEnum,
|
|
17
|
+
} from "../interfaces/IEventPromotion";
|
|
18
|
+
// import EventPromotionDiscountTypeEnum from '../interfaces/I'
|
|
14
19
|
// import Fee from "src/schemas/Fee";
|
|
15
20
|
|
|
16
21
|
interface IPaymentCalculatorParams {
|
|
@@ -18,6 +23,7 @@ interface IPaymentCalculatorParams {
|
|
|
18
23
|
upgrades: ICreateOrderUpgradeParams[];
|
|
19
24
|
fees: IFee[];
|
|
20
25
|
paymentMethodType: PaymentMethodTypeEnum;
|
|
26
|
+
promotions?: IEventPromotion[];
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
// interface IOrderItems {
|
|
@@ -137,32 +143,101 @@ class PaymentUtil {
|
|
|
137
143
|
// },
|
|
138
144
|
|
|
139
145
|
calculatePaymentTotal(params: IPaymentCalculatorParams): any {
|
|
140
|
-
let {
|
|
146
|
+
let {
|
|
147
|
+
tickets = [],
|
|
148
|
+
upgrades = [],
|
|
149
|
+
fees = [],
|
|
150
|
+
paymentMethodType,
|
|
151
|
+
promotions = [],
|
|
152
|
+
} = params;
|
|
141
153
|
|
|
142
154
|
// No items, total is always 0
|
|
143
155
|
if (!tickets.length && !upgrades.length) return 0;
|
|
144
156
|
|
|
145
|
-
|
|
157
|
+
const ticketFeesPromoCodePercent = promotions?.filter(
|
|
158
|
+
(f) =>
|
|
159
|
+
f.appliesTo === EventPromotionAppliesToEnum.PerTicket &&
|
|
160
|
+
f.discountType === EventPromotionDiscountTypeEnum.Percent
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const discountFeePercentPerTicketTotal = tickets?.reduce((cur, ticket) => {
|
|
164
|
+
return (
|
|
165
|
+
cur +
|
|
166
|
+
ticketFeesPromoCodePercent?.reduce((cur, promotion) => {
|
|
167
|
+
const value = cur + applyTicketDiscount(ticket, promotion);
|
|
168
|
+
return value;
|
|
169
|
+
}, 0)
|
|
170
|
+
);
|
|
171
|
+
}, 0);
|
|
172
|
+
|
|
173
|
+
// console.log(
|
|
174
|
+
// "++++++++++++eee+>>>>>>>>>>>>",
|
|
175
|
+
// discountFeePercentPerTicketTotal
|
|
176
|
+
// );
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
if(promotions?.length){
|
|
180
|
+
tickets = tickets.map(ticket => {
|
|
181
|
+
if(promotions && promotions[0].discountType === "Flat"){
|
|
182
|
+
if (promotions[0]?.ticketTypeIds.includes(ticket?.ticketTypeId)){
|
|
183
|
+
const discountValue = Number(promotions[0].discountValue);
|
|
184
|
+
const originalPrice = tickets[0].price;
|
|
185
|
+
const discountedPrice = originalPrice - discountValue;
|
|
186
|
+
return {
|
|
187
|
+
...ticket,
|
|
188
|
+
price : discountedPrice
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const originalPrice = tickets[0].price;
|
|
193
|
+
return {
|
|
194
|
+
...ticket,
|
|
195
|
+
price : originalPrice
|
|
196
|
+
};}
|
|
197
|
+
}
|
|
198
|
+
if(promotions && promotions[0].discountType === "Percent"){
|
|
199
|
+
if (promotions[0]?.ticketTypeIds.includes(ticket?.ticketTypeId)){
|
|
200
|
+
const discountValue = Number(promotions[0].discountValue);
|
|
201
|
+
const percentTicketValue = (ticket.origionalPrice * discountValue) / 100
|
|
202
|
+
const originalPrice = tickets[0].price;
|
|
203
|
+
const discountPercentPrice = originalPrice - percentTicketValue
|
|
204
|
+
// const discountedPrice = originalPrice
|
|
205
|
+
console.log("percentTicketValue",percentTicketValue);
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
...ticket,
|
|
209
|
+
price : discountPercentPrice
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const originalPrice = tickets[0].price;
|
|
214
|
+
return {
|
|
215
|
+
...ticket,
|
|
216
|
+
price : originalPrice
|
|
217
|
+
};}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return ticket;
|
|
221
|
+
})
|
|
222
|
+
}
|
|
146
223
|
|
|
224
|
+
// Filter fees
|
|
147
225
|
fees = fees.filter((fee: IFee) => {
|
|
148
226
|
if (!fee?.paymentMethods || fee?.paymentMethods?.length == 0) {
|
|
149
|
-
return true
|
|
227
|
+
return true;
|
|
150
228
|
} else if (fee?.paymentMethods?.includes(paymentMethodType as any)) {
|
|
151
|
-
return true
|
|
229
|
+
return true;
|
|
152
230
|
} else {
|
|
153
|
-
return false
|
|
231
|
+
return false;
|
|
154
232
|
}
|
|
155
233
|
|
|
156
234
|
// fee.paymentMethods.includes(paymentMethodType)
|
|
157
235
|
// fee?.paymentMethods?.includes(paymentMethodType)
|
|
158
236
|
|
|
159
|
-
|
|
160
|
-
|
|
161
237
|
// let isPayment = paymentMethodType !== fee?.paymentMethods?.includes(paymentMethodType) || PaymentMethodTypeEnum.Check || PaymentMethodTypeEnum.None || PaymentMethodTypeEnum.CardReader ? true: false;
|
|
162
238
|
|
|
163
239
|
// console.log("isPayment ++++>>",isPayment)
|
|
164
240
|
|
|
165
|
-
|
|
166
241
|
// if (
|
|
167
242
|
// fee.paymentMethods &&
|
|
168
243
|
// fee.paymentMethods.includes(FeePaymentMethodEnum.CardReader) &&
|
|
@@ -221,8 +296,7 @@ class PaymentUtil {
|
|
|
221
296
|
});
|
|
222
297
|
|
|
223
298
|
let guestFees = fees.filter(
|
|
224
|
-
(fee: IFee) =>
|
|
225
|
-
fee.filters && fee.filters[0] == FeeFiltersEnum.GuestTicket
|
|
299
|
+
(fee: IFee) => fee.filters && fee.filters[0] == FeeFiltersEnum.GuestTicket
|
|
226
300
|
);
|
|
227
301
|
|
|
228
302
|
fees = fees.filter(
|
|
@@ -230,7 +304,6 @@ class PaymentUtil {
|
|
|
230
304
|
fee.filters && fee.filters[0] !== FeeFiltersEnum.GuestTicket
|
|
231
305
|
);
|
|
232
306
|
|
|
233
|
-
|
|
234
307
|
function applyGuestTicketFee(
|
|
235
308
|
ticket: ICreateOrderTicketParams,
|
|
236
309
|
fee: IFee
|
|
@@ -264,20 +337,63 @@ class PaymentUtil {
|
|
|
264
337
|
|
|
265
338
|
return 0;
|
|
266
339
|
}
|
|
340
|
+
|
|
341
|
+
// Discount codes apply
|
|
342
|
+
|
|
343
|
+
const isDiscount = promotions?.filter((f) => f.discountValue);
|
|
344
|
+
console.log(isDiscount,"isDiscount");
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
const ticketFeesPromoCodeFlat = promotions?.filter(
|
|
348
|
+
(f) =>
|
|
349
|
+
f.appliesTo === EventPromotionAppliesToEnum.PerTicket &&
|
|
350
|
+
f.discountType === EventPromotionDiscountTypeEnum.Flat
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
// const ticketFeesPromoCodePercent = promotions?.filter(
|
|
355
|
+
// (f) =>
|
|
356
|
+
// f.appliesTo === EventPromotionAppliesToEnum.PerTicket &&
|
|
357
|
+
// f.discountType === EventPromotionDiscountTypeEnum.Percent
|
|
358
|
+
// );
|
|
359
|
+
|
|
360
|
+
// const ticketFeesPromoCodeFlatPerOrder = promotions?.filter(
|
|
361
|
+
// (f) =>
|
|
362
|
+
// f.appliesTo === EventPromotionAppliesToEnum.PerOrder &&
|
|
363
|
+
// f.discountType === EventPromotionDiscountTypeEnum.Flat
|
|
364
|
+
// );
|
|
365
|
+
|
|
366
|
+
// const ticketFeesPromoCodePercentPerOrder = promotions?.filter(
|
|
367
|
+
// (f) =>
|
|
368
|
+
// f.appliesTo === EventPromotionAppliesToEnum.PerOrder &&
|
|
369
|
+
// f.discountType === EventPromotionDiscountTypeEnum.Percent
|
|
370
|
+
// );
|
|
371
|
+
|
|
372
|
+
|
|
267
373
|
// Fees applied
|
|
268
|
-
const ticketFeesPromotersFlat = fees
|
|
269
|
-
|
|
270
|
-
f.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
374
|
+
const ticketFeesPromotersFlat = fees.filter(
|
|
375
|
+
(f) =>
|
|
376
|
+
f.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
377
|
+
f.appliedBy == FeeAppliedByEnum.Organization &&
|
|
378
|
+
f.type === FeeTypeEnum.Flat
|
|
379
|
+
);
|
|
380
|
+
const ticketFeesPromotersPercent = fees.filter(
|
|
381
|
+
(f) =>
|
|
382
|
+
f.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
383
|
+
f.appliedBy == FeeAppliedByEnum.Organization &&
|
|
384
|
+
f.type === FeeTypeEnum.Percent
|
|
385
|
+
);
|
|
274
386
|
|
|
275
387
|
const upgradeFeesPromotersFees = fees.filter(
|
|
276
|
-
(f) =>
|
|
388
|
+
(f) =>
|
|
389
|
+
f.appliedTo === FeeAppliedToEnum.Upgrade &&
|
|
390
|
+
f.appliedBy == FeeAppliedByEnum.Organization
|
|
277
391
|
);
|
|
278
392
|
|
|
279
393
|
const upgradeFeesSelloutFees = fees.filter(
|
|
280
|
-
(f) =>
|
|
394
|
+
(f) =>
|
|
395
|
+
f.appliedTo === FeeAppliedToEnum.Upgrade &&
|
|
396
|
+
f.appliedBy == FeeAppliedByEnum.Sellout
|
|
281
397
|
);
|
|
282
398
|
|
|
283
399
|
const selloutFees: any = fees.filter(
|
|
@@ -292,20 +408,136 @@ class PaymentUtil {
|
|
|
292
408
|
// Orders mattes here. Flat type fees must be applied before Percent type fees
|
|
293
409
|
const promoterOrderFees = fees
|
|
294
410
|
.filter(
|
|
295
|
-
(f) =>
|
|
411
|
+
(f) =>
|
|
412
|
+
f.appliedTo === FeeAppliedToEnum.Order &&
|
|
413
|
+
f.name != "Sales tax" &&
|
|
414
|
+
f.appliedBy == FeeAppliedByEnum.Organization
|
|
296
415
|
)
|
|
297
416
|
.sort(({ type }) => {
|
|
298
417
|
if (type === "Flat") return -1;
|
|
299
418
|
else return 1;
|
|
300
419
|
});
|
|
301
|
-
// Caclualtions
|
|
420
|
+
// Caclualtions
|
|
302
421
|
const ticketTotal = tickets.reduce((cur, ticket) => cur + ticket.price, 0);
|
|
303
|
-
const upgradeTotal = upgrades.reduce(
|
|
304
|
-
|
|
422
|
+
const upgradeTotal = upgrades.reduce(
|
|
423
|
+
(cur, upgrade) => cur + upgrade.price,
|
|
424
|
+
0
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
const totalTicketUpgrade = ticketTotal + upgradeTotal;
|
|
428
|
+
|
|
429
|
+
const discountFeeFlatPerTicketTotal = tickets?.reduce((cur, ticket) => {
|
|
430
|
+
return (
|
|
431
|
+
cur +
|
|
432
|
+
ticketFeesPromoCodeFlat?.reduce((cur, promotion) => {
|
|
433
|
+
const value = cur + applyTicketDiscount(ticket, promotion);
|
|
434
|
+
return value;
|
|
435
|
+
}, 0)
|
|
436
|
+
);
|
|
437
|
+
}, 0);
|
|
305
438
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
439
|
+
// console.log("+++++++++++++>>>>>>>>>>>>", discountFeeFlatPerTicketTotal);
|
|
440
|
+
|
|
441
|
+
// const discountFeePercentPerTicketTotal = tickets?.reduce((cur, ticket) => {
|
|
442
|
+
// return (
|
|
443
|
+
// cur +
|
|
444
|
+
// ticketFeesPromoCodePercent?.reduce((cur, promotion) => {
|
|
445
|
+
// const value = cur + applyTicketDiscount(ticket, promotion);
|
|
446
|
+
// return value;
|
|
447
|
+
// }, 0)
|
|
448
|
+
// );
|
|
449
|
+
// }, 0);
|
|
450
|
+
|
|
451
|
+
// console.log(
|
|
452
|
+
// "++++++++++++eee+>>>>>>>>>>>>",
|
|
453
|
+
// discountFeePercentPerTicketTotal
|
|
454
|
+
// );
|
|
455
|
+
|
|
456
|
+
// const discountFeeFlatPerOrderTotal = tickets?.reduce((cur, ticket) => {
|
|
457
|
+
// return (
|
|
458
|
+
// cur +
|
|
459
|
+
// ticketFeesPromoCodeFlatPerOrder?.reduce((cur, promotion) => {
|
|
460
|
+
// const value = cur + applyTicketDiscount(ticket, promotion);
|
|
461
|
+
// return value;
|
|
462
|
+
// }, 0)
|
|
463
|
+
// );
|
|
464
|
+
// }, 0);
|
|
465
|
+
|
|
466
|
+
// console.log("+++++++++++++>>>>>>>>>>>>", discountFeeFlatPerOrderTotal);
|
|
467
|
+
|
|
468
|
+
// const discountFeePercentPerOrderTotal = tickets?.reduce((cur, ticket) => {
|
|
469
|
+
// return (
|
|
470
|
+
// cur +
|
|
471
|
+
// ticketFeesPromoCodePercentPerOrder?.reduce((cur, promotion) => {
|
|
472
|
+
// const value = cur + applyTicketDiscount(ticket, promotion);
|
|
473
|
+
// return value;
|
|
474
|
+
// }, 0)
|
|
475
|
+
// );
|
|
476
|
+
// }, 0);
|
|
477
|
+
|
|
478
|
+
// console.log("+++++++++++++>>>>>>>>>>>>", discountFeePercentPerOrderTotal);
|
|
479
|
+
|
|
480
|
+
// const promoterFeeFlatPerOrderTotal = promoterOrderFees.reduce(
|
|
481
|
+
// (acc, fee: any) => {
|
|
482
|
+
// return fee.type == FeeTypeEnum.Flat ? acc + getFeeAmount(fee) : acc;
|
|
483
|
+
// },
|
|
484
|
+
// 0
|
|
485
|
+
// );
|
|
486
|
+
|
|
487
|
+
const discountFeeFlatPerOrderAmt = promotions?.reduce(
|
|
488
|
+
(cur: number,promotion: IEventPromotion) => {
|
|
489
|
+
if (
|
|
490
|
+
promotion.discountType == EventPromotionDiscountTypeEnum.Flat &&
|
|
491
|
+
promotion.appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
492
|
+
) {
|
|
493
|
+
const value = cur + promotion.discountValue;
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
496
|
+
return cur;
|
|
497
|
+
},
|
|
498
|
+
0
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
// console.log("Amt flat per order",discountFeeFlatPerOrderAmt)
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
const discountFeePercentPerOrderAmt = promotions?.reduce(
|
|
505
|
+
(cur: number,promotion: IEventPromotion) => {
|
|
506
|
+
if (
|
|
507
|
+
promotion.discountType == EventPromotionDiscountTypeEnum.Percent &&
|
|
508
|
+
promotion.appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
509
|
+
) {
|
|
510
|
+
const value = cur + (totalTicketUpgrade * promotion.discountValue)/100;
|
|
511
|
+
return value;
|
|
512
|
+
}
|
|
513
|
+
return cur;
|
|
514
|
+
},
|
|
515
|
+
0
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
// console.log("Amt percent per order",discountFeePercentPerOrderAmt)
|
|
519
|
+
|
|
520
|
+
const discount =
|
|
521
|
+
Math.round(
|
|
522
|
+
discountFeeFlatPerTicketTotal || 0 + discountFeePercentPerTicketTotal || 0) || 0;
|
|
523
|
+
console.log(discount);
|
|
524
|
+
const discountOrder =
|
|
525
|
+
Math.round(
|
|
526
|
+
discountFeeFlatPerOrderAmt || 0 + discountFeePercentPerOrderAmt || 0) || 0;
|
|
527
|
+
console.log(discountOrder);
|
|
528
|
+
|
|
529
|
+
const totalTicketAndUpgrades = Math.round(ticketTotal - discountOrder|| 0 ) + Math.round(upgradeTotal);
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
const promoterFeeFlatPerOrderTotal = promoterOrderFees.reduce(
|
|
534
|
+
(acc, fee: any) => {
|
|
535
|
+
return fee.type == FeeTypeEnum.Flat ? acc + getFeeAmount(fee) : acc;
|
|
536
|
+
},
|
|
537
|
+
0
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
//
|
|
309
541
|
|
|
310
542
|
const promoterFeeFlatPerTicketTotal = tickets.reduce((cur, ticket) => {
|
|
311
543
|
return (
|
|
@@ -317,6 +549,100 @@ class PaymentUtil {
|
|
|
317
549
|
);
|
|
318
550
|
}, 0);
|
|
319
551
|
|
|
552
|
+
// discount
|
|
553
|
+
|
|
554
|
+
// const discountTickets = tickets.filter(
|
|
555
|
+
// (obj, index) =>
|
|
556
|
+
// tickets.findIndex((item) => item.ticketTypeId === obj.ticketTypeId) ===
|
|
557
|
+
// index
|
|
558
|
+
// );
|
|
559
|
+
// console.log(discountTickets, "discountTickets");
|
|
560
|
+
|
|
561
|
+
// const discountFeeFlatPerTicketTotal = tickets?.reduce((cur, ticket) => {
|
|
562
|
+
// return (
|
|
563
|
+
// cur +
|
|
564
|
+
// ticketFeesPromoCodeFlat?.reduce((cur, promotion) => {
|
|
565
|
+
// const value = cur + applyTicketDiscount(ticket, promotion);
|
|
566
|
+
// return value;
|
|
567
|
+
// }, 0)
|
|
568
|
+
// );
|
|
569
|
+
// }, 0);
|
|
570
|
+
|
|
571
|
+
// console.log("+++++++++++++>>>>>>>>>>>>", discountFeeFlatPerTicketTotal);
|
|
572
|
+
|
|
573
|
+
// const discountFeePercentPerTicketTotal = tickets?.reduce((cur, ticket) => {
|
|
574
|
+
// return (
|
|
575
|
+
// cur +
|
|
576
|
+
// ticketFeesPromoCodePercent?.reduce((cur, promotion) => {
|
|
577
|
+
// const value = cur + applyTicketDiscount(ticket, promotion);
|
|
578
|
+
// return value;
|
|
579
|
+
// }, 0)
|
|
580
|
+
// );
|
|
581
|
+
// }, 0);
|
|
582
|
+
|
|
583
|
+
// console.log(
|
|
584
|
+
// "++++++++++++eee+>>>>>>>>>>>>",
|
|
585
|
+
// discountFeePercentPerTicketTotal
|
|
586
|
+
// );
|
|
587
|
+
|
|
588
|
+
// // const discountFeeFlatPerOrderTotal = tickets?.reduce((cur, ticket) => {
|
|
589
|
+
// // return (
|
|
590
|
+
// // cur +
|
|
591
|
+
// // ticketFeesPromoCodeFlatPerOrder?.reduce((cur, promotion) => {
|
|
592
|
+
// // const value = cur + applyTicketDiscount(ticket, promotion);
|
|
593
|
+
// // return value;
|
|
594
|
+
// // }, 0)
|
|
595
|
+
// // );
|
|
596
|
+
// // }, 0);
|
|
597
|
+
|
|
598
|
+
// // console.log("+++++++++++++>>>>>>>>>>>>", discountFeeFlatPerOrderTotal);
|
|
599
|
+
|
|
600
|
+
// const discountFeePercentPerOrderTotal = tickets?.reduce((cur, ticket) => {
|
|
601
|
+
// return (
|
|
602
|
+
// cur +
|
|
603
|
+
// ticketFeesPromoCodePercentPerOrder?.reduce((cur, promotion) => {
|
|
604
|
+
// const value = cur + applyTicketDiscount(ticket, promotion);
|
|
605
|
+
// return value;
|
|
606
|
+
// }, 0)
|
|
607
|
+
// );
|
|
608
|
+
// }, 0);
|
|
609
|
+
|
|
610
|
+
// console.log("+++++++++++++>>>>>>>>>>>>", discountFeePercentPerOrderTotal);
|
|
611
|
+
|
|
612
|
+
// // const promoterFeeFlatPerOrderTotal = promoterOrderFees.reduce(
|
|
613
|
+
// // (acc, fee: any) => {
|
|
614
|
+
// // return fee.type == FeeTypeEnum.Flat ? acc + getFeeAmount(fee) : acc;
|
|
615
|
+
// // },
|
|
616
|
+
// // 0
|
|
617
|
+
// // );
|
|
618
|
+
|
|
619
|
+
// const discountFeeFlatPerOrderAmt = promotions?.reduce(
|
|
620
|
+
// (cur: number,promotion: IEventPromotion) => {
|
|
621
|
+
// if (
|
|
622
|
+
// promotion.discountType == EventPromotionDiscountTypeEnum.Flat &&
|
|
623
|
+
// promotion.appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
624
|
+
// ) {
|
|
625
|
+
// const value = cur + promotion.discountValue;
|
|
626
|
+
// return value;
|
|
627
|
+
// }
|
|
628
|
+
// return cur;
|
|
629
|
+
// },
|
|
630
|
+
// 0
|
|
631
|
+
// );
|
|
632
|
+
|
|
633
|
+
// console.log("Amt flat per order",discountFeeFlatPerOrderAmt)
|
|
634
|
+
|
|
635
|
+
// const discountPercentFeesAmt = promotions.reduce((acc, promotion) => {
|
|
636
|
+
// if (promotion.discountType == EventPromotionDiscountTypeEnum.Percent &&
|
|
637
|
+
// promotion.appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
638
|
+
// ) {
|
|
639
|
+
// return acc + getFeeAmount(promotion, promoterTotal);
|
|
640
|
+
// }
|
|
641
|
+
// return acc;
|
|
642
|
+
// }, 0);
|
|
643
|
+
|
|
644
|
+
// console.log("order amt percent",discountPercentFeesAmt)
|
|
645
|
+
|
|
320
646
|
const promoterFeeFlatPerUpgradeTotal = upgrades.reduce((cur, upgrade) => {
|
|
321
647
|
return (
|
|
322
648
|
cur +
|
|
@@ -349,16 +675,19 @@ class PaymentUtil {
|
|
|
349
675
|
|
|
350
676
|
const promoterFeePercentPerOrder = promoterOrderFees.reduce((acc, fee) => {
|
|
351
677
|
if (fee.type == FeeTypeEnum.Percent) {
|
|
352
|
-
return acc + getFeeAmount(fee, totalTicketAndUpgrades)
|
|
678
|
+
return acc + getFeeAmount(fee, totalTicketAndUpgrades);
|
|
353
679
|
}
|
|
354
|
-
return acc
|
|
355
|
-
}, 0)
|
|
680
|
+
return acc;
|
|
681
|
+
}, 0);
|
|
356
682
|
|
|
357
683
|
const ticketGuestFeeTotalForPromoter = tickets.reduce((cur, ticket) => {
|
|
358
684
|
return (
|
|
359
685
|
cur +
|
|
360
686
|
guestFees.reduce((cur, fee) => {
|
|
361
|
-
const value =
|
|
687
|
+
const value =
|
|
688
|
+
fee.appliedBy == FeeAppliedByEnum.Organization
|
|
689
|
+
? cur + applyGuestTicketFee(ticket, fee)
|
|
690
|
+
: 0;
|
|
362
691
|
return value;
|
|
363
692
|
}, 0)
|
|
364
693
|
);
|
|
@@ -368,86 +697,160 @@ class PaymentUtil {
|
|
|
368
697
|
return (
|
|
369
698
|
cur +
|
|
370
699
|
guestFees.reduce((cur, fee) => {
|
|
371
|
-
const value =
|
|
700
|
+
const value =
|
|
701
|
+
fee.appliedBy == FeeAppliedByEnum.Sellout
|
|
702
|
+
? cur + applyGuestTicketFee(ticket, fee)
|
|
703
|
+
: 0;
|
|
372
704
|
return value;
|
|
373
705
|
}, 0)
|
|
374
706
|
);
|
|
375
707
|
}, 0);
|
|
376
708
|
|
|
709
|
+
// const discount =
|
|
710
|
+
// Math.round(
|
|
711
|
+
// discountFeeFlatPerTicketTotal ||
|
|
712
|
+
// 0 + discountFeePercentPerTicketTotal ||
|
|
713
|
+
// 0 + discountFeeFlatPerOrderAmt ||
|
|
714
|
+
// 0 + discountFeePercentPerOrderTotal ||
|
|
715
|
+
// 0
|
|
716
|
+
// ) || 0;
|
|
717
|
+
// console.log(discount);
|
|
718
|
+
|
|
377
719
|
const orderSubtotal = Math.round(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
720
|
+
totalTicketAndUpgrades+
|
|
721
|
+
// upgradeTotal +
|
|
722
|
+
promoterFeeFlatPerTicketTotal +
|
|
723
|
+
promoterFeeFlatPerOrderTotal +
|
|
724
|
+
promoterFeePercentPerTicketTotal +
|
|
725
|
+
Math.round(promoterFeePercentPerOrder) +
|
|
726
|
+
ticketGuestFeeTotalForPromoter +
|
|
727
|
+
promoterFeeFlatPerUpgradeTotal
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
const discountValue = Math.round(orderSubtotal);
|
|
733
|
+
console.log(discountValue, "discountValue");
|
|
387
734
|
|
|
388
|
-
const
|
|
735
|
+
const salesTaxAmount = salesTaxFees
|
|
736
|
+
? (orderSubtotal * salesTaxFees.value) / 100
|
|
737
|
+
: 0;
|
|
738
|
+
|
|
739
|
+
const promoterTotal = orderSubtotal + Math.round(salesTaxAmount);
|
|
389
740
|
|
|
390
741
|
const selloutPercentFeesAmt = selloutFees.reduce((acc, fee) => {
|
|
391
742
|
if (fee.type == FeeTypeEnum.Percent) {
|
|
392
|
-
return acc + getFeeAmount(fee, promoterTotal)
|
|
743
|
+
return acc + getFeeAmount(fee, promoterTotal);
|
|
393
744
|
}
|
|
394
|
-
return acc
|
|
395
|
-
}, 0)
|
|
396
|
-
|
|
397
|
-
const selloutFeeFlatPerTicketAmt = tickets.reduce((cur: number, ticket: any) => {
|
|
398
|
-
return (
|
|
399
|
-
cur +
|
|
400
|
-
selloutFees.reduce((cur: number, fee: IFee) => {
|
|
401
|
-
if (fee.type == FeeTypeEnum.Flat && fee.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
402
|
-
!fee?.filters?.includes(FeeFiltersEnum.Seated)
|
|
403
|
-
) {
|
|
404
|
-
const value = cur + applyTicketFee(ticket, fee);
|
|
405
|
-
return value;
|
|
406
|
-
}
|
|
407
|
-
return cur
|
|
408
|
-
}, 0)
|
|
409
|
-
);
|
|
745
|
+
return acc;
|
|
410
746
|
}, 0);
|
|
411
747
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
748
|
+
//
|
|
749
|
+
|
|
750
|
+
// const discountPercentFeesAmt = promotions.reduce((acc, promotion) => {
|
|
751
|
+
// if (promotion.discountType == EventPromotionDiscountTypeEnum.Percent) {
|
|
752
|
+
// return acc + getFeeAmount(promotion, promoterTotal);
|
|
753
|
+
// }
|
|
754
|
+
// return acc;
|
|
755
|
+
// }, 0);
|
|
756
|
+
|
|
757
|
+
// console.log(discountPercentFeesAmt)
|
|
758
|
+
|
|
759
|
+
const selloutFeeFlatPerTicketAmt = tickets.reduce(
|
|
760
|
+
(cur: number, ticket: any) => {
|
|
761
|
+
return (
|
|
762
|
+
cur +
|
|
763
|
+
selloutFees.reduce((cur: number, fee: IFee) => {
|
|
764
|
+
if (
|
|
765
|
+
fee.type == FeeTypeEnum.Flat &&
|
|
766
|
+
fee.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
767
|
+
!fee?.filters?.includes(FeeFiltersEnum.Seated)
|
|
768
|
+
) {
|
|
769
|
+
const value = cur + applyTicketFee(ticket, fee);
|
|
770
|
+
return value;
|
|
771
|
+
}
|
|
772
|
+
return cur;
|
|
773
|
+
}, 0)
|
|
774
|
+
);
|
|
775
|
+
},
|
|
776
|
+
0
|
|
777
|
+
);
|
|
778
|
+
|
|
779
|
+
const selloutFeeFlatPerOrderAmt = selloutFees.reduce(
|
|
780
|
+
(cur: number, fee: IFee) => {
|
|
781
|
+
if (
|
|
782
|
+
fee.type === FeeTypeEnum.Flat &&
|
|
783
|
+
fee.appliedTo === FeeAppliedToEnum.Order
|
|
784
|
+
) {
|
|
785
|
+
const value = cur + fee.value;
|
|
786
|
+
return value;
|
|
787
|
+
}
|
|
788
|
+
return cur;
|
|
789
|
+
},
|
|
790
|
+
0
|
|
791
|
+
);
|
|
792
|
+
|
|
793
|
+
// if (fee.type === FeeTypeEnum.Percent) {
|
|
794
|
+
// return amt * (fee.value / 100);
|
|
795
|
+
// }
|
|
796
|
+
// const discountFeeFlatPerOrderAmt = promotions?.reduce(
|
|
797
|
+
// (cur: number,promotion: IEventPromotion) => {
|
|
798
|
+
// if (
|
|
799
|
+
// promotion.discountType == EventPromotionDiscountTypeEnum.Percent &&
|
|
800
|
+
// promotion.appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
801
|
+
// ) {
|
|
802
|
+
// // const value = cur + promotion.discountValue;
|
|
803
|
+
// // return value;
|
|
804
|
+
// return amt * (promotion.discountType / 100);
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
// }
|
|
808
|
+
// return cur;
|
|
809
|
+
// },
|
|
810
|
+
// 0
|
|
811
|
+
// );
|
|
812
|
+
|
|
813
|
+
// console.log(discountFeeFlatPerOrderAmt)
|
|
814
|
+
|
|
815
|
+
|
|
419
816
|
const selloutSeatedFeeAmt = tickets.reduce((cur: number, ticket: any) => {
|
|
420
817
|
return (
|
|
421
818
|
cur +
|
|
422
819
|
selloutFees.reduce((cur: number, fee: IFee) => {
|
|
423
|
-
if (
|
|
820
|
+
if (
|
|
821
|
+
fee.type == FeeTypeEnum.Flat &&
|
|
822
|
+
fee.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
424
823
|
fee?.filters?.includes(FeeFiltersEnum.Seated)
|
|
425
824
|
) {
|
|
426
825
|
const value = cur + applyTicketFee(ticket, fee);
|
|
427
826
|
return value;
|
|
428
827
|
}
|
|
429
828
|
|
|
430
|
-
return cur
|
|
431
|
-
|
|
829
|
+
return cur;
|
|
432
830
|
}, 0)
|
|
433
831
|
);
|
|
434
832
|
}, 0);
|
|
435
833
|
|
|
436
834
|
const selloutFeesTotal = Math.round(
|
|
437
835
|
selloutPercentFeesAmt +
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
836
|
+
selloutFeeFlatPerTicketAmt +
|
|
837
|
+
selloutFeeFlatPerOrderAmt +
|
|
838
|
+
selloutSeatedFeeAmt +
|
|
839
|
+
ticketGuestFeeTotalForSellout +
|
|
840
|
+
SelloutFeeFlatPerUpgradeTotal
|
|
841
|
+
);
|
|
842
|
+
const preStripeTotal = promoterTotal + selloutFeesTotal;
|
|
843
|
+
|
|
844
|
+
let stripeFeeAmt = 0;
|
|
845
|
+
|
|
846
|
+
const stripeFeePercentage =
|
|
847
|
+
stripeFees.find((fee) => fee.type == FeeTypeEnum.Percent)?.value || 0;
|
|
848
|
+
const stripeFeeFlat =
|
|
849
|
+
stripeFees.find((fee) => fee.type == FeeTypeEnum.Flat)?.value || 0;
|
|
850
|
+
stripeFeeAmt =
|
|
851
|
+
(preStripeTotal + stripeFeeFlat) / (1 - stripeFeePercentage / 100) -
|
|
852
|
+
preStripeTotal;
|
|
853
|
+
|
|
451
854
|
function applyTicketFee(
|
|
452
855
|
ticket: ICreateOrderTicketParams,
|
|
453
856
|
fee: IFee
|
|
@@ -477,6 +880,25 @@ class PaymentUtil {
|
|
|
477
880
|
|
|
478
881
|
return 0;
|
|
479
882
|
}
|
|
883
|
+
//
|
|
884
|
+
function applyTicketDiscount(
|
|
885
|
+
ticket: ICreateOrderTicketParams,
|
|
886
|
+
promotion: IEventPromotion
|
|
887
|
+
): any {
|
|
888
|
+
if (
|
|
889
|
+
promotion.ticketTypeIds.includes(ticket?.ticketTypeId) ||
|
|
890
|
+
promotion.ticketTypeIds.length == 0
|
|
891
|
+
) {
|
|
892
|
+
if (promotion?.discountType === EventPromotionDiscountTypeEnum.Flat) {
|
|
893
|
+
return promotion.discountValue;
|
|
894
|
+
}
|
|
895
|
+
if (promotion.discountType === EventPromotionDiscountTypeEnum.Percent) {
|
|
896
|
+
return (ticket.origionalPrice * promotion.discountValue )/100;
|
|
897
|
+
}
|
|
898
|
+
} else {
|
|
899
|
+
return 0;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
480
902
|
|
|
481
903
|
function applyUpgradeFee(
|
|
482
904
|
upgrade: ICreateOrderUpgradeParams,
|
|
@@ -500,6 +922,17 @@ class PaymentUtil {
|
|
|
500
922
|
return 0;
|
|
501
923
|
}
|
|
502
924
|
|
|
925
|
+
// function getDiscount(promotion: IEventPromotion, amt = 0) {
|
|
926
|
+
// if (promotion?.discountType === EventPromotionDiscountTypeEnum.Flat) {
|
|
927
|
+
// return (amt -);
|
|
928
|
+
// }
|
|
929
|
+
// if (promotion?.discountType === EventPromotionDiscountTypeEnum.Percent) {
|
|
930
|
+
// return amt * (promotion.discountValue/ 100);
|
|
931
|
+
// }
|
|
932
|
+
// }
|
|
933
|
+
|
|
934
|
+
// console.log(getDiscount)
|
|
935
|
+
|
|
503
936
|
// return Calculated fees amount based on type
|
|
504
937
|
function getFeeAmount(fee, amt = 0) {
|
|
505
938
|
if (fee.type === FeeTypeEnum.Flat) {
|
|
@@ -509,9 +942,47 @@ class PaymentUtil {
|
|
|
509
942
|
return amt * (fee.value / 100);
|
|
510
943
|
}
|
|
511
944
|
}
|
|
512
|
-
let promoterFeeAmount =
|
|
513
|
-
|
|
514
|
-
|
|
945
|
+
let promoterFeeAmount =
|
|
946
|
+
promoterFeeFlatPerTicketTotal +
|
|
947
|
+
promoterFeeFlatPerOrderTotal +
|
|
948
|
+
promoterFeePercentPerTicketTotal +
|
|
949
|
+
promoterFeePercentPerOrder +
|
|
950
|
+
ticketGuestFeeTotalForPromoter +
|
|
951
|
+
promoterFeeFlatPerUpgradeTotal;
|
|
952
|
+
|
|
953
|
+
// let total = {
|
|
954
|
+
// salesTax: Math.round(salesTaxAmount || 0),
|
|
955
|
+
// total: isDiscount && discount > 0
|
|
956
|
+
// ? Math.round(orderSubtotal - discount) +
|
|
957
|
+
// Math.round(
|
|
958
|
+
// promoterFeeAmount +
|
|
959
|
+
// (isDiscount && discount > 0 ? stripeDiscountFeeAmt : stripeFeeAmt) +
|
|
960
|
+
// selloutFeesTotal +
|
|
961
|
+
// salesTaxAmount || 0
|
|
962
|
+
// )
|
|
963
|
+
// : Math.round(preStripeTotal) + Math.round(isDiscount ? stripeDiscountFeeAmt : stripeFeeAmt) || 0,
|
|
964
|
+
// promoterFees: Math.round(promoterFeeAmount || 0),
|
|
965
|
+
// stripeFees: Math.round(isDiscount ? stripeDiscountFeeAmt : stripeFeeAmt || 0),
|
|
966
|
+
// selloutFees: Math.round(selloutFeesTotal || 0),
|
|
967
|
+
// orderSubtotal: Math.round(orderSubtotal || 0),
|
|
968
|
+
// subTotal: isDiscount && discount > 0
|
|
969
|
+
// ? Math.round(orderSubtotal - discount || 0)
|
|
970
|
+
// : Math.round(totalTicketAndUpgrades || 0),
|
|
971
|
+
// // subTotal: Math.round(totalTicketAndUpgrades || 0),
|
|
972
|
+
|
|
973
|
+
// totalFees: Math.round(
|
|
974
|
+
// promoterFeeAmount +
|
|
975
|
+
// stripeDiscountFeeAmt +
|
|
976
|
+
// selloutFeesTotal +
|
|
977
|
+
// salesTaxAmount || 0
|
|
978
|
+
// ),
|
|
979
|
+
// totalWithoutTaxFees: Math.round(
|
|
980
|
+
// promoterFeeAmount + stripeFeeAmt + selloutFeesTotal || 0
|
|
981
|
+
// ),
|
|
982
|
+
// guestFeeForPromoter: Math.round(ticketGuestFeeTotalForPromoter || 0),
|
|
983
|
+
// guestFeeForSellout: Math.round(ticketGuestFeeTotalForSellout || 0),
|
|
984
|
+
// discountAmount: Math.round(discount) || 0,
|
|
985
|
+
// };
|
|
515
986
|
|
|
516
987
|
let total = {
|
|
517
988
|
salesTax: Math.round(salesTaxAmount || 0),
|
|
@@ -525,17 +996,20 @@ class PaymentUtil {
|
|
|
525
996
|
totalWithoutTaxFees: Math.round((promoterFeeAmount + stripeFeeAmt + selloutFeesTotal) || 0),
|
|
526
997
|
guestFeeForPromoter: Math.round(ticketGuestFeeTotalForPromoter || 0),
|
|
527
998
|
guestFeeForSellout: Math.round(ticketGuestFeeTotalForSellout || 0),
|
|
999
|
+
discountAmount: Math.round(discount || discountOrder) || 0,
|
|
1000
|
+
|
|
528
1001
|
}
|
|
529
|
-
|
|
1002
|
+
// console.log(total, "total");
|
|
1003
|
+
return total;
|
|
530
1004
|
}
|
|
531
1005
|
|
|
532
|
-
|
|
533
1006
|
calculatePaymentSubtotal(params: IPaymentCalculatorParams): number {
|
|
534
1007
|
let {
|
|
535
1008
|
tickets = [],
|
|
536
1009
|
upgrades = [],
|
|
537
1010
|
paymentMethodType,
|
|
538
1011
|
// fees
|
|
1012
|
+
// promotions
|
|
539
1013
|
} = params;
|
|
540
1014
|
|
|
541
1015
|
if (paymentMethodType === PaymentMethodTypeEnum.None) return 0;
|
|
@@ -545,10 +1019,38 @@ class PaymentUtil {
|
|
|
545
1019
|
(cur, upgrade) => cur + upgrade.price,
|
|
546
1020
|
0
|
|
547
1021
|
); // + (upgrade.price * tax/100)
|
|
548
|
-
|
|
1022
|
+
// const discountFeeFlatPerOrderAmt = promotions?.reduce(
|
|
1023
|
+
// (cur: number,promotion: IEventPromotion) => {
|
|
1024
|
+
// if (
|
|
1025
|
+
// promotion.discountType == EventPromotionDiscountTypeEnum.Flat &&
|
|
1026
|
+
// promotion.appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
1027
|
+
// ) {
|
|
1028
|
+
// const value = cur + promotion.discountValue;
|
|
1029
|
+
// return value;
|
|
1030
|
+
// }
|
|
1031
|
+
// return cur;
|
|
1032
|
+
// },
|
|
1033
|
+
// 0
|
|
1034
|
+
// );
|
|
1035
|
+
|
|
1036
|
+
// const totalTicketUpgrade = ticketTotal + upgradeTotal
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
return ticketTotal + upgradeTotal
|
|
549
1049
|
}
|
|
550
1050
|
|
|
551
1051
|
|
|
1052
|
+
|
|
1053
|
+
|
|
552
1054
|
calculatePaymentSubtotalValue(params: any): number {
|
|
553
1055
|
let {
|
|
554
1056
|
tickets = [],
|
|
@@ -564,11 +1066,9 @@ class PaymentUtil {
|
|
|
564
1066
|
(cur, upgrade) => cur + upgrade.price,
|
|
565
1067
|
0
|
|
566
1068
|
); // + (upgrade.price * tax/100)
|
|
567
|
-
return ticketTotal + upgradeTotal;
|
|
1069
|
+
return ticketTotal + upgradeTotal ;
|
|
568
1070
|
}
|
|
569
1071
|
|
|
570
|
-
|
|
571
|
-
|
|
572
1072
|
calculateFee(params: IPaymentCalculatorParams): number {
|
|
573
1073
|
let { fees } = params;
|
|
574
1074
|
const salesTax = fees.filter((f) => f.name == "Sales tax");
|
|
@@ -583,7 +1083,7 @@ class PaymentUtil {
|
|
|
583
1083
|
const total = this.calculatePaymentTotal(params);
|
|
584
1084
|
// let subtotal = this.calculatePaymentSubtotal(params);
|
|
585
1085
|
// return Math.round(total - subtotal);
|
|
586
|
-
return total
|
|
1086
|
+
return total;
|
|
587
1087
|
}
|
|
588
1088
|
calculateOrganizationFee(params: IPaymentCalculatorParams): number {
|
|
589
1089
|
let { tickets = [], upgrades = [], fees = [], paymentMethodType } = params;
|
|
@@ -640,26 +1140,25 @@ class PaymentUtil {
|
|
|
640
1140
|
// }
|
|
641
1141
|
|
|
642
1142
|
calculateGuestFee(tickets: any, event: any): number {
|
|
643
|
-
|
|
644
1143
|
let guestTicketFees = event?.fees.filter(
|
|
645
1144
|
(fee: IFee) =>
|
|
646
1145
|
fee.filters && fee.filters[0] === FeeFiltersEnum.GuestTicket
|
|
647
1146
|
);
|
|
648
1147
|
|
|
649
1148
|
let stripeFees = event?.fees.filter(
|
|
650
|
-
(fee: IFee) =>
|
|
1149
|
+
(fee: IFee) =>
|
|
1150
|
+
fee.appliedBy === FeeAppliedByEnum.Stripe &&
|
|
1151
|
+
fee.type === FeeTypeEnum.Percent
|
|
651
1152
|
);
|
|
652
1153
|
|
|
653
|
-
|
|
654
1154
|
let guestFeesValue = guestTicketFees && guestTicketFees[0]?.value;
|
|
655
1155
|
let stripeFeesValue = stripeFees && stripeFees[0]?.value;
|
|
656
1156
|
let guestMembers = tickets.filter((a) => a.guestTicket).length;
|
|
657
1157
|
let guestFees = (guestFeesValue as number) * guestMembers;
|
|
658
1158
|
return guestTicketFees.length > 0 && event.organization.isTegIntegration
|
|
659
|
-
? guestFees + guestFees * stripeFeesValue / 100
|
|
1159
|
+
? guestFees + (guestFees * stripeFeesValue) / 100
|
|
660
1160
|
: 0;
|
|
661
1161
|
}
|
|
662
|
-
|
|
663
1162
|
}
|
|
664
1163
|
|
|
665
1164
|
export default new PaymentUtil();
|