turf-common 1.4.2-beta.45 → 1.4.2-beta.47

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/README.md CHANGED
@@ -1,20 +1,20 @@
1
- ## 1 npm init -y
2
-
3
- ## 2 npm login
4
-
5
- ## 3 npm version patch
6
-
7
- # //it increase version
8
-
9
- ## 3 npm publish --access public
10
-
11
- # //npm publish by default --access public
12
-
13
- ## 4 npm run version:deploy
14
-
15
- ### deploy version
16
-
17
- ## Client side
18
-
19
- update package command <br />
20
- npm update turf-comman
1
+ ## 1 npm init -y
2
+
3
+ ## 2 npm login
4
+
5
+ ## 3 npm version patch
6
+
7
+ # //it increase version
8
+
9
+ ## 3 npm publish --access public
10
+
11
+ # //npm publish by default --access public
12
+
13
+ ## 4 npm run version:deploy
14
+
15
+ ### deploy version
16
+
17
+ ## Client side
18
+
19
+ update package command <br />
20
+ npm update turf-comman
@@ -39,6 +39,7 @@ export declare class BookingCode {
39
39
  }): number;
40
40
  isModificationAllowed(delayInMinutes?: number): boolean;
41
41
  isDeletionAllowed(delayInMinutes?: number): boolean;
42
+ isCreationAllowed(delayInMinutes?: number): boolean;
42
43
  static sortByCode(bookingCodes: BookingCode[]): void;
43
44
  static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
44
45
  static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
@@ -54,6 +55,7 @@ export declare class BookingCode {
54
55
  static isValidTimeRange(timeSlot: string): boolean;
55
56
  static dateFormat(dates: Array<Date>): Array<string>;
56
57
  static getDateCode(date: Date): string;
58
+ static getMonthCode(date: Date): number;
57
59
  /**
58
60
  * Returns list of month codes (YYMM) in the Date range inclusive
59
61
  * @param {Date} from - Start Date
@@ -121,6 +121,12 @@ var BookingCode = /** @class */ (function () {
121
121
  var currentTime = date_util_1.dateUtilService.getIndianDate();
122
122
  return bookingFromDateTimeWithDelay > currentTime;
123
123
  };
124
+ BookingCode.prototype.isCreationAllowed = function (delayInMinutes) {
125
+ if (delayInMinutes === void 0) { delayInMinutes = _utils_1.DEFAULT_BOOKING_DELAY_IN_MINUTES; }
126
+ var bookingFromDateTimeWithDelay = date_util_1.dateUtilService.addMinutesTo(date_util_1.dateUtilService.convertStringToDate(this.getDateWithFromTimeCode(), "yyMMddHHmm"), delayInMinutes);
127
+ var currentTime = date_util_1.dateUtilService.getIndianDate();
128
+ return bookingFromDateTimeWithDelay > currentTime;
129
+ };
124
130
  BookingCode.sortByCode = function (bookingCodes) {
125
131
  bookingCodes.sort(function (_a, _b) {
126
132
  var code1 = _a.code;
@@ -310,6 +316,11 @@ var BookingCode = /** @class */ (function () {
310
316
  .toString()
311
317
  .padStart(2, "0")).concat(date.getDate().toString().padStart(2, "0"));
312
318
  };
319
+ BookingCode.getMonthCode = function (date) {
320
+ return parseInt("".concat(date.getFullYear() % 2000).concat((date.getMonth() + 1)
321
+ .toString()
322
+ .padStart(2, "0")));
323
+ };
313
324
  /**
314
325
  * Returns list of month codes (YYMM) in the Date range inclusive
315
326
  * @param {Date} from - Start Date
@@ -320,14 +331,18 @@ var BookingCode = /** @class */ (function () {
320
331
  from = new Date(from.getTime());
321
332
  to = new Date(to.getTime());
322
333
  var monthCodes = [];
323
- while (from < to) {
324
- var fromDateCode = BookingCode.getDateCode(from);
325
- monthCodes.push(parseInt("".concat(fromDateCode.slice(0, 4))));
326
- from.setMonth(from.getMonth() + 1);
327
- }
328
- var toDateCode = BookingCode.getDateCode(to);
329
- if (!monthCodes.includes(parseInt("".concat(toDateCode.slice(0, 4))))) {
330
- monthCodes.push(parseInt("".concat(toDateCode.slice(0, 4))));
334
+ var fromMonthCode = BookingCode.getMonthCode(from);
335
+ var toMonthCode = BookingCode.getMonthCode(to);
336
+ var currentMonthCode = fromMonthCode;
337
+ while (currentMonthCode <= toMonthCode) {
338
+ monthCodes.push(currentMonthCode);
339
+ // Change of year handling
340
+ if (currentMonthCode % 100 === 12) {
341
+ currentMonthCode = currentMonthCode + 100 - 11;
342
+ }
343
+ else {
344
+ currentMonthCode = currentMonthCode + 1;
345
+ }
331
346
  }
332
347
  return monthCodes;
333
348
  };
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "turf-common",
3
- "version": "1.4.2-beta.45",
4
- "description": "",
5
- "main": "./build/index.js",
6
- "types": "./build/index.d.ts",
7
- "files": [
8
- "build/**/*"
9
- ],
10
- "scripts": {
11
- "clean": "rm -rf build",
12
- "build": "npm run clean && tsc",
13
- "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
14
- "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
15
- "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
16
- "test": "jest",
17
- "test:pattern": "jest -i unit/charges/discount-relative",
18
- "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
19
- "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "github__bellex-dev__turf-common:bellex-dev/turf-common.git"
24
- },
25
- "keywords": [],
26
- "author": "",
27
- "license": "ISC",
28
- "devDependencies": {
29
- "@types/jest": "^29.5.11",
30
- "@types/node": "^20.8.9",
31
- "@typescript-eslint/eslint-plugin": "^6.7.2",
32
- "@typescript-eslint/parser": "^6.7.2",
33
- "del-cli": "^5.1.0",
34
- "eslint": "^8.50.0",
35
- "jest": "^29.7.0",
36
- "ts-jest": "^29.1.1",
37
- "ts-node": "^10.9.2",
38
- "typescript": "^5.2.2"
39
- },
40
- "dependencies": {
41
- "date-fns": "^2.30.0"
42
- }
43
- }
1
+ {
2
+ "name": "turf-common",
3
+ "version": "1.4.2-beta.47",
4
+ "description": "",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "files": [
8
+ "build/**/*"
9
+ ],
10
+ "scripts": {
11
+ "clean": "rm -rf build",
12
+ "build": "npm run clean && tsc",
13
+ "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
14
+ "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
15
+ "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
16
+ "test": "jest",
17
+ "test:pattern": "jest -i unit/charges/discount-relative",
18
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
19
+ "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "github__bellex-dev__turf-common:bellex-dev/turf-common.git"
24
+ },
25
+ "keywords": [],
26
+ "author": "",
27
+ "license": "ISC",
28
+ "devDependencies": {
29
+ "@types/jest": "^29.5.11",
30
+ "@types/node": "^20.8.9",
31
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
32
+ "@typescript-eslint/parser": "^6.7.2",
33
+ "del-cli": "^5.1.0",
34
+ "eslint": "^8.50.0",
35
+ "jest": "^29.7.0",
36
+ "ts-jest": "^29.1.1",
37
+ "ts-node": "^10.9.2",
38
+ "typescript": "^5.2.2"
39
+ },
40
+ "dependencies": {
41
+ "date-fns": "^2.30.0"
42
+ }
43
+ }