turf-common 1.4.2-beta.8 → 2.0.0
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 +20 -20
- package/build/jest.config.js +2 -1
- package/build/src/@model.d.ts +1 -0
- package/build/src/@model.js +1 -0
- package/build/src/enums/booking-history-operation-type.enum.d.ts +4 -1
- package/build/src/enums/booking-history-operation-type.enum.js +3 -0
- package/build/src/enums/organization-status.enum.d.ts +4 -0
- package/build/src/enums/organization-status.enum.js +6 -1
- package/build/src/enums/transaction-type.enum.d.ts +2 -1
- package/build/src/enums/transaction-type.enum.js +1 -0
- package/build/src/interface/api/booking-availablity-by-pitch.interface.d.ts +1 -0
- package/build/src/interface/api/booking-pending-payment-writeoff.interface.d.ts +10 -0
- package/build/src/interface/api/booking-pending-payment-writeoff.interface.js +2 -0
- package/build/src/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
- package/build/src/interface/api/create-user.interface.d.ts +1 -1
- package/build/src/interface/api/get-availability-by-turf.interface.d.ts +1 -0
- package/build/src/interface/api/get-booking-by-organization-id.interface.d.ts +1 -1
- package/build/src/interface/api/get-booking-history.interface.d.ts +1 -0
- package/build/src/interface/api/get-collection.interface.d.ts +1 -1
- package/build/src/interface/api/get-organization-configuration.interface.d.ts +8 -0
- package/build/src/interface/api/get-organization-configuration.interface.js +2 -0
- package/build/src/interface/api/index.d.ts +3 -0
- package/build/src/interface/api/index.js +3 -0
- package/build/src/interface/api/login-response.interface.d.ts +4 -1
- package/build/src/interface/api/one-slot-booking.interface.d.ts +2 -0
- package/build/src/interface/api/staff-member-list.interface.d.ts +1 -1
- package/build/src/interface/api/update-organization-configuration.interface.d.ts +6 -0
- package/build/src/interface/api/update-organization-configuration.interface.js +2 -0
- package/build/src/interface/api/update-recurring-booking.interface.d.ts +1 -0
- package/build/src/interface/api/update-staff-member.interface.d.ts +1 -1
- package/build/src/interface/entity/organization-entity.interface.d.ts +15 -3
- package/build/src/interface/entity/user-entity.interface.d.ts +6 -6
- package/build/src/interface/get-booking-by-id.interface.d.ts +2 -2
- package/build/src/interface/model/booking-details-model.interface.d.ts +8 -0
- package/build/src/interface/user-entity-essential-info.interface.d.ts +1 -1
- package/build/src/models/booking-code-model.d.ts +16 -2
- package/build/src/models/booking-code-model.js +83 -40
- package/build/src/models/charge-model.d.ts +2 -0
- package/build/src/models/charge-model.js +41 -11
- package/build/src/models/entity/booking-details-model.d.ts +2 -1
- package/build/src/models/entity/booking-details-model.js +19 -0
- package/build/src/models/entity/booking-entity-model.d.ts +1 -0
- package/build/src/models/entity/booking-entity-model.js +3 -0
- package/build/src/models/entity/user-model.d.ts +6 -6
- package/build/src/models/time-slot-model.d.ts +1 -0
- package/build/src/models/time-slot-model.js +3 -0
- package/build/src/models/turf-availability-model.d.ts +18 -3
- package/build/src/models/turf-availability-model.js +60 -3
- package/build/src/models/weekday-time-slot-model.d.ts +12 -0
- package/build/src/models/weekday-time-slot-model.js +30 -0
- package/build/src/utils/constant.d.ts +3 -0
- package/build/src/utils/constant.js +4 -1
- package/build/src/utils/date-util.d.ts +8 -1
- package/build/src/utils/date-util.js +22 -3
- package/build/tests/booking-code/method.spec.d.ts +1 -0
- package/build/tests/booking-code/method.spec.js +11 -0
- package/build/tests/unit/charges/discount-relative/basic.spec.d.ts +1 -0
- package/build/tests/unit/charges/discount-relative/basic.spec.js +209 -0
- package/build/tests/unit/charges/extension/basic.amount-fully-paid.spec.d.ts +1 -0
- package/build/tests/unit/charges/extension/basic.amount-fully-paid.spec.js +208 -0
- package/build/tests/unit/charges/extension/basic.spec.d.ts +1 -0
- package/build/tests/unit/charges/extension/basic.spec.js +215 -0
- package/build/tests/unit/pricing-plan/basic-scenario.spec.js +1 -1
- package/package.json +17 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dateUtilService = exports.DateUtilService = void 0;
|
|
3
|
+
exports.dateUtilService = exports.Timezone = exports.DateUtilService = void 0;
|
|
4
4
|
var date_fns_1 = require("date-fns");
|
|
5
5
|
var _model_1 = require("../@model");
|
|
6
6
|
var DateUtilService = /** @class */ (function () {
|
|
@@ -31,12 +31,20 @@ var DateUtilService = /** @class */ (function () {
|
|
|
31
31
|
DateUtilService.prototype.addNDaysToDate = function (date, n) {
|
|
32
32
|
return (0, date_fns_1.add)(date, { days: n });
|
|
33
33
|
};
|
|
34
|
-
DateUtilService.prototype.
|
|
34
|
+
DateUtilService.prototype.addMinutesTo = function (date, minutes) {
|
|
35
|
+
return (0, date_fns_1.add)(date, { minutes: minutes });
|
|
36
|
+
};
|
|
37
|
+
DateUtilService.prototype.convertStringToDate = function (dateString, format, offset) {
|
|
38
|
+
if (offset === void 0) { offset = 330 * 60 * 1000; }
|
|
35
39
|
var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
|
|
36
40
|
// IST has a fixed offset of UTC+5:30
|
|
37
|
-
var indianDate = new Date(parsedDate.getTime() +
|
|
41
|
+
var indianDate = new Date(parsedDate.getTime() + offset);
|
|
38
42
|
return indianDate;
|
|
39
43
|
};
|
|
44
|
+
DateUtilService.prototype.getIndianDate = function (date) {
|
|
45
|
+
if (date === void 0) { date = new Date(); }
|
|
46
|
+
return new Date(date.getTime() + 330 * 60 * 1000);
|
|
47
|
+
};
|
|
40
48
|
DateUtilService.prototype.isInPast = function (date) {
|
|
41
49
|
return date < new Date();
|
|
42
50
|
};
|
|
@@ -151,7 +159,18 @@ var DateUtilService = /** @class */ (function () {
|
|
|
151
159
|
DateUtilService.prototype.formatDate = function (date, formatString) {
|
|
152
160
|
return (0, date_fns_1.format)(date, formatString);
|
|
153
161
|
};
|
|
162
|
+
DateUtilService.prototype.convertDateToTimezone = function (date, timeZone) {
|
|
163
|
+
return new Date(date.toLocaleString("en-US", { timeZone: timeZone }));
|
|
164
|
+
// return new Date(date.getTime() + offset);
|
|
165
|
+
};
|
|
166
|
+
DateUtilService.prototype.convertDateToUTC = function (now) {
|
|
167
|
+
return new Date(now.getTime() + now.getTimezoneOffset() * 60 * 1000);
|
|
168
|
+
};
|
|
154
169
|
return DateUtilService;
|
|
155
170
|
}());
|
|
156
171
|
exports.DateUtilService = DateUtilService;
|
|
172
|
+
var Timezone;
|
|
173
|
+
(function (Timezone) {
|
|
174
|
+
Timezone["IST"] = "Asia/Kolkata";
|
|
175
|
+
})(Timezone || (exports.Timezone = Timezone = {}));
|
|
157
176
|
exports.dateUtilService = new DateUtilService();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 001005_0P_1,006010_2P_1,011999_5P_1
|
|
3
|
+
// 000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// 1_5#1#1#0P,1_5#3#0.95#5P,1_5#6#0.93#7P,1_5#12#0.9#10P,6_10#1#0.98#2P,6_10#3#0.931#6.9P,6_10#6#0.9114#8.86P,6_10#12#0.882#11.8P,11_99#1#0.95#5P,11_99#3#0.9025#9.75P,11_99#6#0.8835#11.65P,11_99#12#0.855#14.5P
|
|
6
|
+
describe("AppController (e2e)", function () {
|
|
7
|
+
it("Method Testing ", function () {
|
|
8
|
+
// BookingCode.previousTimeChecker("2115",240428, 0, 45);
|
|
9
|
+
// BookingCode.previousTimeChecker("2109",240428, 0, 51);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var _enum_1 = require("../../../../@enum");
|
|
4
|
+
var _model_1 = require("../../../../src/@model");
|
|
5
|
+
var booking_entity_test_1 = require("../../../utils/models/booking-entity-test");
|
|
6
|
+
describe("AppController (e2e)", function () {
|
|
7
|
+
var initialBookingCode1 = _model_1.BookingCode.getInstanceByComponents(1, 1, 230813, '1000', '1200', '500,500,500,500');
|
|
8
|
+
var initialBookingCode2 = _model_1.BookingCode.getInstanceByComponents(1, 1, 230814, '1000', '1100', '500,500');
|
|
9
|
+
var modify1ExtendBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 1, 230814, '1000', '1200', '500,500,500,500');
|
|
10
|
+
var modify2ExtensionBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '1200', '1230', '500');
|
|
11
|
+
var modify3ReduceOldBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '1000', '1230', '500,500,500,500,500');
|
|
12
|
+
var modify3ReduceNewBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '1000', '1100', '500,500');
|
|
13
|
+
var modify4ExtensionBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '0900', '1000', '500,500');
|
|
14
|
+
var modify5DeleteNewBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '0900', '1100', '500,500,500,500');
|
|
15
|
+
var bookingCodes = [
|
|
16
|
+
initialBookingCode1, initialBookingCode2
|
|
17
|
+
];
|
|
18
|
+
var initialGrossAmount = bookingCodes
|
|
19
|
+
.map(function (bookingCode) { return bookingCode.getCost(); })
|
|
20
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
21
|
+
var totalBookingHours = booking_entity_test_1.BookingEntityTest.getTotalHours(bookingCodes);
|
|
22
|
+
var chargeModel = new _model_1.ChargesModel(initialGrossAmount, 0, "", totalBookingHours, _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL);
|
|
23
|
+
var currentChargeModel = chargeModel;
|
|
24
|
+
it("create", function () {
|
|
25
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
26
|
+
var expectedAdditionalBookingGrossAmount = 0;
|
|
27
|
+
var expectedCancellationGrossAmount = 0;
|
|
28
|
+
var expectedTotalCancellationCharges = 0;
|
|
29
|
+
var expectedRefundPayable = 0;
|
|
30
|
+
var expectedNetTotal = 2700;
|
|
31
|
+
var expectedAmountPaid = 0;
|
|
32
|
+
var expectedAmountPayable = 2700;
|
|
33
|
+
var expectedTotalRefundedAmount = 0;
|
|
34
|
+
var expectedCouponCode = "100PHU";
|
|
35
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE;
|
|
36
|
+
var initialGrossAmount = bookingCodes
|
|
37
|
+
.map(function (bookingCode) { return bookingCode.getCost(); })
|
|
38
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
39
|
+
chargeModel = new _model_1.ChargesModel(initialGrossAmount, 0, "100PHU", totalBookingHours, _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE);
|
|
40
|
+
currentChargeModel = chargeModel;
|
|
41
|
+
expect(chargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
42
|
+
expect(chargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
43
|
+
expect(chargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
44
|
+
expect(chargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
45
|
+
expect(chargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
46
|
+
expect(chargeModel.netTotal).toEqual(expectedNetTotal);
|
|
47
|
+
expect(chargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
48
|
+
expect(chargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
49
|
+
expect(chargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
50
|
+
expect(chargeModel.couponCode).toEqual(expectedCouponCode);
|
|
51
|
+
expect(chargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
52
|
+
});
|
|
53
|
+
it("1. modify extend", function () {
|
|
54
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
55
|
+
var expectedAdditionalBookingGrossAmount = 1000;
|
|
56
|
+
var expectedCancellationGrossAmount = 0;
|
|
57
|
+
var expectedTotalCancellationCharges = 0;
|
|
58
|
+
var expectedRefundPayable = 0;
|
|
59
|
+
var expectedNetTotal = 3600;
|
|
60
|
+
var expectedAmountPaid = 0;
|
|
61
|
+
var expectedAmountPayable = 3600;
|
|
62
|
+
var expectedTotalRefundedAmount = 0;
|
|
63
|
+
var expectedCouponCode = "100PHU";
|
|
64
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE;
|
|
65
|
+
if (currentChargeModel)
|
|
66
|
+
currentChargeModel = currentChargeModel.modify({
|
|
67
|
+
oldBookingCode: initialBookingCode2,
|
|
68
|
+
newBookingCode: modify1ExtendBookingCode,
|
|
69
|
+
});
|
|
70
|
+
expect(currentChargeModel).not.toBeNull();
|
|
71
|
+
if (currentChargeModel) {
|
|
72
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
73
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
74
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
75
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
76
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
77
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
78
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
79
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
80
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
81
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
82
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
it("2. extension", function () {
|
|
86
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
87
|
+
var expectedAdditionalBookingGrossAmount = 1000 + 500;
|
|
88
|
+
var expectedCancellationGrossAmount = 0;
|
|
89
|
+
var expectedTotalCancellationCharges = 0;
|
|
90
|
+
var expectedRefundPayable = 0;
|
|
91
|
+
var expectedNetTotal = 3600 + 450;
|
|
92
|
+
var expectedAmountPaid = 0;
|
|
93
|
+
var expectedAmountPayable = 3600 + 450;
|
|
94
|
+
var expectedTotalRefundedAmount = 0;
|
|
95
|
+
var expectedCouponCode = "100PHU";
|
|
96
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE;
|
|
97
|
+
if (currentChargeModel)
|
|
98
|
+
currentChargeModel = currentChargeModel.extension(modify2ExtensionBookingCode);
|
|
99
|
+
expect(currentChargeModel).not.toBeNull();
|
|
100
|
+
if (currentChargeModel) {
|
|
101
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
102
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
103
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
104
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
105
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
106
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
107
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
108
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
109
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
110
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
111
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
it("3. modify reduce", function () {
|
|
115
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
116
|
+
var expectedAdditionalBookingGrossAmount = 1500;
|
|
117
|
+
var expectedCancellationGrossAmount = 0 + 1500;
|
|
118
|
+
var expectedTotalCancellationCharges = 0 + 100;
|
|
119
|
+
var expectedRefundPayable = 0;
|
|
120
|
+
var expectedNetTotal = 4050 - 1500 + 150;
|
|
121
|
+
var expectedAmountPaid = 0;
|
|
122
|
+
var expectedAmountPayable = 4050 - 1500 + 150 + 100;
|
|
123
|
+
var expectedTotalRefundedAmount = 0;
|
|
124
|
+
var expectedCouponCode = "100PHU";
|
|
125
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE;
|
|
126
|
+
if (currentChargeModel)
|
|
127
|
+
currentChargeModel = currentChargeModel.modify({
|
|
128
|
+
oldBookingCode: modify3ReduceOldBookingCode,
|
|
129
|
+
newBookingCode: modify3ReduceNewBookingCode,
|
|
130
|
+
cancellationUnit: "100U",
|
|
131
|
+
});
|
|
132
|
+
expect(currentChargeModel).not.toBeNull();
|
|
133
|
+
if (currentChargeModel) {
|
|
134
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
135
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
136
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
137
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
138
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
139
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
140
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
141
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
142
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
143
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
144
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
it("4. extension", function () {
|
|
148
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
149
|
+
var expectedAdditionalBookingGrossAmount = 1500 + 1000;
|
|
150
|
+
var expectedCancellationGrossAmount = 1500;
|
|
151
|
+
var expectedTotalCancellationCharges = 100;
|
|
152
|
+
var expectedRefundPayable = 0;
|
|
153
|
+
var expectedNetTotal = 2700 + 900;
|
|
154
|
+
var expectedAmountPaid = 0;
|
|
155
|
+
var expectedAmountPayable = 2800 + 900;
|
|
156
|
+
var expectedTotalRefundedAmount = 0;
|
|
157
|
+
var expectedCouponCode = "100PHU";
|
|
158
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE;
|
|
159
|
+
if (currentChargeModel)
|
|
160
|
+
currentChargeModel = currentChargeModel.extension(modify4ExtensionBookingCode);
|
|
161
|
+
expect(currentChargeModel).not.toBeNull();
|
|
162
|
+
if (currentChargeModel) {
|
|
163
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
164
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
165
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
166
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
167
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
168
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
169
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
170
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
171
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
172
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
173
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
it("5. delete", function () {
|
|
177
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
178
|
+
var expectedAdditionalBookingGrossAmount = 2500;
|
|
179
|
+
var expectedCancellationGrossAmount = 1500 + 2000;
|
|
180
|
+
var expectedTotalCancellationCharges = 100 + 100;
|
|
181
|
+
var expectedRefundPayable = 0;
|
|
182
|
+
var expectedNetTotal = 3600 - 2000 + 200;
|
|
183
|
+
var expectedAmountPaid = 0;
|
|
184
|
+
var expectedAmountPayable = 3700 - 2000 + 200 + 100;
|
|
185
|
+
var expectedTotalRefundedAmount = 0;
|
|
186
|
+
var expectedCouponCode = "100PHU";
|
|
187
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_RELATIVE;
|
|
188
|
+
if (currentChargeModel) {
|
|
189
|
+
currentChargeModel = currentChargeModel.modify({
|
|
190
|
+
oldBookingCode: modify5DeleteNewBookingCode,
|
|
191
|
+
cancellationUnit: "100U",
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
expect(currentChargeModel).not.toBeNull();
|
|
195
|
+
if (currentChargeModel) {
|
|
196
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
197
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
198
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
199
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
200
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
201
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
202
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
203
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
204
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
205
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
206
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var _enum_1 = require("../../../../@enum");
|
|
4
|
+
var _model_1 = require("../../../../src/@model");
|
|
5
|
+
var booking_entity_test_1 = require("../../../utils/models/booking-entity-test");
|
|
6
|
+
describe("AppController (e2e)", function () {
|
|
7
|
+
var initialBookingCode1 = _model_1.BookingCode.getInstanceByComponents(1, 1, 230813, '1000', '1200', '500,500,500,500');
|
|
8
|
+
var initialBookingCode2 = _model_1.BookingCode.getInstanceByComponents(1, 1, 230814, '1000', '1100', '500,500');
|
|
9
|
+
var modify1ExtendBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 1, 230814, '1000', '1200', '500,500,500,500');
|
|
10
|
+
var modify2ExtensionBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '1200', '1230', '500');
|
|
11
|
+
var modify3ReduceOldBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '1000', '1230', '500,500,500,500,500');
|
|
12
|
+
var modify3ReduceNewBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '1000', '1100', '500,500');
|
|
13
|
+
var modify4ExtensionBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '0900', '1000', '500,500');
|
|
14
|
+
var modify5DeleteNewBookingCode = _model_1.BookingCode.getInstanceByComponents(1, 2, 230814, '0900', '1100', '500,500,500,500');
|
|
15
|
+
var bookingCodes = [
|
|
16
|
+
initialBookingCode1, initialBookingCode2
|
|
17
|
+
];
|
|
18
|
+
var initialGrossAmount = bookingCodes
|
|
19
|
+
.map(function (bookingCode) { return bookingCode.getCost(); })
|
|
20
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
21
|
+
var totalBookingHours = booking_entity_test_1.BookingEntityTest.getTotalHours(bookingCodes);
|
|
22
|
+
var chargeModel = new _model_1.ChargesModel(initialGrossAmount, 0, "", totalBookingHours, _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL);
|
|
23
|
+
var currentChargeModel = chargeModel;
|
|
24
|
+
it("create", function () {
|
|
25
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
26
|
+
var expectedAdditionalBookingGrossAmount = 0;
|
|
27
|
+
var expectedCancellationGrossAmount = 0;
|
|
28
|
+
var expectedTotalCancellationCharges = 0;
|
|
29
|
+
var expectedRefundPayable = 0;
|
|
30
|
+
var expectedNetTotal = 2700;
|
|
31
|
+
var expectedAmountPaid = 2700;
|
|
32
|
+
var expectedAmountPayable = 0;
|
|
33
|
+
var expectedTotalRefundedAmount = 0;
|
|
34
|
+
var expectedCouponCode = "100PHU";
|
|
35
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
36
|
+
var initialGrossAmount = bookingCodes
|
|
37
|
+
.map(function (bookingCode) { return bookingCode.getCost(); })
|
|
38
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
39
|
+
chargeModel = new _model_1.ChargesModel(initialGrossAmount, 2700, "100PHU", totalBookingHours, _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL);
|
|
40
|
+
currentChargeModel = chargeModel;
|
|
41
|
+
expect(chargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
42
|
+
expect(chargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
43
|
+
expect(chargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
44
|
+
expect(chargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
45
|
+
expect(chargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
46
|
+
expect(chargeModel.netTotal).toEqual(expectedNetTotal);
|
|
47
|
+
expect(chargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
48
|
+
expect(chargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
49
|
+
expect(chargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
50
|
+
expect(chargeModel.couponCode).toEqual(expectedCouponCode);
|
|
51
|
+
expect(chargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
52
|
+
});
|
|
53
|
+
it("1. modify extend", function () {
|
|
54
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
55
|
+
var expectedAdditionalBookingGrossAmount = 1000;
|
|
56
|
+
var expectedCancellationGrossAmount = 0;
|
|
57
|
+
var expectedTotalCancellationCharges = 0;
|
|
58
|
+
var expectedRefundPayable = 0;
|
|
59
|
+
var expectedNetTotal = 2700 + 900;
|
|
60
|
+
var expectedAmountPaid = 2700;
|
|
61
|
+
var expectedAmountPayable = 0 + 900;
|
|
62
|
+
var expectedTotalRefundedAmount = 0;
|
|
63
|
+
var expectedCouponCode = "100PHU";
|
|
64
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
65
|
+
if (currentChargeModel)
|
|
66
|
+
currentChargeModel = currentChargeModel.modify({
|
|
67
|
+
oldBookingCode: initialBookingCode2,
|
|
68
|
+
newBookingCode: modify1ExtendBookingCode,
|
|
69
|
+
});
|
|
70
|
+
expect(currentChargeModel).not.toBeNull();
|
|
71
|
+
if (currentChargeModel) {
|
|
72
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
73
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
74
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
75
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
76
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
77
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
78
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
79
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
80
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
81
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
82
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
it("2. extension", function () {
|
|
86
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
87
|
+
var expectedAdditionalBookingGrossAmount = 1000 + 500;
|
|
88
|
+
var expectedCancellationGrossAmount = 0;
|
|
89
|
+
var expectedTotalCancellationCharges = 0;
|
|
90
|
+
var expectedRefundPayable = 0;
|
|
91
|
+
var expectedNetTotal = 3600 + 450;
|
|
92
|
+
var expectedAmountPaid = 2700;
|
|
93
|
+
var expectedAmountPayable = 900 + 450;
|
|
94
|
+
var expectedTotalRefundedAmount = 0;
|
|
95
|
+
var expectedCouponCode = "100PHU";
|
|
96
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
97
|
+
if (currentChargeModel)
|
|
98
|
+
currentChargeModel = currentChargeModel.extension(modify2ExtensionBookingCode);
|
|
99
|
+
expect(currentChargeModel).not.toBeNull();
|
|
100
|
+
if (currentChargeModel) {
|
|
101
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
102
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
103
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
104
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
105
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
106
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
107
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
108
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
109
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
110
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
111
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
it("3. modify reduce", function () {
|
|
115
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
116
|
+
var expectedAdditionalBookingGrossAmount = 1500;
|
|
117
|
+
var expectedCancellationGrossAmount = 0 + 1500;
|
|
118
|
+
var expectedTotalCancellationCharges = 0 + 100;
|
|
119
|
+
var expectedNetTotal = 4050 - 1500 + 450;
|
|
120
|
+
var expectedAmountPaid = 2700;
|
|
121
|
+
var expectedAmountPayable = 1350 + 450 + 100 - 1500;
|
|
122
|
+
var expectedRefundPayable = 0;
|
|
123
|
+
var expectedTotalRefundedAmount = 0;
|
|
124
|
+
var expectedCouponCode = "";
|
|
125
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
126
|
+
if (currentChargeModel)
|
|
127
|
+
currentChargeModel = currentChargeModel.modify({
|
|
128
|
+
oldBookingCode: modify3ReduceOldBookingCode,
|
|
129
|
+
newBookingCode: modify3ReduceNewBookingCode,
|
|
130
|
+
cancellationUnit: "100U",
|
|
131
|
+
});
|
|
132
|
+
expect(currentChargeModel).not.toBeNull();
|
|
133
|
+
if (currentChargeModel) {
|
|
134
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
135
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
136
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
137
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
138
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
139
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
140
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
141
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
142
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
143
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
144
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
it("4. extension", function () {
|
|
148
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
149
|
+
var expectedAdditionalBookingGrossAmount = 1500 + 1000;
|
|
150
|
+
var expectedCancellationGrossAmount = 1500;
|
|
151
|
+
var expectedTotalCancellationCharges = 100;
|
|
152
|
+
var expectedNetTotal = 3000 + 1000;
|
|
153
|
+
var expectedAmountPaid = 2700;
|
|
154
|
+
var expectedAmountPayable = 400 + 1000;
|
|
155
|
+
var expectedRefundPayable = 0;
|
|
156
|
+
var expectedTotalRefundedAmount = 0;
|
|
157
|
+
var expectedCouponCode = "";
|
|
158
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
159
|
+
if (currentChargeModel)
|
|
160
|
+
currentChargeModel = currentChargeModel.extension(modify4ExtensionBookingCode);
|
|
161
|
+
expect(currentChargeModel).not.toBeNull();
|
|
162
|
+
if (currentChargeModel) {
|
|
163
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
164
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
165
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
166
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
167
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
168
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
169
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
170
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
171
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
172
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
173
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
it("5. delete", function () {
|
|
177
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
178
|
+
var expectedAdditionalBookingGrossAmount = 2500;
|
|
179
|
+
var expectedCancellationGrossAmount = 1500 + 2000;
|
|
180
|
+
var expectedTotalCancellationCharges = 100 + 100;
|
|
181
|
+
var expectedNetTotal = 4000 - 2000;
|
|
182
|
+
var expectedAmountPaid = 2700;
|
|
183
|
+
var expectedAmountPayable = 1400 - 2000 + 100 < 0 ? 0 : 1400 - 2000 + 100;
|
|
184
|
+
var expectedRefundPayable = 1400 - 2000 + 100 < 0 ? Math.abs(1400 - 2000 + 100) : 0;
|
|
185
|
+
var expectedTotalRefundedAmount = 0;
|
|
186
|
+
var expectedCouponCode = "";
|
|
187
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
188
|
+
if (currentChargeModel)
|
|
189
|
+
currentChargeModel = currentChargeModel.modify({
|
|
190
|
+
oldBookingCode: modify5DeleteNewBookingCode,
|
|
191
|
+
cancellationUnit: "100U",
|
|
192
|
+
});
|
|
193
|
+
expect(currentChargeModel).not.toBeNull();
|
|
194
|
+
if (currentChargeModel) {
|
|
195
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
196
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
197
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
198
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
199
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
200
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
201
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
202
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
203
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
204
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
205
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|