turf-common 1.0.1 → 1.0.2

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.
Files changed (38) hide show
  1. package/README.md +11 -0
  2. package/build/enums/modification-discount-policy.enum.d.ts +5 -0
  3. package/build/enums/modification-discount-policy.enum.js +9 -0
  4. package/build/exceptions/app-badrequest.exception.d.ts +5 -0
  5. package/build/exceptions/app-badrequest.exception.js +28 -0
  6. package/build/index.d.ts +8 -1
  7. package/build/index.js +22 -5
  8. package/build/interface/get-booking-codes-per-thirty-min.interface.d.ts +4 -0
  9. package/build/interface/get-booking-codes-per-thirty-min.interface.js +2 -0
  10. package/build/models/booking-code-model.d.ts +72 -0
  11. package/build/models/booking-code-model.js +414 -0
  12. package/build/models/charge-model.d.ts +44 -0
  13. package/build/models/charge-model.js +227 -0
  14. package/build/models/time-slot-model.d.ts +18 -0
  15. package/build/models/time-slot-model.js +95 -0
  16. package/build/modules/app-badrequest-exception-module/app-badrequest-exception-model.d.ts +5 -0
  17. package/build/modules/app-badrequest-exception-module/app-badrequest-exception-model.js +28 -0
  18. package/build/modules/app-badrequest-exception-module/types/app-badrequest-exception.type.d.ts +4 -0
  19. package/build/modules/app-badrequest-exception-module/types/app-badrequest-exception.type.js +2 -0
  20. package/build/modules/booking-module/booking-code-model.d.ts +71 -0
  21. package/build/modules/booking-module/booking-code-model.js +407 -0
  22. package/build/modules/booking-module/interfaces/get-booking-codes-per-thirty-min.interface.d.ts +4 -0
  23. package/build/modules/booking-module/interfaces/get-booking-codes-per-thirty-min.interface.js +2 -0
  24. package/build/modules/charge-module/charge-model.d.ts +44 -0
  25. package/build/modules/charge-module/charge-model.js +227 -0
  26. package/build/modules/charge-module/enums/modification-discount-policy.enum.d.ts +5 -0
  27. package/build/modules/charge-module/enums/modification-discount-policy.enum.js +9 -0
  28. package/build/modules/charge-module/types/booking-modification.type.d.ts +6 -0
  29. package/build/modules/charge-module/types/booking-modification.type.js +2 -0
  30. package/build/modules/date-module/date-code-model.d.ts +8 -0
  31. package/build/modules/date-module/date-code-model.js +38 -0
  32. package/build/modules/time-slot-module/time-slot-model.d.ts +18 -0
  33. package/build/modules/time-slot-module/time-slot-model.js +95 -0
  34. package/build/types/app-badrequest-exception.type.d.ts +4 -0
  35. package/build/types/app-badrequest-exception.type.js +2 -0
  36. package/build/types/booking-modification.type.d.ts +6 -0
  37. package/build/types/booking-modification.type.js +2 -0
  38. package/package.json +3 -3
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChargesModel = void 0;
4
+ var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
5
+ var modification_discount_policy_enum_1 = require("../enums/modification-discount-policy.enum");
6
+ var ChargesModel = /** @class */ (function () {
7
+ function ChargesModel(initialGrossAmount, paidAmount, couponCode, discountPolicy) {
8
+ this.initialBookingGrossAmount = initialGrossAmount;
9
+ this.amountPaid = paidAmount;
10
+ this.couponCode = couponCode;
11
+ this.additionalBookingGrossAmount = 0;
12
+ this.cancelledBookingGrossAmount = 0;
13
+ this.totalCancellationCharges = 0;
14
+ this.refundPayable = 0;
15
+ this.totalRefundedAmount = 0;
16
+ this.netTotal = this.getNetAmount();
17
+ this.amountPayable = this.getPayableRefundAmount();
18
+ this.discountPolicy = discountPolicy;
19
+ }
20
+ ChargesModel.prototype.getGrossAmount = function () {
21
+ return (this.initialBookingGrossAmount +
22
+ this.additionalBookingGrossAmount -
23
+ this.cancelledBookingGrossAmount);
24
+ };
25
+ ChargesModel.prototype.getNetAmount = function () {
26
+ return this.getGrossAmount() - this.getDiscountAmount();
27
+ };
28
+ ChargesModel.prototype.getDiscountAmount = function () {
29
+ if ([
30
+ modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL,
31
+ modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_RECALL,
32
+ ].includes(this.discountPolicy) &&
33
+ this.cancelledBookingGrossAmount > 0) {
34
+ this.couponCode = "";
35
+ }
36
+ return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount());
37
+ };
38
+ ChargesModel.prototype.getPayableRefundAmount = function () {
39
+ return (this.getNetAmount() +
40
+ this.totalCancellationCharges -
41
+ this.amountPaid +
42
+ this.totalRefundedAmount);
43
+ };
44
+ // setRefundedAmount(refundAmount: number) {
45
+ // this.paidAmount = this.paidAmount - refundAmount;
46
+ // this.totalRefundAmount = this.totalRefundAmount - refundAmount;
47
+ // this.refundedAmount += refundAmount;
48
+ // }
49
+ ChargesModel.getDiscountAmount = function (couponCode, totalCost, validationApply) {
50
+ if (validationApply === void 0) { validationApply = false; }
51
+ var discountAmount = 0;
52
+ if (couponCode) {
53
+ if (couponCode.slice(-1) === "P") {
54
+ var percentDiscount = parseFloat(couponCode);
55
+ if (validationApply && percentDiscount > 90) {
56
+ throw new app_badrequest_exception_1.AppBadRequestException({
57
+ key: "couponCode",
58
+ message: ["Discount should not be more than 90P"],
59
+ });
60
+ }
61
+ discountAmount = totalCost * (percentDiscount / 100);
62
+ }
63
+ else if (couponCode.slice(-1) === "U") {
64
+ discountAmount = parseFloat(couponCode);
65
+ }
66
+ }
67
+ return Math.round(discountAmount);
68
+ };
69
+ ChargesModel.prototype.setValues = function (values) {
70
+ if (values === void 0) { values = {}; }
71
+ var that = this.clone();
72
+ if (values.totalRefundedAmount) {
73
+ that.totalRefundedAmount += values.totalRefundedAmount;
74
+ that.refundPayable -= values.totalRefundedAmount;
75
+ }
76
+ if (values.amountPaid) {
77
+ that.amountPaid = that.amountPaid + values.amountPaid;
78
+ that.amountPayable = that.amountPayable - values.amountPaid;
79
+ }
80
+ return that;
81
+ };
82
+ ChargesModel.prototype.modify = function (bookingModification) {
83
+ var oldBookingCode = bookingModification.oldBookingCode, newBookingCode = bookingModification.newBookingCode, cancellationUnit = bookingModification.cancellationUnit;
84
+ if (!newBookingCode) {
85
+ return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
86
+ }
87
+ if (!newBookingCode)
88
+ return null;
89
+ var oldTimeSlotMinutes = oldBookingCode.getTimeslot().getTotalMinutes();
90
+ var newTimeSlotMinutes = newBookingCode.getTimeslot().getTotalMinutes();
91
+ if (oldTimeSlotMinutes === newTimeSlotMinutes) {
92
+ return this.modifyMove(oldBookingCode, newBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
93
+ }
94
+ if (oldTimeSlotMinutes > newTimeSlotMinutes) {
95
+ return this.modifyReduce(oldBookingCode, newBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
96
+ }
97
+ if (oldTimeSlotMinutes < newTimeSlotMinutes) {
98
+ return this.modifyExtend(oldBookingCode, newBookingCode);
99
+ }
100
+ return null;
101
+ };
102
+ ChargesModel.prototype.modifyExtend = function (oldBookingCode, newBookingCode) {
103
+ var newChargeModel = this.clone();
104
+ newChargeModel.additionalBookingGrossAmount +=
105
+ newBookingCode.getCost() - oldBookingCode.getCost();
106
+ newChargeModel.netTotal = newChargeModel.getNetAmount();
107
+ newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
108
+ // console.log(newChargeModel.payableAmount);
109
+ if (newChargeModel.amountPayable > 0) {
110
+ newChargeModel.refundPayable = 0;
111
+ }
112
+ else {
113
+ newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
114
+ newChargeModel.amountPayable = 0;
115
+ }
116
+ return newChargeModel;
117
+ };
118
+ ChargesModel.prototype.modifyReduce = function (oldBookingCode, newBookingCode, cancellationUnit) {
119
+ var newChargeModel = this.clone();
120
+ newChargeModel.couponCode = "";
121
+ var costDifference = oldBookingCode.getCost() - newBookingCode.getCost();
122
+ // console.log(`costDifference ${costDifference}`);
123
+ newChargeModel.cancelledBookingGrossAmount += costDifference;
124
+ var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
125
+ // console.log(`cancellationCharges ${cancellationCharges}`);
126
+ newChargeModel.totalCancellationCharges += cancellationCharges;
127
+ newChargeModel.netTotal = newChargeModel.getNetAmount();
128
+ // console.log(`newChargeModel.netAmount ${newChargeModel.netAmount}`);
129
+ newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
130
+ // console.log(`newChargeModel.payableAmount ${newChargeModel.payableAmount}`);
131
+ if (newChargeModel.amountPayable > 0) {
132
+ newChargeModel.refundPayable = 0;
133
+ }
134
+ else {
135
+ newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
136
+ newChargeModel.amountPayable = 0;
137
+ }
138
+ return newChargeModel;
139
+ };
140
+ ChargesModel.prototype.modifyMove = function (oldBookingCode, newBookingCode, cancellationUnit) {
141
+ var newChargeModel = this.clone();
142
+ var costDifference = newBookingCode.getCost() - oldBookingCode.getCost();
143
+ if (costDifference === 0) {
144
+ return newChargeModel;
145
+ }
146
+ if (costDifference > 0) {
147
+ newChargeModel.additionalBookingGrossAmount += costDifference;
148
+ }
149
+ else {
150
+ newChargeModel.cancelledBookingGrossAmount += Math.abs(costDifference);
151
+ var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, Math.abs(costDifference));
152
+ newChargeModel.totalCancellationCharges += cancellationCharges;
153
+ }
154
+ newChargeModel.netTotal = newChargeModel.getNetAmount();
155
+ newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
156
+ if (newChargeModel.amountPayable > 0) {
157
+ newChargeModel.refundPayable = 0;
158
+ }
159
+ else {
160
+ newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
161
+ newChargeModel.amountPayable = 0;
162
+ }
163
+ return newChargeModel;
164
+ };
165
+ ChargesModel.prototype.clone = function () {
166
+ var that = new ChargesModel(this.initialBookingGrossAmount, this.amountPaid, this.couponCode, this.discountPolicy);
167
+ Object.assign(that, this);
168
+ return that;
169
+ };
170
+ ChargesModel.prototype.modifyDelete = function (bookingCode, cancellationUnit) {
171
+ var newChargeModel = this.clone();
172
+ newChargeModel.couponCode = "";
173
+ var costDifference = bookingCode.getCost();
174
+ newChargeModel.cancelledBookingGrossAmount += costDifference;
175
+ var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
176
+ newChargeModel.totalCancellationCharges += cancellationCharges;
177
+ newChargeModel.netTotal = newChargeModel.getNetAmount();
178
+ newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
179
+ if (newChargeModel.amountPayable > 0) {
180
+ newChargeModel.refundPayable = 0;
181
+ }
182
+ else {
183
+ newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
184
+ newChargeModel.amountPayable = 0;
185
+ }
186
+ return newChargeModel;
187
+ };
188
+ ChargesModel.getInstanceByInterface = function (bookingDetailsEntity, discountPolicy) {
189
+ if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
190
+ var chargesModel = new ChargesModel(bookingDetailsEntity.initialBookingGrossAmount, bookingDetailsEntity.amountPaid, bookingDetailsEntity.couponCode, discountPolicy);
191
+ Object.assign(chargesModel, bookingDetailsEntity);
192
+ return chargesModel;
193
+ };
194
+ ChargesModel.assignByInterface = function (bookingDetailsEntity, discountPolicy) {
195
+ if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
196
+ var newChargeModel = new ChargesModel(bookingDetailsEntity.initialBookingGrossAmount, bookingDetailsEntity.amountPaid, bookingDetailsEntity.couponCode, discountPolicy);
197
+ newChargeModel.additionalBookingGrossAmount =
198
+ bookingDetailsEntity.additionalBookingGrossAmount;
199
+ newChargeModel.initialBookingGrossAmount =
200
+ bookingDetailsEntity.initialBookingGrossAmount;
201
+ newChargeModel.cancelledBookingGrossAmount =
202
+ bookingDetailsEntity.cancelledBookingGrossAmount;
203
+ newChargeModel.refundPayable = bookingDetailsEntity.refundPayable;
204
+ newChargeModel.totalRefundedAmount =
205
+ bookingDetailsEntity.totalRefundedAmount;
206
+ newChargeModel.amountPaid = bookingDetailsEntity.amountPaid;
207
+ newChargeModel.totalCancellationCharges =
208
+ bookingDetailsEntity.totalCancellationCharges;
209
+ newChargeModel.netTotal = bookingDetailsEntity.netTotal;
210
+ newChargeModel.couponCode = bookingDetailsEntity.couponCode;
211
+ newChargeModel.amountPayable = bookingDetailsEntity.amountPayable;
212
+ return newChargeModel;
213
+ };
214
+ ChargesModel.prototype.getTotalAmount = function () {
215
+ return this.getNetAmount() + this.totalCancellationCharges;
216
+ };
217
+ ChargesModel.prototype.getPaymentStatus = function () {
218
+ var payableRefundAmount = this.getPayableRefundAmount();
219
+ return payableRefundAmount < 0
220
+ ? "Refund"
221
+ : payableRefundAmount === 0
222
+ ? "Paid"
223
+ : "Pending";
224
+ };
225
+ return ChargesModel;
226
+ }());
227
+ exports.ChargesModel = ChargesModel;
@@ -0,0 +1,18 @@
1
+ export declare class TimeSlot {
2
+ fromTime: string;
3
+ toTime: string;
4
+ constructor(fromTime: string, toTime: string);
5
+ isOverLap(timeSlot: TimeSlot): boolean;
6
+ getOverlapTime(timeSlot: TimeSlot): TimeSlot | null;
7
+ getNonOverlapTimeSlots(existingPriceSlot: TimeSlot): string[];
8
+ getStartMinutes(): number;
9
+ getEndMinutes(): number;
10
+ getHalfHourMinutes(): number[];
11
+ getHalfHourTimeCodes(): string[];
12
+ getHalfHourTimeRangeCodes(): string[];
13
+ getTotalMinutes(): number;
14
+ static convertToCode(minute: number): string;
15
+ static _getMinutes(timeCode: string): number;
16
+ static getHalfHourTimeCodes(): string[];
17
+ static getHalfHourTimeRangeCodes(): string[];
18
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimeSlot = void 0;
4
+ var TimeSlot = /** @class */ (function () {
5
+ function TimeSlot(fromTime, toTime) {
6
+ this.fromTime = fromTime;
7
+ this.toTime = toTime;
8
+ }
9
+ TimeSlot.prototype.isOverLap = function (timeSlot) {
10
+ return this.fromTime < timeSlot.toTime && this.toTime > timeSlot.fromTime;
11
+ };
12
+ TimeSlot.prototype.getOverlapTime = function (timeSlot) {
13
+ if (!this.isOverLap(timeSlot)) {
14
+ return null;
15
+ }
16
+ return new TimeSlot(this.fromTime > timeSlot.fromTime ? this.fromTime : timeSlot.fromTime, this.toTime < timeSlot.toTime ? this.toTime : timeSlot.toTime);
17
+ };
18
+ TimeSlot.prototype.getNonOverlapTimeSlots = function (existingPriceSlot) {
19
+ var overLapFromTime = this.fromTime > existingPriceSlot.fromTime
20
+ ? this.fromTime
21
+ : existingPriceSlot.fromTime;
22
+ var overLapToTime = this.toTime < existingPriceSlot.toTime
23
+ ? this.toTime
24
+ : existingPriceSlot.toTime;
25
+ var nonOverlapTimeSlots = [];
26
+ if (existingPriceSlot.fromTime < overLapFromTime) {
27
+ nonOverlapTimeSlots.push("".concat(existingPriceSlot.fromTime).concat(overLapFromTime));
28
+ }
29
+ if (existingPriceSlot.toTime > overLapToTime) {
30
+ nonOverlapTimeSlots.push("".concat(overLapToTime).concat(existingPriceSlot.toTime));
31
+ }
32
+ return nonOverlapTimeSlots;
33
+ };
34
+ TimeSlot.prototype.getStartMinutes = function () {
35
+ return TimeSlot._getMinutes(this.fromTime);
36
+ };
37
+ TimeSlot.prototype.getEndMinutes = function () {
38
+ return TimeSlot._getMinutes(this.toTime);
39
+ };
40
+ TimeSlot.prototype.getHalfHourMinutes = function () {
41
+ var minutes = [this.getStartMinutes()];
42
+ var endMinutes = this.getEndMinutes();
43
+ while (minutes[minutes.length - 1] < endMinutes) {
44
+ minutes.push(minutes[minutes.length - 1] + 30);
45
+ }
46
+ return minutes;
47
+ };
48
+ TimeSlot.prototype.getHalfHourTimeCodes = function () {
49
+ return this.getHalfHourMinutes().map(function (minute) {
50
+ return TimeSlot.convertToCode(minute);
51
+ });
52
+ };
53
+ TimeSlot.prototype.getHalfHourTimeRangeCodes = function () {
54
+ var halfHourCodes = this.getHalfHourTimeCodes();
55
+ var halfHourRangeCodes = [];
56
+ for (var index = 0; index < halfHourCodes.length - 1; index++) {
57
+ halfHourRangeCodes.push(halfHourCodes[index] + halfHourCodes[index + 1]);
58
+ }
59
+ return halfHourRangeCodes;
60
+ };
61
+ TimeSlot.prototype.getTotalMinutes = function () {
62
+ return this.getEndMinutes() - this.getStartMinutes();
63
+ };
64
+ // static padStart(timeCode: string, length: number, padString: string): string {
65
+ // return timeCode.padStart(length, padString);
66
+ // }
67
+ TimeSlot.convertToCode = function (minute) {
68
+ return "".concat(Math.floor(minute / 60)
69
+ .toString()
70
+ .padStart(2, "0")).concat(Math.floor(minute % 60)
71
+ .toString()
72
+ .padStart(2, "0"));
73
+ };
74
+ TimeSlot._getMinutes = function (timeCode) {
75
+ return parseInt(timeCode.slice(0, 2)) * 60 + parseInt(timeCode.slice(2, 4));
76
+ };
77
+ TimeSlot.getHalfHourTimeCodes = function () {
78
+ var minutes = [0];
79
+ var endMinutes = 24 * 60;
80
+ while (minutes[minutes.length - 1] < endMinutes) {
81
+ minutes.push(minutes[minutes.length - 1] + 30);
82
+ }
83
+ return minutes.map(function (minute) { return TimeSlot.convertToCode(minute); });
84
+ };
85
+ TimeSlot.getHalfHourTimeRangeCodes = function () {
86
+ var halfHourCodes = TimeSlot.getHalfHourTimeCodes();
87
+ var halfHourRangeCodes = [];
88
+ for (var index = 0; index < halfHourCodes.length - 1; index++) {
89
+ halfHourRangeCodes.push(halfHourCodes[index] + halfHourCodes[index + 1]);
90
+ }
91
+ return halfHourRangeCodes;
92
+ };
93
+ return TimeSlot;
94
+ }());
95
+ exports.TimeSlot = TimeSlot;
@@ -0,0 +1,5 @@
1
+ import { TAppBadRequestException } from "./types/app-badrequest-exception.type";
2
+ export declare class AppBadRequestException extends Error {
3
+ appBadRequestException: TAppBadRequestException;
4
+ constructor(appBadRequestException: TAppBadRequestException);
5
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.AppBadRequestException = void 0;
19
+ var AppBadRequestException = /** @class */ (function (_super) {
20
+ __extends(AppBadRequestException, _super);
21
+ function AppBadRequestException(appBadRequestException) {
22
+ var _this = _super.call(this) || this;
23
+ _this.appBadRequestException = appBadRequestException;
24
+ return _this;
25
+ }
26
+ return AppBadRequestException;
27
+ }(Error));
28
+ exports.AppBadRequestException = AppBadRequestException;
@@ -0,0 +1,4 @@
1
+ export type TAppBadRequestException = {
2
+ key: string;
3
+ message: string[];
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,71 @@
1
+ import { TimeSlot } from "../time-slot-module/time-slot-model";
2
+ import { IGetBookingCodesPerThirtyMinutes } from "./interfaces/get-booking-codes-per-thirty-min.interface";
3
+ export declare class BookingCode {
4
+ code: string;
5
+ turfid: string;
6
+ pitchCode: string;
7
+ slot: string;
8
+ fromTime: string;
9
+ toTime: string;
10
+ date: string;
11
+ cost: string;
12
+ constructor(code: string, cost?: string);
13
+ parse(): BookingCode;
14
+ getBookingTimeInMinutes(): number;
15
+ getPitchNo(): number;
16
+ getHalfHourTimeCodes(): string[];
17
+ /**
18
+ *
19
+ * @returns {Array<string>} - List of half hour time slot codes between start time & end time inclusive
20
+ * @example fromTime: 0000; toTime: 0130
21
+ * // returns ['00000030','00300100','01000130']
22
+ */
23
+ getHalfHourTimeRangeCodes(): string[];
24
+ getValidDate(): Date;
25
+ getDateCode(): string;
26
+ getWeekday(): number;
27
+ getMonthCode(): string;
28
+ getDateWithFromTimeCode(): string;
29
+ getCodeWithoutTurfCode(): string;
30
+ static sortByCode(bookingCodes: BookingCode[]): void;
31
+ static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
32
+ static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean): number;
33
+ static getDiscountAmount(couponCode: string, totalCost: number): number;
34
+ static isValidDate(date: string): boolean;
35
+ static parseDateCode(dateCode: string): Date;
36
+ static getWeekday(dateCode: number): number;
37
+ static convertToDate(str: string): Date;
38
+ static previousDateChecker(fromDate: number, index: number, errorKey?: string): void;
39
+ static previousTimeChecker(fromTime: string, fromDate: number, index: number): void;
40
+ static getDateCodesByWeek(fromDate: number, toDate: number, selectedWeekday: number): string[];
41
+ static getDatesByWeek(fromDate: number, toDate: number, selectedWeekday: number): Date[];
42
+ static isValidTimeRange(timeSlot: string): boolean;
43
+ static dateFormat(dates: Array<Date>): Array<string>;
44
+ static getDateCode(date: Date): string;
45
+ /**
46
+ * Returns list of month codes (YYMM) in the Date range inclusive
47
+ * @param {Date} from - Start Date
48
+ * @param {Date} to - End Date
49
+ * @return {Array<Number>} - The array of month codes (YYMM)
50
+ */
51
+ static getMonthCodesRange(from: Date, to: Date): number[];
52
+ static getNMonthCodes(n: number): number[];
53
+ static getCodes(fromDate: number, toDate: number, weekday: number, turfId: number, from: string, to: string): string[];
54
+ static getNextDayDateCode(dateCode: number): number;
55
+ getUtcDateWithTime(dateCodeWithTime: string): Date;
56
+ static getUtcDateWithTime(dateCodeWithTime: string): Date;
57
+ getNoOfHoursDifference(): number;
58
+ static getBookingCodesPerThirtyMinutes(from: string, to: string, bookingDate: string): IGetBookingCodesPerThirtyMinutes[];
59
+ static getCostPerThirtyMinutes(bookingCodePerThirtyMinutesPerSlot: {
60
+ slotCodePerThirtyMinute: string;
61
+ bookingDate: string;
62
+ }[], pricePerThirtyMinutesData: {
63
+ [date: string]: {
64
+ [time: string]: number;
65
+ };
66
+ }): string;
67
+ static padBookingCode(bookingCodeWithoutTurfCode: string): string;
68
+ static getInstance(turfId: number, bookingCodeWithoutTurfCode: string): BookingCode;
69
+ getCost(): number;
70
+ getTimeslot(): TimeSlot;
71
+ }