@sellout/models 0.0.108 → 0.0.109
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/package.json +4 -4
- package/src/graphql/mutations/breakApartOrder.ts +1 -0
- package/src/graphql/mutations/createEvent.mutation.ts +1 -0
- package/src/graphql/mutations/createVenue.mutation.ts +1 -1
- package/src/graphql/mutations/publishEvent.mutation.ts +1 -0
- package/src/graphql/mutations/updateEvent.mutation.ts +1 -0
- package/src/graphql/mutations/updateVenue.mutation.ts +1 -1
- 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 +18 -15
- package/src/graphql/queries/publicEvent.query.ts +2 -0
- package/src/graphql/queries/venue.query.ts +1 -0
- package/src/graphql/queries/venues.query.ts +1 -0
- package/src/interfaces/IEvent.ts +9 -0
- package/src/interfaces/IOrder.ts +7 -0
- package/src/interfaces/IPayment.ts +1 -0
- package/src/interfaces/IVenue.ts +1 -0
- package/src/proto/event.proto +1 -0
- package/src/proto/order.proto +2 -0
- package/src/proto/venue.proto +1 -0
- package/src/schemas/Event.ts +5 -0
- package/src/schemas/Order.ts +8 -0
- package/src/schemas/Venue.ts +4 -0
- package/src/utils/AnalyticsUtil.ts +7 -7
- package/src/utils/FeeUtil.ts +9 -0
- package/src/utils/PaymentUtil.ts +55 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sellout/models",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.109",
|
|
4
4
|
"description": "Sellout.io models",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@hapi/joi": "^16.1.7",
|
|
20
|
-
"@sellout/service": "^0.0.
|
|
21
|
-
"@sellout/utils": "^0.0.
|
|
20
|
+
"@sellout/service": "^0.0.109",
|
|
21
|
+
"@sellout/utils": "^0.0.109",
|
|
22
22
|
"@types/hapi__joi": "^16.0.1",
|
|
23
23
|
"@types/shortid": "^0.0.29",
|
|
24
24
|
"apollo-link-debounce": "^2.1.0",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"protobufjs": "^6.11.2",
|
|
33
33
|
"typescript": "^4.4.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "314575a9bae7a664a22b810532633cd53920a78b"
|
|
36
36
|
}
|
|
@@ -14,21 +14,23 @@ const query = gql`
|
|
|
14
14
|
}
|
|
15
15
|
orgId
|
|
16
16
|
eventId
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
venueIds
|
|
18
|
+
eventName
|
|
19
|
+
event {
|
|
20
|
+
_id
|
|
21
|
+
posterImageUrl
|
|
22
|
+
schedule {
|
|
23
|
+
startsAt
|
|
24
|
+
}
|
|
25
|
+
venue {
|
|
26
|
+
_id
|
|
27
|
+
address {
|
|
28
|
+
state
|
|
29
|
+
city
|
|
30
|
+
timezone
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
32
34
|
fees {
|
|
33
35
|
_id
|
|
34
36
|
name
|
|
@@ -54,6 +56,7 @@ const query = gql`
|
|
|
54
56
|
promotionCode
|
|
55
57
|
type
|
|
56
58
|
channel
|
|
59
|
+
tax
|
|
57
60
|
ipAddress
|
|
58
61
|
address {
|
|
59
62
|
lat
|
package/src/interfaces/IEvent.ts
CHANGED
|
@@ -38,6 +38,10 @@ export enum EventAgeEnum {
|
|
|
38
38
|
TwentyOnePlus = '21+',
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export enum EventTaxDeductionEnum {
|
|
42
|
+
false = 'No',
|
|
43
|
+
true = 'Yes',
|
|
44
|
+
}
|
|
41
45
|
export enum SendQRCodeEnum {
|
|
42
46
|
UponOrder = 'Upon order',
|
|
43
47
|
TwoWeeksBefore = 'Two weeks before show',
|
|
@@ -50,6 +54,10 @@ export enum EventProcessAsEnum {
|
|
|
50
54
|
// Free = 'Free',
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
export enum EventSaleTaxEnum {
|
|
58
|
+
SalesTax="Sales tax"
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
export default interface IEvent {
|
|
54
62
|
_id?: string;
|
|
55
63
|
orgId: string;
|
|
@@ -63,6 +71,7 @@ export default interface IEvent {
|
|
|
63
71
|
publishable: boolean;
|
|
64
72
|
seatingChartKey?: string;
|
|
65
73
|
age?: EventAgeEnum;
|
|
74
|
+
taxDeduction?: boolean;
|
|
66
75
|
active?: boolean;
|
|
67
76
|
userAgreement?: string;
|
|
68
77
|
processAs?: EventProcessAsEnum;
|
package/src/interfaces/IOrder.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { OrderChannelEnum } from '../enums/OrderChannelEnum';
|
|
|
9
9
|
import IProcessingFee from './IProcessingFees';
|
|
10
10
|
import IUser from "./IUser";
|
|
11
11
|
import IFee from "./IFee";
|
|
12
|
+
import IEvent from "./IEvent";
|
|
13
|
+
import IVenue from "./IVenue";
|
|
12
14
|
|
|
13
15
|
export default interface IOrder {
|
|
14
16
|
_id?: string;
|
|
@@ -34,14 +36,19 @@ export default interface IOrder {
|
|
|
34
36
|
promotionCode?: string;
|
|
35
37
|
ipAddress?: string;
|
|
36
38
|
address?: IAddress;
|
|
39
|
+
tax?: number;
|
|
37
40
|
customFields?: IOrderCustomField[];
|
|
38
41
|
refundReason?: string; // BACKFILL
|
|
39
42
|
payments: IPayment[];
|
|
40
43
|
processingFee?: IProcessingFee
|
|
41
44
|
};
|
|
42
45
|
|
|
46
|
+
export interface IEventGraphQL extends IEvent {
|
|
47
|
+
venue?: IVenue;
|
|
48
|
+
}
|
|
43
49
|
|
|
44
50
|
export interface IOrderGraphQL extends IOrder {
|
|
45
51
|
user: IUser;
|
|
46
52
|
fees: IFee;
|
|
53
|
+
event: IEventGraphQL;
|
|
47
54
|
};
|
package/src/interfaces/IVenue.ts
CHANGED
package/src/proto/event.proto
CHANGED
package/src/proto/order.proto
CHANGED
|
@@ -34,6 +34,7 @@ message Order {
|
|
|
34
34
|
string refundReason = 23;
|
|
35
35
|
repeated Payment payments = 24;
|
|
36
36
|
ProcessingFees processingFee = 25;
|
|
37
|
+
float tax = 26;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
message ProcessingFees {
|
|
@@ -102,6 +103,7 @@ message Payment {
|
|
|
102
103
|
string createdBy = 7;
|
|
103
104
|
string promotionCode = 8;
|
|
104
105
|
string paymentMethodType = 9;
|
|
106
|
+
int32 tax = 10;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
/****************************************************************************************
|
package/src/proto/venue.proto
CHANGED
package/src/schemas/Event.ts
CHANGED
package/src/schemas/Order.ts
CHANGED
|
@@ -180,6 +180,10 @@ const Payment = {
|
|
|
180
180
|
type: Number,
|
|
181
181
|
required: false,
|
|
182
182
|
},
|
|
183
|
+
tax: {
|
|
184
|
+
type: Number,
|
|
185
|
+
required: false,
|
|
186
|
+
},
|
|
183
187
|
feeIds: [{
|
|
184
188
|
type: String,
|
|
185
189
|
required: false,
|
|
@@ -229,6 +233,10 @@ export default {
|
|
|
229
233
|
type: String,
|
|
230
234
|
required: true,
|
|
231
235
|
},
|
|
236
|
+
tax: {
|
|
237
|
+
type: Number,
|
|
238
|
+
default: null,
|
|
239
|
+
},
|
|
232
240
|
venueIds: [{
|
|
233
241
|
type: String,
|
|
234
242
|
required: false,
|
package/src/schemas/Venue.ts
CHANGED
|
@@ -879,20 +879,20 @@ export default {
|
|
|
879
879
|
return intervals[interval]();
|
|
880
880
|
},
|
|
881
881
|
|
|
882
|
-
getDateFormat(time: any, interval: AnalyticsIntervalEnum) {
|
|
882
|
+
getDateFormat(time: any, interval: AnalyticsIntervalEnum, timezone: string = 'America/Denver') {
|
|
883
883
|
switch(interval) {
|
|
884
884
|
case AnalyticsIntervalEnum.Hour:
|
|
885
|
-
return Time.format(time, 'h:mma');
|
|
885
|
+
return Time.format(time, 'h:mma',timezone);
|
|
886
886
|
case AnalyticsIntervalEnum.Day:
|
|
887
|
-
return Time.format(time, 'MMM DD');
|
|
887
|
+
return Time.format(time, 'MMM DD',timezone);
|
|
888
888
|
case AnalyticsIntervalEnum.Week:
|
|
889
|
-
return `${Time.format(time, 'MMM DD')} - ${Time.format(time + (Time.DAY * 7), 'MMM DD')}`;
|
|
889
|
+
return `${Time.format(time, 'MMM DD',timezone)} - ${Time.format(time + (Time.DAY * 7), 'MMM DD',timezone)}`;
|
|
890
890
|
case AnalyticsIntervalEnum.Month:
|
|
891
|
-
return Time.format(time, 'MMM YYYY');
|
|
891
|
+
return Time.format(time, 'MMM YYYY',timezone);
|
|
892
892
|
case AnalyticsIntervalEnum.Year:
|
|
893
|
-
return Time.format(time, 'YYYY');
|
|
893
|
+
return Time.format(time, 'YYYY',timezone);
|
|
894
894
|
default:
|
|
895
|
-
return Time.format(time, 'MMM DD');
|
|
895
|
+
return Time.format(time, 'MMM DD',timezone);
|
|
896
896
|
}
|
|
897
897
|
},
|
|
898
898
|
|
package/src/utils/FeeUtil.ts
CHANGED
|
@@ -34,6 +34,15 @@ export default {
|
|
|
34
34
|
return true;
|
|
35
35
|
});
|
|
36
36
|
},
|
|
37
|
+
|
|
38
|
+
taxFees(fees: any[] = []) {
|
|
39
|
+
return fees.filter((fee) => {
|
|
40
|
+
if (fee.name.toLowerCase() === 'sales tax') {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
},
|
|
37
46
|
/****************************************************************************************
|
|
38
47
|
* Fee validate
|
|
39
48
|
****************************************************************************************/
|
package/src/utils/PaymentUtil.ts
CHANGED
|
@@ -165,11 +165,11 @@ class PaymentUtil {
|
|
|
165
165
|
})
|
|
166
166
|
const upgradeFees = fees.filter(f => f.appliedTo === FeeAppliedToEnum.Upgrade);
|
|
167
167
|
// Orders mattes here. Flat type fees must be applied before Percent type fees
|
|
168
|
-
const orderFees = fees.filter(f => f.appliedTo === FeeAppliedToEnum.Order).sort(({ type }) => {
|
|
168
|
+
const orderFees = fees.filter(f => f.appliedTo === FeeAppliedToEnum.Order && f.name != 'Sales tax').sort(({ type }) => {
|
|
169
169
|
if (type === 'Flat') return -1;
|
|
170
170
|
else return 1;
|
|
171
171
|
});
|
|
172
|
-
|
|
172
|
+
const salesTax = fees.filter(f => f.name == 'Sales tax');
|
|
173
173
|
|
|
174
174
|
function applyTicketFee(ticket: ICreateOrderTicketParams, fee: IFee): number {
|
|
175
175
|
// Ignore seated fees if not seated
|
|
@@ -201,7 +201,7 @@ class PaymentUtil {
|
|
|
201
201
|
if (fee.type === FeeTypeEnum.Flat) {
|
|
202
202
|
return upgrade.price + fee.value;
|
|
203
203
|
} if (fee.type === FeeTypeEnum.Percent) {
|
|
204
|
-
return (upgrade.price
|
|
204
|
+
return (upgrade.price * fee.value / 100);
|
|
205
205
|
}
|
|
206
206
|
} else {
|
|
207
207
|
return 0;
|
|
@@ -220,21 +220,29 @@ class PaymentUtil {
|
|
|
220
220
|
|
|
221
221
|
const ticketTotal = tickets.reduce((cur, ticket) => cur + ticket.price, 0);
|
|
222
222
|
|
|
223
|
+
const ticketTaxFeeTotal = tickets.reduce((cur, ticket) => {
|
|
224
|
+
return cur + salesTax.reduce((cur, fee) => {
|
|
225
|
+
const value = cur + applyTicketFee(ticket, fee);
|
|
226
|
+
return value;
|
|
227
|
+
}, 0);
|
|
228
|
+
}, 0);
|
|
223
229
|
const ticketFeeTotal = tickets.reduce((cur, ticket) => {
|
|
224
230
|
return cur + ticketFees.reduce((cur, fee) => {
|
|
225
231
|
const value = cur + applyTicketFee(ticket, fee);
|
|
226
|
-
// console.log(`${fee.name}: ${value}`);
|
|
227
232
|
return value;
|
|
228
233
|
}, 0);
|
|
229
234
|
}, 0);
|
|
230
235
|
|
|
231
236
|
const upgradeTotal = upgrades.reduce((cur, upgrade) => cur + upgrade.price, 0);
|
|
232
237
|
|
|
238
|
+
const upgradeTaxFeeTotal = upgrades.reduce((cur, upgrade) => {
|
|
239
|
+
return cur + salesTax.reduce((curr, fee) => curr + applyUpgradeFee(upgrade, fee), 0);
|
|
240
|
+
}, 0);
|
|
241
|
+
|
|
233
242
|
const upgradeFeeTotal = upgrades.reduce((cur, upgrade) => {
|
|
234
243
|
return cur + upgradeFees.reduce((cur, fee) => cur + applyUpgradeFee(upgrade, fee), 0);
|
|
235
244
|
}, 0);
|
|
236
|
-
|
|
237
|
-
const orderSubtotal = Math.round(ticketTotal + ticketFeeTotal + upgradeTotal + upgradeFeeTotal);
|
|
245
|
+
const orderSubtotal = Math.round(ticketTotal + ticketTaxFeeTotal + ticketFeeTotal + upgradeTaxFeeTotal + upgradeTotal + upgradeFeeTotal);
|
|
238
246
|
|
|
239
247
|
// console.log(`Order SubTotal:`, orderSubtotal);
|
|
240
248
|
|
|
@@ -251,16 +259,31 @@ class PaymentUtil {
|
|
|
251
259
|
tickets = [],
|
|
252
260
|
upgrades = [],
|
|
253
261
|
paymentMethodType,
|
|
262
|
+
// fees
|
|
254
263
|
} = params;
|
|
255
264
|
|
|
256
265
|
if(paymentMethodType === PaymentMethodTypeEnum.None) return 0;
|
|
257
|
-
|
|
258
|
-
const
|
|
266
|
+
|
|
267
|
+
const ticketTotal = tickets.reduce((cur, ticket) => cur + ticket.price , 0); // + (ticket.price * tax/100)
|
|
268
|
+
const upgradeTotal = upgrades.reduce((cur, upgrade) => cur + upgrade.price, 0); // + (upgrade.price * tax/100)
|
|
259
269
|
return ticketTotal + upgradeTotal;
|
|
260
270
|
}
|
|
261
271
|
calculateFee(params: IPaymentCalculatorParams): number {
|
|
272
|
+
let {
|
|
273
|
+
fees
|
|
274
|
+
} = params;
|
|
275
|
+
const salesTax = fees.filter(f => f.name == 'Sales tax');
|
|
276
|
+
const tax = salesTax.length > 0 ? salesTax[0].value : 0
|
|
262
277
|
const total = this.calculatePaymentTotal(params);
|
|
263
|
-
|
|
278
|
+
let subtotal = this.calculatePaymentSubtotal(params);
|
|
279
|
+
subtotal = subtotal + (subtotal*tax/100)
|
|
280
|
+
return Math.round(total - subtotal);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
calculateFeeWithoutTax(params: IPaymentCalculatorParams): number {
|
|
284
|
+
|
|
285
|
+
const total = this.calculatePaymentTotal(params);
|
|
286
|
+
let subtotal = this.calculatePaymentSubtotal(params);
|
|
264
287
|
return Math.round(total - subtotal);
|
|
265
288
|
}
|
|
266
289
|
calculateOrganizationFee(params: IPaymentCalculatorParams): number {
|
|
@@ -272,7 +295,6 @@ class PaymentUtil {
|
|
|
272
295
|
} = params;
|
|
273
296
|
|
|
274
297
|
fees = FeeUtil.promoterFees(fees);
|
|
275
|
-
|
|
276
298
|
return this.calculateFee({
|
|
277
299
|
tickets,
|
|
278
300
|
upgrades,
|
|
@@ -280,6 +302,24 @@ class PaymentUtil {
|
|
|
280
302
|
paymentMethodType,
|
|
281
303
|
});
|
|
282
304
|
}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
calculateTaxFee(params: IPaymentCalculatorParams): number {
|
|
308
|
+
let {
|
|
309
|
+
tickets = [],
|
|
310
|
+
upgrades = [],
|
|
311
|
+
fees = [],
|
|
312
|
+
paymentMethodType,
|
|
313
|
+
} = params;
|
|
314
|
+
|
|
315
|
+
fees = FeeUtil.taxFees(fees);
|
|
316
|
+
return this.calculateFeeWithoutTax({
|
|
317
|
+
tickets,
|
|
318
|
+
upgrades,
|
|
319
|
+
fees,
|
|
320
|
+
paymentMethodType,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
283
323
|
calculatePlatformFee(params: IPaymentCalculatorParams): number {
|
|
284
324
|
let {
|
|
285
325
|
tickets = [],
|
|
@@ -310,6 +350,11 @@ class PaymentUtil {
|
|
|
310
350
|
const organizationFee = this.calculateOrganizationFee(params);
|
|
311
351
|
return total - subtotal - organizationFee;
|
|
312
352
|
}
|
|
353
|
+
// calculateTaxFee(params: IPaymentCalculatorParams): number {
|
|
354
|
+
// const organizationFee = this.calculateTaxFee(params);
|
|
355
|
+
// console.log(organizationFee,'............................salesTax..')
|
|
356
|
+
// return organizationFee;
|
|
357
|
+
// }
|
|
313
358
|
|
|
314
359
|
}
|
|
315
360
|
|