turf-common 1.4.2-beta.3 → 1.4.2-beta.31

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 (45) hide show
  1. package/build/jest.config.js +2 -1
  2. package/build/src/@model.d.ts +1 -0
  3. package/build/src/@model.js +1 -0
  4. package/build/src/enums/booking-history-operation-type.enum.d.ts +2 -1
  5. package/build/src/enums/booking-history-operation-type.enum.js +1 -0
  6. package/build/src/enums/valid-coupon-type.enum.d.ts +3 -0
  7. package/build/src/enums/valid-coupon-type.enum.js +18 -0
  8. package/build/src/interface/api/booking-availablity-by-pitch.interface.d.ts +1 -0
  9. package/build/src/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
  10. package/build/src/interface/api/get-availability-by-turf.interface.d.ts +1 -0
  11. package/build/src/interface/api/one-slot-booking.interface.d.ts +2 -0
  12. package/build/src/interface/api/update-recurring-booking.interface.d.ts +1 -0
  13. package/build/src/interface/model/booking-details-model.interface.d.ts +8 -0
  14. package/build/src/models/booking-code-model.d.ts +10 -2
  15. package/build/src/models/booking-code-model.js +37 -33
  16. package/build/src/models/charge-model.d.ts +2 -0
  17. package/build/src/models/charge-model.js +34 -11
  18. package/build/src/models/entity/booking-details-model.d.ts +2 -1
  19. package/build/src/models/entity/booking-details-model.js +19 -0
  20. package/build/src/models/entity/booking-entity-model.d.ts +1 -0
  21. package/build/src/models/entity/booking-entity-model.js +3 -0
  22. package/build/src/models/pitch-slab-model.d.ts +1 -0
  23. package/build/src/models/pitch-slab-model.js +15 -0
  24. package/build/src/models/subscribed-pricing-plan-model.d.ts +1 -0
  25. package/build/src/models/subscribed-pricing-plan-model.js +7 -0
  26. package/build/src/models/time-slot-model.d.ts +1 -0
  27. package/build/src/models/time-slot-model.js +3 -0
  28. package/build/src/models/turf-availability-model.d.ts +18 -3
  29. package/build/src/models/turf-availability-model.js +60 -3
  30. package/build/src/models/weekday-time-slot-model.d.ts +12 -0
  31. package/build/src/models/weekday-time-slot-model.js +30 -0
  32. package/build/src/utils/constant.d.ts +2 -0
  33. package/build/src/utils/constant.js +3 -1
  34. package/build/src/utils/date-util.d.ts +3 -1
  35. package/build/src/utils/date-util.js +10 -2
  36. package/build/tests/booking-code/method.spec.d.ts +1 -0
  37. package/build/tests/booking-code/method.spec.js +11 -0
  38. package/build/tests/unit/charges/discount-relative/basic.spec.d.ts +1 -0
  39. package/build/tests/unit/charges/discount-relative/basic.spec.js +209 -0
  40. package/build/tests/unit/charges/extension/basic.amount-fully-paid.spec.d.ts +1 -0
  41. package/build/tests/unit/charges/extension/basic.amount-fully-paid.spec.js +208 -0
  42. package/build/tests/unit/charges/extension/basic.spec.d.ts +1 -0
  43. package/build/tests/unit/charges/extension/basic.spec.js +215 -0
  44. package/build/tests/unit/pricing-plan/basic-scenario.spec.js +1 -1
  45. package/package.json +2 -2
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // Sync object
4
4
  var config = {
5
- verbose: true,
5
+ // verbose: true,
6
6
  transform: {
7
7
  "^.+\\.tsx?$": "ts-jest",
8
8
  },
9
+ testMatch: ["**/tests/**/*.spec.ts"],
9
10
  };
10
11
  exports.default = config;
@@ -7,3 +7,4 @@ export * from "./models/pricing-plan-model";
7
7
  export * from "./models/subscribed-pricing-plan-model";
8
8
  export * from "./models/entity";
9
9
  export * from "./models/turf-availability-model";
10
+ export * from "./models/weekday-time-slot-model";
@@ -23,3 +23,4 @@ __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
25
  __exportStar(require("./models/turf-availability-model"), exports);
