turf-common 1.4.2-beta.29 → 1.4.2-beta.30

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.
@@ -30,12 +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;
34
35
  getPriceByPriceEntities(priceEntities?: {
35
36
  [date: string]: {
36
37
  [time: string]: number;
37
38
  };
38
39
  }): number;
40
+ isModificationAllowed(): boolean;
39
41
  static sortByCode(bookingCodes: BookingCode[]): void;
40
42
  static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
41
43
  static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
@@ -91,6 +91,9 @@ var BookingCode = /** @class */ (function () {
91
91
  BookingCode.prototype.getDateWithFromTimeCode = function () {
92
92
  return "".concat(this.dateCode).concat(this.fromTimeCode);
93
93
  };
94
+ BookingCode.prototype.getDateWithToTimeCode = function () {
95
+ return "".concat(this.dateCode).concat(this.toTimeCode);
96
+ };
94
97
  BookingCode.prototype.getCodeWithoutTurfCode = function () {
95
98
  return "".concat(this.dateCode).concat(this.slot).concat(this.pitchCode);
96
99
  };
@@ -106,6 +109,11 @@ var BookingCode = /** @class */ (function () {
106
109
  }
107
110
  return price;
108
111
  };
112
+ BookingCode.prototype.isModificationAllowed = function () {
113
+ var bookingToDateTimeWithDelay = date_util_1.dateUtilService.addMinutesTo(date_util_1.dateUtilService.convertStringToDate(this.getDateWithToTimeCode(), "yyMMddHHmm"), _utils_1.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES);
114
+ var currentTime = date_util_1.dateUtilService.getIndianDate();
115
+ return bookingToDateTimeWithDelay > currentTime;
116
+ };
109
117
  BookingCode.sortByCode = function (bookingCodes) {
110
118
  bookingCodes.sort(function (_a, _b) {
111
119
  var code1 = _a.code;
@@ -14,6 +14,7 @@ export declare class BookingEntityModel implements IBookingsEntityModel {
14
14
  getBookingTimeInMinutes(): number;
15
15
  isTimeExtended(newBookingEntities: IBookingsEntity[]): boolean;
16
16
  getBookingCode(): BookingCode;
17
+ isModificationAllowed(): boolean;
17
18
  static toMap(bookingEntities: IBookingsEntity[]): {
18
19
  [key: string]: string;
19
20
  };
@@ -27,6 +27,9 @@ var BookingEntityModel = /** @class */ (function () {
27
27
  BookingEntityModel.prototype.getBookingCode = function () {
28
28
  return new booking_code_model_1.BookingCode(this.code, this.cost);
29
29
  };
30
+ BookingEntityModel.prototype.isModificationAllowed = function () {
31
+ return this.getBookingCode().isModificationAllowed();
32
+ };
30
33
  BookingEntityModel.toMap = function (bookingEntities) {
31
34
  var response = {};
32
35
  bookingEntities.forEach(function (bookingEntity) {
@@ -4,3 +4,4 @@ export declare const DELETED_SLOT_SEPARATOR = "d_";
4
4
  export declare const START_OF_DAY_TIME_CODE = "0000";
5
5
  export declare const END_OF_DAY_TIME_CODE = "2400";
6
6
  export declare const DEFAULT_BOOKING_DELAY_IN_MINUTES = 60;
7
+ export declare const DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES = 60;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = exports.END_OF_DAY_TIME_CODE = exports.START_OF_DAY_TIME_CODE = exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
3
+ exports.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES = exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = exports.END_OF_DAY_TIME_CODE = exports.START_OF_DAY_TIME_CODE = exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
4
4
  exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = 7;
5
5
  exports.DEFAULT_PASSWORD = "turf@#123";
6
6
  exports.DELETED_SLOT_SEPARATOR = "d_";
7
7
  exports.START_OF_DAY_TIME_CODE = "0000";
8
8
  exports.END_OF_DAY_TIME_CODE = "2400";
9
9
  exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = 60;
10
+ exports.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES = 60;
@@ -5,6 +5,7 @@ export declare class DateUtilService {
5
5
  getNDaysCode(n: number): string;
6
6
  getDateCode(date: Date): string;
7
7
  addNDaysToDate(date: Date, n: number): Date;
8
+ addMinutesTo(date: Date, minutes: number): Date;
8
9
  convertStringToDate(dateString: string, format: string, offset?: number): Date;
9
10
  getIndianDate(date?: Date): Date;
10
11
  isInPast(date: Date): boolean;
@@ -31,6 +31,9 @@ var DateUtilService = /** @class */ (function () {
31
31
  DateUtilService.prototype.addNDaysToDate = function (date, n) {
32
32
  return (0, date_fns_1.add)(date, { days: n });
33
33
  };
34
+ DateUtilService.prototype.addMinutesTo = function (date, minutes) {
35
+ return (0, date_fns_1.add)(date, { minutes: minutes });
36
+ };
34
37
  DateUtilService.prototype.convertStringToDate = function (dateString, format, offset) {
35
38
  if (offset === void 0) { offset = 330 * 60 * 1000; }
36
39
  var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.4.2-beta.29",
3
+ "version": "1.4.2-beta.30",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",