@sellout/models 0.0.148 → 0.0.149
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.js +2 -0
- package/.dist/graphql/fragments/order.fragment.js.map +1 -1
- package/.dist/graphql/mutations/breakApartOrder.js +1 -0
- package/.dist/graphql/mutations/breakApartOrder.js.map +1 -1
- package/.dist/graphql/mutations/createEvent.mutation.js +2 -0
- package/.dist/graphql/mutations/createEvent.mutation.js.map +1 -1
- package/.dist/graphql/mutations/publishEvent.mutation.js +2 -0
- package/.dist/graphql/mutations/publishEvent.mutation.js.map +1 -1
- package/.dist/graphql/mutations/sendUserPhoneAuthentication.mutation.js +2 -2
- package/.dist/graphql/mutations/updateEvent.mutation.js +2 -0
- package/.dist/graphql/mutations/updateEvent.mutation.js.map +1 -1
- package/.dist/graphql/queries/event.query.js +2 -0
- package/.dist/graphql/queries/event.query.js.map +1 -1
- package/.dist/graphql/queries/events.query.js +2 -0
- package/.dist/graphql/queries/events.query.js.map +1 -1
- package/.dist/graphql/queries/order.query.js +2 -0
- package/.dist/graphql/queries/order.query.js.map +1 -1
- package/.dist/graphql/queries/orders.query.js +1 -0
- package/.dist/graphql/queries/orders.query.js.map +1 -1
- package/.dist/graphql/queries/promoCodeVerify.query.js +1 -0
- package/.dist/graphql/queries/promoCodeVerify.query.js.map +1 -1
- package/.dist/graphql/queries/publicEvent.query.js +2 -0
- package/.dist/graphql/queries/publicEvent.query.js.map +1 -1
- package/.dist/interfaces/ICreateOrderParams.d.ts +3 -0
- package/.dist/interfaces/IEvent.d.ts +2 -0
- package/.dist/interfaces/IEvent.js.map +1 -1
- package/.dist/interfaces/IOrderSummary.d.ts +1 -0
- package/.dist/interfaces/IOrderTicket.d.ts +2 -1
- package/.dist/interfaces/IOrderTicket.js.map +1 -1
- package/.dist/interfaces/IPerformance.d.ts +2 -1
- package/.dist/interfaces/IScan.d.ts +1 -0
- package/.dist/interfaces/ITicketType.d.ts +3 -0
- package/.dist/schemas/Event.d.ts +33 -2
- package/.dist/schemas/Event.js +33 -11
- package/.dist/schemas/Event.js.map +1 -1
- package/.dist/schemas/Order.d.ts +15 -1
- package/.dist/schemas/Order.js +12 -3
- package/.dist/schemas/Order.js.map +1 -1
- package/.dist/sellout-proto.js +785 -36
- package/.dist/utils/EventUtil.d.ts +2 -1
- package/.dist/utils/EventUtil.js +73 -5
- package/.dist/utils/EventUtil.js.map +1 -1
- package/.dist/utils/OrderUtil.js +3 -1
- package/.dist/utils/OrderUtil.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 +2 -0
- package/src/graphql/mutations/breakApartOrder.ts +1 -0
- package/src/graphql/mutations/createEvent.mutation.ts +2 -0
- package/src/graphql/mutations/publishEvent.mutation.ts +2 -0
- package/src/graphql/mutations/sendUserPhoneAuthentication.mutation.ts +2 -2
- package/src/graphql/mutations/updateEvent.mutation.ts +2 -0
- package/src/graphql/queries/event.query.ts +2 -0
- package/src/graphql/queries/events.query.ts +2 -0
- package/src/graphql/queries/order.query.ts +2 -0
- package/src/graphql/queries/orders.query.ts +1 -0
- package/src/graphql/queries/promoCodeVerify.query.ts +1 -0
- package/src/graphql/queries/publicEvent.query.ts +2 -0
- package/src/interfaces/ICreateOrderParams.ts +4 -0
- package/src/interfaces/IEvent.ts +4 -2
- package/src/interfaces/IOrderSummary.ts +1 -0
- package/src/interfaces/IOrderTicket.ts +2 -1
- package/src/interfaces/IPerformance.ts +2 -1
- package/src/interfaces/IScan.ts +1 -0
- package/src/interfaces/ITicketType.ts +4 -1
- package/src/proto/email.proto +14 -0
- package/src/proto/event.proto +5 -1
- package/src/proto/order.proto +4 -1
- package/src/proto/user.proto +1 -0
- package/src/schemas/Event.ts +25 -3
- package/src/schemas/Order.ts +12 -3
- package/src/utils/EventUtil.ts +98 -19
- package/src/utils/OrderUtil.ts +96 -94
package/src/proto/email.proto
CHANGED
|
@@ -50,12 +50,14 @@ message OrderSummaryItem {
|
|
|
50
50
|
string seats = 3;
|
|
51
51
|
string description = 4;
|
|
52
52
|
string type = 5;
|
|
53
|
+
string days = 6;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
message OrderRefundItem {
|
|
56
57
|
string name = 0;
|
|
57
58
|
string refundedAmount = 1;
|
|
58
59
|
string description = 2;
|
|
60
|
+
string days = 3;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
message orderSheetEmailRequest {
|
|
@@ -63,6 +65,11 @@ message orderSheetEmailRequest {
|
|
|
63
65
|
string orgName = 1;
|
|
64
66
|
string url = 2;
|
|
65
67
|
}
|
|
68
|
+
message dayIdsTimeObj {
|
|
69
|
+
int32 startsAt = 0;
|
|
70
|
+
int32 endsAt = 1;
|
|
71
|
+
int32 doorsAt = 2;
|
|
72
|
+
}
|
|
66
73
|
|
|
67
74
|
message QueueOrderReceiptEmailRequest {
|
|
68
75
|
string spanContext = 0;
|
|
@@ -96,6 +103,8 @@ message QueueOrderReceiptEmailRequest {
|
|
|
96
103
|
int32 eventStart = 29;
|
|
97
104
|
int32 eventEnd = 30;
|
|
98
105
|
string timezone = 31;
|
|
106
|
+
repeated string dayIds = 32;
|
|
107
|
+
repeated dayIdsTimeObj dayIdsTime = 33;
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
message QueueOrderQRCodeEmailRequest {
|
|
@@ -131,6 +140,7 @@ message QueueOrderQRCodeEmailRequest {
|
|
|
131
140
|
int32 eventStart = 29;
|
|
132
141
|
int32 eventEnd = 30;
|
|
133
142
|
string timezone = 31;
|
|
143
|
+
repeated dayIdsTimeObj dayIdsTime = 32;
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
message QueueOrderRefundEmailRequest {
|
|
@@ -162,6 +172,8 @@ message QueueOrderRefundEmailRequest {
|
|
|
162
172
|
string orderFeesRefunded = 25;
|
|
163
173
|
string orderTotalRefunded = 26;
|
|
164
174
|
string refundReason = 27;
|
|
175
|
+
repeated dayIdsTimeObj dayIdsTime = 28;
|
|
176
|
+
|
|
165
177
|
}
|
|
166
178
|
|
|
167
179
|
message QueueOrderCanceledEmailRequest {
|
|
@@ -193,6 +205,8 @@ message QueueOrderCanceledEmailRequest {
|
|
|
193
205
|
string orderFeesRefunded = 25;
|
|
194
206
|
string orderTotalRefunded = 26;
|
|
195
207
|
string refundReason = 27;
|
|
208
|
+
repeated dayIdsTimeObj dayIdsTime = 28;
|
|
209
|
+
|
|
196
210
|
}
|
|
197
211
|
|
|
198
212
|
service EmailService {
|
package/src/proto/event.proto
CHANGED
|
@@ -36,6 +36,8 @@ message Event {
|
|
|
36
36
|
bool salesBeginImmediately = 28;
|
|
37
37
|
bool cancel = 29;
|
|
38
38
|
bool taxDeduction = 30;
|
|
39
|
+
bool isMultipleDays = 31;
|
|
40
|
+
string totalDays = 32;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
message PublicEvent {
|
|
@@ -109,6 +111,7 @@ message EventSchedule {
|
|
|
109
111
|
message PerformanceSchedule {
|
|
110
112
|
int32 doorsAt = 1;
|
|
111
113
|
int32 startsAt = 2;
|
|
114
|
+
int32 endsAt = 3;
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
message Performance {
|
|
@@ -121,7 +124,7 @@ message Performance {
|
|
|
121
124
|
string posterImageUrl = 7;
|
|
122
125
|
string videoLink = 8;
|
|
123
126
|
string songLink = 9;
|
|
124
|
-
PerformanceSchedule schedule = 10;
|
|
127
|
+
repeated PerformanceSchedule schedule = 10;
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
message TicketType {
|
|
@@ -137,6 +140,7 @@ message TicketType {
|
|
|
137
140
|
bool rollFees = 10;
|
|
138
141
|
string promo = 11;
|
|
139
142
|
string values = 12;
|
|
143
|
+
repeated string dayIds = 13;
|
|
140
144
|
}
|
|
141
145
|
|
|
142
146
|
message TicketTier {
|
package/src/proto/order.proto
CHANGED
|
@@ -52,11 +52,12 @@ message OrderTicket {
|
|
|
52
52
|
string paymentId = 6;
|
|
53
53
|
string seat = 7;
|
|
54
54
|
Refund refund = 8;
|
|
55
|
-
Scan scan = 9;
|
|
55
|
+
repeated Scan scan = 9;
|
|
56
56
|
string state = 10;
|
|
57
57
|
string qrCodeUrl = 11;
|
|
58
58
|
string values=12;
|
|
59
59
|
string description = 13;
|
|
60
|
+
repeated string dayIds = 14;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
message OrderUpgrade {
|
|
@@ -78,6 +79,7 @@ message Scan {
|
|
|
78
79
|
bool scanned = 0;
|
|
79
80
|
int32 scannedAt = 1;
|
|
80
81
|
string scannedBy = 2;
|
|
82
|
+
int32 startsAt = 3;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
message Refund {
|
|
@@ -140,6 +142,7 @@ message CreateOrderTicketParams {
|
|
|
140
142
|
string values = 6;
|
|
141
143
|
string description = 7;
|
|
142
144
|
string type = 8;
|
|
145
|
+
repeated string dayIds = 9;
|
|
143
146
|
|
|
144
147
|
}
|
|
145
148
|
|
package/src/proto/user.proto
CHANGED
package/src/schemas/Event.ts
CHANGED
|
@@ -228,7 +228,12 @@ const EventUpgrade = {
|
|
|
228
228
|
},
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
export const PerformanceSchedule = {
|
|
231
|
+
export const PerformanceSchedule = [{
|
|
232
|
+
_id: {
|
|
233
|
+
type: String,
|
|
234
|
+
required: false,
|
|
235
|
+
default: shortid.generate,
|
|
236
|
+
},
|
|
232
237
|
doorsAt: {
|
|
233
238
|
type: Number,
|
|
234
239
|
required: false,
|
|
@@ -237,7 +242,11 @@ export const PerformanceSchedule = {
|
|
|
237
242
|
type: Number,
|
|
238
243
|
required: false,
|
|
239
244
|
},
|
|
240
|
-
|
|
245
|
+
endsAt: {
|
|
246
|
+
type: Number,
|
|
247
|
+
required: false,
|
|
248
|
+
},
|
|
249
|
+
}];
|
|
241
250
|
|
|
242
251
|
const Performance = {
|
|
243
252
|
_id: {
|
|
@@ -397,7 +406,12 @@ const TicketType = {
|
|
|
397
406
|
type: String,
|
|
398
407
|
required: false,
|
|
399
408
|
default: "0",
|
|
400
|
-
},
|
|
409
|
+
},dayIds: [
|
|
410
|
+
{
|
|
411
|
+
type: String,
|
|
412
|
+
required: false
|
|
413
|
+
}
|
|
414
|
+
]
|
|
401
415
|
};
|
|
402
416
|
|
|
403
417
|
|
|
@@ -447,10 +461,18 @@ export default {
|
|
|
447
461
|
type: String,
|
|
448
462
|
required: false,
|
|
449
463
|
},
|
|
464
|
+
isMultipleDays: {
|
|
465
|
+
type: Boolean,
|
|
466
|
+
required: true,
|
|
467
|
+
default: false
|
|
468
|
+
},
|
|
450
469
|
age: {
|
|
451
470
|
type: String,
|
|
452
471
|
required: true,
|
|
453
472
|
default: EventAgeEnum.AllAges
|
|
473
|
+
}, totalDays: {
|
|
474
|
+
type: String,
|
|
475
|
+
required: true,
|
|
454
476
|
},
|
|
455
477
|
active: {
|
|
456
478
|
type: Boolean,
|
package/src/schemas/Order.ts
CHANGED
|
@@ -27,6 +27,7 @@ const Refund = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const Scan = {
|
|
30
|
+
_id: false,
|
|
30
31
|
scanned: {
|
|
31
32
|
type: Boolean,
|
|
32
33
|
required: true,
|
|
@@ -40,7 +41,10 @@ const Scan = {
|
|
|
40
41
|
type: String,
|
|
41
42
|
required: false,
|
|
42
43
|
default: '',
|
|
43
|
-
},
|
|
44
|
+
},startsAt:{
|
|
45
|
+
type: Number,
|
|
46
|
+
required: false,
|
|
47
|
+
}
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
const OrderTicket = {
|
|
@@ -80,7 +84,7 @@ const OrderTicket = {
|
|
|
80
84
|
required: false,
|
|
81
85
|
default: '',
|
|
82
86
|
},
|
|
83
|
-
scan: Scan,
|
|
87
|
+
scan: [Scan],
|
|
84
88
|
refund: Refund,
|
|
85
89
|
state: {
|
|
86
90
|
type: String,
|
|
@@ -97,7 +101,12 @@ const OrderTicket = {
|
|
|
97
101
|
},description:{
|
|
98
102
|
type: String,
|
|
99
103
|
required: false
|
|
100
|
-
}
|
|
104
|
+
},dayIds:[
|
|
105
|
+
{
|
|
106
|
+
type: String,
|
|
107
|
+
required: false
|
|
108
|
+
}
|
|
109
|
+
]
|
|
101
110
|
};
|
|
102
111
|
|
|
103
112
|
const OrderUpgrade = {
|
package/src/utils/EventUtil.ts
CHANGED
|
@@ -13,7 +13,9 @@ import ITicketType from "../interfaces/ITicketType";
|
|
|
13
13
|
import IEventPromotion from "../interfaces/IEventPromotion";
|
|
14
14
|
import { EventPromotionTypeEnum } from "../interfaces/IEventPromotion";
|
|
15
15
|
import { DropDownEnum } from "../enums/DropDownEnum";
|
|
16
|
-
import { SendQRCodeEnum} from "../interfaces/IEvent";
|
|
16
|
+
import { SendQRCodeEnum } from "../interfaces/IEvent";
|
|
17
|
+
import IEventSchedule from "src/interfaces/IEventSchedule";
|
|
18
|
+
|
|
17
19
|
export default {
|
|
18
20
|
/****************************************************************************************
|
|
19
21
|
* Schedule
|
|
@@ -58,10 +60,10 @@ export default {
|
|
|
58
60
|
},
|
|
59
61
|
hasEnded(event): boolean {
|
|
60
62
|
const {
|
|
61
|
-
schedule: { endsAt }
|
|
63
|
+
schedule: { endsAt },
|
|
62
64
|
} = event;
|
|
63
65
|
const now = Time.now();
|
|
64
|
-
return endsAt < now
|
|
66
|
+
return endsAt < now;
|
|
65
67
|
},
|
|
66
68
|
isUnavailable(event: IEvent): boolean {
|
|
67
69
|
if (!event.published) return true;
|
|
@@ -75,14 +77,16 @@ export default {
|
|
|
75
77
|
const ticketTypeCount = event.ticketTypes?.length;
|
|
76
78
|
const promotionCodeTicketCount = [
|
|
77
79
|
...new Set(
|
|
78
|
-
event.promotions
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
event.promotions
|
|
81
|
+
?.filter((a) => a.type === "Unlock")
|
|
82
|
+
.reduce((cur: string[], promotion) => {
|
|
83
|
+
// (this.isOnSale(event) ? promotion.type === "Unlock" : (promotion.type === "Presale" || promotion.type === "Unlock"))
|
|
84
|
+
// if(2!==2)
|
|
85
|
+
return [...cur, ...promotion.ticketTypeIds];
|
|
86
|
+
}, [])
|
|
83
87
|
),
|
|
84
88
|
].length;
|
|
85
|
-
|
|
89
|
+
|
|
86
90
|
return ticketTypeCount === promotionCodeTicketCount;
|
|
87
91
|
},
|
|
88
92
|
/****************************************************************************************
|
|
@@ -92,18 +96,24 @@ export default {
|
|
|
92
96
|
const {
|
|
93
97
|
performances: [performance],
|
|
94
98
|
} = event;
|
|
95
|
-
const {
|
|
99
|
+
const {
|
|
100
|
+
schedule: { doorsAt, startsAt },
|
|
96
101
|
} = performance;
|
|
97
102
|
/*
|
|
98
103
|
changing to lower case
|
|
99
104
|
becuse previosly it is stored with different values
|
|
100
105
|
like Upon Order, Upon order
|
|
101
|
-
*/
|
|
102
|
-
if
|
|
103
|
-
|
|
106
|
+
*/
|
|
107
|
+
if (
|
|
108
|
+
event.sendQRCode.toLowerCase() === SendQRCodeEnum.UponOrder.toLowerCase()
|
|
109
|
+
) {
|
|
110
|
+
return Time.now();
|
|
104
111
|
}
|
|
105
112
|
|
|
106
|
-
if (
|
|
113
|
+
if (
|
|
114
|
+
event.sendQRCode.toLowerCase() ===
|
|
115
|
+
SendQRCodeEnum.TwoWeeksBefore.toLowerCase()
|
|
116
|
+
) {
|
|
107
117
|
const TWO_WEEKS = 14 * 24 * 60 * 60;
|
|
108
118
|
return startsAt - TWO_WEEKS;
|
|
109
119
|
}
|
|
@@ -125,8 +135,10 @@ export default {
|
|
|
125
135
|
|
|
126
136
|
// Never send a receipt if we are
|
|
127
137
|
// send a qr code upon order
|
|
128
|
-
if
|
|
129
|
-
|
|
138
|
+
if (
|
|
139
|
+
event.sendQRCode.toLowerCase() === SendQRCodeEnum.UponOrder.toLowerCase()
|
|
140
|
+
) {
|
|
141
|
+
return false;
|
|
130
142
|
}
|
|
131
143
|
// if (event.sendQRCode === "Upon Order") {
|
|
132
144
|
// return false;
|
|
@@ -383,7 +395,10 @@ export default {
|
|
|
383
395
|
|
|
384
396
|
if (
|
|
385
397
|
!required &&
|
|
386
|
-
(value === undefined ||
|
|
398
|
+
(value === undefined ||
|
|
399
|
+
value === "NaN" ||
|
|
400
|
+
value === "" ||
|
|
401
|
+
value === DropDownEnum.Select)
|
|
387
402
|
) {
|
|
388
403
|
return true;
|
|
389
404
|
}
|
|
@@ -522,10 +537,10 @@ export default {
|
|
|
522
537
|
/****************************************************************************************
|
|
523
538
|
* Ticket validate
|
|
524
539
|
****************************************************************************************/
|
|
525
|
-
validateTicket(ticket: ITicketType, isPaid: Boolean): any {
|
|
540
|
+
validateTicket(ticket: ITicketType, isPaid: Boolean ,isMultipleDays:boolean): any {
|
|
526
541
|
let ticketSchema;
|
|
527
542
|
let limit = isPaid ? "Purchase limit" : "RSVP limit";
|
|
528
|
-
|
|
543
|
+
|
|
529
544
|
let used = ticket.totalQty - ticket.remainingQty;
|
|
530
545
|
ticketSchema = Joi.object()
|
|
531
546
|
.options({ abortEarly: false })
|
|
@@ -546,6 +561,7 @@ export default {
|
|
|
546
561
|
"number.min": `"${limit}" must be greater than 0`,
|
|
547
562
|
"number.base": `"${limit}" must be a number`,
|
|
548
563
|
}),
|
|
564
|
+
dayIds: Joi.array().min(isMultipleDays ? 1 : 0).items(Joi.string()).default([]).messages({"array.min": "Ticket must have selected atleast one day."}),
|
|
549
565
|
tiers: Joi.array().items(
|
|
550
566
|
Joi.object()
|
|
551
567
|
.keys({
|
|
@@ -709,4 +725,67 @@ export default {
|
|
|
709
725
|
.unknown(true);
|
|
710
726
|
return refundFieldSchema.validate(refundField);
|
|
711
727
|
},
|
|
728
|
+
validateEventDates(event: IEvent): any {
|
|
729
|
+
const schedule: IEventSchedule = event?.schedule as IEventSchedule;
|
|
730
|
+
const announceAt = schedule?.announceAt as number;
|
|
731
|
+
const ticketsAt = schedule?.ticketsAt as number;
|
|
732
|
+
const ticketsEndAt = schedule?.ticketsEndAt as number;
|
|
733
|
+
const performance = event?.performances?.[0];
|
|
734
|
+
const startsAt =
|
|
735
|
+
(performance?.schedule &&
|
|
736
|
+
(performance?.schedule[0]?.startsAt as number)) ||
|
|
737
|
+
0;
|
|
738
|
+
const endsAt = event?.totalDays?.length === 0 ? (event?.schedule?.endsAt as number) :
|
|
739
|
+
(performance?.schedule &&
|
|
740
|
+
(performance?.schedule[performance?.schedule?.length - 1]
|
|
741
|
+
?.endsAt as number)) ||
|
|
742
|
+
0;
|
|
743
|
+
/* Actions */
|
|
744
|
+
let message = "" as string;
|
|
745
|
+
|
|
746
|
+
performance?.schedule?.some((a, i) => {
|
|
747
|
+
if (a.startsAt < a.doorsAt) {
|
|
748
|
+
message =
|
|
749
|
+
performance?.schedule && performance?.schedule?.length > 1
|
|
750
|
+
? "Doors Open should be less than or equal to Event Begins on day " +
|
|
751
|
+
(i + 1) +
|
|
752
|
+
"."
|
|
753
|
+
: "Doors Open should be less than or equal to Event Begins.";
|
|
754
|
+
return message;
|
|
755
|
+
} else if (a.startsAt >(event?.totalDays?.length === 0 ? (event?.schedule?.endsAt as number) : a.endsAt)) {
|
|
756
|
+
message =
|
|
757
|
+
performance?.schedule && performance?.schedule?.length > 1
|
|
758
|
+
? "Event Ends should be greater than Event Begins on day " +
|
|
759
|
+
(i + 1) +
|
|
760
|
+
"."
|
|
761
|
+
: "Event Ends should be greater than Event Begins.";
|
|
762
|
+
return message;
|
|
763
|
+
} else if (performance?.schedule && performance?.schedule?.length > 1) {
|
|
764
|
+
const aa =
|
|
765
|
+
performance?.schedule?.[i + 1]?.startsAt &&
|
|
766
|
+
performance?.schedule?.[i + 1]?.startsAt > (event?.totalDays?.length === 0 ? (event?.schedule?.endsAt as number) : a.endsAt);
|
|
767
|
+
if (!aa && aa !== undefined) {
|
|
768
|
+
message=(
|
|
769
|
+
"Day " +
|
|
770
|
+
(i + 2) +
|
|
771
|
+
" Event Begins should be greater than day " +
|
|
772
|
+
(i + 1) +
|
|
773
|
+
" Event Ends."
|
|
774
|
+
);
|
|
775
|
+
return message;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
if (announceAt > startsAt) {
|
|
780
|
+
message = "Announcement Date should be less than Event Begins.";
|
|
781
|
+
return message;
|
|
782
|
+
} else if (ticketsAt < announceAt || ticketsAt > ticketsEndAt) {
|
|
783
|
+
message = "Sales Begin should be greater than or equal to Announcement Date and less than Sales End.";
|
|
784
|
+
return message;
|
|
785
|
+
} else if (ticketsEndAt > endsAt) {
|
|
786
|
+
message = "Sales End should be less than or equal to Event Ends.";
|
|
787
|
+
return message;
|
|
788
|
+
}
|
|
789
|
+
return message;
|
|
790
|
+
},
|
|
712
791
|
};
|
package/src/utils/OrderUtil.ts
CHANGED
|
@@ -20,115 +20,115 @@ export default {
|
|
|
20
20
|
Order
|
|
21
21
|
*****************************************************************************************/
|
|
22
22
|
orderTotal(order: IOrder, fees: any[]): number {
|
|
23
|
-
if(order.payments && order.payments.length > 0) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
if (order.payments && order.payments.length > 0) {
|
|
24
|
+
return order.payments.reduce((cur: number, payment: IPayment): number => {
|
|
25
|
+
return cur + PaymentUtil.calculatePaymentTotal({
|
|
26
|
+
tickets: order.tickets.filter(ticket => ticket.paymentId === payment._id),
|
|
27
|
+
upgrades: order.upgrades.filter(upgrade => upgrade.paymentId === payment._id),
|
|
28
|
+
fees: fees,
|
|
29
|
+
paymentMethodType: payment.paymentMethodType,
|
|
30
|
+
})
|
|
31
|
+
}, 0);
|
|
32
|
+
} else {
|
|
33
|
+
if (
|
|
34
|
+
(!order.tickets || !order.tickets.length) &&
|
|
35
|
+
(!order.upgrades || !order.upgrades.length)
|
|
36
|
+
)
|
|
37
|
+
return 0;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (!order.tickets) order.tickets = [];
|
|
40
|
+
if (!order.upgrades) order.upgrades = [];
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const ticketFees = fees.filter(f => f.appliedTo === "Ticket");
|
|
43
|
+
const upgradeFees = fees.filter(f => f.appliedTo === "Upgrade");
|
|
44
|
+
let orderFees = fees.filter(f => f.appliedTo === "Order");
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
function applyTicketFee(ticket, fee) {
|
|
47
|
+
if (fee.filters.includes("Seated") && !ticket.seat) return 0;
|
|
48
|
+
const noMax = fee.maxAppliedToPrice === 0;
|
|
49
|
+
if (
|
|
50
|
+
(fee.minAppliedToPrice <= ticket.price &&
|
|
51
|
+
ticket.price <= fee.maxAppliedToPrice) ||
|
|
52
|
+
noMax
|
|
53
|
+
) {
|
|
54
|
+
if (fee.type === "Flat") {
|
|
55
|
+
return fee.value;
|
|
56
|
+
}
|
|
57
|
+
if (fee.type === "Percent") {
|
|
58
|
+
return (ticket.price * fee.value) / 100;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
return 0;
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function applyUpgradeFee(upgrade, fee) {
|
|
66
|
+
const noMax = fee.maxAppliedToPrice === 0;
|
|
67
|
+
if (
|
|
68
|
+
(fee.minAppliedToPrice <= upgrade.price &&
|
|
69
|
+
upgrade.price <= fee.minAppliedToPrice) ||
|
|
70
|
+
noMax
|
|
71
|
+
) {
|
|
72
|
+
if (fee.type === "Flat") {
|
|
73
|
+
return fee.value;
|
|
74
|
+
}
|
|
75
|
+
if (fee.type === "Percent") {
|
|
76
|
+
return (upgrade.price * fee.value) / 100;
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
return 0;
|
|
59
80
|
}
|
|
60
|
-
} else {
|
|
61
|
-
return 0;
|
|
62
81
|
}
|
|
63
|
-
}
|
|
64
82
|
|
|
65
|
-
|
|
66
|
-
const noMax = fee.maxAppliedToPrice === 0;
|
|
67
|
-
if (
|
|
68
|
-
(fee.minAppliedToPrice <= upgrade.price &&
|
|
69
|
-
upgrade.price <= fee.minAppliedToPrice) ||
|
|
70
|
-
noMax
|
|
71
|
-
) {
|
|
83
|
+
function applyOrderFee(orderSubtotal, fee) {
|
|
72
84
|
if (fee.type === "Flat") {
|
|
73
|
-
return fee.value;
|
|
85
|
+
return orderSubtotal + fee.value;
|
|
74
86
|
}
|
|
75
87
|
if (fee.type === "Percent") {
|
|
76
|
-
return (
|
|
88
|
+
return orderSubtotal / (1 - fee.value / 100);
|
|
77
89
|
}
|
|
78
|
-
} else {
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function applyOrderFee(orderSubtotal, fee) {
|
|
84
|
-
if (fee.type === "Flat") {
|
|
85
|
-
return orderSubtotal + fee.value;
|
|
86
|
-
}
|
|
87
|
-
if (fee.type === "Percent") {
|
|
88
|
-
return orderSubtotal / (1 - fee.value / 100);
|
|
89
90
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const ticketTotal = order.tickets.reduce(
|
|
93
|
-
(cur, ticket) => cur + ticket.price,
|
|
94
|
-
0
|
|
95
|
-
);
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
ticketFees.reduce((cur, fee) => cur + applyTicketFee(ticket, fee), 0)
|
|
92
|
+
const ticketTotal = order.tickets.reduce(
|
|
93
|
+
(cur, ticket) => cur + ticket.price,
|
|
94
|
+
0
|
|
101
95
|
);
|
|
102
|
-
}, 0);
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
const ticketFeeTotal = order.tickets.reduce((cur, ticket) => {
|
|
98
|
+
return (
|
|
99
|
+
cur +
|
|
100
|
+
ticketFees.reduce((cur, fee) => cur + applyTicketFee(ticket, fee), 0)
|
|
101
|
+
);
|
|
102
|
+
}, 0);
|
|
108
103
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
upgradeFees.reduce((cur, fee) => cur + applyUpgradeFee(upgrade, fee), 0)
|
|
104
|
+
const upgradeTotal = order.upgrades.reduce(
|
|
105
|
+
(cur, upgrade) => cur + upgrade.price,
|
|
106
|
+
0
|
|
113
107
|
);
|
|
114
|
-
}, 0);
|
|
115
108
|
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
const upgradeFeeTotal = order.upgrades.reduce((cur, upgrade) => {
|
|
110
|
+
return (
|
|
111
|
+
cur +
|
|
112
|
+
upgradeFees.reduce((cur, fee) => cur + applyUpgradeFee(upgrade, fee), 0)
|
|
113
|
+
);
|
|
114
|
+
}, 0);
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
orderFees = orderFees.sort(({ type }) => {
|
|
122
|
-
if (type === "Flat") return -1;
|
|
123
|
-
return 1;
|
|
124
|
-
});
|
|
116
|
+
const orderSubtotal =
|
|
117
|
+
ticketTotal + ticketFeeTotal + upgradeTotal + upgradeFeeTotal;
|
|
125
118
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
// Order matters here. Flat type fees must be
|
|
120
|
+
// applied before Percent type fees
|
|
121
|
+
orderFees = orderFees.sort(({ type }) => {
|
|
122
|
+
if (type === "Flat") return -1;
|
|
123
|
+
return 1;
|
|
124
|
+
});
|
|
129
125
|
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
const orderTotal = orderFees.reduce((cur, fee) => {
|
|
127
|
+
return applyOrderFee(cur, fee);
|
|
128
|
+
}, orderSubtotal);
|
|
129
|
+
|
|
130
|
+
return Math.round(orderTotal);
|
|
131
|
+
}
|
|
132
132
|
},
|
|
133
133
|
orderTotalWithRefund(order, fees) {
|
|
134
134
|
return this.orderTotal(order, fees) - (order.refundedAmount || 0);
|
|
@@ -202,7 +202,9 @@ export default {
|
|
|
202
202
|
const subtotal = this.orderSubtotal(order);
|
|
203
203
|
const selloutFees = this.selloutFees(order, fees);
|
|
204
204
|
const promoterFees = this.promoterFees(order, fees);
|
|
205
|
-
|
|
205
|
+
let stripeFee = total - subtotal - selloutFees - promoterFees;
|
|
206
|
+
let stripeFeeT = stripeFee < 0 ? 0 : stripeFee;
|
|
207
|
+
return stripeFeeT;
|
|
206
208
|
},
|
|
207
209
|
promoterFees(order, fees) {
|
|
208
210
|
if (!order.tickets) order.tickets = [];
|
|
@@ -305,9 +307,9 @@ export default {
|
|
|
305
307
|
/*****************************************************************************************
|
|
306
308
|
Custom Field
|
|
307
309
|
*****************************************************************************************/
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
310
|
+
customField(order: IOrder | ICreateOrderParams, eventCustomFieldId: string): IOrderCustomField | null {
|
|
311
|
+
return order?.customFields?.find(
|
|
312
|
+
(customField) => customField.customFieldId === eventCustomFieldId
|
|
313
|
+
) ?? null;
|
|
314
|
+
}
|
|
313
315
|
};
|