@sellout/models 0.0.280 → 0.0.281
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 +1 -0
- package/.dist/graphql/fragments/event.fragment.js.map +1 -1
- package/.dist/graphql/mutations/createEvent.mutation.js +3 -0
- package/.dist/graphql/mutations/createEvent.mutation.js.map +1 -1
- package/.dist/graphql/mutations/duplicateEvent.mutation.d.ts +2 -0
- package/.dist/graphql/mutations/duplicateEvent.mutation.js +86 -0
- package/.dist/graphql/mutations/duplicateEvent.mutation.js.map +1 -0
- package/.dist/interfaces/IEvent.d.ts +1 -0
- package/.dist/sellout-proto.js +1139 -7
- package/.dist/utils/PaymentUtil.js +1 -0
- package/.dist/utils/PaymentUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/graphql/fragments/event.fragment.ts +1 -0
- package/src/graphql/mutations/createEvent.mutation.ts +3 -0
- package/src/graphql/mutations/duplicateEvent.mutation.ts +82 -0
- package/src/interfaces/IEvent.ts +1 -0
- package/src/proto/broadcast.proto +4 -1
- package/src/proto/email.proto +13 -0
- package/src/proto/event.proto +24 -1
- package/src/utils/PaymentUtil.ts +365 -0
package/src/utils/PaymentUtil.ts
CHANGED
|
@@ -15,6 +15,8 @@ import IEventPromotion, {
|
|
|
15
15
|
EventPromotionAppliesToEnum,
|
|
16
16
|
EventPromotionDiscountTypeEnum,
|
|
17
17
|
} from "../interfaces/IEventPromotion";
|
|
18
|
+
|
|
19
|
+
// import OrderUtil from "./OrderUtil";
|
|
18
20
|
// import EventPromotionDiscountTypeEnum from '../interfaces/I'
|
|
19
21
|
// import Fee from "src/schemas/Fee";
|
|
20
22
|
|
|
@@ -1033,6 +1035,7 @@ class PaymentUtil {
|
|
|
1033
1035
|
// console.log(total, "total");
|
|
1034
1036
|
return total;
|
|
1035
1037
|
}
|
|
1038
|
+
|
|
1036
1039
|
|
|
1037
1040
|
calculatePaymentSubtotal(params: IPaymentCalculatorParams): number {
|
|
1038
1041
|
let {
|
|
@@ -1068,6 +1071,8 @@ class PaymentUtil {
|
|
|
1068
1071
|
(cur, upgrade) => cur + upgrade.price,
|
|
1069
1072
|
0
|
|
1070
1073
|
); // + (upgrade.price * tax/100)
|
|
1074
|
+
console.log(ticketTotal + upgradeTotal,"ticketTotal + upgradeTotal");
|
|
1075
|
+
|
|
1071
1076
|
return ticketTotal + upgradeTotal;
|
|
1072
1077
|
}
|
|
1073
1078
|
|
|
@@ -1161,6 +1166,366 @@ class PaymentUtil {
|
|
|
1161
1166
|
? guestFees + (guestFees * stripeFeesValue) / 100
|
|
1162
1167
|
: 0;
|
|
1163
1168
|
}
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
// CalculatePromoterFeeList = (params: {
|
|
1172
|
+
// tickets;
|
|
1173
|
+
// fees;
|
|
1174
|
+
// promotions;
|
|
1175
|
+
// upgrades;
|
|
1176
|
+
// discountCode;
|
|
1177
|
+
// }) => {
|
|
1178
|
+
|
|
1179
|
+
// let tickets: any = params.tickets;
|
|
1180
|
+
// let upgrades: any = params.upgrades;
|
|
1181
|
+
// let promoterFees: any = [];
|
|
1182
|
+
|
|
1183
|
+
// params.fees.forEach((item) => {
|
|
1184
|
+
// const newItem = { ...item, amount: 0 };
|
|
1185
|
+
// if (newItem.appliedBy === FeeAppliedByEnum.Organization) {
|
|
1186
|
+
// if (newItem.name === "Sales tax") {
|
|
1187
|
+
// } else {
|
|
1188
|
+
// promoterFees.push(newItem);
|
|
1189
|
+
// }
|
|
1190
|
+
// }
|
|
1191
|
+
// });
|
|
1192
|
+
|
|
1193
|
+
// const promotionsCode = params?.promotions?.filter((promo) => {
|
|
1194
|
+
// const promoCode = promo?.code?.toLowerCase();
|
|
1195
|
+
// const discountCode =
|
|
1196
|
+
// typeof params?.discountCode === "string"
|
|
1197
|
+
// ? params.discountCode.toLowerCase()
|
|
1198
|
+
// : "";
|
|
1199
|
+
// return promoCode === discountCode;
|
|
1200
|
+
// });
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
// if (promotionsCode.length != 0) {
|
|
1204
|
+
// tickets = tickets.map((ticket) => {
|
|
1205
|
+
// if (
|
|
1206
|
+
// promotionsCode &&
|
|
1207
|
+
// promotionsCode[0].discountType ===
|
|
1208
|
+
// EventPromotionDiscountTypeEnum.Flat &&
|
|
1209
|
+
// promotionsCode[0].appliesTo === EventPromotionAppliesToEnum.PerTicket
|
|
1210
|
+
// ) {
|
|
1211
|
+
// if (promotionsCode[0]?.ticketTypeIds.length == 0) {
|
|
1212
|
+
// const discountValue = Number(promotionsCode[0].discountValue);
|
|
1213
|
+
// const originalPrice = ticket.price;
|
|
1214
|
+
// const discountedPrice = originalPrice - discountValue;
|
|
1215
|
+
// return {
|
|
1216
|
+
// ...ticket,
|
|
1217
|
+
// price: discountedPrice,
|
|
1218
|
+
// };
|
|
1219
|
+
// } else {
|
|
1220
|
+
// if (
|
|
1221
|
+
// promotionsCode &&
|
|
1222
|
+
// promotionsCode[0].ticketTypeIds.includes(ticket?.ticketTypeId)
|
|
1223
|
+
// ) {
|
|
1224
|
+
// const discountValue = Number(promotionsCode[0].discountValue);
|
|
1225
|
+
// const originalPrice = ticket.price;
|
|
1226
|
+
// const discountedPrice = originalPrice - discountValue;
|
|
1227
|
+
// return {
|
|
1228
|
+
// ...ticket,
|
|
1229
|
+
// price: discountedPrice,
|
|
1230
|
+
// };
|
|
1231
|
+
// } else {
|
|
1232
|
+
// const originalPrice = ticket.price;
|
|
1233
|
+
// return {
|
|
1234
|
+
// ...ticket,
|
|
1235
|
+
// price: originalPrice,
|
|
1236
|
+
// };
|
|
1237
|
+
// }
|
|
1238
|
+
// }
|
|
1239
|
+
// }
|
|
1240
|
+
|
|
1241
|
+
// if (
|
|
1242
|
+
// promotionsCode &&
|
|
1243
|
+
// promotionsCode[0].discountType ===
|
|
1244
|
+
// EventPromotionDiscountTypeEnum.Percent &&
|
|
1245
|
+
// promotionsCode[0].appliesTo === EventPromotionAppliesToEnum.PerTicket
|
|
1246
|
+
// ) {
|
|
1247
|
+
// if (promotionsCode[0]?.ticketTypeIds.length == 0) {
|
|
1248
|
+
// const discountValue = Number(promotionsCode[0].discountValue);
|
|
1249
|
+
// const percentTicketValue =
|
|
1250
|
+
// (ticket.origionalPrice * discountValue) / 100;
|
|
1251
|
+
// const originalPrice = ticket.price;
|
|
1252
|
+
// const discountPercentPrice = originalPrice - percentTicketValue;
|
|
1253
|
+
|
|
1254
|
+
// return {
|
|
1255
|
+
// ...ticket,
|
|
1256
|
+
// price: discountPercentPrice,
|
|
1257
|
+
// };
|
|
1258
|
+
// } else {
|
|
1259
|
+
// if (
|
|
1260
|
+
// promotionsCode[0]?.ticketTypeIds.includes(ticket?.ticketTypeId)
|
|
1261
|
+
// ) {
|
|
1262
|
+
// const discountValue = Number(promotionsCode[0].discountValue);
|
|
1263
|
+
// const percentTicketValue =
|
|
1264
|
+
// (ticket.origionalPrice * discountValue) / 100;
|
|
1265
|
+
// const originalPrice = ticket.price;
|
|
1266
|
+
// const discountPercentPrice = originalPrice - percentTicketValue;
|
|
1267
|
+
|
|
1268
|
+
// return {
|
|
1269
|
+
// ...ticket,
|
|
1270
|
+
// price: discountPercentPrice,
|
|
1271
|
+
// };
|
|
1272
|
+
// } else {
|
|
1273
|
+
// const originalPrice = ticket.price;
|
|
1274
|
+
// return {
|
|
1275
|
+
// ...ticket,
|
|
1276
|
+
// price: originalPrice,
|
|
1277
|
+
// };
|
|
1278
|
+
// }
|
|
1279
|
+
// }
|
|
1280
|
+
// }
|
|
1281
|
+
// return ticket;
|
|
1282
|
+
// });
|
|
1283
|
+
// }
|
|
1284
|
+
|
|
1285
|
+
// const discountFeeFlatPerOrderAmt = promotionsCode?.reduce(
|
|
1286
|
+
// (cur: number, promotion: any) => {
|
|
1287
|
+
// if (
|
|
1288
|
+
// promotionsCode?.length &&
|
|
1289
|
+
// promotionsCode[0].discountType ===
|
|
1290
|
+
// EventPromotionDiscountTypeEnum.Flat &&
|
|
1291
|
+
// promotionsCode[0].appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
1292
|
+
// ) {
|
|
1293
|
+
// const value = cur + promotion.discountValue;
|
|
1294
|
+
// return value;
|
|
1295
|
+
// }
|
|
1296
|
+
// return cur;
|
|
1297
|
+
// },
|
|
1298
|
+
// 0
|
|
1299
|
+
// );
|
|
1300
|
+
// const ticketTotal = tickets.reduce((cur, ticket) => cur + ticket.price, 0);
|
|
1301
|
+
// const upgradeTotal = upgrades.reduce(
|
|
1302
|
+
// (cur, upgrade) => cur + upgrade.price,
|
|
1303
|
+
// 0
|
|
1304
|
+
// );
|
|
1305
|
+
// const totalTicketUpgrade = ticketTotal + upgradeTotal;
|
|
1306
|
+
|
|
1307
|
+
// const discountFeePercentPerOrderAmt = promotionsCode?.reduce(
|
|
1308
|
+
// (cur: number, promotion: any) => {
|
|
1309
|
+
// if (
|
|
1310
|
+
// promotionsCode?.length &&
|
|
1311
|
+
// promotionsCode[0].discountType ===
|
|
1312
|
+
// EventPromotionDiscountTypeEnum.Percent &&
|
|
1313
|
+
// promotionsCode[0].appliesTo === EventPromotionAppliesToEnum.PerOrder
|
|
1314
|
+
// ) {
|
|
1315
|
+
// const value =
|
|
1316
|
+
// cur + (totalTicketUpgrade * promotion.discountValue) / 100;
|
|
1317
|
+
// return value;
|
|
1318
|
+
// }
|
|
1319
|
+
// return cur;
|
|
1320
|
+
// },
|
|
1321
|
+
// 0
|
|
1322
|
+
// );
|
|
1323
|
+
|
|
1324
|
+
// const discountOrder =
|
|
1325
|
+
// Math.round(
|
|
1326
|
+
// discountFeeFlatPerOrderAmt || 0 + discountFeePercentPerOrderAmt || 0
|
|
1327
|
+
// ) || 0;
|
|
1328
|
+
|
|
1329
|
+
// let newSubtotal = this.calculatePaymentSubtotalValue({
|
|
1330
|
+
// tickets: tickets,
|
|
1331
|
+
// upgrades: upgrades,
|
|
1332
|
+
// });
|
|
1333
|
+
|
|
1334
|
+
// let subtotal = newSubtotal - discountOrder;
|
|
1335
|
+
|
|
1336
|
+
// const ticketFeesPromotersPercent = params.fees.filter(
|
|
1337
|
+
// (f) =>
|
|
1338
|
+
// f.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
1339
|
+
// f.appliedBy == FeeAppliedByEnum.Organization &&
|
|
1340
|
+
// f.type === FeeTypeEnum.Percent
|
|
1341
|
+
// );
|
|
1342
|
+
|
|
1343
|
+
// const ticketFeesPromotersFlat = params.fees.filter(
|
|
1344
|
+
// (f) =>
|
|
1345
|
+
// f.appliedTo === FeeAppliedToEnum.Ticket &&
|
|
1346
|
+
// f.appliedBy == FeeAppliedByEnum.Organization &&
|
|
1347
|
+
// f.type === FeeTypeEnum.Flat
|
|
1348
|
+
// );
|
|
1349
|
+
|
|
1350
|
+
// function applyTicketFee(
|
|
1351
|
+
// ticket: ICreateOrderTicketParams,
|
|
1352
|
+
// fee: IFee
|
|
1353
|
+
// ): number {
|
|
1354
|
+
// // Ignore seated fees if not seated
|
|
1355
|
+
// if (
|
|
1356
|
+
// fee.filters &&
|
|
1357
|
+
// fee.filters.includes(FeeFiltersEnum.Seated) &&
|
|
1358
|
+
// !ticket.seat
|
|
1359
|
+
// ) {
|
|
1360
|
+
// return 0;
|
|
1361
|
+
// }
|
|
1362
|
+
|
|
1363
|
+
// const minFee = fee.minAppliedToPrice || 0;
|
|
1364
|
+
// const maxFee = fee.maxAppliedToPrice || Infinity;
|
|
1365
|
+
// if (minFee <= ticket.price && ticket.price <= maxFee) {
|
|
1366
|
+
// if (fee.type === FeeTypeEnum.Flat) {
|
|
1367
|
+
// return fee.value;
|
|
1368
|
+
// }
|
|
1369
|
+
// if (fee.type === FeeTypeEnum.Percent) {
|
|
1370
|
+
// return (ticket.price * fee.value) / 100;
|
|
1371
|
+
// }
|
|
1372
|
+
// } else {
|
|
1373
|
+
// return 0;
|
|
1374
|
+
// }
|
|
1375
|
+
// return 0;
|
|
1376
|
+
// }
|
|
1377
|
+
|
|
1378
|
+
// function getFeeAmount(fee, amt = 0) {
|
|
1379
|
+
// if (fee.type === FeeTypeEnum.Flat) {
|
|
1380
|
+
// return fee.value;
|
|
1381
|
+
// }
|
|
1382
|
+
// if (fee.type === FeeTypeEnum.Percent) {
|
|
1383
|
+
// return amt * (fee.value / 100);
|
|
1384
|
+
// }
|
|
1385
|
+
// }
|
|
1386
|
+
|
|
1387
|
+
// const promoterOrderFees = params.fees
|
|
1388
|
+
// .filter(
|
|
1389
|
+
// (f) =>
|
|
1390
|
+
// f.appliedTo === FeeAppliedToEnum.Order &&
|
|
1391
|
+
// f.name != "Sales tax" &&
|
|
1392
|
+
// f.appliedBy == FeeAppliedByEnum.Organization
|
|
1393
|
+
// )
|
|
1394
|
+
// .sort(({ type }) => {
|
|
1395
|
+
// if (type === "Flat") return -1;
|
|
1396
|
+
// else return 1;
|
|
1397
|
+
// });
|
|
1398
|
+
|
|
1399
|
+
// let promoCodeAdd = 0;
|
|
1400
|
+
// let promoterFeePercentPerOrder11 = 0;
|
|
1401
|
+
|
|
1402
|
+
// promoterFees.map((promo) => {
|
|
1403
|
+
// if (
|
|
1404
|
+
// promo.type === FeeTypeEnum.Percent &&
|
|
1405
|
+
// promo.appliedTo === FeeAppliedToEnum.Ticket
|
|
1406
|
+
// ) {
|
|
1407
|
+
// const promoterFeePercentPerTicketTotal = tickets.reduce(
|
|
1408
|
+
// (cur, ticket) => {
|
|
1409
|
+
// let mainPrice = ticket.price;
|
|
1410
|
+
// return (
|
|
1411
|
+
// cur +
|
|
1412
|
+
// ticketFeesPromotersPercent.reduce((cur, fee) => {
|
|
1413
|
+
// const value = cur + applyTicketFee(ticket, fee);
|
|
1414
|
+
// ticket.price = mainPrice;
|
|
1415
|
+
// return value;
|
|
1416
|
+
// }, 0)
|
|
1417
|
+
// );
|
|
1418
|
+
// },
|
|
1419
|
+
// 0
|
|
1420
|
+
// );
|
|
1421
|
+
// promo.amount = promoterFeePercentPerTicketTotal;
|
|
1422
|
+
// } else if (
|
|
1423
|
+
// promo.type === FeeTypeEnum.Percent &&
|
|
1424
|
+
// promo.appliedTo === FeeAppliedToEnum.Order
|
|
1425
|
+
// ) {
|
|
1426
|
+
// promoterFeePercentPerOrder11 = promoterOrderFees.reduce((acc, fee) => {
|
|
1427
|
+
// if (fee.type == FeeTypeEnum.Percent) {
|
|
1428
|
+
// return acc + getFeeAmount(fee, subtotal);
|
|
1429
|
+
// }
|
|
1430
|
+
// return acc;
|
|
1431
|
+
// }, 0);
|
|
1432
|
+
|
|
1433
|
+
// promo.amount = Math.round(promoterFeePercentPerOrder11);
|
|
1434
|
+
// } else {
|
|
1435
|
+
// if (
|
|
1436
|
+
// promo.appliedTo == FeeAppliedToEnum.Ticket &&
|
|
1437
|
+
// promo.type === FeeTypeEnum.Flat
|
|
1438
|
+
// ) {
|
|
1439
|
+
// let promoterFeeFlatPerTicketTotal = tickets.reduce((cur, ticket) => {
|
|
1440
|
+
// let mainPrice = ticket.price;
|
|
1441
|
+
// ticket.price = ticket.origionalPrice;
|
|
1442
|
+
|
|
1443
|
+
// return (
|
|
1444
|
+
// cur +
|
|
1445
|
+
// ticketFeesPromotersFlat.reduce((cur, fee) => {
|
|
1446
|
+
// const value = cur + applyTicketFee(ticket, fee);
|
|
1447
|
+
// ticket.price = mainPrice;
|
|
1448
|
+
// return value;
|
|
1449
|
+
// }, 0)
|
|
1450
|
+
// );
|
|
1451
|
+
// }, 0);
|
|
1452
|
+
// promo.amount = promoterFeeFlatPerTicketTotal;
|
|
1453
|
+
// } else if (
|
|
1454
|
+
// promo.appliedTo == FeeAppliedToEnum.Order &&
|
|
1455
|
+
// promo.type === FeeTypeEnum.Flat
|
|
1456
|
+
// ) {
|
|
1457
|
+
// let promoterFeeFlatPerOrder = 0;
|
|
1458
|
+
// promoterFeeFlatPerOrder = promoterOrderFees.reduce((acc, fee) => {
|
|
1459
|
+
// if (fee.type == FeeTypeEnum.Flat) {
|
|
1460
|
+
// return acc + getFeeAmount(fee, subtotal);
|
|
1461
|
+
// }
|
|
1462
|
+
// return acc;
|
|
1463
|
+
// }, 0);
|
|
1464
|
+
|
|
1465
|
+
// promo.amount = promoterFeeFlatPerOrder;
|
|
1466
|
+
// }
|
|
1467
|
+
// }
|
|
1468
|
+
// promoCodeAdd += Math.round(promo.amount * 100) / 100 || 0;
|
|
1469
|
+
// });
|
|
1470
|
+
|
|
1471
|
+
// const applyUpgradeFee = (upgrade, fee): number => {
|
|
1472
|
+
// const minFee = fee.minAppliedToPrice || 0;
|
|
1473
|
+
// const maxFee = fee.maxAppliedToPrice || Infinity;
|
|
1474
|
+
|
|
1475
|
+
// if (minFee <= upgrade.price && upgrade.price <= maxFee) {
|
|
1476
|
+
// if (fee.type === FeeTypeEnum.Flat) {
|
|
1477
|
+
// return fee.value;
|
|
1478
|
+
// }
|
|
1479
|
+
// if (fee.type === FeeTypeEnum.Percent) {
|
|
1480
|
+
// let percent = (upgrade.price * fee.value) / 100;
|
|
1481
|
+
// return Math.round(percent * 100) / 100 || 0;
|
|
1482
|
+
// }
|
|
1483
|
+
// } else {
|
|
1484
|
+
// return 0;
|
|
1485
|
+
// }
|
|
1486
|
+
|
|
1487
|
+
// return 0;
|
|
1488
|
+
// };
|
|
1489
|
+
|
|
1490
|
+
// for (let index = 0; index < promoterFees.length; index++) {
|
|
1491
|
+
// let promoterUpgradeFee = promoterFees[index];
|
|
1492
|
+
// if (promoterUpgradeFee?.appliedTo === FeeAppliedToEnum.Upgrade) {
|
|
1493
|
+
// let promoterUpgardeFeeArr = [promoterUpgradeFee];
|
|
1494
|
+
// const promoterFeeFlatPerUpgardeAmt = params.upgrades.reduce(
|
|
1495
|
+
// (cur: number, upgrade: any) => {
|
|
1496
|
+
// return (
|
|
1497
|
+
// cur +
|
|
1498
|
+
// promoterUpgardeFeeArr.reduce((cur, fee) => {
|
|
1499
|
+
// const value = cur + applyUpgradeFee(upgrade, fee);
|
|
1500
|
+
// return value;
|
|
1501
|
+
// }, 0)
|
|
1502
|
+
// );
|
|
1503
|
+
// },
|
|
1504
|
+
// 0
|
|
1505
|
+
// );
|
|
1506
|
+
// promoterUpgradeFee.amount = Math.round(promoterFeeFlatPerUpgardeAmt);
|
|
1507
|
+
// promoCodeAdd += Math.round(promoterUpgradeFee.amount) || 0;
|
|
1508
|
+
// }
|
|
1509
|
+
// }
|
|
1510
|
+
|
|
1511
|
+
// const promoterFeeList = promoterFees
|
|
1512
|
+
// .filter(
|
|
1513
|
+
// (f) =>
|
|
1514
|
+
// f.name !== "Sales tax" &&
|
|
1515
|
+
// f.amount > 0 &&
|
|
1516
|
+
// f.appliedBy === "Organization"
|
|
1517
|
+
// )
|
|
1518
|
+
// .map((f) => ({
|
|
1519
|
+
// name: f.name,
|
|
1520
|
+
// amount: f.amount,
|
|
1521
|
+
// }));
|
|
1522
|
+
// return promoterFeeList;
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
// };
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1164
1529
|
}
|
|
1165
1530
|
|
|
1166
1531
|
export default new PaymentUtil();
|