turf-common 1.2.1-beta.11 → 1.2.1-beta.13
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/build/interface/entity/booking-details-entity.interface.d.ts +1 -0
- package/build/interface/model/charge-model.interface.d.ts +1 -0
- package/build/models/booking-code-model.d.ts +5 -0
- package/build/models/booking-code-model.js +11 -0
- package/build/models/charge-model.d.ts +2 -1
- package/build/models/charge-model.js +5 -4
- package/build/models/entity/booking-details-model.d.ts +1 -0
- package/build/utils/date-util.d.ts +1 -0
- package/build/utils/date-util.js +9 -0
- package/package.json +1 -1
|
@@ -86,4 +86,9 @@ 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
|
+
getTotalTime(unit?: "minute" | "hr"): number;
|
|
90
|
+
getAcrossDateCodes(): {
|
|
91
|
+
fromDateCode: string;
|
|
92
|
+
toDateCode: string;
|
|
93
|
+
};
|
|
89
94
|
}
|
|
@@ -523,6 +523,17 @@ 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
|
+
BookingCode.prototype.getTotalTime = function (unit) {
|
|
527
|
+
if (unit === void 0) { unit = "minute"; }
|
|
528
|
+
return date_util_1.dateUtilService.calculateDateDifference(this.getAcrossDateCodes().fromDateCode, this.getAcrossDateCodes().toDateCode, unit);
|
|
529
|
+
};
|
|
530
|
+
BookingCode.prototype.getAcrossDateCodes = function () {
|
|
531
|
+
var fromDateCode = "".concat(this.dateCode).concat(this.fromTimeCode);
|
|
532
|
+
var toDateCode = "".concat(this.fromTimeCode > this.toTimeCode
|
|
533
|
+
? date_util_1.dateUtilService.addNDaysToDateCode(this.dateCode, 1)
|
|
534
|
+
: this.dateCode).concat(this.toTimeCode);
|
|
535
|
+
return { fromDateCode: fromDateCode, toDateCode: toDateCode };
|
|
536
|
+
};
|
|
526
537
|
return BookingCode;
|
|
527
538
|
}());
|
|
528
539
|
exports.BookingCode = BookingCode;
|
|
@@ -11,9 +11,10 @@ export declare class ChargesModel implements IChargeModel {
|
|
|
11
11
|
amountPaid: number;
|
|
12
12
|
amountPayable: number;
|
|
13
13
|
totalRefundedAmount: number;
|
|
14
|
+
totalBookingHours: number;
|
|
14
15
|
couponCode: string;
|
|
15
16
|
discountPolicy: ModificationDiscountPolicy;
|
|
16
|
-
constructor(initialGrossAmount: number, paidAmount: number, couponCode: string, discountPolicy: ModificationDiscountPolicy);
|
|
17
|
+
constructor(initialGrossAmount: number, paidAmount: number, couponCode: string, totalBookingHours: number, discountPolicy: ModificationDiscountPolicy);
|
|
17
18
|
getGrossAmount(): number;
|
|
18
19
|
getNetAmount(): number;
|
|
19
20
|
getDiscountAmount(): number;
|
|
@@ -4,7 +4,7 @@ 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
6
|
var ChargesModel = /** @class */ (function () {
|
|
7
|
-
function ChargesModel(initialGrossAmount, paidAmount, couponCode, discountPolicy) {
|
|
7
|
+
function ChargesModel(initialGrossAmount, paidAmount, couponCode, totalBookingHours, discountPolicy) {
|
|
8
8
|
this.initialBookingGrossAmount = initialGrossAmount;
|
|
9
9
|
this.amountPaid = paidAmount;
|
|
10
10
|
this.couponCode = couponCode;
|
|
@@ -13,6 +13,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
13
13
|
this.totalCancellationCharges = 0;
|
|
14
14
|
this.refundPayable = 0;
|
|
15
15
|
this.totalRefundedAmount = 0;
|
|
16
|
+
this.totalBookingHours = totalBookingHours;
|
|
16
17
|
this.netTotal = this.getNetAmount();
|
|
17
18
|
this.amountPayable = this.getPayableRefundAmount();
|
|
18
19
|
this.discountPolicy = discountPolicy;
|
|
@@ -33,7 +34,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
33
34
|
this.cancelledBookingGrossAmount > 0) {
|
|
34
35
|
this.couponCode = "";
|
|
35
36
|
}
|
|
36
|
-
return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount());
|
|
37
|
+
return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount(), false, this.totalBookingHours);
|
|
37
38
|
};
|
|
38
39
|
ChargesModel.prototype.getPayableRefundAmount = function () {
|
|
39
40
|
return (this.getNetAmount() +
|
|
@@ -182,7 +183,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
182
183
|
return newChargeModel;
|
|
183
184
|
};
|
|
184
185
|
ChargesModel.prototype.clone = function () {
|
|
185
|
-
var that = new ChargesModel(this.initialBookingGrossAmount, this.amountPaid, this.couponCode, this.discountPolicy);
|
|
186
|
+
var that = new ChargesModel(this.initialBookingGrossAmount, this.amountPaid, this.couponCode, this.totalBookingHours, this.discountPolicy);
|
|
186
187
|
Object.assign(that, this);
|
|
187
188
|
return that;
|
|
188
189
|
};
|
|
@@ -206,7 +207,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
206
207
|
};
|
|
207
208
|
ChargesModel.getInstance = function (chargeData, discountPolicy) {
|
|
208
209
|
if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
|
|
209
|
-
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, discountPolicy);
|
|
210
|
+
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, chargeData.totalBookingHours, discountPolicy);
|
|
210
211
|
Object.assign(chargesModel, chargeData);
|
|
211
212
|
return chargesModel;
|
|
212
213
|
};
|
|
@@ -32,6 +32,7 @@ export declare class BookingDetailsModel implements IBookingDetailsModel {
|
|
|
32
32
|
updatedOn: Date;
|
|
33
33
|
createdBy: number;
|
|
34
34
|
updatedBy: number;
|
|
35
|
+
totalBookingHours: number;
|
|
35
36
|
constructor(data: IBookingDetailsEntity);
|
|
36
37
|
static getIdAndCreatedBy(bookingDetailsEntities: IBookingDetailsEntity[]): number[][];
|
|
37
38
|
assignCharges(chargeModel: ChargesModel): void;
|
|
@@ -12,5 +12,6 @@ export declare class DateUtilService {
|
|
|
12
12
|
formatTimeSlotCode(timeSlot: string, both?: boolean, date?: Date | null): string;
|
|
13
13
|
formatDateCode(dateCode: string): string;
|
|
14
14
|
getDateNDaysFromToday(n: number): Date;
|
|
15
|
+
calculateDateDifference(fromDateCode: string, toDateCode: string, unit?: "minute" | "hr"): number;
|
|
15
16
|
}
|
|
16
17
|
export declare const dateUtilService: DateUtilService;
|
package/build/utils/date-util.js
CHANGED
|
@@ -63,6 +63,15 @@ var DateUtilService = /** @class */ (function () {
|
|
|
63
63
|
futureDate.setDate(today.getDate() + n);
|
|
64
64
|
return futureDate;
|
|
65
65
|
};
|
|
66
|
+
DateUtilService.prototype.calculateDateDifference = function (fromDateCode, toDateCode, unit) {
|
|
67
|
+
if (unit === void 0) { unit = "minute"; }
|
|
68
|
+
var fromDate = (0, date_fns_1.parse)(fromDateCode, "yyMMddHHmm", new Date());
|
|
69
|
+
var toDate = (0, date_fns_1.parse)(toDateCode, "yyMMddHHmm", new Date());
|
|
70
|
+
var minutesDifference = (0, date_fns_1.differenceInMinutes)(toDate, fromDate);
|
|
71
|
+
return unit === "minute"
|
|
72
|
+
? minutesDifference
|
|
73
|
+
: parseFloat((minutesDifference / 60).toFixed(1));
|
|
74
|
+
};
|
|
66
75
|
return DateUtilService;
|
|
67
76
|
}());
|
|
68
77
|
exports.DateUtilService = DateUtilService;
|