turf-common 1.2.1-beta.8 → 1.3.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 +2 -0
- package/build/@enum.js +2 -0
- package/build/@model.d.ts +1 -0
- package/build/@model.js +1 -0
- package/build/@type.d.ts +2 -0
- package/build/@type.js +2 -0
- package/build/@utils.d.ts +1 -0
- package/build/@utils.js +1 -0
- package/build/enums/availability-view.enum.d.ts +4 -0
- package/build/enums/availability-view.enum.js +8 -0
- package/build/enums/booking-history-operation-type.enum.d.ts +4 -2
- package/build/enums/booking-history-operation-type.enum.js +4 -2
- package/build/enums/environment.enum.d.ts +5 -0
- package/build/enums/environment.enum.js +9 -0
- package/build/enums/valid-coupon-type.enum.d.ts +3 -1
- package/build/enums/valid-coupon-type.enum.js +2 -0
- package/build/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
- package/build/interface/api/get-availability-by-turf.interface.d.ts +29 -0
- package/build/interface/api/get-availability-by-turf.interface.js +2 -0
- package/build/interface/api/get-tournament.interface.d.ts +4 -0
- package/build/interface/api/get-tournament.interface.js +2 -0
- package/build/interface/api/index.d.ts +2 -0
- package/build/interface/api/index.js +2 -0
- package/build/interface/api/list-of-coupons.interface.d.ts +6 -0
- package/build/interface/convert-to-midnight-time.interface.d.ts +5 -0
- package/build/interface/convert-to-midnight-time.interface.js +2 -0
- package/build/interface/entity/booking-details-entity.interface.d.ts +2 -0
- package/build/interface/entity/booking-history-entity.interface.d.ts +4 -0
- package/build/interface/get-booking-by-id.interface.d.ts +2 -3
- package/build/interface/model/charge-model.interface.d.ts +1 -0
- package/build/interface/ng-date-structure.interface.d.ts +5 -0
- package/build/interface/ng-date-structure.interface.js +2 -0
- package/build/models/booking-code-model.d.ts +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 +12 -0
- package/build/utils/string-utils.js +53 -0
- package/package.json +1 -1
- package/build/utils/format-string-with-hyphens.d.ts +0 -1
- package/build/utils/format-string-with-hyphens.js +0 -7
package/build/@enum.d.ts
CHANGED
|
@@ -22,3 +22,5 @@ export * from "./enums/booking-fetch-filter.enum";
|
|
|
22
22
|
export * from "./enums/timezone.enum";
|
|
23
23
|
export * from "./enums/bookings-status.enum";
|
|
24
24
|
export * from "./enums/organization-type.enum";
|
|
25
|
+
export * from "./enums/environment.enum";
|
|
26
|
+
export * from "./enums/availability-view.enum";
|
package/build/@enum.js
CHANGED
|
@@ -38,3 +38,5 @@ __exportStar(require("./enums/booking-fetch-filter.enum"), exports);
|
|
|
38
38
|
__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
|
+
__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,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Environment = void 0;
|
|
4
|
+
var Environment;
|
|
5
|
+
(function (Environment) {
|
|
6
|
+
Environment["DEVELOPMENT"] = "development";
|
|
7
|
+
Environment["PRODUCTION"] = "production";
|
|
8
|
+
Environment["TEST"] = "test";
|
|
9
|
+
})(Environment || (exports.Environment = Environment = {}));
|
|
@@ -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;
|