turf-common 1.2.1-beta.13 → 1.2.1-beta.15

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.
@@ -86,6 +86,11 @@ export declare class BookingCode {
86
86
  formatDateAndTime(formateDateAndTime: IFormateDateAndTime): string;
87
87
  static timeFormatter(timeFormatter: ITimeFormatter): string;
88
88
  static dateFormatter(dateFormatter: IDateFormatter): string;
89
+ /**
90
+ * Calculates the total time difference between two date codes.
91
+ * @param unit - Optional. Specifies the unit of time for the result. Valid values are "minute" or "hr". Defaults to "minute" if not provided.
92
+ * @returns The total time difference in the specified unit (minutes or hours) between the "from" and "to" date codes.
93
+ */
89
94
  getTotalTime(unit?: "minute" | "hr"): number;
90
95
  getAcrossDateCodes(): {
91
96
  fromDateCode: string;
@@ -523,6 +523,11 @@ var BookingCode = /** @class */ (function () {
523
523
  var dateFormat = dateFormatter.dateFormat, dateCode = dateFormatter.dateCode;
524
524
  return (0, date_fns_1.format)(BookingCode.convertToDate(dateCode), dateFormat);
525
525
  };
526
+ /**
527
+ * Calculates the total time difference between two date codes.
528
+ * @param unit - Optional. Specifies the unit of time for the result. Valid values are "minute" or "hr". Defaults to "minute" if not provided.
529
+ * @returns The total time difference in the specified unit (minutes or hours) between the "from" and "to" date codes.
530
+ */
526
531
  BookingCode.prototype.getTotalTime = function (unit) {
527
532
  if (unit === void 0) { unit = "minute"; }
528
533
  return date_util_1.dateUtilService.calculateDateDifference(this.getAcrossDateCodes().fromDateCode, this.getAcrossDateCodes().toDateCode, unit);
@@ -101,13 +101,17 @@ var ChargesModel = /** @class */ (function () {
101
101
  };
102
102
  ChargesModel.prototype.modify = function (bookingModification) {
103
103
  var oldBookingCode = bookingModification.oldBookingCode, newBookingCode = bookingModification.newBookingCode, cancellationUnit = bookingModification.cancellationUnit;
104
+ this.totalBookingHours =
105
+ this.totalBookingHours -
106
+ oldBookingCode.getTotalTime("hr") +
107
+ (newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
104
108
  if (!newBookingCode) {
105
109
  return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
106
110
  }
107
111
  if (!newBookingCode)
108
112
  return null;
109
- var oldTimeSlotMinutes = oldBookingCode.getTimeslot().getTotalMinutes();
110
- var newTimeSlotMinutes = newBookingCode.getTimeslot().getTotalMinutes();
113
+ var oldTimeSlotMinutes = oldBookingCode.getTotalTime();
114
+ var newTimeSlotMinutes = newBookingCode.getTotalTime();
111
115
  if (oldTimeSlotMinutes === newTimeSlotMinutes) {
112
116
  return this.modifyMove(oldBookingCode, newBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
113
117
  }
@@ -188,6 +192,7 @@ var ChargesModel = /** @class */ (function () {
188
192
  return that;
189
193
  };
190
194
  ChargesModel.prototype.modifyDelete = function (bookingCode, cancellationUnit) {
195
+ this.couponCode = "";
191
196
  var newChargeModel = this.clone();
192
197
  newChargeModel.couponCode = "";
193
198
  var costDifference = bookingCode.getCost();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.13",
3
+ "version": "1.2.1-beta.15",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",