turf-common 1.2.1-beta.23 → 1.2.1-beta.25

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.
@@ -130,7 +130,7 @@ var BookingCode = /** @class */ (function () {
130
130
  message: ["Coupon with code ".concat(couponCode, " is wrong ")],
131
131
  });
132
132
  }
133
- if (code && (code[0] === "P" || code[0] === "PHP")) {
133
+ if (code === "P" || code === "PHP") {
134
134
  var percentDiscount = parseFloat(couponCode);
135
135
  if (validationApply) {
136
136
  if (percentDiscount > 90) {
@@ -142,10 +142,10 @@ var BookingCode = /** @class */ (function () {
142
142
  }
143
143
  discount = totalCost * (percentDiscount / 100);
144
144
  }
145
- else if (code && code[0] === "U") {
145
+ else if (code === "U") {
146
146
  discount = parseFloat(couponCode);
147
147
  }
148
- else if (code && code[0] === "PHU") {
148
+ else if (code === "PHU") {
149
149
  if (totalBookingHours === undefined) {
150
150
  throw new app_badrequest_exception_1.AppBadRequestException({
151
151
  key: "totalBookingHours",
@@ -60,7 +60,7 @@ var ChargesModel = /** @class */ (function () {
60
60
  message: ["Coupon with code ".concat(couponCode, " is wrong ")],
61
61
  });
62
62
  }
63
- if (code && (code[0] === "P" || code[0] === "PHP")) {
63
+ if (code === "P" || code === "PHP") {
64
64
  var percentDiscount = parseFloat(couponCode);
65
65
  if (validationApply && percentDiscount > 90) {
66
66
  throw new app_badrequest_exception_1.AppBadRequestException({
@@ -70,10 +70,10 @@ var ChargesModel = /** @class */ (function () {
70
70
  }
71
71
  discountAmount = totalCost * (percentDiscount / 100);
72
72
  }
73
- else if (code && code[0] === "U") {
73
+ else if (code === "U") {
74
74
  discountAmount = parseFloat(couponCode);
75
75
  }
76
- else if (code && code[0] === "PHU") {
76
+ else if (code === "PHU") {
77
77
  if (totalBookingHours === undefined) {
78
78
  throw new app_badrequest_exception_1.AppBadRequestException({
79
79
  key: "totalBookingHours",
@@ -102,10 +102,10 @@ var ChargesModel = /** @class */ (function () {
102
102
  };
103
103
  ChargesModel.prototype.modify = function (bookingModification) {
104
104
  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);
105
+ // this.totalBookingHours =
106
+ // this.totalBookingHours -
107
+ // oldBookingCode.getTotalTime("hr") +
108
+ // (newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
109
109
  if (!newBookingCode) {
110
110
  return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
111
111
  }
@@ -125,7 +125,11 @@ var ChargesModel = /** @class */ (function () {
125
125
  return null;
126
126
  };
127
127
  ChargesModel.prototype.modifyExtend = function (oldBookingCode, newBookingCode) {
128
+ var newTotalBookingHours = this.totalBookingHours -
129
+ oldBookingCode.getTotalTime("hr") +
130
+ (newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
128
131
  var newChargeModel = this.clone();
132
+ newChargeModel.totalBookingHours = newTotalBookingHours;
129
133
  newChargeModel.additionalBookingGrossAmount +=
130
134
  newBookingCode.getCost() - oldBookingCode.getCost();
131
135
  newChargeModel.netTotal = newChargeModel.getNetAmount();
@@ -23,8 +23,8 @@ declare class StringUtil {
23
23
  * @throws {TypeError} - If the provided 'couponCode' is not a string.
24
24
  */
25
25
  getCouponDetails(couponCode: string): {
26
- code: RegExpMatchArray | null;
27
- value: RegExpMatchArray | null;
26
+ code: string;
27
+ value: string;
28
28
  };
29
29
  }
30
30
  export declare const stringUtil: StringUtil;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stringUtil = void 0;
4
+ var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
4
5
  var StringUtil = /** @class */ (function () {
5
6
  function StringUtil() {
6
7
  }
@@ -65,9 +66,15 @@ var StringUtil = /** @class */ (function () {
65
66
  StringUtil.prototype.getCouponDetails = function (couponCode) {
66
67
  var code = couponCode.match(/[a-zA-Z]+/g);
67
68
  var value = couponCode.match(/\d+/g);
69
+ if (!code || !value) {
70
+ throw new app_badrequest_exception_1.AppBadRequestException({
71
+ key: "couponCode",
72
+ message: ["coupon with code ".concat(couponCode, " is wrong ")],
73
+ });
74
+ }
68
75
  return {
69
- code: code,
70
- value: value,
76
+ code: code[0],
77
+ value: value[0],
71
78
  };
72
79
  };
73
80
  return StringUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.23",
3
+ "version": "1.2.1-beta.25",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",