turf-common 1.4.2-beta.7 → 2.0.0
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/jest.config.js +2 -1
- package/build/src/@model.d.ts +1 -0
- package/build/src/@model.js +1 -0
- package/build/src/enums/booking-history-operation-type.enum.d.ts +4 -1
- package/build/src/enums/booking-history-operation-type.enum.js +3 -0
- package/build/src/enums/organization-status.enum.d.ts +4 -0
- package/build/src/enums/organization-status.enum.js +6 -1
- package/build/src/enums/transaction-type.enum.d.ts +2 -1
- package/build/src/enums/transaction-type.enum.js +1 -0
- 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/booking-pending-payment-writeoff.interface.d.ts +10 -0
- package/build/src/interface/api/booking-pending-payment-writeoff.interface.js +2 -0
- package/build/src/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
- package/build/src/interface/api/create-user.interface.d.ts +1 -1
- package/build/src/interface/api/get-availability-by-turf.interface.d.ts +1 -0
- package/build/src/interface/api/get-booking-by-organization-id.interface.d.ts +1 -1
- package/build/src/interface/api/get-booking-history.interface.d.ts +1 -0
- package/build/src/interface/api/get-collection.interface.d.ts +1 -1
- package/build/src/interface/api/get-organization-configuration.interface.d.ts +8 -0
- package/build/src/interface/api/get-organization-configuration.interface.js +2 -0
- package/build/src/interface/api/index.d.ts +3 -0
- package/build/src/interface/api/index.js +3 -0
- package/build/src/interface/api/login-response.interface.d.ts +4 -1
- package/build/src/interface/api/one-slot-booking.interface.d.ts +2 -0
- package/build/src/interface/api/staff-member-list.interface.d.ts +1 -1
- package/build/src/interface/api/update-organization-configuration.interface.d.ts +6 -0
- package/build/src/interface/api/update-organization-configuration.interface.js +2 -0
- package/build/src/interface/api/update-recurring-booking.interface.d.ts +1 -0
- package/build/src/interface/api/update-staff-member.interface.d.ts +1 -1
- package/build/src/interface/entity/organization-entity.interface.d.ts +15 -3
- package/build/src/interface/entity/user-entity.interface.d.ts +6 -6
- package/build/src/interface/get-booking-by-id.interface.d.ts +2 -2
- package/build/src/interface/model/booking-details-model.interface.d.ts +8 -0
- package/build/src/interface/user-entity-essential-info.interface.d.ts +1 -1
- package/build/src/models/booking-code-model.d.ts +16 -2
- package/build/src/models/booking-code-model.js +83 -40
- package/build/src/models/charge-model.d.ts +2 -0
- package/build/src/models/charge-model.js +41 -11
- package/build/src/models/entity/booking-details-model.d.ts +2 -1
- package/build/src/models/entity/booking-details-model.js +19 -0
- package/build/src/models/entity/booking-entity-model.d.ts +1 -0
- package/build/src/models/entity/booking-entity-model.js +3 -0
- package/build/src/models/entity/user-model.d.ts +6 -6
- package/build/src/models/time-slot-model.d.ts +1 -0
- package/build/src/models/time-slot-model.js +3 -0
- package/build/src/models/turf-availability-model.d.ts +18 -3
- package/build/src/models/turf-availability-model.js +60 -3
- package/build/src/models/weekday-time-slot-model.d.ts +12 -0
- package/build/src/models/weekday-time-slot-model.js +30 -0
- package/build/src/utils/constant.d.ts +3 -0
- package/build/src/utils/constant.js +4 -1
- package/build/src/utils/date-util.d.ts +8 -1
- package/build/src/utils/date-util.js +22 -3
- package/build/tests/booking-code/method.spec.d.ts +1 -0
- package/build/tests/booking-code/method.spec.js +11 -0
- package/build/tests/unit/charges/discount-relative/basic.spec.d.ts +1 -0
- package/build/tests/unit/charges/discount-relative/basic.spec.js +209 -0
- package/build/tests/unit/charges/extension/basic.amount-fully-paid.spec.d.ts +1 -0
- package/build/tests/unit/charges/extension/basic.amount-fully-paid.spec.js +208 -0
- package/build/tests/unit/charges/extension/basic.spec.d.ts +1 -0
- package/build/tests/unit/charges/extension/basic.spec.js +215 -0
- package/build/tests/unit/pricing-plan/basic-scenario.spec.js +1 -1
- package/package.json +54 -43
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BookingCode } from "./booking-code-model";
|
|
1
2
|
import { IBookingModification } from "../types/booking-modification.type";
|
|
2
3
|
import { ModificationDiscountPolicy } from "../enums/modification-discount-policy.enum";
|
|
3
4
|
import { IChargeModel } from "../interface/model/charge-model.interface";
|
|
@@ -27,6 +28,7 @@ export declare class ChargesModel implements IChargeModel {
|
|
|
27
28
|
private modifyMove;
|
|
28
29
|
clone(): ChargesModel;
|
|
29
30
|
private modifyDelete;
|
|
31
|
+
extension(extensionBookingCode: BookingCode): ChargesModel;
|
|
30
32
|
static getInstance(chargeData: IChargeModel, discountPolicy?: ModificationDiscountPolicy): ChargesModel;
|
|
31
33
|
getTotalAmount(): number;
|
|
32
34
|
getPaymentStatus(): "Refund" | "Paid" | "Pending";
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.ChargesModel = void 0;
|
|
4
15
|
var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
|
|
@@ -9,15 +20,15 @@ var ChargesModel = /** @class */ (function () {
|
|
|
9
20
|
this.initialBookingGrossAmount = initialGrossAmount;
|
|
10
21
|
this.amountPaid = paidAmount;
|
|
11
22
|
this.couponCode = couponCode;
|
|
23
|
+
this.totalBookingHours = totalBookingHours;
|
|
24
|
+
this.discountPolicy = discountPolicy;
|
|
12
25
|
this.additionalBookingGrossAmount = 0;
|
|
13
26
|
this.cancelledBookingGrossAmount = 0;
|
|
14
27
|
this.totalCancellationCharges = 0;
|
|
15
28
|
this.refundPayable = 0;
|
|
16
29
|
this.totalRefundedAmount = 0;
|
|
17
|
-
this.totalBookingHours = totalBookingHours;
|
|
18
30
|
this.netTotal = this.getNetAmount();
|
|
19
31
|
this.amountPayable = this.getPayableRefundAmount();
|
|
20
|
-
this.discountPolicy = discountPolicy;
|
|
21
32
|
}
|
|
22
33
|
ChargesModel.prototype.getGrossAmount = function () {
|
|
23
34
|
return (this.initialBookingGrossAmount +
|
|
@@ -35,6 +46,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
35
46
|
this.cancelledBookingGrossAmount > 0) {
|
|
36
47
|
this.couponCode = "";
|
|
37
48
|
}
|
|
49
|
+
// console.log("getDiscountAmount", this.couponCode);
|
|
38
50
|
return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount(), false, this.totalBookingHours);
|
|
39
51
|
};
|
|
40
52
|
ChargesModel.prototype.getPayableRefundAmount = function () {
|
|
@@ -102,10 +114,6 @@ var ChargesModel = /** @class */ (function () {
|
|
|
102
114
|
};
|
|
103
115
|
ChargesModel.prototype.modify = function (bookingModification) {
|
|
104
116
|
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);
|
|
109
117
|
if (!newBookingCode) {
|
|
110
118
|
return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
|
|
111
119
|
}
|
|
@@ -150,9 +158,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
150
158
|
(newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
|
|
151
159
|
var newChargeModel = this.clone();
|
|
152
160
|
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
153
|
-
newChargeModel.couponCode = "";
|
|
154
161
|
var costDifference = oldBookingCode.getCost() - newBookingCode.getCost();
|
|
155
|
-
// console.log(`costDifference ${costDifference}`);
|
|
156
162
|
newChargeModel.cancelledBookingGrossAmount += costDifference;
|
|
157
163
|
var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
|
|
158
164
|
// console.log(`cancellationCharges ${cancellationCharges}`);
|
|
@@ -208,7 +214,6 @@ var ChargesModel = /** @class */ (function () {
|
|
|
208
214
|
var newTotalBookingHours = this.totalBookingHours - bookingCode.getTotalTime("hr");
|
|
209
215
|
var newChargeModel = this.clone();
|
|
210
216
|
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
211
|
-
newChargeModel.couponCode = "";
|
|
212
217
|
var costDifference = bookingCode.getCost();
|
|
213
218
|
newChargeModel.cancelledBookingGrossAmount += costDifference;
|
|
214
219
|
var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
|
|
@@ -224,10 +229,35 @@ var ChargesModel = /** @class */ (function () {
|
|
|
224
229
|
}
|
|
225
230
|
return newChargeModel;
|
|
226
231
|
};
|
|
232
|
+
ChargesModel.prototype.extension = function (extensionBookingCode) {
|
|
233
|
+
var newTotalBookingHours = this.totalBookingHours + (extensionBookingCode ? extensionBookingCode.getTotalTime("hr") : 0);
|
|
234
|
+
var newChargeModel = this.clone();
|
|
235
|
+
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
236
|
+
newChargeModel.additionalBookingGrossAmount += extensionBookingCode.getCost();
|
|
237
|
+
newChargeModel.netTotal = newChargeModel.getNetAmount();
|
|
238
|
+
newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
|
|
239
|
+
// console.log(newChargeModel.payableAmount);
|
|
240
|
+
if (newChargeModel.amountPayable > 0) {
|
|
241
|
+
newChargeModel.refundPayable = 0;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
|
|
245
|
+
newChargeModel.amountPayable = 0;
|
|
246
|
+
}
|
|
247
|
+
return newChargeModel;
|
|
248
|
+
};
|
|
227
249
|
ChargesModel.getInstance = function (chargeData, discountPolicy) {
|
|
228
250
|
if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
|
|
229
|
-
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, chargeData.totalBookingHours, discountPolicy);
|
|
230
|
-
|
|
251
|
+
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, parseFloat(chargeData.totalBookingHours.toString()), discountPolicy);
|
|
252
|
+
var initialBookingGrossAmount = chargeData.initialBookingGrossAmount, amountPaid = chargeData.amountPaid, couponCode = chargeData.couponCode, totalBookingHours = chargeData.totalBookingHours, rest = __rest(chargeData, ["initialBookingGrossAmount", "amountPaid", "couponCode", "totalBookingHours"]);
|
|
253
|
+
chargesModel.additionalBookingGrossAmount = rest.additionalBookingGrossAmount;
|
|
254
|
+
chargesModel.cancelledBookingGrossAmount = rest.cancelledBookingGrossAmount;
|
|
255
|
+
chargesModel.refundPayable = rest.refundPayable;
|
|
256
|
+
chargesModel.totalRefundedAmount = rest.totalRefundedAmount;
|
|
257
|
+
chargesModel.totalCancellationCharges = rest.totalCancellationCharges;
|
|
258
|
+
chargesModel.netTotal = rest.netTotal;
|
|
259
|
+
chargesModel.amountPayable = rest.amountPayable;
|
|
260
|
+
// Object.assign(chargesModel, rest);
|
|
231
261
|
return chargesModel;
|
|
232
262
|
};
|
|
233
263
|
// static assignByInterface(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BookingDetailsStatus } from "../../enums/booking-details-status.enum";
|
|
2
|
-
import { IBookingDetailsModel } from "../../interface/model/booking-details-model.interface";
|
|
2
|
+
import { IBookingDetailsModel, IEventBookingDetails } from "../../interface/model/booking-details-model.interface";
|
|
3
3
|
import { IBookingDetailsWithBooking } from "../../types/bookingdetails-with-booking.type";
|
|
4
4
|
import { IBookingDetailsEntity } from "../../interface/entity/booking-details-entity.interface";
|
|
5
5
|
import { IBookingsEntity } from "../../interface/entity/bookings-entity.interface";
|
|
@@ -35,6 +35,7 @@ export declare class BookingDetailsModel implements IBookingDetailsModel {
|
|
|
35
35
|
totalBookingHours: number;
|
|
36
36
|
type: string | null;
|
|
37
37
|
constructor(data: IBookingDetailsEntity);
|
|
38
|
+
getEventDetails(): IEventBookingDetails;
|
|
38
39
|
static getIdAndCreatedBy(bookingDetailsEntities: IBookingDetailsEntity[]): number[][];
|
|
39
40
|
assignCharges(chargeModel: ChargesModel): void;
|
|
40
41
|
static toMap(bookingDetailsEntities: IBookingDetailsEntity[], bookingsEntities: IBookingsEntity[]): IBookingDetailsWithBooking;
|
|
@@ -13,10 +13,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.BookingDetailsModel = void 0;
|
|
15
15
|
var booking_entity_model_1 = require("./booking-entity-model");
|
|
16
|
+
var weekday_time_slot_model_1 = require("../weekday-time-slot-model");
|
|
16
17
|
var BookingDetailsModel = /** @class */ (function () {
|
|
17
18
|
function BookingDetailsModel(data) {
|
|
18
19
|
Object.assign(this, data);
|
|
19
20
|
}
|
|
21
|
+
BookingDetailsModel.prototype.getEventDetails = function () {
|
|
22
|
+
var _a;
|
|
23
|
+
if (((_a = this.type) === null || _a === void 0 ? void 0 : _a.split("#")[0]) === "event") {
|
|
24
|
+
var startDateCode = Number(this.type.split("#")[1].split(",")[0]);
|
|
25
|
+
var endDateCode = Number(this.type.split("#")[1].split(",")[1]);
|
|
26
|
+
var pitchIds = this.type.split("#")[3].split(",").map(Number);
|
|
27
|
+
var weekdaySlots = this.type.split("#")[2].split(",").map(function (weekdayTimeSlotCode) { return new weekday_time_slot_model_1.WeekdayTimeSlot(weekdayTimeSlotCode); });
|
|
28
|
+
return {
|
|
29
|
+
startDateCode: startDateCode,
|
|
30
|
+
endDateCode: endDateCode,
|
|
31
|
+
weekdaySlots: weekdaySlots,
|
|
32
|
+
pitchIds: pitchIds,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error("Booking is not an event");
|
|
37
|
+
}
|
|
38
|
+
};
|
|
20
39
|
BookingDetailsModel.getIdAndCreatedBy = function (bookingDetailsEntities) {
|
|
21
40
|
var bookingDetailsIds = [];
|
|
22
41
|
var userIds = [];
|
|
@@ -14,6 +14,7 @@ export declare class BookingEntityModel implements IBookingsEntityModel {
|
|
|
14
14
|
getBookingTimeInMinutes(): number;
|
|
15
15
|
isTimeExtended(newBookingEntities: IBookingsEntity[]): boolean;
|
|
16
16
|
getBookingCode(): BookingCode;
|
|
17
|
+
isModificationAllowed(): boolean;
|
|
17
18
|
static toMap(bookingEntities: IBookingsEntity[]): {
|
|
18
19
|
[key: string]: string;
|
|
19
20
|
};
|
|
@@ -27,6 +27,9 @@ var BookingEntityModel = /** @class */ (function () {
|
|
|
27
27
|
BookingEntityModel.prototype.getBookingCode = function () {
|
|
28
28
|
return new booking_code_model_1.BookingCode(this.code, this.cost);
|
|
29
29
|
};
|
|
30
|
+
BookingEntityModel.prototype.isModificationAllowed = function () {
|
|
31
|
+
return this.getBookingCode().isModificationAllowed();
|
|
32
|
+
};
|
|
30
33
|
BookingEntityModel.toMap = function (bookingEntities) {
|
|
31
34
|
var response = {};
|
|
32
35
|
bookingEntities.forEach(function (bookingEntity) {
|
|
@@ -4,16 +4,16 @@ import { IUserModel } from "../../interface/model/user-model.interface";
|
|
|
4
4
|
import { ITurfEntity } from "../../interface/entity/turf-entity.interface";
|
|
5
5
|
export declare class UserModel implements IUserModel {
|
|
6
6
|
id: number;
|
|
7
|
-
|
|
7
|
+
name: string;
|
|
8
8
|
phone: string;
|
|
9
9
|
password: string;
|
|
10
10
|
email: string;
|
|
11
11
|
status: UserStatus;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
isEmailVerified: boolean;
|
|
13
|
+
isMobileVerified: boolean;
|
|
14
|
+
isAccountVerified: boolean;
|
|
15
|
+
requireNewPassword: boolean;
|
|
16
|
+
organizationId: number;
|
|
17
17
|
type: UserType;
|
|
18
18
|
createdOn: Date;
|
|
19
19
|
updatedOn: Date;
|
|
@@ -12,6 +12,7 @@ export declare class TimeSlot {
|
|
|
12
12
|
getHalfHourTimeCodes(): string[];
|
|
13
13
|
getHalfHourTimeRangeCodes(): string[];
|
|
14
14
|
getTotalMinutes(): number;
|
|
15
|
+
isInclusive(timeSlot: TimeSlot): boolean;
|
|
15
16
|
static convertToCode(minute: number): string;
|
|
16
17
|
static _getMinutes(timeCode: string): number;
|
|
17
18
|
static getHalfHourTimeCodes(): string[];
|
|
@@ -64,6 +64,9 @@ var TimeSlot = /** @class */ (function () {
|
|
|
64
64
|
TimeSlot.prototype.getTotalMinutes = function () {
|
|
65
65
|
return this.getEndMinutes() - this.getStartMinutes();
|
|
66
66
|
};
|
|
67
|
+
TimeSlot.prototype.isInclusive = function (timeSlot) {
|
|
68
|
+
return this.fromTime <= timeSlot.fromTime && timeSlot.toTime <= this.toTime;
|
|
69
|
+
};
|
|
67
70
|
// static padStart(timeCode: string, length: number, padString: string): string {
|
|
68
71
|
// return timeCode.padStart(length, padString);
|
|
69
72
|
// }
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { IGetAvailabilityByTurf } from "../@type";
|
|
1
|
+
import { IGetAvailabilityByTurf, IGetAvailabilityByTurfRequest } from "../@type";
|
|
2
2
|
interface ITurfAvailability {
|
|
3
3
|
data: IGetAvailabilityByTurf;
|
|
4
4
|
dateCodes: string[];
|
|
5
5
|
timeSlotCodesDateWise: Record<string, string[]>;
|
|
6
|
+
apiRequestModel?: IGetAvailabilityByTurfRequest;
|
|
6
7
|
getTotalAvailablePrice(): number;
|
|
7
8
|
getTotalNonAvailablePrice(): number;
|
|
8
9
|
getTotalAvailableHours(): number;
|
|
@@ -26,7 +27,8 @@ export declare class TurfAvailability implements ITurfAvailability {
|
|
|
26
27
|
toTimeCode: string;
|
|
27
28
|
pitchCodes: string[];
|
|
28
29
|
weekDays: number[];
|
|
29
|
-
|
|
30
|
+
apiRequestModel?: IGetAvailabilityByTurfRequest;
|
|
31
|
+
constructor(data: IGetAvailabilityByTurf, apiRequestModel?: IGetAvailabilityByTurfRequest | null);
|
|
30
32
|
getTotalAvailablePrice(): number;
|
|
31
33
|
getTotalNonAvailablePrice(): number;
|
|
32
34
|
getTotalAvailableHours(): number;
|
|
@@ -39,10 +41,23 @@ export declare class TurfAvailability implements ITurfAvailability {
|
|
|
39
41
|
weekdays: number[];
|
|
40
42
|
}[];
|
|
41
43
|
getPitchIds(): number[];
|
|
42
|
-
static fromJson(json: IGetAvailabilityByTurf): TurfAvailability;
|
|
44
|
+
static fromJson(json: IGetAvailabilityByTurf, apiRequestModel?: IGetAvailabilityByTurfRequest | null): TurfAvailability;
|
|
43
45
|
static toJson(turfAvailability: TurfAvailability): IGetAvailabilityByTurf;
|
|
44
46
|
getTotalTime(): number;
|
|
45
47
|
getCode(): string;
|
|
48
|
+
getEventCode(): string;
|
|
49
|
+
static parseEventCode(eventCode: string): {
|
|
50
|
+
fromDateCode: string;
|
|
51
|
+
toDateCode: string;
|
|
52
|
+
data: {
|
|
53
|
+
fromDateCode: string;
|
|
54
|
+
toDateCode: string;
|
|
55
|
+
fromTimeCode: string;
|
|
56
|
+
toTimeCode: string;
|
|
57
|
+
weekDay: number;
|
|
58
|
+
}[];
|
|
59
|
+
pitchIds: string[];
|
|
60
|
+
};
|
|
46
61
|
parse(): void;
|
|
47
62
|
static parse(eventCode: string): {
|
|
48
63
|
pitchCodes: string[];
|
|
@@ -4,9 +4,13 @@ exports.TurfAvailability = void 0;
|
|
|
4
4
|
var _utils_1 = require("../@utils");
|
|
5
5
|
var booking_code_model_1 = require("./booking-code-model");
|
|
6
6
|
var TurfAvailability = /** @class */ (function () {
|
|
7
|
-
function TurfAvailability(data) {
|
|
7
|
+
function TurfAvailability(data, apiRequestModel) {
|
|
8
8
|
var _this = this;
|
|
9
|
+
if (apiRequestModel === void 0) { apiRequestModel = null; }
|
|
9
10
|
this.data = data;
|
|
11
|
+
if (apiRequestModel) {
|
|
12
|
+
this.apiRequestModel = apiRequestModel;
|
|
13
|
+
}
|
|
10
14
|
this.dateCodes = Object.keys(data).sort();
|
|
11
15
|
this.timeSlotCodesDateWise = {};
|
|
12
16
|
Object.entries(data).forEach(function (_a) {
|
|
@@ -116,7 +120,8 @@ var TurfAvailability = /** @class */ (function () {
|
|
|
116
120
|
var pitchIdList = Array.from(pitchIds).sort(function (a, b) { return a - b; });
|
|
117
121
|
return pitchIdList;
|
|
118
122
|
};
|
|
119
|
-
TurfAvailability.fromJson = function (json) {
|
|
123
|
+
TurfAvailability.fromJson = function (json, apiRequestModel) {
|
|
124
|
+
if (apiRequestModel === void 0) { apiRequestModel = null; }
|
|
120
125
|
var data = {};
|
|
121
126
|
Object.entries(json).forEach(function (_a) {
|
|
122
127
|
var dateCode = _a[0], value = _a[1];
|
|
@@ -141,7 +146,11 @@ var TurfAvailability = /** @class */ (function () {
|
|
|
141
146
|
});
|
|
142
147
|
data[dateCode] = dateData;
|
|
143
148
|
});
|
|
144
|
-
|
|
149
|
+
var turfAvailability = new TurfAvailability(data);
|
|
150
|
+
if (apiRequestModel) {
|
|
151
|
+
turfAvailability.apiRequestModel = apiRequestModel;
|
|
152
|
+
}
|
|
153
|
+
return turfAvailability;
|
|
145
154
|
};
|
|
146
155
|
TurfAvailability.toJson = function (turfAvailability) {
|
|
147
156
|
var data = {};
|
|
@@ -178,6 +187,54 @@ var TurfAvailability = /** @class */ (function () {
|
|
|
178
187
|
return "";
|
|
179
188
|
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
189
|
};
|
|
190
|
+
TurfAvailability.prototype.getEventCode = function () {
|
|
191
|
+
if (this.apiRequestModel) {
|
|
192
|
+
return "event#".concat(this.apiRequestModel.dateRange, "#").concat(this.apiRequestModel.weekdayTimeSlots.join(","), "#").concat(this.apiRequestModel.pitch);
|
|
193
|
+
}
|
|
194
|
+
return "";
|
|
195
|
+
};
|
|
196
|
+
TurfAvailability.parseEventCode = function (eventCode) {
|
|
197
|
+
var eventCodes = eventCode.split("#");
|
|
198
|
+
var dateCodeRange = eventCodes[1];
|
|
199
|
+
var weekdayTimeSlots = eventCodes[2].split(",");
|
|
200
|
+
var timeSlotsByWeekday = {};
|
|
201
|
+
for (var _i = 0, weekdayTimeSlots_1 = weekdayTimeSlots; _i < weekdayTimeSlots_1.length; _i++) {
|
|
202
|
+
var weekdayTimeSlot = weekdayTimeSlots_1[_i];
|
|
203
|
+
var weekday = parseInt(weekdayTimeSlot.slice(0, 1));
|
|
204
|
+
if (!timeSlotsByWeekday[weekday]) {
|
|
205
|
+
timeSlotsByWeekday[weekday] = [];
|
|
206
|
+
}
|
|
207
|
+
timeSlotsByWeekday[weekday].push(weekdayTimeSlot.slice(1));
|
|
208
|
+
}
|
|
209
|
+
var weekdays = Array.from(new Set(weekdayTimeSlots.map(function (timeSlot) { return parseInt(timeSlot.slice(0, 1)); })));
|
|
210
|
+
var dateCodes = [];
|
|
211
|
+
for (var _a = 0, weekdays_1 = weekdays; _a < weekdays_1.length; _a++) {
|
|
212
|
+
var weekday = weekdays_1[_a];
|
|
213
|
+
dateCodes.push.apply(dateCodes, booking_code_model_1.BookingCode.getDateCodesByWeek(Number(dateCodeRange.slice(0, 6)), Number(dateCodeRange.slice(7, 13)), weekday));
|
|
214
|
+
}
|
|
215
|
+
var data = [];
|
|
216
|
+
dateCodes.sort();
|
|
217
|
+
for (var _b = 0, dateCodes_1 = dateCodes; _b < dateCodes_1.length; _b++) {
|
|
218
|
+
var dateCode = dateCodes_1[_b];
|
|
219
|
+
var dateCodeWeekday = booking_code_model_1.BookingCode.getWeekday(Number(dateCode));
|
|
220
|
+
for (var _c = 0, _d = timeSlotsByWeekday[dateCodeWeekday] || []; _c < _d.length; _c++) {
|
|
221
|
+
var timeslot = _d[_c];
|
|
222
|
+
data.push({
|
|
223
|
+
fromDateCode: dateCode,
|
|
224
|
+
toDateCode: dateCode,
|
|
225
|
+
fromTimeCode: timeslot.slice(0, 4),
|
|
226
|
+
toTimeCode: timeslot.slice(4, 8),
|
|
227
|
+
weekDay: dateCodeWeekday,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
fromDateCode: dateCodes[0],
|
|
233
|
+
toDateCode: dateCodes[dateCodes.length - 1],
|
|
234
|
+
data: data,
|
|
235
|
+
pitchIds: eventCodes[3].split(","),
|
|
236
|
+
};
|
|
237
|
+
};
|
|
181
238
|
TurfAvailability.prototype.parse = function () {
|
|
182
239
|
if (!Object.keys(this.data).length)
|
|
183
240
|
return;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TimeSlot } from "./time-slot-model";
|
|
2
|
+
export declare class WeekdayTimeSlot {
|
|
3
|
+
code: string;
|
|
4
|
+
weekday: number;
|
|
5
|
+
timeSlot: TimeSlot;
|
|
6
|
+
constructor(code: string);
|
|
7
|
+
parse(): void;
|
|
8
|
+
getWeekday(): number;
|
|
9
|
+
getFromTimeCode(): string;
|
|
10
|
+
getToTimeCode(): string;
|
|
11
|
+
getTimeSlot(): TimeSlot;
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WeekdayTimeSlot = void 0;
|
|
4
|
+
var time_slot_model_1 = require("./time-slot-model");
|
|
5
|
+
var WeekdayTimeSlot = /** @class */ (function () {
|
|
6
|
+
function WeekdayTimeSlot(code) {
|
|
7
|
+
if (code.length !== 9)
|
|
8
|
+
throw new Error("Invalid weekday time slot code: ".concat(code, ". Expected length: 9."));
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.parse();
|
|
11
|
+
}
|
|
12
|
+
WeekdayTimeSlot.prototype.parse = function () {
|
|
13
|
+
this.weekday = parseInt(this.code.slice(0, 1));
|
|
14
|
+
this.timeSlot = new time_slot_model_1.TimeSlot(this.code.slice(1, 5), this.code.slice(5, 9));
|
|
15
|
+
};
|
|
16
|
+
WeekdayTimeSlot.prototype.getWeekday = function () {
|
|
17
|
+
return this.weekday;
|
|
18
|
+
};
|
|
19
|
+
WeekdayTimeSlot.prototype.getFromTimeCode = function () {
|
|
20
|
+
return this.timeSlot.fromTime;
|
|
21
|
+
};
|
|
22
|
+
WeekdayTimeSlot.prototype.getToTimeCode = function () {
|
|
23
|
+
return this.timeSlot.toTime;
|
|
24
|
+
};
|
|
25
|
+
WeekdayTimeSlot.prototype.getTimeSlot = function () {
|
|
26
|
+
return this.timeSlot;
|
|
27
|
+
};
|
|
28
|
+
return WeekdayTimeSlot;
|
|
29
|
+
}());
|
|
30
|
+
exports.WeekdayTimeSlot = WeekdayTimeSlot;
|
|
@@ -3,3 +3,6 @@ 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 = 60;
|
|
7
|
+
export declare const DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES = 120;
|
|
8
|
+
export declare const DEFAULT_BOOKING_DELETION_DELAY_IN_MINUTES: number;
|
|
@@ -1,8 +1,11 @@
|
|
|
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_DELETION_DELAY_IN_MINUTES = exports.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES = 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 = 60;
|
|
10
|
+
exports.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES = 120;
|
|
11
|
+
exports.DEFAULT_BOOKING_DELETION_DELAY_IN_MINUTES = 7 * 24 * 60;
|
|
@@ -5,7 +5,9 @@ export declare class DateUtilService {
|
|
|
5
5
|
getNDaysCode(n: number): string;
|
|
6
6
|
getDateCode(date: Date): string;
|
|
7
7
|
addNDaysToDate(date: Date, n: number): Date;
|
|
8
|
-
|
|
8
|
+
addMinutesTo(date: Date, minutes: number): Date;
|
|
9
|
+
convertStringToDate(dateString: string, format: string, offset?: number): Date;
|
|
10
|
+
getIndianDate(date?: Date): Date;
|
|
9
11
|
isInPast(date: Date): boolean;
|
|
10
12
|
getDateFromDatabaseDate: (date: string) => Date;
|
|
11
13
|
noOfDaysBetweenDates: (date1: Date, date2: Date) => number;
|
|
@@ -52,5 +54,10 @@ export declare class DateUtilService {
|
|
|
52
54
|
*/
|
|
53
55
|
getBookingCodeByWeekDaysAndDateRange(startDateCode: string, endDateCode: string, weekdays: number[]): string[];
|
|
54
56
|
formatDate(date: Date, formatString: string): string;
|
|
57
|
+
convertDateToTimezone(date: Date, timeZone: Timezone): Date;
|
|
58
|
+
convertDateToUTC(now: Date): Date;
|
|
59
|
+
}
|
|
60
|
+
export declare enum Timezone {
|
|
61
|
+
IST = "Asia/Kolkata"
|
|
55
62
|
}
|
|
56
63
|
export declare const dateUtilService: DateUtilService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dateUtilService = exports.DateUtilService = void 0;
|
|
3
|
+
exports.dateUtilService = exports.Timezone = exports.DateUtilService = void 0;
|
|
4
4
|
var date_fns_1 = require("date-fns");
|
|
5
5
|
var _model_1 = require("../@model");
|
|
6
6
|
var DateUtilService = /** @class */ (function () {
|
|
@@ -31,12 +31,20 @@ var DateUtilService = /** @class */ (function () {
|
|
|
31
31
|
DateUtilService.prototype.addNDaysToDate = function (date, n) {
|
|
32
32
|
return (0, date_fns_1.add)(date, { days: n });
|
|
33
33
|
};
|
|
34
|
-
DateUtilService.prototype.
|
|
34
|
+
DateUtilService.prototype.addMinutesTo = function (date, minutes) {
|
|
35
|
+
return (0, date_fns_1.add)(date, { minutes: minutes });
|
|
36
|
+
};
|
|
37
|
+
DateUtilService.prototype.convertStringToDate = function (dateString, format, offset) {
|
|
38
|
+
if (offset === void 0) { offset = 330 * 60 * 1000; }
|
|
35
39
|
var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
|
|
36
40
|
// IST has a fixed offset of UTC+5:30
|
|
37
|
-
var indianDate = new Date(parsedDate.getTime() +
|
|
41
|
+
var indianDate = new Date(parsedDate.getTime() + offset);
|
|
38
42
|
return indianDate;
|
|
39
43
|
};
|
|
44
|
+
DateUtilService.prototype.getIndianDate = function (date) {
|
|
45
|
+
if (date === void 0) { date = new Date(); }
|
|
46
|
+
return new Date(date.getTime() + 330 * 60 * 1000);
|
|
47
|
+
};
|
|
40
48
|
DateUtilService.prototype.isInPast = function (date) {
|
|
41
49
|
return date < new Date();
|
|
42
50
|
};
|
|
@@ -151,7 +159,18 @@ var DateUtilService = /** @class */ (function () {
|
|
|
151
159
|
DateUtilService.prototype.formatDate = function (date, formatString) {
|
|
152
160
|
return (0, date_fns_1.format)(date, formatString);
|
|
153
161
|
};
|
|
162
|
+
DateUtilService.prototype.convertDateToTimezone = function (date, timeZone) {
|
|
163
|
+
return new Date(date.toLocaleString("en-US", { timeZone: timeZone }));
|
|
164
|
+
// return new Date(date.getTime() + offset);
|
|
165
|
+
};
|
|
166
|
+
DateUtilService.prototype.convertDateToUTC = function (now) {
|
|
167
|
+
return new Date(now.getTime() + now.getTimezoneOffset() * 60 * 1000);
|
|
168
|
+
};
|
|
154
169
|
return DateUtilService;
|
|
155
170
|
}());
|
|
156
171
|
exports.DateUtilService = DateUtilService;
|
|
172
|
+
var Timezone;
|
|
173
|
+
(function (Timezone) {
|
|
174
|
+
Timezone["IST"] = "Asia/Kolkata";
|
|
175
|
+
})(Timezone || (exports.Timezone = Timezone = {}));
|
|
157
176
|
exports.dateUtilService = new DateUtilService();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 001005_0P_1,006010_2P_1,011999_5P_1
|
|
3
|
+
// 000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// 1_5#1#1#0P,1_5#3#0.95#5P,1_5#6#0.93#7P,1_5#12#0.9#10P,6_10#1#0.98#2P,6_10#3#0.931#6.9P,6_10#6#0.9114#8.86P,6_10#12#0.882#11.8P,11_99#1#0.95#5P,11_99#3#0.9025#9.75P,11_99#6#0.8835#11.65P,11_99#12#0.855#14.5P
|
|
6
|
+
describe("AppController (e2e)", function () {
|
|
7
|
+
it("Method Testing ", function () {
|
|
8
|
+
// BookingCode.previousTimeChecker("2115",240428, 0, 45);
|
|
9
|
+
// BookingCode.previousTimeChecker("2109",240428, 0, 51);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|