turf-common 1.2.1-beta.20 → 1.2.1-beta.22

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.
@@ -1,5 +1,6 @@
1
1
  import { BookingDetailsStatus, PaymentMode, UserType } from "../@enum";
2
- export interface IGetBookingById {
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;
@@ -92,6 +92,15 @@ export declare class BookingCode {
92
92
  * @returns The total time difference in the specified unit (minutes or hours) between the "from" and "to" date codes.
93
93
  */
94
94
  getTotalTime(unit?: "minute" | "hr"): number;
95
+ /**
96
+ * Gets the date codes across a time range.
97
+ *
98
+ * @returns An object containing the date codes for the from and to time.
99
+ * @description
100
+ * The `fromDateCode` is generated by combining the current instance's `dateCode` and `fromTimeCode`.
101
+ * The `toDateCode` is generated based on the `fromTimeCode` and `toTimeCode`. If `fromTimeCode` is greater
102
+ * than `toTimeCode`, it adds one day to the current instance's `dateCode`.
103
+ */
95
104
  getAcrossDateCodes(): {
96
105
  fromDateCode: string;
97
106
  toDateCode: string;
@@ -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"; }
@@ -121,8 +122,8 @@ var BookingCode = /** @class */ (function () {
121
122
  var discount = 0;
122
123
  var discountedCost = 0;
123
124
  if (couponCode) {
124
- var code = couponCode.match(/[a-zA-Z]+/g);
125
- var value = couponCode.match(/\d+/g);
125
+ var code = _utils_1.stringUtil.getCouponDetails(couponCode).code;
126
+ var value = _utils_1.stringUtil.getCouponDetails(couponCode).value;
126
127
  if (validationApply && !code && !value) {
127
128
  throw new app_badrequest_exception_1.AppBadRequestException({
128
129
  key: "couponCode",
@@ -532,6 +533,15 @@ var BookingCode = /** @class */ (function () {
532
533
  if (unit === void 0) { unit = "minute"; }
533
534
  return date_util_1.dateUtilService.calculateDateDifference(this.getAcrossDateCodes().fromDateCode, this.getAcrossDateCodes().toDateCode, unit);
534
535
  };
536
+ /**
537
+ * Gets the date codes across a time range.
538
+ *
539
+ * @returns An object containing the date codes for the from and to time.
540
+ * @description
541
+ * The `fromDateCode` is generated by combining the current instance's `dateCode` and `fromTimeCode`.
542
+ * The `toDateCode` is generated based on the `fromTimeCode` and `toTimeCode`. If `fromTimeCode` is greater
543
+ * than `toTimeCode`, it adds one day to the current instance's `dateCode`.
544
+ */
535
545
  BookingCode.prototype.getAcrossDateCodes = function () {
536
546
  var fromDateCode = "".concat(this.dateCode).concat(this.fromTimeCode);
537
547
  var toDateCode = "".concat(this.fromTimeCode > this.toTimeCode
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChargesModel = void 0;
4
4
  var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
5
5
  var modification_discount_policy_enum_1 = require("../enums/modification-discount-policy.enum");
6
+ var _utils_1 = require("../@utils");
6
7
  var ChargesModel = /** @class */ (function () {
7
8
  function ChargesModel(initialGrossAmount, paidAmount, couponCode, totalBookingHours, discountPolicy) {
8
9
  this.initialBookingGrossAmount = initialGrossAmount;
@@ -51,8 +52,8 @@ var ChargesModel = /** @class */ (function () {
51
52
  if (validationApply === void 0) { validationApply = false; }
52
53
  var discountAmount = 0;
53
54
  if (couponCode) {
54
- var code = couponCode.match(/[a-zA-Z]+/g);
55
- var value = couponCode.match(/\d+/g);
55
+ var code = _utils_1.stringUtil.getCouponDetails(couponCode).code;
56
+ var value = _utils_1.stringUtil.getCouponDetails(couponCode).value;
56
57
  if (validationApply && !code && !value) {
57
58
  throw new app_badrequest_exception_1.AppBadRequestException({
58
59
  key: "couponCode",
@@ -15,6 +15,17 @@ declare class StringUtil {
15
15
  */
16
16
  formatStringWithHyphens(inputString: string): string;
17
17
  generateRandomPassword(): string;
18
+ /**
19
+ * Extracts details from a coupon code.
20
+ *
21
+ * @param {string} couponCode - The coupon code to analyze.
22
+ * @returns {Object} - Object with 'code' (alphabetic part) and 'value' (numeric part) properties.
23
+ * @throws {TypeError} - If the provided 'couponCode' is not a string.
24
+ */
25
+ getCouponDetails(couponCode: string): {
26
+ code: RegExpMatchArray | null;
27
+ value: RegExpMatchArray | null;
28
+ };
18
29
  }
19
30
  export declare const stringUtil: StringUtil;
20
31
  export {};
@@ -55,6 +55,21 @@ var StringUtil = /** @class */ (function () {
55
55
  }
56
56
  return passwordArray.join("");
57
57
  };
58
+ /**
59
+ * Extracts details from a coupon code.
60
+ *
61
+ * @param {string} couponCode - The coupon code to analyze.
62
+ * @returns {Object} - Object with 'code' (alphabetic part) and 'value' (numeric part) properties.
63
+ * @throws {TypeError} - If the provided 'couponCode' is not a string.
64
+ */
65
+ StringUtil.prototype.getCouponDetails = function (couponCode) {
66
+ var code = couponCode.match(/[a-zA-Z]+/g);
67
+ var value = couponCode.match(/\d+/g);
68
+ return {
69
+ code: code,
70
+ value: value,
71
+ };
72
+ };
58
73
  return StringUtil;
59
74
  }());
60
75
  exports.stringUtil = new StringUtil();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.20",
3
+ "version": "1.2.1-beta.22",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",