26
+ __exportStar(require("./models/weekday-time-slot-model"), exports);
@@ -7,6 +7,7 @@ export declare enum BookingHistoryOperationType {
7
7
  REFUND = "refund",
8
8
  PAYMENT = "payment",
9
9
  MERGED = "merged",
10
- DELETE_SLOT_EVENT = "delete_slot_event"
10
+ DELETE_SLOT_EVENT = "delete_slot_event",
11
+ EXTENSION = "extension"
11
12
  }
12
13
  export declare const OPERATION_TYPES: BookingHistoryOperationType[];
@@ -12,6 +12,7 @@ var BookingHistoryOperationType;
12
12
  BookingHistoryOperationType["PAYMENT"] = "payment";
13
13
  BookingHistoryOperationType["MERGED"] = "merged";
14
14
  BookingHistoryOperationType["DELETE_SLOT_EVENT"] = "delete_slot_event";
15
+ BookingHistoryOperationType["EXTENSION"] = "extension";
15
16
  })(BookingHistoryOperationType || (exports.BookingHistoryOperationType = BookingHistoryOperationType = {}));
16
17
  exports.OPERATION_TYPES = [
17
18
  BookingHistoryOperationType.DELETE,
@@ -4,3 +4,6 @@ export declare enum ValidCouponType {
4
4
  PER_HOUR_UNIT = "per hour unit",
5
5
  PER_HOUR_PERCENTAGE = "per hour percentage"
6
6
  }
7
+ export declare namespace ValidCouponType {
8
+ function UILabel(value: ValidCouponType): string;
9
+ }
@@ -8,3 +8,21 @@ var ValidCouponType;
8
8
  ValidCouponType["PER_HOUR_UNIT"] = "per hour unit";
9
9
  ValidCouponType["PER_HOUR_PERCENTAGE"] = "per hour percentage";
10
10
  })(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
11
+ // Create namespace for the enum and add method UILabel to get the label of the enum value.
12
+ (function (ValidCouponType) {
13
+ function UILabel(value) {
14
+ switch (value) {
15
+ case ValidCouponType.PERCENTAGE:
16
+ return "Percentage";
17
+ case ValidCouponType.UNIT:
18
+ return "Price";
19
+ case ValidCouponType.PER_HOUR_UNIT:
20
+ return "Price Hour Unit";
21
+ case ValidCouponType.PER_HOUR_PERCENTAGE:
22
+ return "Per Hour Percentage";
23
+ default:
24
+ return "";
25
+ }
26
+ }
27
+ ValidCouponType.UILabel = UILabel;
28
+ })(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
@@ -36,4 +36,5 @@ export interface IBookingAvailabilitySlotRequest {
36
36
  weekdays: number[];
37
37
  from: string;
38
38
  to: string;
39
+ pitchNo: number;
39
40
  }
@@ -1,5 +1,5 @@
1
1
  import { PaymentMode, BookingDetailsStatus } from "../../@enum";
2
- import { IBookingDetailsEntity, IGetAvailabilityByTurf, IModifyEntity } from "../../@type";
2
+ import { IBookingDetailsEntity, IGetAvailabilityByTurf, IGetAvailabilityByTurfRequest, IModifyEntity } from "../../@type";
3
3
  export interface ICreateRecurringSlotBookingResponse extends IModifyEntity<IBookingDetailsEntity> {
4
4
  }
5
5
  export interface ICreateRecurringSlotsBookingDetailsRequest {
@@ -18,7 +18,9 @@ export interface ICreateRecurringSlotsBookingDetailsRequest {
18
18
  slot: IRecurringSlot[];
19
19
  turf_slot?: {
20
20
  availability_details: IGetAvailabilityByTurf;
21
+ apiRequestModel?: IGetAvailabilityByTurfRequest;
21
22
  };
23
+ deleteIntermediateBookings: boolean;
22
24
  }
23
25
  export declare class IRecurringSlot {
24
26
  fromDate: number;
@@ -26,4 +28,5 @@ export declare class IRecurringSlot {
26
28
  weekdays: number[];
27
29
  from: string;
28
30
  to: string;
31
+ pitchNo: number;
29
32
  }
@@ -6,6 +6,7 @@ export interface IGetAvailabilityByTurfRequest {
6
6
  pitch: string;
7
7
  view: AvailabilityView;
8
8
  weekDays: number[];
9
+ weekdayTimeSlots: string[];
9
10
  }
10
11
  export interface IGetAvailabilityByTurf {
11
12
  [dateCode: string]: IAvailabilityData;
@@ -12,6 +12,7 @@ export interface ICreateOneSlotBookingDetailsRequest {
12
12
  discountedCost: number;
13
13
  amountPaid: number;
14
14
  pitchId: number;
15
+ pitchIds?: number[];
15
16
  status: BookingDetailsStatus;
16
17
  sport: string;
17
18
  remarks?: string | null;
@@ -21,4 +22,5 @@ export interface ICreateOneSlot {
21
22
  date: number;
22
23
  from: string;
23
24
  to: string;
25
+ pitchNo: number;
24
26
  }
@@ -34,6 +34,7 @@ export interface IUpdateRecurringBookingResponse extends IModifyEntity<IBookingD
34
34
  discountPolicy?: string;
35
35
  delete_slot?: IDeleteBookingByCodesDto;
36
36
  update_slot?: IUpdateBookingByCodesDto;
37
+ extension_booking_codes?: string[];
37
38
  }
38
39
  export interface IUpdateRecurringSlotBookingDetailsRequest {
39
40
  customerName?: string;
@@ -1,5 +1,13 @@
1
+ import { WeekdayTimeSlot } from "../../@model";
1
2
  import { ChargesModel } from "../../models/charge-model";
2
3
  import { IBookingDetailsEntity } from "../entity/booking-details-entity.interface";
4
+ export interface IEventBookingDetails {
5
+ startDateCode: number;
6
+ endDateCode: number;
7
+ weekdaySlots: WeekdayTimeSlot[];
8
+ pitchIds: number[];
9
+ }
3
10
  export interface IBookingDetailsModel extends IBookingDetailsEntity {
4
11
  assignCharges(chargeModel: ChargesModel): void;
12
+ getEventDetails(): IEventBookingDetails;
5
13
  }
@@ -20,7 +20,7 @@ export declare class BookingCode {
20
20
  getHalfHourTimeCodes(): string[];
21
21
  /**
22
22
  *
23
- * @returns {Array<string>} - List of half hour time slot codes between start time & end time inclusive
23
+ * @returns ['00000030','00300100','01000130']: string[] - List of half hour time slot codes between start time & end time inclusive
24
24
  * @example fromTime: 0000; toTime: 0130
25
25
  * // returns ['00000030','00300100','01000130']
26
26
  */
@@ -30,7 +30,14 @@ export declare class BookingCode {
30
30
  getWeekday(): number;
31
31
  getMonthCode(): string;
32
32
  getDateWithFromTimeCode(): string;
33
+ getDateWithToTimeCode(): string;
33
34
  getCodeWithoutTurfCode(): string;
35
+ getPriceByPriceEntities(priceEntities?: {
36
+ [date: string]: {
37
+ [time: string]: number;
38
+ };
39
+ }): number;
40
+ isModificationAllowed(delayInMinutes?: number): boolean;
34
41
  static sortByCode(bookingCodes: BookingCode[]): void;
35
42
  static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
36
43
  static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
@@ -40,7 +47,7 @@ export declare class BookingCode {
40
47
  static getWeekday(dateCode: number): number;
41
48
  static convertToDate(str: string): Date;
42
49
  static previousDateChecker(fromDate: number, index: number, errorKey?: string): void;
43
- static previousTimeChecker(fromTime: string, fromDate: number, index: number): void;
50
+ static previousTimeChecker(fromTime: string, fromDate: number, index: number, bookingDelayInMinutes?: number, date?: Date): void;
44
51
  static getDateCodesByWeek(fromDate: number, toDate: number, selectedWeekday: number): string[];
45
52
  static getDatesByWeek(fromDate: number, toDate: number, selectedWeekday: number): Date[];
46
53
  static isValidTimeRange(timeSlot: string): boolean;
@@ -136,4 +143,5 @@ export declare class BookingCode {
136
143
  * Additionally, the pitch number and turf ID must match between the two codes.
137
144
  */
138
145
  isAdjacentBookingCode(nextBookingCode: BookingCode): boolean;
146
+ static getInstanceByComponents(turfId: number, pitchCode: number, dateCode: number, fromTimeCode: string, toTimeCode: string, priceCsv: string): BookingCode;
139
147
  }
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.BookingCode = void 0;
15
4
  var time_slot_model_1 = require("./time-slot-model");
@@ -60,7 +49,7 @@ var BookingCode = /** @class */ (function () {
60
49
  };
61
50
  /**
62
51
  *
63
- * @returns {Array<string>} - List of half hour time slot codes between start time & end time inclusive
52
+ * @returns ['00000030','00300100','01000130']: string[] - List of half hour time slot codes between start time & end time inclusive
64
53
  * @example fromTime: 0000; toTime: 0130
65
54
  * // returns ['00000030','00300100','01000130']
66
55
  */
@@ -102,9 +91,30 @@ var BookingCode = /** @class */ (function () {
102
91
  BookingCode.prototype.getDateWithFromTimeCode = function () {
103
92
  return "".concat(this.dateCode).concat(this.fromTimeCode);
104
93
  };
94
+ BookingCode.prototype.getDateWithToTimeCode = function () {
95
+ return "".concat(this.dateCode).concat(this.toTimeCode);
96
+ };
105
97
  BookingCode.prototype.getCodeWithoutTurfCode = function () {
106
98
  return "".concat(this.dateCode).concat(this.slot).concat(this.pitchCode);
107
99
  };
100
+ BookingCode.prototype.getPriceByPriceEntities = function (priceEntities) {
101
+ var halfHourTimeRangeCodes = this.getHalfHourTimeRangeCodes();
102
+ var weekDay = this.getWeekday();
103
+ var monthCode = this.getMonthCode();
104
+ var price = 0;
105
+ for (var _i = 0, halfHourTimeRangeCodes_1 = halfHourTimeRangeCodes; _i < halfHourTimeRangeCodes_1.length; _i++) {
106
+ var halfHourTimeRangeCode = halfHourTimeRangeCodes_1[_i];
107
+ price +=
108
+ priceEntities[monthCode + weekDay][halfHourTimeRangeCode] < 0 ? 0 : priceEntities[monthCode + weekDay][halfHourTimeRangeCode];
109
+ }
110
+ return price;
111
+ };
112
+ BookingCode.prototype.isModificationAllowed = function (delayInMinutes) {
113
+ if (delayInMinutes === void 0) { delayInMinutes = _utils_1.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES; }
114
+ var bookingToDateTimeWithDelay = date_util_1.dateUtilService.addMinutesTo(date_util_1.dateUtilService.convertStringToDate(this.getDateWithToTimeCode(), "yyMMddHHmm"), delayInMinutes || _utils_1.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES);
115
+ var currentTime = date_util_1.dateUtilService.getIndianDate();
116
+ return bookingToDateTimeWithDelay > currentTime;
117
+ };
108
118
  BookingCode.sortByCode = function (bookingCodes) {
109
119
  bookingCodes.sort(function (_a, _b) {
110
120
  var code1 = _a.code;
@@ -157,7 +167,7 @@ var BookingCode = /** @class */ (function () {
157
167
  discount = parseFloat(couponCode) * totalBookingHours;
158
168
  }
159
169
  }
160
- discountedCost = totalCost - discount;
170
+ discountedCost = totalCost - Math.round(discount);
161
171
  return Math.round(discountedCost);
162
172
  };
163
173
  BookingCode.getDiscountAmount = function (couponCode, totalCost) {
@@ -221,26 +231,17 @@ var BookingCode = /** @class */ (function () {
221
231
  }
222
232
  };
223
233
  //---------------------
224
- BookingCode.previousTimeChecker = function (fromTime, fromDate, index) {
225
- var now = new Date();
226
- this.convertToDate(fromDate.toString());
227
- var delayInBooking = 15;
228
- if (this.convertToDate(fromDate.toString()) > now) {
229
- return; //do nothing if fromDate is in future
230
- }
231
- else if (this.convertToDate(fromDate.toString()) <= now) {
232
- now.setMinutes(now.getMinutes() - delayInBooking); // 15minutes buffer for late bookings
233
- var options = {
234
- timeZone: "Asia/Kolkata",
235
- };
236
- var timeFormat = new Intl.DateTimeFormat("en-US", __assign(__assign({}, options), { hour: "2-digit", minute: "2-digit", hour12: false }));
237
- var currentTimeObj = timeFormat.format(now).replace(/:/g, "");
238
- if (fromTime < currentTimeObj) {
239
- throw new app_badrequest_exception_1.AppBadRequestException({
240
- key: "slot.".concat(index),
241
- message: ["Booking time should be in future"],
242
- });
243
- }
234
+ BookingCode.previousTimeChecker = function (fromTime, fromDate, index, bookingDelayInMinutes, date) {
235
+ if (bookingDelayInMinutes === void 0) { bookingDelayInMinutes = _utils_1.DEFAULT_BOOKING_DELAY_IN_MINUTES; }
236
+ if (date === void 0) { date = date_util_1.dateUtilService.getIndianDate(); }
237
+ var now = date;
238
+ var bookingDate = date_util_1.dateUtilService.convertStringToDate(fromDate.toString() + fromTime, "yyMMddHHmm");
239
+ var difference = bookingDate.getTime() - now.getTime() + bookingDelayInMinutes * 60 * 1000;
240
+ if (difference < 0) {
241
+ throw new app_badrequest_exception_1.AppBadRequestException({
242
+ key: "slot.".concat(index),
243
+ message: ["Booking time should be in future"],
244
+ });
244
245
  }
245
246
  };
246
247
  //---------------------
@@ -608,6 +609,9 @@ var BookingCode = /** @class */ (function () {
608
609
  this.pitchNumber === nextBookingCode.pitchNumber &&
609
610
  this.turfId === nextBookingCode.turfId);
610
611
  };
612
+ BookingCode.getInstanceByComponents = function (turfId, pitchCode, dateCode, fromTimeCode, toTimeCode, priceCsv) {
613
+ return new BookingCode("".concat(turfId.toString().padStart(4, "0")).concat(dateCode.toString().padStart(6, "0")).concat(fromTimeCode).concat(toTimeCode).concat(pitchCode.toString().padStart(2, "0")), priceCsv);
614
+ };
611
615
  /**
612
616
  * Extracts the numeric part of a bookingCode, excluding a predefined deleted slot separator.
613
617
  *
@@ -1,3 +1,4 @@
1
+ import { BookingCode } from "./booking-code-model";
1
2
  import { IBookingModification } from "../types/booking-modification.type";
2
3
  import { ModificationDiscountPolicy } from "../enums/modification-discount-policy.enum";
3
4
  import { IChargeModel } from "../interface/model/charge-model.interface";
@@ -27,6 +28,7 @@ export declare class ChargesModel implements IChargeModel {
27
28
  private modifyMove;
28
29
  clone(): ChargesModel;
29
30
  private modifyDelete;
31
+ extension(extensionBookingCode: BookingCode): ChargesModel;
30
32
  static getInstance(chargeData: IChargeModel, discountPolicy?: ModificationDiscountPolicy): ChargesModel;
31
33
  getTotalAmount(): number;
32
34
  getPaymentStatus(): "Refund" | "Paid" | "Pending";
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.ChargesModel = void 0;
4
15
  var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
@@ -9,15 +20,15 @@ var ChargesModel = /** @class */ (function () {
9
20
  this.initialBookingGrossAmount = initialGrossAmount;
10
21
  this.amountPaid = paidAmount;
11
22
  this.couponCode = couponCode;
23
+ this.totalBookingHours = totalBookingHours;
24
+ this.discountPolicy = discountPolicy;
12
25
  this.additionalBookingGrossAmount = 0;
13
26
  this.cancelledBookingGrossAmount = 0;
14
27
  this.totalCancellationCharges = 0;
15
28
  this.refundPayable = 0;
16
29
  this.totalRefundedAmount = 0;
17
- this.totalBookingHours = totalBookingHours;
18
30
  this.netTotal = this.getNetAmount();
19
31
  this.amountPayable = this.getPayableRefundAmount();
20
- this.discountPolicy = discountPolicy;
21
32
  }
22
33
  ChargesModel.prototype.getGrossAmount = function () {
23
34
  return (this.initialBookingGrossAmount +
@@ -35,6 +46,7 @@ var ChargesModel = /** @class */ (function () {
35
46
  this.cancelledBookingGrossAmount > 0) {
36
47
  this.couponCode = "";
37
48
  }
49
+ // console.log("getDiscountAmount", this.couponCode);
38
50
  return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount(), false, this.totalBookingHours);
39
51
  };
40
52
  ChargesModel.prototype.getPayableRefundAmount = function () {
@@ -102,10 +114,6 @@ var ChargesModel = /** @class */ (function () {
102
114
  };
103
115
  ChargesModel.prototype.modify = function (bookingModification) {
104
116
  var oldBookingCode = bookingModification.oldBookingCode, newBookingCode = bookingModification.newBookingCode, cancellationUnit = bookingModification.cancellationUnit;
105
- // this.totalBookingHours =
106
- // this.totalBookingHours -
107
- // oldBookingCode.getTotalTime("hr") +
108
- // (newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
109
117
  if (!newBookingCode) {
110
118
  return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
111
119
  }
@@ -150,9 +158,7 @@ var ChargesModel = /** @class */ (function () {
150
158
  (newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
151
159
  var newChargeModel = this.clone();
152
160
  newChargeModel.totalBookingHours = newTotalBookingHours;
153
- newChargeModel.couponCode = "";
154
161
  var costDifference = oldBookingCode.getCost() - newBookingCode.getCost();
155
- // console.log(`costDifference ${costDifference}`);
156
162
  newChargeModel.cancelledBookingGrossAmount += costDifference;
157
163
  var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
158
164
  // console.log(`cancellationCharges ${cancellationCharges}`);
@@ -208,7 +214,6 @@ var ChargesModel = /** @class */ (function () {
208
214
  var newTotalBookingHours = this.totalBookingHours - bookingCode.getTotalTime("hr");
209
215
  var newChargeModel = this.clone();
210
216
  newChargeModel.totalBookingHours = newTotalBookingHours;
211
- newChargeModel.couponCode = "";
212
217
  var costDifference = bookingCode.getCost();
213
218
  newChargeModel.cancelledBookingGrossAmount += costDifference;
214
219
  var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
@@ -224,10 +229,28 @@ var ChargesModel = /** @class */ (function () {
224
229
  }
225
230
  return newChargeModel;
226
231
  };
232
+ ChargesModel.prototype.extension = function (extensionBookingCode) {
233
+ var newTotalBookingHours = this.totalBookingHours + (extensionBookingCode ? extensionBookingCode.getTotalTime("hr") : 0);
234
+ var newChargeModel = this.clone();
235
+ newChargeModel.totalBookingHours = newTotalBookingHours;
236
+ newChargeModel.additionalBookingGrossAmount += extensionBookingCode.getCost();
237
+ newChargeModel.netTotal = newChargeModel.getNetAmount();
238
+ newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
239
+ // console.log(newChargeModel.payableAmount);
240
+ if (newChargeModel.amountPayable > 0) {
241
+ newChargeModel.refundPayable = 0;
242
+ }
243
+ else {
244
+ newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
245
+ newChargeModel.amountPayable = 0;
246
+ }
247
+ return newChargeModel;
248
+ };
227
249
  ChargesModel.getInstance = function (chargeData, discountPolicy) {
228
250
  if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
229
- var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, chargeData.totalBookingHours, discountPolicy);
230
- Object.assign(chargesModel, chargeData);
251
+ var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, parseFloat(chargeData.totalBookingHours.toString()), discountPolicy);
252
+ var initialBookingGrossAmount = chargeData.initialBookingGrossAmount, amountPaid = chargeData.amountPaid, couponCode = chargeData.couponCode, totalBookingHours = chargeData.totalBookingHours, rest = __rest(chargeData, ["initialBookingGrossAmount", "amountPaid", "couponCode", "totalBookingHours"]);
253
+ Object.assign(chargesModel, rest);
231
254
  return chargesModel;
232
255
  };
233
256
  // static assignByInterface(
@@ -1,5 +1,5 @@
1
1
  import { BookingDetailsStatus } from "../../enums/booking-details-status.enum";
2
- import { IBookingDetailsModel } from "../../interface/model/booking-details-model.interface";
2
+ import { IBookingDetailsModel, IEventBookingDetails } from "../../interface/model/booking-details-model.interface";
3
3
  import { IBookingDetailsWithBooking } from "../../types/bookingdetails-with-booking.type";
4
4
  import { IBookingDetailsEntity } from "../../interface/entity/booking-details-entity.interface";
5
5
  import { IBookingsEntity } from "../../interface/entity/bookings-entity.interface";
@@ -35,6 +35,7 @@ export declare class BookingDetailsModel implements IBookingDetailsModel {
35
35
  totalBookingHours: number;
36
36
  type: string | null;
37
37
  constructor(data: IBookingDetailsEntity);
38
+ getEventDetails(): IEventBookingDetails;
38
39
  static getIdAndCreatedBy(bookingDetailsEntities: IBookingDetailsEntity[]): number[][];
39
40
  assignCharges(chargeModel: ChargesModel): void;
40
41
  static toMap(bookingDetailsEntities: IBookingDetailsEntity[], bookingsEntities: IBookingsEntity[]): IBookingDetailsWithBooking;
@@ -13,10 +13,29 @@ var __assign = (this && this.__assign) || function () {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.BookingDetailsModel = void 0;
15
15
  var booking_entity_model_1 = require("./booking-entity-model");
16
+ var weekday_time_slot_model_1 = require("../weekday-time-slot-model");
16
17
  var BookingDetailsModel = /** @class */ (function () {
17
18
  function BookingDetailsModel(data) {
18
19
  Object.assign(this, data);
19
20
  }
21
+ BookingDetailsModel.prototype.getEventDetails = function () {
22
+ var _a;
23
+ if (((_a = this.type) === null || _a === void 0 ? void 0 : _a.split("#")[0]) === "event") {
24
+ var startDateCode = Number(this.type.split("#")[1].split(",")[0]);
25
+ var endDateCode = Number(this.type.split("#")[1].split(",")[1]);
26
+ var pitchIds = this.type.split("#")[3].split(",").map(Number);
27
+ var weekdaySlots = this.type.split("#")[2].split(",").map(function (weekdayTimeSlotCode) { return new weekday_time_slot_model_1.WeekdayTimeSlot(weekdayTimeSlotCode); });
28
+ return {
29
+ startDateCode: startDateCode,
30
+ endDateCode: endDateCode,
31
+ weekdaySlots: weekdaySlots,
32
+ pitchIds: pitchIds,
33
+ };
34
+ }
35
+ else {
36
+ throw new Error("Booking is not an event");
37
+ }
38
+ };
20
39
  BookingDetailsModel.getIdAndCreatedBy = function (bookingDetailsEntities) {
21
40
  var bookingDetailsIds = [];
22
41
  var userIds = [];
@@ -14,6 +14,7 @@ export declare class BookingEntityModel implements IBookingsEntityModel {
14
14
  getBookingTimeInMinutes(): number;
15
15
  isTimeExtended(newBookingEntities: IBookingsEntity[]): boolean;
16
16
  getBookingCode(): BookingCode;
17
+ isModificationAllowed(): boolean;
17
18
  static toMap(bookingEntities: IBookingsEntity[]): {
18
19
  [key: string]: string;
19
20
  };
@@ -27,6 +27,9 @@ var BookingEntityModel = /** @class */ (function () {
27
27
  BookingEntityModel.prototype.getBookingCode = function () {
28
28
  return new booking_code_model_1.BookingCode(this.code, this.cost);
29
29
  };
30
+ BookingEntityModel.prototype.isModificationAllowed = function () {
31
+ return this.getBookingCode().isModificationAllowed();
32
+ };
30
33
  BookingEntityModel.toMap = function (bookingEntities) {
31
34
  var response = {};
32
35
  bookingEntities.forEach(function (bookingEntity) {
@@ -11,4 +11,5 @@ export declare class PitchSlabModelV2 implements IPitchSlabV2 {
11
11
  from: number;
12
12
  to: number;
13
13
  constructor(data: IPitchSlabV2);
14
+ getRange(): string;
14
15
  }
@@ -27,6 +27,21 @@ var PitchSlabModelV2 = /** @class */ (function () {
27
27
  this.to = data.to;
28
28
  // this.discount = data.discount;
29
29
  }
30
+ // public getDiscount(): number {
31
+ // if (this.discount.indexOf("P") > -1) {
32
+ // return parseFloat(this.discount.replace("P", ""));
33
+ // }
34
+ // return 0;
35
+ // }
36
+ // public getBasePrice(basePrice: number): number {
37
+ // return basePrice * (1 - this.getDiscount() / 100);
38
+ // }
39
+ PitchSlabModelV2.prototype.getRange = function () {
40
+ if (this.to >= 99) {
41
+ return "".concat(this.from - 1, "+");
42
+ }
43
+ return "".concat(this.from, "-").concat(this.to);
44
+ };
30
45
  return PitchSlabModelV2;
31
46
  }());
32
47
  exports.PitchSlabModelV2 = PitchSlabModelV2;
@@ -44,6 +44,7 @@ export declare class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
44
44
  hourInMonth: number;
45
45
  months: number | undefined;
46
46
  constructor(data: IPricingPlanModelV2, pitchCount: number, billingCycle: string);
47
+ getPlanBasePriceFormatted(): string;
47
48
  getCodeByPitchCountCycle(): string;
48
49
  getCodeByCycle(): string[];
49
50
  getDiscount(): string;
@@ -150,6 +150,13 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
150
150
  return _this;
151
151
  // this.selectedPitchSlabBasePrice = this.base_price;
152
152
  }
153
+ SubscribedPricingPlanModelV2.prototype.getPlanBasePriceFormatted = function () {
154
+ // Format -> #.##
155
+ return parseFloat((this.getBasePriceV2()).toFixed(2)).toLocaleString('en-IN', {
156
+ minimumFractionDigits: 2,
157
+ maximumFractionDigits: 2,
158
+ });
159
+ };
153
160
  SubscribedPricingPlanModelV2.prototype.getCodeByPitchCountCycle = function () {
154
161
  var _this = this;
155
162
  var codes = this.billing_cost_code.split(",");
@@ -12,6 +12,7 @@ export declare class TimeSlot {
12
12
  getHalfHourTimeCodes(): string[];
13
13
  getHalfHourTimeRangeCodes(): string[];
14
14
  getTotalMinutes(): number;
15
+ isInclusive(timeSlot: TimeSlot): boolean;
15
16
  static convertToCode(minute: number): string;
16
17
  static _getMinutes(timeCode: string): number;
17
18
  static getHalfHourTimeCodes(): string[];
@@ -64,6 +64,9 @@ var TimeSlot = /** @class */ (function () {
64
64
  TimeSlot.prototype.getTotalMinutes = function () {
65
65
  return this.getEndMinutes() - this.getStartMinutes();
66
66
  };
67
+ TimeSlot.prototype.isInclusive = function (timeSlot) {
68
+ return this.fromTime <= timeSlot.fromTime && timeSlot.toTime <= this.toTime;
69
+ };
67
70
  // static padStart(timeCode: string, length: number, padString: string): string {
68
71
  // return timeCode.padStart(length, padString);
69
72
  // }
@@ -1,8 +1,9 @@
1
- import { IGetAvailabilityByTurf } from "../@type";
1
+ import { IGetAvailabilityByTurf, IGetAvailabilityByTurfRequest } from "../@type";
2
2
  interface ITurfAvailability {
3
3
  data: IGetAvailabilityByTurf;
4
4
  dateCodes: string[];
5
5
  timeSlotCodesDateWise: Record<string, string[]>;
6
+ apiRequestModel?: IGetAvailabilityByTurfRequest;
6
7
  getTotalAvailablePrice(): number;
7
8
  getTotalNonAvailablePrice(): number;
8
9
  getTotalAvailableHours(): number;
@@ -26,7 +27,8 @@ export declare class TurfAvailability implements ITurfAvailability {
26
27
  toTimeCode: string;
27
28
  pitchCodes: string[];
28
29
  weekDays: number[];
29
- constructor(data: IGetAvailabilityByTurf);
30
+ apiRequestModel?: IGetAvailabilityByTurfRequest;
31
+ constructor(data: IGetAvailabilityByTurf, apiRequestModel?: IGetAvailabilityByTurfRequest | null);
30
32
  getTotalAvailablePrice(): number;
31
33
  getTotalNonAvailablePrice(): number;
32
34
  getTotalAvailableHours(): number;
@@ -39,10 +41,23 @@ export declare class TurfAvailability implements ITurfAvailability {
39
41
  weekdays: number[];
40
42
  }[];
41
43
  getPitchIds(): number[];
42
- static fromJson(json: IGetAvailabilityByTurf): TurfAvailability;
44
+ static fromJson(json: IGetAvailabilityByTurf, apiRequestModel?: IGetAvailabilityByTurfRequest | null): TurfAvailability;
43
45
  static toJson(turfAvailability: TurfAvailability): IGetAvailabilityByTurf;
44
46
  getTotalTime(): number;
45
47
  getCode(): string;
48
+ getEventCode(): string;
49
+ static parseEventCode(eventCode: string): {
50
+ fromDateCode: string;
51
+ toDateCode: string;
52
+ data: {
53
+ fromDateCode: string;
54
+ toDateCode: string;
55
+ fromTimeCode: string;
56
+ toTimeCode: string;
57
+ weekDay: number;
58
+ }[];
59
+ pitchIds: string[];
60
+ };
46
61
  parse(): void;
47
62
  static parse(eventCode: string): {
48
63
  pitchCodes: string[];