turf-common 1.4.2-beta.1 → 1.4.2-beta.13
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/build/src/enums/valid-coupon-type.enum.d.ts +3 -0
- package/build/src/enums/valid-coupon-type.enum.js +18 -0
- package/build/src/interface/api/booking-availablity-by-pitch.interface.d.ts +1 -0
- package/build/src/interface/api/create-recurring-slot-booking.interface.d.ts +1 -0
- package/build/src/interface/api/one-slot-booking.interface.d.ts +2 -0
- package/build/src/models/booking-code-model.d.ts +7 -2
- package/build/src/models/booking-code-model.js +18 -5
- package/build/src/models/pitch-slab-model.d.ts +1 -0
- package/build/src/models/pitch-slab-model.js +15 -0
- package/build/src/models/subscribed-pricing-plan-model.d.ts +9 -0
- package/build/src/models/subscribed-pricing-plan-model.js +43 -8
- package/build/src/utils/constant.d.ts +1 -0
- package/build/src/utils/constant.js +2 -1
- package/package.json +1 -1
|
@@ -8,3 +8,21 @@ var ValidCouponType;
|
|
|
8
8
|
ValidCouponType["PER_HOUR_UNIT"] = "per hour unit";
|
|
9
9
|
ValidCouponType["PER_HOUR_PERCENTAGE"] = "per hour percentage";
|
|
10
10
|
})(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
|
|
11
|
+
// Create namespace for the enum and add method UILabel to get the label of the enum value.
|
|
12
|
+
(function (ValidCouponType) {
|
|
13
|
+
function UILabel(value) {
|
|
14
|
+
switch (value) {
|
|
15
|
+
case ValidCouponType.PERCENTAGE:
|
|
16
|
+
return "Percentage";
|
|
17
|
+
case ValidCouponType.UNIT:
|
|
18
|
+
return "Price";
|
|
19
|
+
case ValidCouponType.PER_HOUR_UNIT:
|
|
20
|
+
return "Price Hour Unit";
|
|
21
|
+
case ValidCouponType.PER_HOUR_PERCENTAGE:
|
|
22
|
+
return "Per Hour Percentage";
|
|
23
|
+
default:
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
ValidCouponType.UILabel = UILabel;
|
|
28
|
+
})(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
|
|
@@ -12,6 +12,7 @@ export interface ICreateOneSlotBookingDetailsRequest {
|
|
|
12
12
|
discountedCost: number;
|
|
13
13
|
amountPaid: number;
|
|
14
14
|
pitchId: number;
|
|
15
|
+
pitchIds: number[];
|
|
15
16
|
status: BookingDetailsStatus;
|
|
16
17
|
sport: string;
|
|
17
18
|
remarks?: string | null;
|
|
@@ -21,4 +22,5 @@ export interface ICreateOneSlot {
|
|
|
21
22
|
date: number;
|
|
22
23
|
from: string;
|
|
23
24
|
to: string;
|
|
25
|
+
pitchNo: number;
|
|
24
26
|
}
|
|
@@ -20,7 +20,7 @@ export declare class BookingCode {
|
|
|
20
20
|
getHalfHourTimeCodes(): string[];
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
|
-
* @returns
|
|
23
|
+
* @returns ['00000030','00300100','01000130']: string[] - List of half hour time slot codes between start time & end time inclusive
|
|
24
24
|
* @example fromTime: 0000; toTime: 0130
|
|
25
25
|
* // returns ['00000030','00300100','01000130']
|
|
26
26
|
*/
|
|
@@ -31,6 +31,11 @@ export declare class BookingCode {
|
|
|
31
31
|
getMonthCode(): string;
|
|
32
32
|
getDateWithFromTimeCode(): string;
|
|
33
33
|
getCodeWithoutTurfCode(): string;
|
|
34
|
+
getPriceByPriceEntities(priceEntities?: {
|
|
35
|
+
[date: string]: {
|
|
36
|
+
[time: string]: number;
|
|
37
|
+
};
|
|
38
|
+
}): number;
|
|
34
39
|
static sortByCode(bookingCodes: BookingCode[]): void;
|
|
35
40
|
static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
|
|
36
41
|
static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
|
|
@@ -40,7 +45,7 @@ export declare class BookingCode {
|
|
|
40
45
|
static getWeekday(dateCode: number): number;
|
|
41
46
|
static convertToDate(str: string): Date;
|
|
42
47
|
static previousDateChecker(fromDate: number, index: number, errorKey?: string): void;
|
|
43
|
-
static previousTimeChecker(fromTime: string, fromDate: number, index: number): void;
|
|
48
|
+
static previousTimeChecker(fromTime: string, fromDate: number, index: number, bookingDelayInMinutes?: number): void;
|
|
44
49
|
static getDateCodesByWeek(fromDate: number, toDate: number, selectedWeekday: number): string[];
|
|
45
50
|
static getDatesByWeek(fromDate: number, toDate: number, selectedWeekday: number): Date[];
|
|
46
51
|
static isValidTimeRange(timeSlot: string): boolean;
|
|
@@ -60,7 +60,7 @@ var BookingCode = /** @class */ (function () {
|
|
|
60
60
|
};
|
|
61
61
|
/**
|
|
62
62
|
*
|
|
63
|
-
* @returns
|
|
63
|
+
* @returns ['00000030','00300100','01000130']: string[] - List of half hour time slot codes between start time & end time inclusive
|
|
64
64
|
* @example fromTime: 0000; toTime: 0130
|
|
65
65
|
* // returns ['00000030','00300100','01000130']
|
|
66
66
|
*/
|
|
@@ -105,6 +105,18 @@ var BookingCode = /** @class */ (function () {
|
|
|
105
105
|
BookingCode.prototype.getCodeWithoutTurfCode = function () {
|
|
106
106
|
return "".concat(this.dateCode).concat(this.slot).concat(this.pitchCode);
|
|
107
107
|
};
|
|
108
|
+
BookingCode.prototype.getPriceByPriceEntities = function (priceEntities) {
|
|
109
|
+
var halfHourTimeRangeCodes = this.getHalfHourTimeRangeCodes();
|
|
110
|
+
var weekDay = this.getWeekday();
|
|
111
|
+
var monthCode = this.getMonthCode();
|
|
112
|
+
var price = 0;
|
|
113
|
+
for (var _i = 0, halfHourTimeRangeCodes_1 = halfHourTimeRangeCodes; _i < halfHourTimeRangeCodes_1.length; _i++) {
|
|
114
|
+
var halfHourTimeRangeCode = halfHourTimeRangeCodes_1[_i];
|
|
115
|
+
price +=
|
|
116
|
+
priceEntities[monthCode + weekDay][halfHourTimeRangeCode] < 0 ? 0 : priceEntities[monthCode + weekDay][halfHourTimeRangeCode];
|
|
117
|
+
}
|
|
118
|
+
return price;
|
|
119
|
+
};
|
|
108
120
|
BookingCode.sortByCode = function (bookingCodes) {
|
|
109
121
|
bookingCodes.sort(function (_a, _b) {
|
|
110
122
|
var code1 = _a.code;
|
|
@@ -157,7 +169,7 @@ var BookingCode = /** @class */ (function () {
|
|
|
157
169
|
discount = parseFloat(couponCode) * totalBookingHours;
|
|
158
170
|
}
|
|
159
171
|
}
|
|
160
|
-
discountedCost = totalCost - discount;
|
|
172
|
+
discountedCost = totalCost - Math.round(discount);
|
|
161
173
|
return Math.round(discountedCost);
|
|
162
174
|
};
|
|
163
175
|
BookingCode.getDiscountAmount = function (couponCode, totalCost) {
|
|
@@ -221,15 +233,16 @@ var BookingCode = /** @class */ (function () {
|
|
|
221
233
|
}
|
|
222
234
|
};
|
|
223
235
|
//---------------------
|
|
224
|
-
BookingCode.previousTimeChecker = function (fromTime, fromDate, index) {
|
|
236
|
+
BookingCode.previousTimeChecker = function (fromTime, fromDate, index, bookingDelayInMinutes) {
|
|
237
|
+
if (bookingDelayInMinutes === void 0) { bookingDelayInMinutes = _utils_1.DEFAULT_BOOKING_DELAY_IN_MINUTES; }
|
|
225
238
|
var now = new Date();
|
|
226
239
|
this.convertToDate(fromDate.toString());
|
|
227
|
-
|
|
240
|
+
// const delayInBooking = 15;
|
|
228
241
|
if (this.convertToDate(fromDate.toString()) > now) {
|
|
229
242
|
return; //do nothing if fromDate is in future
|
|
230
243
|
}
|
|
231
244
|
else if (this.convertToDate(fromDate.toString()) <= now) {
|
|
232
|
-
now.setMinutes(now.getMinutes() -
|
|
245
|
+
now.setMinutes(now.getMinutes() - bookingDelayInMinutes); // 15minutes buffer for late bookings
|
|
233
246
|
var options = {
|
|
234
247
|
timeZone: "Asia/Kolkata",
|
|
235
248
|
};
|
|
@@ -27,6 +27,21 @@ var PitchSlabModelV2 = /** @class */ (function () {
|
|
|
27
27
|
this.to = data.to;
|
|
28
28
|
// this.discount = data.discount;
|
|
29
29
|
}
|
|
30
|
+
// public getDiscount(): number {
|
|
31
|
+
// if (this.discount.indexOf("P") > -1) {
|
|
32
|
+
// return parseFloat(this.discount.replace("P", ""));
|
|
33
|
+
// }
|
|
34
|
+
// return 0;
|
|
35
|
+
// }
|
|
36
|
+
// public getBasePrice(basePrice: number): number {
|
|
37
|
+
// return basePrice * (1 - this.getDiscount() / 100);
|
|
38
|
+
// }
|
|
39
|
+
PitchSlabModelV2.prototype.getRange = function () {
|
|
40
|
+
if (this.to >= 99) {
|
|
41
|
+
return "".concat(this.from - 1, "+");
|
|
42
|
+
}
|
|
43
|
+
return "".concat(this.from, "-").concat(this.to);
|
|
44
|
+
};
|
|
30
45
|
return PitchSlabModelV2;
|
|
31
46
|
}());
|
|
32
47
|
exports.PitchSlabModelV2 = PitchSlabModelV2;
|
|
@@ -44,6 +44,7 @@ export declare class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
|
|
|
44
44
|
hourInMonth: number;
|
|
45
45
|
months: number | undefined;
|
|
46
46
|
constructor(data: IPricingPlanModelV2, pitchCount: number, billingCycle: string);
|
|
47
|
+
getPlanBasePriceFormatted(): string;
|
|
47
48
|
getCodeByPitchCountCycle(): string;
|
|
48
49
|
getCodeByCycle(): string[];
|
|
49
50
|
getDiscount(): string;
|
|
@@ -61,10 +62,18 @@ export declare class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
|
|
|
61
62
|
getGrossAmount(config?: {
|
|
62
63
|
roundDown: boolean;
|
|
63
64
|
}): number;
|
|
65
|
+
getGrossAmountV2(config?: {
|
|
66
|
+
roundDown: boolean;
|
|
67
|
+
}): number;
|
|
64
68
|
getNetAmount(config?: {
|
|
65
69
|
roundDown: boolean;
|
|
66
70
|
}): number;
|
|
71
|
+
getNetAmountV2(config?: {
|
|
72
|
+
roundDown: boolean;
|
|
73
|
+
}): number;
|
|
67
74
|
getBillingDiscount(): number;
|
|
75
|
+
getBillingDiscountV2(): number;
|
|
76
|
+
getDiscountBasePrice(): number;
|
|
68
77
|
getMonthDifference(that: SubscribedPricingPlanModelV2): number;
|
|
69
78
|
getGrossAmountByMonth(month: number): number;
|
|
70
79
|
getNetAmountByMonth(month: number): number;
|
|
@@ -150,6 +150,13 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
150
150
|
return _this;
|
|
151
151
|
// this.selectedPitchSlabBasePrice = this.base_price;
|
|
152
152
|
}
|
|
153
|
+
SubscribedPricingPlanModelV2.prototype.getPlanBasePriceFormatted = function () {
|
|
154
|
+
// Format -> #.##
|
|
155
|
+
return parseFloat((this.getBasePriceV2()).toFixed(2)).toLocaleString('en-IN', {
|
|
156
|
+
minimumFractionDigits: 2,
|
|
157
|
+
maximumFractionDigits: 2,
|
|
158
|
+
});
|
|
159
|
+
};
|
|
153
160
|
SubscribedPricingPlanModelV2.prototype.getCodeByPitchCountCycle = function () {
|
|
154
161
|
var _this = this;
|
|
155
162
|
var codes = this.billing_cost_code.split(",");
|
|
@@ -254,6 +261,17 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
254
261
|
return Math.round(this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours());
|
|
255
262
|
}
|
|
256
263
|
};
|
|
264
|
+
SubscribedPricingPlanModelV2.prototype.getGrossAmountV2 = function (config) {
|
|
265
|
+
if (config === void 0) { config = { roundDown: false }; }
|
|
266
|
+
var grossAmount = this.base_price * this.pitchCount * this.getTotalHours();
|
|
267
|
+
var roundDown = config.roundDown;
|
|
268
|
+
if (roundDown) {
|
|
269
|
+
return Math.floor(grossAmount);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
return Math.round(grossAmount);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
257
275
|
// Tested
|
|
258
276
|
SubscribedPricingPlanModelV2.prototype.getNetAmount = function (config) {
|
|
259
277
|
var _this = this;
|
|
@@ -278,6 +296,17 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
278
296
|
this.getTotalHours());
|
|
279
297
|
}
|
|
280
298
|
};
|
|
299
|
+
SubscribedPricingPlanModelV2.prototype.getNetAmountV2 = function (config) {
|
|
300
|
+
if (config === void 0) { config = { roundDown: false }; }
|
|
301
|
+
var roundDown = config.roundDown;
|
|
302
|
+
var netAmount = this.base_price * this.getDiscountBasePrice() * this.pitchCount * this.getTotalHours();
|
|
303
|
+
if (roundDown) {
|
|
304
|
+
return Math.floor(netAmount);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
return Math.round(netAmount);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
281
310
|
// Tested
|
|
282
311
|
SubscribedPricingPlanModelV2.prototype.getBillingDiscount = function () {
|
|
283
312
|
var _this = this;
|
|
@@ -294,6 +323,19 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
294
323
|
var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
|
|
295
324
|
return parseFloat(((basePriceByPitchSlab - basePriceByPitchCycle) / basePriceByPitchSlab * 100).toFixed(2));
|
|
296
325
|
};
|
|
326
|
+
SubscribedPricingPlanModelV2.prototype.getBillingDiscountV2 = function () {
|
|
327
|
+
var discountBasePrice = this.getDiscountBasePrice();
|
|
328
|
+
return parseFloat(((this.base_price - discountBasePrice) / this.base_price * 100).toFixed(2));
|
|
329
|
+
};
|
|
330
|
+
SubscribedPricingPlanModelV2.prototype.getDiscountBasePrice = function () {
|
|
331
|
+
var _this = this;
|
|
332
|
+
var codesByBillingCycle = this.getCodeByCycle();
|
|
333
|
+
var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
|
|
334
|
+
var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
|
|
335
|
+
return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
|
|
336
|
+
})[0];
|
|
337
|
+
return parseFloat(parseFloat(codeByPitchCycle.split("#")[2]).toFixed(2));
|
|
338
|
+
};
|
|
297
339
|
SubscribedPricingPlanModelV2.prototype.getMonthDifference = function (that) {
|
|
298
340
|
return that.getMonths() - this.getMonths();
|
|
299
341
|
};
|
|
@@ -348,14 +390,7 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
348
390
|
};
|
|
349
391
|
// Tested
|
|
350
392
|
SubscribedPricingPlanModelV2.prototype.getBasePriceBySelectedBillingCycleDiscount = function () {
|
|
351
|
-
|
|
352
|
-
var codesByBillingCycle = this.getCodeByCycle();
|
|
353
|
-
var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
|
|
354
|
-
var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
|
|
355
|
-
return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
|
|
356
|
-
})[0];
|
|
357
|
-
var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
|
|
358
|
-
return parseFloat(basePriceByPitchCycle.toFixed(2));
|
|
393
|
+
return this.getDiscountBasePrice();
|
|
359
394
|
};
|
|
360
395
|
// Tested
|
|
361
396
|
SubscribedPricingPlanModelV2.prototype.getTotalHours = function () {
|
|
@@ -3,3 +3,4 @@ export declare const DEFAULT_PASSWORD = "turf@#123";
|
|
|
3
3
|
export declare const DELETED_SLOT_SEPARATOR = "d_";
|
|
4
4
|
export declare const START_OF_DAY_TIME_CODE = "0000";
|
|
5
5
|
export declare const END_OF_DAY_TIME_CODE = "2400";
|
|
6
|
+
export declare const DEFAULT_BOOKING_DELAY_IN_MINUTES = 15;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.END_OF_DAY_TIME_CODE = exports.START_OF_DAY_TIME_CODE = exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
|
|
3
|
+
exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = exports.END_OF_DAY_TIME_CODE = exports.START_OF_DAY_TIME_CODE = exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
|
|
4
4
|
exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = 7;
|
|
5
5
|
exports.DEFAULT_PASSWORD = "turf@#123";
|
|
6
6
|
exports.DELETED_SLOT_SEPARATOR = "d_";
|
|
7
7
|
exports.START_OF_DAY_TIME_CODE = "0000";
|
|
8
8
|
exports.END_OF_DAY_TIME_CODE = "2400";
|
|
9
|
+
exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = 15;
|