turf-common 1.4.2-beta.12 → 1.4.2-beta.14

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.
@@ -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;
@@ -45,7 +45,7 @@ export declare class BookingCode {
45
45
  static getWeekday(dateCode: number): number;
46
46
  static convertToDate(str: string): Date;
47
47
  static previousDateChecker(fromDate: number, index: number, errorKey?: string): void;
48
- static previousTimeChecker(fromTime: string, fromDate: number, index: number): void;
48
+ static previousTimeChecker(fromTime: string, fromDate: number, index: number, bookingDelayInMinutes?: number, date?: Date): void;
49
49
  static getDateCodesByWeek(fromDate: number, toDate: number, selectedWeekday: number): string[];
50
50
  static getDatesByWeek(fromDate: number, toDate: number, selectedWeekday: number): Date[];
51
51
  static isValidTimeRange(timeSlot: string): boolean;
@@ -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");
@@ -233,26 +222,18 @@ var BookingCode = /** @class */ (function () {
233
222
  }
234
223
  };
235
224
  //---------------------
236
- BookingCode.previousTimeChecker = function (fromTime, fromDate, index) {
237
- var now = new Date();
238
- this.convertToDate(fromDate.toString());
239
- var delayInBooking = 15;
240
- if (this.convertToDate(fromDate.toString()) > now) {
241
- return; //do nothing if fromDate is in future
242
- }
243
- else if (this.convertToDate(fromDate.toString()) <= now) {
244
- now.setMinutes(now.getMinutes() - delayInBooking); // 15minutes buffer for late bookings
245
- var options = {
246
- timeZone: "Asia/Kolkata",
247
- };
248
- var timeFormat = new Intl.DateTimeFormat("en-US", __assign(__assign({}, options), { hour: "2-digit", minute: "2-digit", hour12: false }));
249
- var currentTimeObj = timeFormat.format(now).replace(/:/g, "");
250
- if (fromTime < currentTimeObj) {
251
- throw new app_badrequest_exception_1.AppBadRequestException({
252
- key: "slot.".concat(index),
253
- message: ["Booking time should be in future"],
254
- });
255
- }
225
+ BookingCode.previousTimeChecker = function (fromTime, fromDate, index, bookingDelayInMinutes, date) {
226
+ if (bookingDelayInMinutes === void 0) { bookingDelayInMinutes = _utils_1.DEFAULT_BOOKING_DELAY_IN_MINUTES; }
227
+ if (date === void 0) { date = date_util_1.dateUtilService.getIndianDate(); }
228
+ var now = date;
229
+ console.log("previousTimeChecker now", now);
230
+ var bookingDate = date_util_1.dateUtilService.convertStringToDate(fromDate.toString() + fromTime, "yyMMddHHmm");
231
+ var difference = bookingDate.getTime() - now.getTime() + bookingDelayInMinutes * 60 * 1000;
232
+ if (difference < 0) {
233
+ throw new app_badrequest_exception_1.AppBadRequestException({
234
+ key: "slot.".concat(index),
235
+ message: ["Booking time should be in future"],
236
+ });
256
237
  }
257
238
  };
258
239
  //---------------------
@@ -3,3 +3,4 @@ export declare const DEFAULT_PASSWORD = "turf@#123";
3
3
  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
+ export declare const DEFAULT_BOOKING_DELAY_IN_MINUTES = 15;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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_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
+ exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = 15;
@@ -5,7 +5,8 @@ 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
- convertStringToDate(dateString: string, format: string): Date;
8
+ convertStringToDate(dateString: string, format: string, offset?: number): Date;
9
+ getIndianDate(date?: Date): Date;
9
10
  isInPast(date: Date): boolean;
10
11
  getDateFromDatabaseDate: (date: string) => Date;
11
12
  noOfDaysBetweenDates: (date1: Date, date2: Date) => number;
@@ -31,12 +31,17 @@ 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.convertStringToDate = function (dateString, format) {
34
+ DateUtilService.prototype.convertStringToDate = function (dateString, format, offset) {
35
+ if (offset === void 0) { offset = 330 * 60 * 1000; }
35
36
  var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
36
37
  // IST has a fixed offset of UTC+5:30
37
- var indianDate = new Date(parsedDate.getTime() + 330 * 60 * 1000);
38
+ var indianDate = new Date(parsedDate.getTime() + offset);
38
39
  return indianDate;
39
40
  };
41
+ DateUtilService.prototype.getIndianDate = function (date) {
42
+ if (date === void 0) { date = new Date(); }
43
+ return new Date(date.getTime() + 330 * 60 * 1000);
44
+ };
40
45
  DateUtilService.prototype.isInPast = function (date) {
41
46
  return date < new Date();
42
47
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ // 001005_0P_1,006010_2P_1,011999_5P_1
3
+ // 000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ var _model_1 = require("../../@model");
6
+ // 1_5#1#1#0P,1_5#3#0.95#5P,1_5#6#0.93#7P,1_5#12#0.9#10P,6_10#1#0.98#2P,6_10#3#0.931#6.9P,6_10#6#0.9114#8.86P,6_10#12#0.882#11.8P,11_99#1#0.95#5P,11_99#3#0.9025#9.75P,11_99#6#0.8835#11.65P,11_99#12#0.855#14.5P
7
+ describe("AppController (e2e)", function () {
8
+ it("Method Testing ", function () {
9
+ _model_1.BookingCode.previousTimeChecker("2115", 240428, 0, 45);
10
+ _model_1.BookingCode.previousTimeChecker("2109", 240428, 0, 51);
11
+ });
12
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.4.2-beta.12",
3
+ "version": "1.4.2-beta.14",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
15
15
  "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
16
16
  "test": "jest",
17
- "test:pattern": "jest -i TURF-533",
17
+ "test:pattern": "jest -i method",
18
18
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
19
19
  "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
20
20
  },