turf-common 1.2.1-beta.9 → 1.3.1-beta.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/@enum.d.ts +1 -0
- package/build/@enum.js +1 -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/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-booking-history.interface.d.ts +4 -0
- package/build/interface/api/get-booking-history.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 +35 -1
- package/build/models/booking-code-model.js +91 -6
- package/build/models/charge-model.d.ts +3 -2
- package/build/models/charge-model.js +48 -9
- 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 +40 -0
- package/build/utils/date-util.js +89 -1
- package/build/utils/string-utils.d.ts +11 -0
- package/build/utils/string-utils.js +22 -0
- package/package.json +1 -1
package/build/@enum.d.ts
CHANGED
package/build/@enum.js
CHANGED
|
@@ -39,3 +39,4 @@ __exportStar(require("./enums/timezone.enum"), exports);
|
|
|
39
39
|
__exportStar(require("./enums/bookings-status.enum"), exports);
|
|
40
40
|
__exportStar(require("./enums/organization-type.enum"), exports);
|
|
41
41
|
__exportStar(require("./enums/environment.enum"), exports);
|
|
42
|
+
__exportStar(require("./enums/availability-view.enum"), exports);
|
package/build/@model.d.ts
CHANGED
package/build/@model.js
CHANGED
|
@@ -22,3 +22,4 @@ __exportStar(require("./models/pitch-slab-model"), exports);
|
|
|
22
22
|
__exportStar(require("./models/pricing-plan-model"), exports);
|
|
23
23
|
__exportStar(require("./models/subscribed-pricing-plan-model"), exports);
|
|
24
24
|
__exportStar(require("./models/entity"), exports);
|
|
25
|
+
__exportStar(require("./models/turf-availability-model"), exports);
|
package/build/@type.d.ts
CHANGED
|
@@ -29,3 +29,5 @@ export * from "./interface/modify-entity.interface";
|
|
|
29
29
|
export * from "./interface/key-value.interface";
|
|
30
30
|
export * from "./interface/ui/upgrade-subscription-data.interface";
|
|
31
31
|
export * from "./interface/ui/booking-data.interface";
|
|
32
|
+
export * from "./interface/ng-date-structure.interface";
|
|
33
|
+
export * from "./interface/convert-to-midnight-time.interface";
|
package/build/@type.js
CHANGED
|
@@ -46,3 +46,5 @@ __exportStar(require("./interface/key-value.interface"), exports);
|
|
|
46
46
|
// changes for the ui
|
|
47
47
|
__exportStar(require("./interface/ui/upgrade-subscription-data.interface"), exports);
|
|
48
48
|
__exportStar(require("./interface/ui/booking-data.interface"), exports);
|
|
49
|
+
__exportStar(require("./interface/ng-date-structure.interface"), exports);
|
|
50
|
+
__exportStar(require("./interface/convert-to-midnight-time.interface"), exports);
|
package/build/@utils.d.ts
CHANGED
package/build/@utils.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./interface/api/utils"), exports);
|
|
|
18
18
|
__exportStar(require("./utils/string-utils"), exports);
|
|
19
19
|
__exportStar(require("./utils/date-util"), exports);
|
|
20
20
|
__exportStar(require("./utils/math-util"), exports);
|
|
21
|
+
__exportStar(require("./utils/constant"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AvailabilityView = void 0;
|
|
4
|
+
var AvailabilityView;
|
|
5
|
+
(function (AvailabilityView) {
|
|
6
|
+
AvailabilityView["NORMAL"] = "normal";
|
|
7
|
+
AvailabilityView["MERGED"] = "merged";
|
|
8
|
+
})(AvailabilityView || (exports.AvailabilityView = AvailabilityView = {}));
|
|
@@ -5,6 +5,8 @@ export declare enum BookingHistoryOperationType {
|
|
|
5
5
|
DELETE_INSERT = "delete_insert",
|
|
6
6
|
DELETE_SLOT = "delete_slot",
|
|
7
7
|
REFUND = "refund",
|
|
8
|
-
PAYMENT = "payment"
|
|
8
|
+
PAYMENT = "payment",
|
|
9
|
+
MERGED = "merged",
|
|
10
|
+
DELETE_SLOT_EVENT = "delete_slot_event"
|
|
9
11
|
}
|
|
10
|
-
export declare const
|
|
12
|
+
export declare const OPERATION_TYPES: BookingHistoryOperationType[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OPERATION_TYPES = exports.BookingHistoryOperationType = void 0;
|
|
4
4
|
var BookingHistoryOperationType;
|
|
5
5
|
(function (BookingHistoryOperationType) {
|
|
6
6
|
BookingHistoryOperationType["DELETE"] = "delete";
|
|
@@ -10,8 +10,10 @@ var BookingHistoryOperationType;
|
|
|
10
10
|
BookingHistoryOperationType["DELETE_SLOT"] = "delete_slot";
|
|
11
11
|
BookingHistoryOperationType["REFUND"] = "refund";
|
|
12
12
|
BookingHistoryOperationType["PAYMENT"] = "payment";
|
|
13
|
+
BookingHistoryOperationType["MERGED"] = "merged";
|
|
14
|
+
BookingHistoryOperationType["DELETE_SLOT_EVENT"] = "delete_slot_event";
|
|
13
15
|
})(BookingHistoryOperationType || (exports.BookingHistoryOperationType = BookingHistoryOperationType = {}));
|
|
14
|
-
exports.
|
|
16
|
+
exports.OPERATION_TYPES = [
|
|
15
17
|
BookingHistoryOperationType.DELETE,
|
|
16
18
|
BookingHistoryOperationType.REFUND,
|
|
17
19
|
BookingHistoryOperationType.PAYMENT,
|
|
@@ -5,4 +5,6 @@ var ValidCouponType;
|
|
|
5
5
|
(function (ValidCouponType) {
|
|
6
6
|
ValidCouponType["PERCENTAGE"] = "percentage";
|
|
7
7
|
ValidCouponType["UNIT"] = "unit";
|
|
8
|
+
ValidCouponType["PER_HOUR_UNIT"] = "per hour unit";
|
|
9
|
+
ValidCouponType["PER_HOUR_PERCENTAGE"] = "per hour percentage";
|
|
8
10
|
})(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PaymentMode, BookingDetailsStatus } from "../../@enum";
|
|
2
|
-
import { IBookingDetailsEntity, IModifyEntity } from "../../@type";
|
|
2
|
+
import { IBookingDetailsEntity, IGetAvailabilityByTurf, IModifyEntity } from "../../@type";
|
|
3
3
|
export interface ICreateRecurringSlotBookingResponse extends IModifyEntity<IBookingDetailsEntity> {
|
|
4
4
|
}
|
|
5
5
|
export interface ICreateRecurringSlotsBookingDetailsRequest {
|
|
@@ -16,6 +16,9 @@ export interface ICreateRecurringSlotsBookingDetailsRequest {
|
|
|
16
16
|
sport: string;
|
|
17
17
|
remarks?: string | null;
|
|
18
18
|
slot: IRecurringSlot[];
|
|
19
|
+
turf_slot?: {
|
|
20
|
+
availability_details: IGetAvailabilityByTurf;
|
|
21
|
+
};
|
|
19
22
|
}
|
|
20
23
|
export declare class IRecurringSlot {
|
|
21
24
|
fromDate: number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BookingDetailsStatus } from "../../@enum";
|
|
2
|
+
import { AvailabilityView } from "../../enums/availability-view.enum";
|
|
3
|
+
export interface IGetAvailabilityByTurfRequest {
|
|
4
|
+
dateRange: string;
|
|
5
|
+
timeRange?: string;
|
|
6
|
+
pitch: string;
|
|
7
|
+
view: AvailabilityView;
|
|
8
|
+
weekDays: number[];
|
|
9
|
+
}
|
|
10
|
+
export interface IGetAvailabilityByTurf {
|
|
11
|
+
[dateCode: string]: IAvailabilityData;
|
|
12
|
+
}
|
|
13
|
+
export interface ITurfAvailabilityDetails {
|
|
14
|
+
[pitchId: string]: ITurfAvailabilityDetail;
|
|
15
|
+
}
|
|
16
|
+
export interface ITurfAvailabilityDetail {
|
|
17
|
+
price: number;
|
|
18
|
+
bookingId?: number;
|
|
19
|
+
status?: BookingDetailsStatus;
|
|
20
|
+
priceSlot?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface IAvailabilityData {
|
|
23
|
+
[timeSlot: string]: ITurfAvailabilityBooking;
|
|
24
|
+
}
|
|
25
|
+
export interface ITurfAvailabilityBooking {
|
|
26
|
+
available: number[];
|
|
27
|
+
notavailable: number[];
|
|
28
|
+
details: ITurfAvailabilityDetails;
|
|
29
|
+
}
|
|
@@ -73,3 +73,5 @@ export * from "./get-cancelled-booking.interface";
|
|
|
73
73
|
export * from "./get-sports.interface";
|
|
74
74
|
export * from "../entity/sports-entity.interface";
|
|
75
75
|
export * from "../api/update-sports-interface";
|
|
76
|
+
export * from "./get-availability-by-turf.interface";
|
|
77
|
+
export * from "./get-tournament.interface";
|
|
@@ -91,3 +91,5 @@ __exportStar(require("./get-cancelled-booking.interface"), exports);
|
|
|
91
91
|
__exportStar(require("./get-sports.interface"), exports);
|
|
92
92
|
__exportStar(require("../entity/sports-entity.interface"), exports);
|
|
93
93
|
__exportStar(require("../api/update-sports-interface"), exports);
|
|
94
|
+
__exportStar(require("./get-availability-by-turf.interface"), exports);
|
|
95
|
+
__exportStar(require("./get-tournament.interface"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BookingDetailsStatus } from "../../@enum";
|
|
1
2
|
import { BookingHistoryOperationType } from "../../enums/booking-history-operation-type.enum";
|
|
2
3
|
import { PaymentMode } from "../../enums/payment-mode.enum";
|
|
3
4
|
import { IEntityAuditColumn } from "./entity-audit-column.interface";
|
|
@@ -28,4 +29,7 @@ export interface IBookingHistoryEntity extends IEntityAuditColumn {
|
|
|
28
29
|
amountPayable: number;
|
|
29
30
|
refundPayable: number;
|
|
30
31
|
totalRefundedAmount: number;
|
|
32
|
+
type: string | null;
|
|
33
|
+
totalBookingHours: number;
|
|
34
|
+
status: BookingDetailsStatus;
|
|
31
35
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BookingDetailsStatus, PaymentMode, UserType } from "../@enum";
|
|
2
|
-
|
|
2
|
+
import { IBookingDetailsEntity } from "./entity";
|
|
3
|
+
export interface IGetBookingById extends Omit<IBookingDetailsEntity, "createdBy" | "updatedBy"> {
|
|
3
4
|
id: number;
|
|
4
5
|
customerName: string;
|
|
5
6
|
contact: string;
|
|
@@ -8,8 +9,6 @@ export interface IGetBookingById {
|
|
|
8
9
|
totalCost: number;
|
|
9
10
|
discountedCost: number;
|
|
10
11
|
amountPaid: number;
|
|
11
|
-
createdOn: Date;
|
|
12
|
-
updatedOn: Date;
|
|
13
12
|
createdBy: {
|
|
14
13
|
firstname: string;
|
|
15
14
|
type: UserType;
|
|
@@ -33,7 +33,7 @@ export declare class BookingCode {
|
|
|
33
33
|
getCodeWithoutTurfCode(): string;
|
|
34
34
|
static sortByCode(bookingCodes: BookingCode[]): void;
|
|
35
35
|
static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
|
|
36
|
-
static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean): number;
|
|
36
|
+
static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
|
|
37
37
|
static getDiscountAmount(couponCode: string, totalCost: number): number;
|
|
38
38
|
static isValidDate(date: string): boolean;
|
|
39
39
|
static parseDateCode(dateCode: string): Date;
|
|
@@ -70,6 +70,13 @@ export declare class BookingCode {
|
|
|
70
70
|
}): string;
|
|
71
71
|
static padBookingCode(bookingCodeWithoutTurfCode: string): string;
|
|
72
72
|
static getInstance(turfId: number, bookingCodeWithoutTurfCode: string): BookingCode;
|
|
73
|
+
/**
|
|
74
|
+
* Extracts the numeric part of a bookingCode, excluding a predefined deleted slot separator.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} bookingCode - The input bookingCode to extract from.
|
|
77
|
+
* @returns {string} The numeric part of the bookingCode.
|
|
78
|
+
*/
|
|
79
|
+
static extractBookingCodeByDeletedSlotSeparator: (bookingCode: string) => string;
|
|
73
80
|
getCost(): number;
|
|
74
81
|
getTimeslot(): TimeSlot;
|
|
75
82
|
static getIndianTimeZoneDate(bookingBufferOffsetHour?: number): Date;
|
|
@@ -86,4 +93,31 @@ export declare class BookingCode {
|
|
|
86
93
|
formatDateAndTime(formateDateAndTime: IFormateDateAndTime): string;
|
|
87
94
|
static timeFormatter(timeFormatter: ITimeFormatter): string;
|
|
88
95
|
static dateFormatter(dateFormatter: IDateFormatter): string;
|
|
96
|
+
/**
|
|
97
|
+
* Calculates the total time difference between two date codes.
|
|
98
|
+
* @param unit - Optional. Specifies the unit of time for the result. Valid values are "minute" or "hr". Defaults to "minute" if not provided.
|
|
99
|
+
* @returns The total time difference in the specified unit (minutes or hours) between the "from" and "to" date codes.
|
|
100
|
+
*/
|
|
101
|
+
getTotalTime(unit?: "minute" | "hr"): number;
|
|
102
|
+
/**
|
|
103
|
+
* Gets the date codes across a time range.
|
|
104
|
+
*
|
|
105
|
+
* @returns An object containing the date codes for the from and to time.
|
|
106
|
+
* @description
|
|
107
|
+
* The `fromDateCode` is generated by combining the current instance's `dateCode` and `fromTimeCode`.
|
|
108
|
+
* The `toDateCode` is generated based on the `fromTimeCode` and `toTimeCode`. If `fromTimeCode` is greater
|
|
109
|
+
* than `toTimeCode`, it adds one day to the current instance's `dateCode`.
|
|
110
|
+
*/
|
|
111
|
+
getAcrossDateCodes(): {
|
|
112
|
+
fromDateCode: string;
|
|
113
|
+
toDateCode: string;
|
|
114
|
+
};
|
|
115
|
+
static getTotalTimeByBookingCodes(bookingCodes: BookingCode[]): number;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves booking codes for a booking scenario that may span across different days.
|
|
118
|
+
* If the booking spans multiple days, two codes are generated for each day; otherwise, a single code is used.
|
|
119
|
+
*
|
|
120
|
+
* @returns {string[]} An array containing the booking codes.
|
|
121
|
+
*/
|
|
122
|
+
getBookingCodesByAcrossDateBookingCode(): string[];
|
|
89
123
|
}
|
|
@@ -17,6 +17,7 @@ var charge_model_1 = require("./charge-model");
|
|
|
17
17
|
var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
|
|
18
18
|
var date_util_1 = require("../utils/date-util");
|
|
19
19
|
var date_fns_1 = require("date-fns");
|
|
20
|
+
var _utils_1 = require("../@utils");
|
|
20
21
|
var BookingCode = /** @class */ (function () {
|
|
21
22
|
function BookingCode(code, cost) {
|
|
22
23
|
if (cost === void 0) { cost = "-1"; }
|
|
@@ -116,12 +117,20 @@ var BookingCode = /** @class */ (function () {
|
|
|
116
117
|
var code = turfId + bookingDate + fhfm + thtm + pitchCode;
|
|
117
118
|
return code;
|
|
118
119
|
};
|
|
119
|
-
BookingCode.getDiscountedCost = function (couponCode, totalCost, validationApply) {
|
|
120
|
+
BookingCode.getDiscountedCost = function (couponCode, totalCost, validationApply, totalBookingHours) {
|
|
120
121
|
if (validationApply === void 0) { validationApply = true; }
|
|
121
122
|
var discount = 0;
|
|
122
123
|
var discountedCost = 0;
|
|
123
124
|
if (couponCode) {
|
|
124
|
-
|
|
125
|
+
var code = _utils_1.stringUtil.getCouponDetails(couponCode).code;
|
|
126
|
+
var value = _utils_1.stringUtil.getCouponDetails(couponCode).value;
|
|
127
|
+
if (validationApply && !code && !value) {
|
|
128
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
129
|
+
key: "couponCode",
|
|
130
|
+
message: ["Coupon with code ".concat(couponCode, " is wrong ")],
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (code === "P" || code === "PHP") {
|
|
125
134
|
var percentDiscount = parseFloat(couponCode);
|
|
126
135
|
if (validationApply) {
|
|
127
136
|
if (percentDiscount > 90) {
|
|
@@ -133,9 +142,20 @@ var BookingCode = /** @class */ (function () {
|
|
|
133
142
|
}
|
|
134
143
|
discount = totalCost * (percentDiscount / 100);
|
|
135
144
|
}
|
|
136
|
-
else if (
|
|
145
|
+
else if (code === "U") {
|
|
137
146
|
discount = parseFloat(couponCode);
|
|
138
147
|
}
|
|
148
|
+
else if (code === "PHU") {
|
|
149
|
+
if (totalBookingHours === undefined) {
|
|
150
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
151
|
+
key: "totalBookingHours",
|
|
152
|
+
message: [
|
|
153
|
+
"Total Booking Hours is mandatory to calculate per hour unit",
|
|
154
|
+
],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
discount = parseFloat(couponCode) * totalBookingHours;
|
|
158
|
+
}
|
|
139
159
|
}
|
|
140
160
|
discountedCost = totalCost - discount;
|
|
141
161
|
return Math.round(discountedCost);
|
|
@@ -481,6 +501,9 @@ var BookingCode = /** @class */ (function () {
|
|
|
481
501
|
};
|
|
482
502
|
BookingCode.prototype.formatDateAndTime = function (formateDateAndTime) {
|
|
483
503
|
var dateFormat = formateDateAndTime.dateFormat, timeFormat = formateDateAndTime.timeFormat, separator = formateDateAndTime.separator, timeSeparator = formateDateAndTime.timeSeparator;
|
|
504
|
+
this.toTimeCode = date_util_1.dateUtilService
|
|
505
|
+
.handle2400HourInDateCode("".concat(this.dateCode).concat(this.toTimeCode))
|
|
506
|
+
.slice(-4);
|
|
484
507
|
var formattedDate = BookingCode.dateFormatter({
|
|
485
508
|
dateFormat: dateFormat,
|
|
486
509
|
dateCode: this.dateCode,
|
|
@@ -496,14 +519,76 @@ var BookingCode = /** @class */ (function () {
|
|
|
496
519
|
return "".concat(formattedDate).concat(separator).concat(formattedFromTime).concat(timeSeparator).concat(formattedToTime);
|
|
497
520
|
};
|
|
498
521
|
BookingCode.timeFormatter = function (timeFormatter) {
|
|
499
|
-
var
|
|
500
|
-
|
|
501
|
-
return (0, date_fns_1.format)(parsedFromTime, timeFormat);
|
|
522
|
+
var parsedFromTime = (0, date_fns_1.parse)(timeFormatter.timeCode, "HHmm", new Date());
|
|
523
|
+
return (0, date_fns_1.format)(parsedFromTime, timeFormatter.timeFormat);
|
|
502
524
|
};
|
|
503
525
|
BookingCode.dateFormatter = function (dateFormatter) {
|
|
504
526
|
var dateFormat = dateFormatter.dateFormat, dateCode = dateFormatter.dateCode;
|
|
505
527
|
return (0, date_fns_1.format)(BookingCode.convertToDate(dateCode), dateFormat);
|
|
506
528
|
};
|
|
529
|
+
/**
|
|
530
|
+
* Calculates the total time difference between two date codes.
|
|
531
|
+
* @param unit - Optional. Specifies the unit of time for the result. Valid values are "minute" or "hr". Defaults to "minute" if not provided.
|
|
532
|
+
* @returns The total time difference in the specified unit (minutes or hours) between the "from" and "to" date codes.
|
|
533
|
+
*/
|
|
534
|
+
BookingCode.prototype.getTotalTime = function (unit) {
|
|
535
|
+
if (unit === void 0) { unit = "minute"; }
|
|
536
|
+
return date_util_1.dateUtilService.calculateDateDifference(this.getAcrossDateCodes().fromDateCode, this.getAcrossDateCodes().toDateCode, unit);
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
* Gets the date codes across a time range.
|
|
540
|
+
*
|
|
541
|
+
* @returns An object containing the date codes for the from and to time.
|
|
542
|
+
* @description
|
|
543
|
+
* The `fromDateCode` is generated by combining the current instance's `dateCode` and `fromTimeCode`.
|
|
544
|
+
* The `toDateCode` is generated based on the `fromTimeCode` and `toTimeCode`. If `fromTimeCode` is greater
|
|
545
|
+
* than `toTimeCode`, it adds one day to the current instance's `dateCode`.
|
|
546
|
+
*/
|
|
547
|
+
BookingCode.prototype.getAcrossDateCodes = function () {
|
|
548
|
+
var fromDateCode = "".concat(this.dateCode).concat(this.fromTimeCode);
|
|
549
|
+
var toDateCode = "".concat(this.fromTimeCode > this.toTimeCode
|
|
550
|
+
? date_util_1.dateUtilService.addNDaysToDateCode(this.dateCode, 1)
|
|
551
|
+
: this.dateCode).concat(this.toTimeCode);
|
|
552
|
+
return { fromDateCode: fromDateCode, toDateCode: toDateCode };
|
|
553
|
+
};
|
|
554
|
+
BookingCode.getTotalTimeByBookingCodes = function (bookingCodes) {
|
|
555
|
+
var totalBookingHours = 0;
|
|
556
|
+
bookingCodes.forEach(function (bookingCode) {
|
|
557
|
+
totalBookingHours += new BookingCode(bookingCode.code).getTotalTime("hr");
|
|
558
|
+
});
|
|
559
|
+
return totalBookingHours;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* Retrieves booking codes for a booking scenario that may span across different days.
|
|
563
|
+
* If the booking spans multiple days, two codes are generated for each day; otherwise, a single code is used.
|
|
564
|
+
*
|
|
565
|
+
* @returns {string[]} An array containing the booking codes.
|
|
566
|
+
*/
|
|
567
|
+
BookingCode.prototype.getBookingCodesByAcrossDateBookingCode = function () {
|
|
568
|
+
var bookingCodes = [];
|
|
569
|
+
// Check if the booking spans across different days
|
|
570
|
+
if (this.fromTimeCode > this.toTimeCode) {
|
|
571
|
+
var firstDayCode = "".concat(this.turfId).concat(this.dateCode).concat(this.fromTimeCode, "2400").concat(this.pitchCode);
|
|
572
|
+
var secondDayCode = "".concat(this.turfId).concat(date_util_1.dateUtilService.addNDaysToDateCode(this.dateCode, 1), "0000").concat(this.toTimeCode).concat(this.pitchCode);
|
|
573
|
+
bookingCodes.push(firstDayCode);
|
|
574
|
+
bookingCodes.push(secondDayCode);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
bookingCodes.push(this.code);
|
|
578
|
+
}
|
|
579
|
+
return bookingCodes;
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* Extracts the numeric part of a bookingCode, excluding a predefined deleted slot separator.
|
|
583
|
+
*
|
|
584
|
+
* @param {string} bookingCode - The input bookingCode to extract from.
|
|
585
|
+
* @returns {string} The numeric part of the bookingCode.
|
|
586
|
+
*/
|
|
587
|
+
BookingCode.extractBookingCodeByDeletedSlotSeparator = function (bookingCode) {
|
|
588
|
+
return bookingCode.startsWith(_utils_1.DELETED_SLOT_SEPARATOR)
|
|
589
|
+
? bookingCode.slice(_utils_1.DELETED_SLOT_SEPARATOR.length)
|
|
590
|
+
: bookingCode;
|
|
591
|
+
};
|
|
507
592
|
return BookingCode;
|
|
508
593
|
}());
|
|
509
594
|
exports.BookingCode = BookingCode;
|
|
@@ -11,14 +11,15 @@ export declare class ChargesModel implements IChargeModel {
|
|
|
11
11
|
amountPaid: number;
|
|
12
12
|
amountPayable: number;
|
|
13
13
|
totalRefundedAmount: number;
|
|
14
|
+
totalBookingHours: number;
|
|
14
15
|
couponCode: string;
|
|
15
16
|
discountPolicy: ModificationDiscountPolicy;
|
|
16
|
-
constructor(initialGrossAmount: number, paidAmount: number, couponCode: string, discountPolicy: ModificationDiscountPolicy);
|
|
17
|
+
constructor(initialGrossAmount: number, paidAmount: number, couponCode: string, totalBookingHours: number, discountPolicy: ModificationDiscountPolicy);
|
|
17
18
|
getGrossAmount(): number;
|
|
18
19
|
getNetAmount(): number;
|
|
19
20
|
getDiscountAmount(): number;
|
|
20
21
|
getPayableRefundAmount(): number;
|
|
21
|
-
static getDiscountAmount(couponCode: string, totalCost: number, validationApply?: boolean): number;
|
|
22
|
+
static getDiscountAmount(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
|
|
22
23
|
setValues(values?: Partial<ChargesModel>): ChargesModel;
|
|
23
24
|
modify(bookingModification: IBookingModification): ChargesModel | null;
|
|
24
25
|
private modifyExtend;
|
|
@@ -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,7 +226,7 @@ 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
|
};
|
|
@@ -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,44 @@ 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
|
+
* Handles the special case when the hours and minutes portion of the date code is set to "2400" by adjusting to the next day.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} dateCode - The original date code.
|
|
21
|
+
* @returns {string} The adjusted date code.
|
|
22
|
+
*/
|
|
23
|
+
handle2400HourInDateCode(dateTimeCode: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Adds or subtracts a specified number of months from a given date in YYMM format.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} dateCode - A string representing a date in YYMM format.
|
|
28
|
+
* @param {number} N - An integer representing the number of months to add or subtract.
|
|
29
|
+
* Use a positive value to add months and a negative value to subtract months.
|
|
30
|
+
* @returns {string} A string representing the resulting date in YYMM format.
|
|
31
|
+
*/
|
|
32
|
+
addNMonth(dateCode: string, N: number): string;
|
|
33
|
+
/**
|
|
34
|
+
* Gets an array of month codes between two specified dates (inclusive).
|
|
35
|
+
* 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.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} startDateCode - The starting date code in "yyMMdd" format.
|
|
38
|
+
* @param {string} endDateCode - The ending date code in "yyMMdd" format.
|
|
39
|
+
* @returns {number[]} An array of month codes representing each month between the start and end dates (inclusive).
|
|
40
|
+
* Each element in the array is a number in the "yyMM" format.
|
|
41
|
+
*/
|
|
42
|
+
getMonthRangeByDateCodes(startDateCode: string, endDateCode: string): number[];
|
|
43
|
+
convertToMidnight(time: IConvertToMidNightTime): IConvertToMidNightTime;
|
|
44
|
+
convertMonthsToNumber: (months: INgbDateStruct) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves booking date codes for a specified date range and weekdays.
|
|
47
|
+
*
|
|
48
|
+
* @param startDateCode - The starting date code for the date range.
|
|
49
|
+
* @param endDateCode - The ending date code for the date range.
|
|
50
|
+
* @param weekdays - An array of numbers representing weekdays (1 for Monday through 7 for Sunday).
|
|
51
|
+
* @returns An array of booking date codes based on the provided date range and weekdays.
|
|
52
|
+
*/
|
|
53
|
+
getBookingCodeByWeekDaysAndDateRange(startDateCode: string, endDateCode: string, weekdays: number[]): string[];
|
|
54
|
+
formatDate(date: Date, formatString: string): string;
|
|
15
55
|
}
|
|
16
56
|
export declare const dateUtilService: DateUtilService;
|
package/build/utils/date-util.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dateUtilService = exports.DateUtilService = void 0;
|
|
4
4
|
var date_fns_1 = require("date-fns");
|
|
5
|
+
var _model_1 = require("../@model");
|
|
5
6
|
var DateUtilService = /** @class */ (function () {
|
|
6
7
|
function DateUtilService() {
|
|
7
8
|
this.getDateFromDatabaseDate = function (date) { return (0, date_fns_1.parseISO)(date); };
|
|
@@ -10,6 +11,13 @@ var DateUtilService = /** @class */ (function () {
|
|
|
10
11
|
var dayDifference = Math.ceil((date2.getTime() - date1.getTime()) / oneDay);
|
|
11
12
|
return dayDifference - 1; //minus 1 day
|
|
12
13
|
};
|
|
14
|
+
this.convertMonthsToNumber = function (months) {
|
|
15
|
+
var year = months.year.toString().slice(2, 4);
|
|
16
|
+
var month = months.month.toString().padStart(2, "0");
|
|
17
|
+
var day = months.day.toString().padStart(2, "0");
|
|
18
|
+
var dates = year.concat(month).concat(day);
|
|
19
|
+
return "".concat(dates);
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
22
|
DateUtilService.prototype.getTodayCode = function () {
|
|
15
23
|
return (0, date_fns_1.format)(new Date(), "yyMMdd");
|
|
@@ -24,7 +32,10 @@ var DateUtilService = /** @class */ (function () {
|
|
|
24
32
|
return (0, date_fns_1.add)(date, { days: n });
|
|
25
33
|
};
|
|
26
34
|
DateUtilService.prototype.convertStringToDate = function (dateString, format) {
|
|
27
|
-
|
|
35
|
+
var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
|
|
36
|
+
// IST has a fixed offset of UTC+5:30
|
|
37
|
+
var indianDate = new Date(parsedDate.getTime() + 330 * 60 * 1000);
|
|
38
|
+
return indianDate;
|
|
28
39
|
};
|
|
29
40
|
DateUtilService.prototype.isInPast = function (date) {
|
|
30
41
|
return date < new Date();
|
|
@@ -63,6 +74,83 @@ var DateUtilService = /** @class */ (function () {
|
|
|
63
74
|
futureDate.setDate(today.getDate() + n);
|
|
64
75
|
return futureDate;
|
|
65
76
|
};
|
|
77
|
+
DateUtilService.prototype.calculateDateDifference = function (fromDateCode, toDateCode, unit) {
|
|
78
|
+
if (unit === void 0) { unit = "minute"; }
|
|
79
|
+
toDateCode = this.handle2400HourInDateCode(toDateCode);
|
|
80
|
+
var fromDate = (0, date_fns_1.parse)(fromDateCode, "yyMMddHHmm", new Date());
|
|
81
|
+
var toDate = (0, date_fns_1.parse)(toDateCode, "yyMMddHHmm", new Date());
|
|
82
|
+
var minutesDifference = (0, date_fns_1.differenceInMinutes)(toDate, fromDate);
|
|
83
|
+
return unit === "minute"
|
|
84
|
+
? minutesDifference
|
|
85
|
+
: parseFloat((minutesDifference / 60).toFixed(1));
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Handles the special case when the hours and minutes portion of the date code is set to "2400" by adjusting to the next day.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} dateCode - The original date code.
|
|
91
|
+
* @returns {string} The adjusted date code.
|
|
92
|
+
*/
|
|
93
|
+
DateUtilService.prototype.handle2400HourInDateCode = function (dateTimeCode) {
|
|
94
|
+
if (dateTimeCode.slice(-4, -2) === "24") {
|
|
95
|
+
dateTimeCode =
|
|
96
|
+
exports.dateUtilService.addNDaysToDateCode(dateTimeCode.slice(0, -4), 1) +
|
|
97
|
+
"00" +
|
|
98
|
+
dateTimeCode.slice(-2);
|
|
99
|
+
}
|
|
100
|
+
return dateTimeCode;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Adds or subtracts a specified number of months from a given date in YYMM format.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} dateCode - A string representing a date in YYMM format.
|
|
106
|
+
* @param {number} N - An integer representing the number of months to add or subtract.
|
|
107
|
+
* Use a positive value to add months and a negative value to subtract months.
|
|
108
|
+
* @returns {string} A string representing the resulting date in YYMM format.
|
|
109
|
+
*/
|
|
110
|
+
DateUtilService.prototype.addNMonth = function (dateCode, N) {
|
|
111
|
+
var date = (0, date_fns_1.parse)("20".concat(dateCode), "yyyyMM", new Date());
|
|
112
|
+
var resultDate = N >= 0 ? (0, date_fns_1.addMonths)(date, N) : (0, date_fns_1.subMonths)(date, Math.abs(N));
|
|
113
|
+
return (0, date_fns_1.format)(resultDate, "yyMM");
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Gets an array of month codes between two specified dates (inclusive).
|
|
117
|
+
* 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.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} startDateCode - The starting date code in "yyMMdd" format.
|
|
120
|
+
* @param {string} endDateCode - The ending date code in "yyMMdd" format.
|
|
121
|
+
* @returns {number[]} An array of month codes representing each month between the start and end dates (inclusive).
|
|
122
|
+
* Each element in the array is a number in the "yyMM" format.
|
|
123
|
+
*/
|
|
124
|
+
DateUtilService.prototype.getMonthRangeByDateCodes = function (startDateCode, endDateCode) {
|
|
125
|
+
var startDate = exports.dateUtilService.convertStringToDate(startDateCode, "yyMMdd");
|
|
126
|
+
var endDate = exports.dateUtilService.convertStringToDate(endDateCode, "yyMMdd");
|
|
127
|
+
return _model_1.BookingCode.getMonthCodesRange(startDate, endDate);
|
|
128
|
+
};
|
|
129
|
+
DateUtilService.prototype.convertToMidnight = function (time) {
|
|
130
|
+
if (time.hour === 0 && time.minute === 0)
|
|
131
|
+
return { hour: 24, minute: 0 };
|
|
132
|
+
return time;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves booking date codes for a specified date range and weekdays.
|
|
136
|
+
*
|
|
137
|
+
* @param startDateCode - The starting date code for the date range.
|
|
138
|
+
* @param endDateCode - The ending date code for the date range.
|
|
139
|
+
* @param weekdays - An array of numbers representing weekdays (1 for Monday through 7 for Sunday).
|
|
140
|
+
* @returns An array of booking date codes based on the provided date range and weekdays.
|
|
141
|
+
*/
|
|
142
|
+
DateUtilService.prototype.getBookingCodeByWeekDaysAndDateRange = function (startDateCode, endDateCode, weekdays) {
|
|
143
|
+
var bookingDateCodes = [];
|
|
144
|
+
weekdays.forEach(function (weekDay) {
|
|
145
|
+
var startDateCodeCopy = Number(startDateCode);
|
|
146
|
+
var endDateCodeCopy = Number(endDateCode);
|
|
147
|
+
bookingDateCodes.push.apply(bookingDateCodes, _model_1.BookingCode.getDateCodesByWeek(startDateCodeCopy, endDateCodeCopy, weekDay));
|
|
148
|
+
});
|
|
149
|
+
return bookingDateCodes.map(Number).sort().map(String);
|
|
150
|
+
};
|
|
151
|
+
DateUtilService.prototype.formatDate = function (date, formatString) {
|
|
152
|
+
return (0, date_fns_1.format)(date, formatString);
|
|
153
|
+
};
|
|
66
154
|
return DateUtilService;
|
|
67
155
|
}());
|
|
68
156
|
exports.DateUtilService = DateUtilService;
|
|
@@ -15,6 +15,17 @@ declare class StringUtil {
|
|
|
15
15
|
*/
|
|
16
16
|
formatStringWithHyphens(inputString: string): string;
|
|
17
17
|
generateRandomPassword(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts details from a coupon code.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} couponCode - The coupon code to analyze.
|
|
22
|
+
* @returns {Object} - Object with 'code' (alphabetic part) and 'value' (numeric part) properties.
|
|
23
|
+
* @throws {TypeError} - If the provided 'couponCode' is not a string.
|
|
24
|
+
*/
|
|
25
|
+
getCouponDetails(couponCode: string): {
|
|
26
|
+
code: string;
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
18
29
|
}
|
|
19
30
|
export declare const stringUtil: StringUtil;
|
|
20
31
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stringUtil = void 0;
|
|
4
|
+
var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
|
|
4
5
|
var StringUtil = /** @class */ (function () {
|
|
5
6
|
function StringUtil() {
|
|
6
7
|
}
|
|
@@ -55,6 +56,27 @@ var StringUtil = /** @class */ (function () {
|
|
|
55
56
|
}
|
|
56
57
|
return passwordArray.join("");
|
|
57
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Extracts details from a coupon code.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} couponCode - The coupon code to analyze.
|
|
63
|
+
* @returns {Object} - Object with 'code' (alphabetic part) and 'value' (numeric part) properties.
|
|
64
|
+
* @throws {TypeError} - If the provided 'couponCode' is not a string.
|
|
65
|
+
*/
|
|
66
|
+
StringUtil.prototype.getCouponDetails = function (couponCode) {
|
|
67
|
+
var code = couponCode.match(/[a-zA-Z]+/g);
|
|
68
|
+
var value = couponCode.match(/\d+/g);
|
|
69
|
+
if (!code || !value) {
|
|
70
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
71
|
+
key: "couponCode",
|
|
72
|
+
message: ["coupon with code ".concat(couponCode, " is wrong ")],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
code: code[0],
|
|
77
|
+
value: value[0],
|
|
78
|
+
};
|
|
79
|
+
};
|
|
58
80
|
return StringUtil;
|
|
59
81
|
}());
|
|
60
82
|
exports.stringUtil = new StringUtil();
|