turf-common 1.2.1-beta.7 → 1.2.1-beta.71
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/@enum.d.ts +2 -0
- package/build/@enum.js +2 -0
- package/build/@model.d.ts +1 -0
- package/build/@model.js +1 -0
- package/build/@type.d.ts +2 -0
- package/build/@type.js +2 -0
- package/build/@utils.d.ts +1 -0
- package/build/@utils.js +1 -0
- package/build/enums/availability-view.enum.d.ts +4 -0
- package/build/enums/availability-view.enum.js +8 -0
- package/build/enums/booking-history-operation-type.enum.d.ts +4 -2
- package/build/enums/booking-history-operation-type.enum.js +4 -2
- package/build/enums/environment.enum.d.ts +5 -0
- package/build/enums/environment.enum.js +9 -0
- package/build/enums/valid-coupon-type.enum.d.ts +3 -1
- package/build/enums/valid-coupon-type.enum.js +2 -0
- package/build/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
- package/build/interface/api/get-availability-by-turf.interface.d.ts +29 -0
- package/build/interface/api/get-availability-by-turf.interface.js +2 -0
- package/build/interface/api/get-tournament.interface.d.ts +4 -0
- package/build/interface/api/get-tournament.interface.js +2 -0
- package/build/interface/api/index.d.ts +2 -0
- package/build/interface/api/index.js +2 -0
- package/build/interface/api/list-of-coupons.interface.d.ts +6 -0
- package/build/interface/convert-to-midnight-time.interface.d.ts +5 -0
- package/build/interface/convert-to-midnight-time.interface.js +2 -0
- package/build/interface/entity/booking-details-entity.interface.d.ts +2 -0
- package/build/interface/entity/booking-history-entity.interface.d.ts +4 -0
- package/build/interface/get-booking-by-id.interface.d.ts +2 -3
- package/build/interface/model/charge-model.interface.d.ts +1 -0
- package/build/interface/ng-date-structure.interface.d.ts +5 -0
- package/build/interface/ng-date-structure.interface.js +2 -0
- package/build/models/booking-code-model.d.ts +28 -1
- package/build/models/booking-code-model.js +66 -3
- package/build/models/charge-model.d.ts +3 -3
- package/build/models/charge-model.js +74 -28
- package/build/models/entity/booking-details-model.d.ts +2 -0
- package/build/models/entity/subscription-model.js +3 -3
- package/build/models/turf-availability-model.d.ts +57 -0
- package/build/models/turf-availability-model.js +239 -0
- package/build/utils/constant.d.ts +2 -0
- package/build/utils/constant.js +3 -1
- package/build/utils/date-util.d.ts +32 -0
- package/build/utils/date-util.js +76 -1
- package/build/utils/string-utils.d.ts +12 -0
- package/build/utils/string-utils.js +53 -0
- package/package.json +1 -1
- package/build/utils/format-string-with-hyphens.d.ts +0 -1
- package/build/utils/format-string-with-hyphens.js +0 -7
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ChargesModel = void 0;
|
|
4
4
|
var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
|
|
5
5
|
var modification_discount_policy_enum_1 = require("../enums/modification-discount-policy.enum");
|
|
6
|
+
var _utils_1 = require("../@utils");
|
|
6
7
|
var ChargesModel = /** @class */ (function () {
|
|
7
|
-
function ChargesModel(initialGrossAmount, paidAmount, couponCode, discountPolicy) {
|
|
8
|
+
function ChargesModel(initialGrossAmount, paidAmount, couponCode, totalBookingHours, discountPolicy) {
|
|
8
9
|
this.initialBookingGrossAmount = initialGrossAmount;
|
|
9
10
|
this.amountPaid = paidAmount;
|
|
10
11
|
this.couponCode = couponCode;
|
|
@@ -13,6 +14,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
13
14
|
this.totalCancellationCharges = 0;
|
|
14
15
|
this.refundPayable = 0;
|
|
15
16
|
this.totalRefundedAmount = 0;
|
|
17
|
+
this.totalBookingHours = totalBookingHours;
|
|
16
18
|
this.netTotal = this.getNetAmount();
|
|
17
19
|
this.amountPayable = this.getPayableRefundAmount();
|
|
18
20
|
this.discountPolicy = discountPolicy;
|
|
@@ -33,7 +35,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
33
35
|
this.cancelledBookingGrossAmount > 0) {
|
|
34
36
|
this.couponCode = "";
|
|
35
37
|
}
|
|
36
|
-
return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount());
|
|
38
|
+
return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount(), false, this.totalBookingHours);
|
|
37
39
|
};
|
|
38
40
|
ChargesModel.prototype.getPayableRefundAmount = function () {
|
|
39
41
|
return (this.getNetAmount() +
|
|
@@ -46,11 +48,19 @@ var ChargesModel = /** @class */ (function () {
|
|
|
46
48
|
// this.totalRefundAmount = this.totalRefundAmount - refundAmount;
|
|
47
49
|
// this.refundedAmount += refundAmount;
|
|
48
50
|
// }
|
|
49
|
-
ChargesModel.getDiscountAmount = function (couponCode, totalCost, validationApply) {
|
|
51
|
+
ChargesModel.getDiscountAmount = function (couponCode, totalCost, validationApply, totalBookingHours) {
|
|
50
52
|
if (validationApply === void 0) { validationApply = false; }
|
|
51
53
|
var discountAmount = 0;
|
|
52
54
|
if (couponCode) {
|
|
53
|
-
|
|
55
|
+
var code = _utils_1.stringUtil.getCouponDetails(couponCode).code;
|
|
56
|
+
var value = _utils_1.stringUtil.getCouponDetails(couponCode).value;
|
|
57
|
+
if (validationApply && !code && !value) {
|
|
58
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
59
|
+
key: "couponCode",
|
|
60
|
+
message: ["Coupon with code ".concat(couponCode, " is wrong ")],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (code === "P" || code === "PHP") {
|
|
54
64
|
var percentDiscount = parseFloat(couponCode);
|
|
55
65
|
if (validationApply && percentDiscount > 90) {
|
|
56
66
|
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
@@ -60,9 +70,20 @@ var ChargesModel = /** @class */ (function () {
|
|
|
60
70
|
}
|
|
61
71
|
discountAmount = totalCost * (percentDiscount / 100);
|
|
62
72
|
}
|
|
63
|
-
else if (
|
|
73
|
+
else if (code === "U") {
|
|
64
74
|
discountAmount = parseFloat(couponCode);
|
|
65
75
|
}
|
|
76
|
+
else if (code === "PHU") {
|
|
77
|
+
if (totalBookingHours === undefined) {
|
|
78
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
79
|
+
key: "totalBookingHours",
|
|
80
|
+
message: [
|
|
81
|
+
"Total Booking Hours is mandatory to calculate per hour unit",
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
discountAmount = parseFloat(couponCode) * totalBookingHours;
|
|
86
|
+
}
|
|
66
87
|
}
|
|
67
88
|
return Math.round(discountAmount);
|
|
68
89
|
};
|
|
@@ -81,13 +102,17 @@ var ChargesModel = /** @class */ (function () {
|
|
|
81
102
|
};
|
|
82
103
|
ChargesModel.prototype.modify = function (bookingModification) {
|
|
83
104
|
var oldBookingCode = bookingModification.oldBookingCode, newBookingCode = bookingModification.newBookingCode, cancellationUnit = bookingModification.cancellationUnit;
|
|
105
|
+
// this.totalBookingHours =
|
|
106
|
+
// this.totalBookingHours -
|
|
107
|
+
// oldBookingCode.getTotalTime("hr") +
|
|
108
|
+
// (newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
|
|
84
109
|
if (!newBookingCode) {
|
|
85
110
|
return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
|
|
86
111
|
}
|
|
87
112
|
if (!newBookingCode)
|
|
88
113
|
return null;
|
|
89
|
-
var oldTimeSlotMinutes = oldBookingCode.
|
|
90
|
-
var newTimeSlotMinutes = newBookingCode.
|
|
114
|
+
var oldTimeSlotMinutes = oldBookingCode.getTotalTime();
|
|
115
|
+
var newTimeSlotMinutes = newBookingCode.getTotalTime();
|
|
91
116
|
if (oldTimeSlotMinutes === newTimeSlotMinutes) {
|
|
92
117
|
return this.modifyMove(oldBookingCode, newBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
|
|
93
118
|
}
|
|
@@ -100,7 +125,11 @@ var ChargesModel = /** @class */ (function () {
|
|
|
100
125
|
return null;
|
|
101
126
|
};
|
|
102
127
|
ChargesModel.prototype.modifyExtend = function (oldBookingCode, newBookingCode) {
|
|
128
|
+
var newTotalBookingHours = this.totalBookingHours -
|
|
129
|
+
oldBookingCode.getTotalTime("hr") +
|
|
130
|
+
(newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
|
|
103
131
|
var newChargeModel = this.clone();
|
|
132
|
+
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
104
133
|
newChargeModel.additionalBookingGrossAmount +=
|
|
105
134
|
newBookingCode.getCost() - oldBookingCode.getCost();
|
|
106
135
|
newChargeModel.netTotal = newChargeModel.getNetAmount();
|
|
@@ -116,7 +145,11 @@ var ChargesModel = /** @class */ (function () {
|
|
|
116
145
|
return newChargeModel;
|
|
117
146
|
};
|
|
118
147
|
ChargesModel.prototype.modifyReduce = function (oldBookingCode, newBookingCode, cancellationUnit) {
|
|
148
|
+
var newTotalBookingHours = this.totalBookingHours -
|
|
149
|
+
oldBookingCode.getTotalTime("hr") +
|
|
150
|
+
(newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
|
|
119
151
|
var newChargeModel = this.clone();
|
|
152
|
+
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
120
153
|
newChargeModel.couponCode = "";
|
|
121
154
|
var costDifference = oldBookingCode.getCost() - newBookingCode.getCost();
|
|
122
155
|
// console.log(`costDifference ${costDifference}`);
|
|
@@ -138,7 +171,11 @@ var ChargesModel = /** @class */ (function () {
|
|
|
138
171
|
return newChargeModel;
|
|
139
172
|
};
|
|
140
173
|
ChargesModel.prototype.modifyMove = function (oldBookingCode, newBookingCode, cancellationUnit) {
|
|
174
|
+
var newTotalBookingHours = this.totalBookingHours -
|
|
175
|
+
oldBookingCode.getTotalTime("hr") +
|
|
176
|
+
(newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
|
|
141
177
|
var newChargeModel = this.clone();
|
|
178
|
+
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
142
179
|
var costDifference = newBookingCode.getCost() - oldBookingCode.getCost();
|
|
143
180
|
if (costDifference === 0) {
|
|
144
181
|
return newChargeModel;
|
|
@@ -163,12 +200,14 @@ var ChargesModel = /** @class */ (function () {
|
|
|
163
200
|
return newChargeModel;
|
|
164
201
|
};
|
|
165
202
|
ChargesModel.prototype.clone = function () {
|
|
166
|
-
var that = new ChargesModel(this.initialBookingGrossAmount, this.amountPaid, this.couponCode, this.discountPolicy);
|
|
203
|
+
var that = new ChargesModel(this.initialBookingGrossAmount, this.amountPaid, this.couponCode, this.totalBookingHours, this.discountPolicy);
|
|
167
204
|
Object.assign(that, this);
|
|
168
205
|
return that;
|
|
169
206
|
};
|
|
170
207
|
ChargesModel.prototype.modifyDelete = function (bookingCode, cancellationUnit) {
|
|
208
|
+
var newTotalBookingHours = this.totalBookingHours - bookingCode.getTotalTime("hr");
|
|
171
209
|
var newChargeModel = this.clone();
|
|
210
|
+
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
172
211
|
newChargeModel.couponCode = "";
|
|
173
212
|
var costDifference = bookingCode.getCost();
|
|
174
213
|
newChargeModel.cancelledBookingGrossAmount += costDifference;
|
|
@@ -187,29 +226,36 @@ var ChargesModel = /** @class */ (function () {
|
|
|
187
226
|
};
|
|
188
227
|
ChargesModel.getInstance = function (chargeData, discountPolicy) {
|
|
189
228
|
if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
|
|
190
|
-
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, discountPolicy);
|
|
229
|
+
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, chargeData.totalBookingHours, discountPolicy);
|
|
191
230
|
Object.assign(chargesModel, chargeData);
|
|
192
231
|
return chargesModel;
|
|
193
232
|
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
233
|
+
// static assignByInterface(
|
|
234
|
+
// chargeData: IChargeModel,
|
|
235
|
+
// discountPolicy: ModificationDiscountPolicy = ModificationDiscountPolicy.DISCOUNT_CONDITIONAL
|
|
236
|
+
// ): ChargesModel {
|
|
237
|
+
// const newChargeModel = new ChargesModel(
|
|
238
|
+
// chargeData.initialBookingGrossAmount,
|
|
239
|
+
// chargeData.amountPaid,
|
|
240
|
+
// chargeData.couponCode,
|
|
241
|
+
// discountPolicy
|
|
242
|
+
// );
|
|
243
|
+
// newChargeModel.additionalBookingGrossAmount =
|
|
244
|
+
// chargeData.additionalBookingGrossAmount;
|
|
245
|
+
// newChargeModel.initialBookingGrossAmount =
|
|
246
|
+
// chargeData.initialBookingGrossAmount;
|
|
247
|
+
// newChargeModel.cancelledBookingGrossAmount =
|
|
248
|
+
// chargeData.cancelledBookingGrossAmount;
|
|
249
|
+
// newChargeModel.refundPayable = chargeData.refundPayable;
|
|
250
|
+
// newChargeModel.totalRefundedAmount = chargeData.totalRefundedAmount;
|
|
251
|
+
// newChargeModel.amountPaid = chargeData.amountPaid;
|
|
252
|
+
// newChargeModel.totalCancellationCharges =
|
|
253
|
+
// chargeData.totalCancellationCharges;
|
|
254
|
+
// newChargeModel.netTotal = chargeData.netTotal;
|
|
255
|
+
// newChargeModel.couponCode = chargeData.couponCode;
|
|
256
|
+
// newChargeModel.amountPayable = chargeData.amountPayable;
|
|
257
|
+
// return newChargeModel;
|
|
258
|
+
// }
|
|
213
259
|
ChargesModel.prototype.getTotalAmount = function () {
|
|
214
260
|
return this.getNetAmount() + this.totalCancellationCharges;
|
|
215
261
|
};
|
|
@@ -32,6 +32,8 @@ export declare class BookingDetailsModel implements IBookingDetailsModel {
|
|
|
32
32
|
updatedOn: Date;
|
|
33
33
|
createdBy: number;
|
|
34
34
|
updatedBy: number;
|
|
35
|
+
totalBookingHours: number;
|
|
36
|
+
type: string | null;
|
|
35
37
|
constructor(data: IBookingDetailsEntity);
|
|
36
38
|
static getIdAndCreatedBy(bookingDetailsEntities: IBookingDetailsEntity[]): number[][];
|
|
37
39
|
assignCharges(chargeModel: ChargesModel): void;
|
|
@@ -45,10 +45,10 @@ var SubscriptionModel = /** @class */ (function () {
|
|
|
45
45
|
return new SubscriptionModel(demo);
|
|
46
46
|
};
|
|
47
47
|
SubscriptionModel.prototype.getFromDate = function () {
|
|
48
|
-
return this.
|
|
48
|
+
return date_util_1.dateUtilService.convertStringToDate(this.fromDateCode, "yyMMdd");
|
|
49
49
|
};
|
|
50
50
|
SubscriptionModel.prototype.getToDate = function () {
|
|
51
|
-
return this.
|
|
51
|
+
return date_util_1.dateUtilService.convertStringToDate(this.toDateCode, "yyMMdd");
|
|
52
52
|
};
|
|
53
53
|
SubscriptionModel.prototype.isRenewalDue = function () {
|
|
54
54
|
// Check if difference 'to' date and today's date is less than 7 days
|
|
@@ -92,7 +92,7 @@ var SubscriptionModel = /** @class */ (function () {
|
|
|
92
92
|
// dateService.convertStringToDate(this.from, "yyyy-MM-dd");
|
|
93
93
|
// const subscribedPitchCount: number = this.noOfPitches;
|
|
94
94
|
var renewalSubscriptionModel = new subscribed_pricing_plan_model_1.SubscribedPricingPlanModel(currentPricingPlanModel, totalPitchCount, billingCycle);
|
|
95
|
-
var toDate = this.
|
|
95
|
+
var toDate = this.getToDate();
|
|
96
96
|
var _a = renewalSubscriptionModel.getNextBillingCycleDateRange(toDate), startDate = _a[0], endDate = _a[1];
|
|
97
97
|
// const [startDateCode, endDateCode]: [string, string] = [
|
|
98
98
|
// dateService.getDateCode(startDate),
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { IGetAvailabilityByTurf } from "../@type";
|
|
2
|
+
interface ITurfAvailability {
|
|
3
|
+
data: IGetAvailabilityByTurf;
|
|
4
|
+
dateCodes: string[];
|
|
5
|
+
timeSlotCodesDateWise: Record<string, string[]>;
|
|
6
|
+
getTotalAvailablePrice(): number;
|
|
7
|
+
getTotalNonAvailablePrice(): number;
|
|
8
|
+
getTotalAvailableHours(): number;
|
|
9
|
+
getTotalNonAvailableHours(): number;
|
|
10
|
+
getSlots(): {
|
|
11
|
+
fromDate: number;
|
|
12
|
+
toDate: number;
|
|
13
|
+
from: string;
|
|
14
|
+
to: string;
|
|
15
|
+
weekdays: number[];
|
|
16
|
+
}[];
|
|
17
|
+
getPitchIds(): number[];
|
|
18
|
+
}
|
|
19
|
+
export declare class TurfAvailability implements ITurfAvailability {
|
|
20
|
+
data: IGetAvailabilityByTurf;
|
|
21
|
+
dateCodes: string[];
|
|
22
|
+
timeSlotCodesDateWise: Record<string, string[]>;
|
|
23
|
+
startDateCode: string;
|
|
24
|
+
endDateCode: string;
|
|
25
|
+
fromTimeCode: string;
|
|
26
|
+
toTimeCode: string;
|
|
27
|
+
pitchCodes: string[];
|
|
28
|
+
weekDays: number[];
|
|
29
|
+
constructor(data: IGetAvailabilityByTurf);
|
|
30
|
+
getTotalAvailablePrice(): number;
|
|
31
|
+
getTotalNonAvailablePrice(): number;
|
|
32
|
+
getTotalAvailableHours(): number;
|
|
33
|
+
getTotalNonAvailableHours(): number;
|
|
34
|
+
getSlots(): {
|
|
35
|
+
fromDate: number;
|
|
36
|
+
toDate: number;
|
|
37
|
+
from: string;
|
|
38
|
+
to: string;
|
|
39
|
+
weekdays: number[];
|
|
40
|
+
}[];
|
|
41
|
+
getPitchIds(): number[];
|
|
42
|
+
static fromJson(json: IGetAvailabilityByTurf): TurfAvailability;
|
|
43
|
+
static toJson(turfAvailability: TurfAvailability): IGetAvailabilityByTurf;
|
|
44
|
+
getTotalTime(): number;
|
|
45
|
+
getCode(): string;
|
|
46
|
+
parse(): void;
|
|
47
|
+
static parse(eventCode: string): {
|
|
48
|
+
pitchCodes: string[];
|
|
49
|
+
startDateCode: string;
|
|
50
|
+
endDateCode: string;
|
|
51
|
+
fromTimeCode: string;
|
|
52
|
+
toTimeCode: string;
|
|
53
|
+
bookingDateCodes: string[];
|
|
54
|
+
weekDays: number[];
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TurfAvailability = void 0;
|
|
4
|
+
var _utils_1 = require("../@utils");
|
|
5
|
+
var booking_code_model_1 = require("./booking-code-model");
|
|
6
|
+
var TurfAvailability = /** @class */ (function () {
|
|
7
|
+
function TurfAvailability(data) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
this.data = data;
|
|
10
|
+
this.dateCodes = Object.keys(data).sort();
|
|
11
|
+
this.timeSlotCodesDateWise = {};
|
|
12
|
+
Object.entries(data).forEach(function (_a) {
|
|
13
|
+
var key = _a[0], value = _a[1];
|
|
14
|
+
_this.timeSlotCodesDateWise[key] = Object.keys(value).sort();
|
|
15
|
+
});
|
|
16
|
+
if (Object.keys(data))
|
|
17
|
+
this.parse();
|
|
18
|
+
}
|
|
19
|
+
TurfAvailability.prototype.getTotalAvailablePrice = function () {
|
|
20
|
+
var totalCost = 0;
|
|
21
|
+
Object.entries(this.data).forEach(function (_a) {
|
|
22
|
+
var dateCode = _a[0], detailsTimeSlotCodeWise = _a[1];
|
|
23
|
+
Object.entries(detailsTimeSlotCodeWise).forEach(function (_a) {
|
|
24
|
+
var timeCode = _a[0], detailsPitchWise = _a[1];
|
|
25
|
+
Object.entries(detailsPitchWise.details).forEach(function (_a) {
|
|
26
|
+
var pitchCode = _a[0], details = _a[1];
|
|
27
|
+
if (!details.bookingId) {
|
|
28
|
+
totalCost += details.price;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return totalCost;
|
|
34
|
+
};
|
|
35
|
+
TurfAvailability.prototype.getTotalNonAvailablePrice = function () {
|
|
36
|
+
var totalCost = 0;
|
|
37
|
+
Object.entries(this.data).forEach(function (_a) {
|
|
38
|
+
var dateCode = _a[0], detailsTimeSlotCodeWise = _a[1];
|
|
39
|
+
Object.entries(detailsTimeSlotCodeWise).forEach(function (_a) {
|
|
40
|
+
var timeCode = _a[0], detailsPitchWise = _a[1];
|
|
41
|
+
Object.entries(detailsPitchWise.details).forEach(function (_a) {
|
|
42
|
+
var pitchCode = _a[0], details = _a[1];
|
|
43
|
+
if (details.bookingId !== undefined) {
|
|
44
|
+
totalCost += details.price;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return totalCost;
|
|
50
|
+
};
|
|
51
|
+
TurfAvailability.prototype.getTotalAvailableHours = function () {
|
|
52
|
+
var totalMinutes = 0;
|
|
53
|
+
Object.entries(this.data).forEach(function (_a) {
|
|
54
|
+
var dateCode = _a[0], detailsTimeSlotCodeWise = _a[1];
|
|
55
|
+
Object.entries(detailsTimeSlotCodeWise).forEach(function (_a) {
|
|
56
|
+
var timeCode = _a[0], detailsPitchWise = _a[1];
|
|
57
|
+
Object.entries(detailsPitchWise.details).forEach(function (_a) {
|
|
58
|
+
var pitchCode = _a[0], details = _a[1];
|
|
59
|
+
pitchCode = pitchCode.padStart(2, "0");
|
|
60
|
+
if (!details.bookingId) {
|
|
61
|
+
totalMinutes += new booking_code_model_1.BookingCode("0000".concat(dateCode).concat(timeCode).concat(pitchCode)).getTotalTime("minute");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return totalMinutes / 60;
|
|
67
|
+
};
|
|
68
|
+
TurfAvailability.prototype.getTotalNonAvailableHours = function () {
|
|
69
|
+
var totalMinutes = 0;
|
|
70
|
+
Object.entries(this.data).forEach(function (_a) {
|
|
71
|
+
var dateCode = _a[0], detailsTimeSlotCodeWise = _a[1];
|
|
72
|
+
Object.entries(detailsTimeSlotCodeWise).forEach(function (_a) {
|
|
73
|
+
var timeCode = _a[0], detailsPitchWise = _a[1];
|
|
74
|
+
Object.entries(detailsPitchWise.details).forEach(function (_a) {
|
|
75
|
+
var pitchCode = _a[0], details = _a[1];
|
|
76
|
+
pitchCode = pitchCode.padStart(2, "0");
|
|
77
|
+
if (details.bookingId !== undefined) {
|
|
78
|
+
totalMinutes += new booking_code_model_1.BookingCode("0000".concat(dateCode).concat(timeCode).concat(pitchCode)).getTotalTime("minute");
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return totalMinutes / 60;
|
|
84
|
+
};
|
|
85
|
+
TurfAvailability.prototype.getSlots = function () {
|
|
86
|
+
this.dateCodes.sort(function (a, b) { return a.localeCompare(b); });
|
|
87
|
+
var fromDate = this.dateCodes[0];
|
|
88
|
+
var toDate = this.dateCodes[this.dateCodes.length - 1];
|
|
89
|
+
var fromDateTimeSlots = this.timeSlotCodesDateWise[fromDate];
|
|
90
|
+
var toDateTimeSlots = this.timeSlotCodesDateWise[toDate];
|
|
91
|
+
fromDateTimeSlots.sort(function (a, b) { return a.localeCompare(b); });
|
|
92
|
+
toDateTimeSlots.sort(function (a, b) { return a.localeCompare(b); });
|
|
93
|
+
var fromTime = fromDateTimeSlots[0].substring(0, 4);
|
|
94
|
+
var toTime = toDateTimeSlots[toDateTimeSlots.length - 1].substring(4, 8);
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
fromDate: parseInt(fromDate, 10),
|
|
98
|
+
toDate: parseInt(toDate, 10),
|
|
99
|
+
from: fromTime,
|
|
100
|
+
to: toTime,
|
|
101
|
+
weekdays: [1, 2, 3, 4, 5, 6, 7],
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
};
|
|
105
|
+
TurfAvailability.prototype.getPitchIds = function () {
|
|
106
|
+
var pitchIds = new Set();
|
|
107
|
+
var slots = this.getSlots();
|
|
108
|
+
if (this.data[slots[0].fromDate.toString()]) {
|
|
109
|
+
Object.entries(this.data[slots[0].fromDate.toString()]).forEach(function (_a) {
|
|
110
|
+
var timeCode = _a[0], detailsPitchWise = _a[1];
|
|
111
|
+
Object.keys(detailsPitchWise.details).forEach(function (pitchCode) {
|
|
112
|
+
pitchIds.add(parseInt(pitchCode, 10));
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
var pitchIdList = Array.from(pitchIds).sort(function (a, b) { return a - b; });
|
|
117
|
+
return pitchIdList;
|
|
118
|
+
};
|
|
119
|
+
TurfAvailability.fromJson = function (json) {
|
|
120
|
+
var data = {};
|
|
121
|
+
Object.entries(json).forEach(function (_a) {
|
|
122
|
+
var dateCode = _a[0], value = _a[1];
|
|
123
|
+
var dateData = {};
|
|
124
|
+
Object.entries(value).forEach(function (_a) {
|
|
125
|
+
var timeCode = _a[0], value = _a[1];
|
|
126
|
+
var timeSlotData = {};
|
|
127
|
+
Object.entries(value.details).forEach(function (_a) {
|
|
128
|
+
var pitchCode = _a[0], value = _a[1];
|
|
129
|
+
timeSlotData[pitchCode] = new TurfAvailabilityDetail({
|
|
130
|
+
price: value.price,
|
|
131
|
+
bookingId: value.bookingId,
|
|
132
|
+
status: value.status,
|
|
133
|
+
priceSlot: value.priceSlot,
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
dateData[timeCode] = new TurfAvailabilityBooking({
|
|
137
|
+
available: value.available,
|
|
138
|
+
notavailable: value.notavailable,
|
|
139
|
+
details: timeSlotData,
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
data[dateCode] = dateData;
|
|
143
|
+
});
|
|
144
|
+
return new TurfAvailability(data);
|
|
145
|
+
};
|
|
146
|
+
TurfAvailability.toJson = function (turfAvailability) {
|
|
147
|
+
var data = {};
|
|
148
|
+
Object.entries(turfAvailability.data).forEach(function (_a) {
|
|
149
|
+
var dateCode = _a[0], value = _a[1];
|
|
150
|
+
var dateData = {};
|
|
151
|
+
Object.entries(value).forEach(function (_a) {
|
|
152
|
+
var timeCode = _a[0], value = _a[1];
|
|
153
|
+
var timeSlotData = {};
|
|
154
|
+
Object.entries(value.details).forEach(function (_a) {
|
|
155
|
+
var pitchCode = _a[0], value = _a[1];
|
|
156
|
+
timeSlotData[pitchCode] = {
|
|
157
|
+
price: value.price,
|
|
158
|
+
bookingId: value.bookingId,
|
|
159
|
+
status: value.status,
|
|
160
|
+
priceSlot: value.priceSlot,
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
dateData[timeCode] = {
|
|
164
|
+
available: value.available,
|
|
165
|
+
notavailable: value.notavailable,
|
|
166
|
+
details: timeSlotData,
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
data[dateCode] = dateData;
|
|
170
|
+
});
|
|
171
|
+
return data;
|
|
172
|
+
};
|
|
173
|
+
TurfAvailability.prototype.getTotalTime = function () {
|
|
174
|
+
return this.getTotalAvailableHours() + this.getTotalNonAvailableHours();
|
|
175
|
+
};
|
|
176
|
+
TurfAvailability.prototype.getCode = function () {
|
|
177
|
+
if (!Object.keys(this.data).length)
|
|
178
|
+
return "";
|
|
179
|
+
return "event#".concat(this.dateCodes[0]).concat(this.dateCodes[this.dateCodes.length - 1], "#").concat(this.timeSlotCodesDateWise[this.dateCodes[0]][0].slice(0, 4)).concat(this.timeSlotCodesDateWise[this.dateCodes[0]][this.timeSlotCodesDateWise[this.dateCodes[0]].length - 1].slice(4, 8), "#").concat(this.getPitchIds(), "#").concat(this.weekDays);
|
|
180
|
+
};
|
|
181
|
+
TurfAvailability.prototype.parse = function () {
|
|
182
|
+
if (!Object.keys(this.data).length)
|
|
183
|
+
return;
|
|
184
|
+
var eventCode = this.getCode();
|
|
185
|
+
var eventCodes = eventCode.split("#");
|
|
186
|
+
var dateCodeRange = eventCodes[1];
|
|
187
|
+
var timeCodeRange = eventCodes[2];
|
|
188
|
+
this.pitchCodes = eventCodes[3].split(",").map(function (id) { return id.padStart(2, "0"); });
|
|
189
|
+
this.startDateCode = dateCodeRange.slice(0, 6);
|
|
190
|
+
this.endDateCode = dateCodeRange.slice(6, 12);
|
|
191
|
+
this.fromTimeCode = timeCodeRange.slice(0, 4);
|
|
192
|
+
this.toTimeCode = timeCodeRange.slice(4, 8);
|
|
193
|
+
this.weekDays = Array.from(new Set(this.dateCodes.map(function (dateCode) {
|
|
194
|
+
return booking_code_model_1.BookingCode.getWeekday(Number(dateCode));
|
|
195
|
+
}))).sort();
|
|
196
|
+
};
|
|
197
|
+
TurfAvailability.parse = function (eventCode) {
|
|
198
|
+
var _a;
|
|
199
|
+
var eventCodes = eventCode.split("#");
|
|
200
|
+
var dateCodeRange = eventCodes[1];
|
|
201
|
+
var timeCodeRange = eventCodes[2];
|
|
202
|
+
var weekDays = ((_a = eventCodes[4]) === null || _a === void 0 ? void 0 : _a.split(",").map(Number)) || [-1];
|
|
203
|
+
var startDateCode = dateCodeRange.slice(0, 6);
|
|
204
|
+
var endDateCode = dateCodeRange.slice(6, 12);
|
|
205
|
+
var bookingDateCodes = !weekDays.includes(-1)
|
|
206
|
+
? _utils_1.dateUtilService.getBookingCodeByWeekDaysAndDateRange(startDateCode, endDateCode, weekDays)
|
|
207
|
+
: [];
|
|
208
|
+
return {
|
|
209
|
+
pitchCodes: eventCodes[3].split(",").map(function (id) { return id.padStart(2, "0"); }),
|
|
210
|
+
startDateCode: startDateCode,
|
|
211
|
+
endDateCode: endDateCode,
|
|
212
|
+
fromTimeCode: timeCodeRange.slice(0, 4),
|
|
213
|
+
toTimeCode: timeCodeRange.slice(4, 8),
|
|
214
|
+
bookingDateCodes: bookingDateCodes,
|
|
215
|
+
weekDays: weekDays,
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
return TurfAvailability;
|
|
219
|
+
}());
|
|
220
|
+
exports.TurfAvailability = TurfAvailability;
|
|
221
|
+
var TurfAvailabilityDetail = /** @class */ (function () {
|
|
222
|
+
function TurfAvailabilityDetail(_a) {
|
|
223
|
+
var price = _a.price, bookingId = _a.bookingId, status = _a.status, priceSlot = _a.priceSlot;
|
|
224
|
+
this.price = price;
|
|
225
|
+
this.bookingId = bookingId;
|
|
226
|
+
this.status = status;
|
|
227
|
+
this.priceSlot = priceSlot;
|
|
228
|
+
}
|
|
229
|
+
return TurfAvailabilityDetail;
|
|
230
|
+
}());
|
|
231
|
+
var TurfAvailabilityBooking = /** @class */ (function () {
|
|
232
|
+
function TurfAvailabilityBooking(_a) {
|
|
233
|
+
var available = _a.available, notavailable = _a.notavailable, details = _a.details;
|
|
234
|
+
this.available = available;
|
|
235
|
+
this.notavailable = notavailable;
|
|
236
|
+
this.details = details;
|
|
237
|
+
}
|
|
238
|
+
return TurfAvailabilityBooking;
|
|
239
|
+
}());
|
package/build/utils/constant.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
|
|
3
|
+
exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
|
|
4
4
|
exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = 7;
|
|
5
|
+
exports.DEFAULT_PASSWORD = "turf@#123";
|
|
6
|
+
exports.DELETED_SLOT_SEPARATOR = "d_";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IConvertToMidNightTime, INgbDateStruct } from "../@type";
|
|
1
2
|
export declare class DateUtilService {
|
|
2
3
|
constructor();
|
|
3
4
|
getTodayCode(): string;
|
|
@@ -12,5 +13,36 @@ export declare class DateUtilService {
|
|
|
12
13
|
formatTimeSlotCode(timeSlot: string, both?: boolean, date?: Date | null): string;
|
|
13
14
|
formatDateCode(dateCode: string): string;
|
|
14
15
|
getDateNDaysFromToday(n: number): Date;
|
|
16
|
+
calculateDateDifference(fromDateCode: string, toDateCode: string, unit?: "minute" | "hr"): number;
|
|
17
|
+
/**
|
|
18
|
+
* Adds or subtracts a specified number of months from a given date in YYMM format.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} dateCode - A string representing a date in YYMM format.
|
|
21
|
+
* @param {number} N - An integer representing the number of months to add or subtract.
|
|
22
|
+
* Use a positive value to add months and a negative value to subtract months.
|
|
23
|
+
* @returns {string} A string representing the resulting date in YYMM format.
|
|
24
|
+
*/
|
|
25
|
+
addNMonth(dateCode: string, N: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets an array of month codes between two specified dates (inclusive).
|
|
28
|
+
* Each month code is represented as a number in the format "yyMM," where "yy" is the two-digit year and "MM" is the two-digit month.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} startDateCode - The starting date code in "yyMMdd" format.
|
|
31
|
+
* @param {string} endDateCode - The ending date code in "yyMMdd" format.
|
|
32
|
+
* @returns {number[]} An array of month codes representing each month between the start and end dates (inclusive).
|
|
33
|
+
* Each element in the array is a number in the "yyMM" format.
|
|
34
|
+
*/
|
|
35
|
+
getMonthRangeByDateCodes(startDateCode: string, endDateCode: string): number[];
|
|
36
|
+
convertToMidnight(time: IConvertToMidNightTime): IConvertToMidNightTime;
|
|
37
|
+
convertMonthsToNumber: (months: INgbDateStruct) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves booking date codes for a specified date range and weekdays.
|
|
40
|
+
*
|
|
41
|
+
* @param startDateCode - The starting date code for the date range.
|
|
42
|
+
* @param endDateCode - The ending date code for the date range.
|
|
43
|
+
* @param weekdays - An array of numbers representing weekdays (1 for Monday through 7 for Sunday).
|
|
44
|
+
* @returns An array of booking date codes based on the provided date range and weekdays.
|
|
45
|
+
*/
|
|
46
|
+
getBookingCodeByWeekDaysAndDateRange(startDateCode: string, endDateCode: string, weekdays: number[]): string[];
|
|
15
47
|
}
|
|
16
48
|
export declare const dateUtilService: DateUtilService;
|