turf-common 1.4.2-beta.3 → 1.4.2-beta.31
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/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 +2 -1
- package/build/src/enums/booking-history-operation-type.enum.js +1 -0
- package/build/src/enums/valid-coupon-type.enum.d.ts +3 -0
- package/build/src/enums/valid-coupon-type.enum.js +18 -0
- package/build/src/interface/api/booking-availablity-by-pitch.interface.d.ts +1 -0
- package/build/src/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
- package/build/src/interface/api/get-availability-by-turf.interface.d.ts +1 -0
- package/build/src/interface/api/one-slot-booking.interface.d.ts +2 -0
- package/build/src/interface/api/update-recurring-booking.interface.d.ts +1 -0
- package/build/src/interface/model/booking-details-model.interface.d.ts +8 -0
- package/build/src/models/booking-code-model.d.ts +10 -2
- package/build/src/models/booking-code-model.js +37 -33
- package/build/src/models/charge-model.d.ts +2 -0
- package/build/src/models/charge-model.js +34 -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/pitch-slab-model.d.ts +1 -0
- package/build/src/models/pitch-slab-model.js +15 -0
- package/build/src/models/subscribed-pricing-plan-model.d.ts +1 -0
- package/build/src/models/subscribed-pricing-plan-model.js +7 -0
- 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 +2 -0
- package/build/src/utils/constant.js +3 -1
- package/build/src/utils/date-util.d.ts +3 -1
- package/build/src/utils/date-util.js +10 -2
- 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 +2 -2
|
@@ -0,0 +1,215 @@
|
|
|
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_CONDITIONAL;
|
|
36
|
+
var expectedTotalBookingHours = 3;
|
|
37
|
+
var initialGrossAmount = bookingCodes
|
|
38
|
+
.map(function (bookingCode) { return bookingCode.getCost(); })
|
|
39
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
40
|
+
chargeModel = new _model_1.ChargesModel(initialGrossAmount, 0, "100PHU", totalBookingHours, _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL);
|
|
41
|
+
currentChargeModel = chargeModel;
|
|
42
|
+
expect(chargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
43
|
+
expect(chargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
44
|
+
expect(chargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
45
|
+
expect(chargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
46
|
+
expect(chargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
47
|
+
expect(chargeModel.netTotal).toEqual(expectedNetTotal);
|
|
48
|
+
expect(chargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
49
|
+
expect(chargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
50
|
+
expect(chargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
51
|
+
expect(chargeModel.couponCode).toEqual(expectedCouponCode);
|
|
52
|
+
expect(chargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
53
|
+
expect(chargeModel.totalBookingHours).toEqual(expectedTotalBookingHours);
|
|
54
|
+
});
|
|
55
|
+
it("1. modify extend", function () {
|
|
56
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
57
|
+
var expectedAdditionalBookingGrossAmount = 1000;
|
|
58
|
+
var expectedCancellationGrossAmount = 0;
|
|
59
|
+
var expectedTotalCancellationCharges = 0;
|
|
60
|
+
var expectedRefundPayable = 0;
|
|
61
|
+
var expectedNetTotal = 3600;
|
|
62
|
+
var expectedAmountPaid = 0;
|
|
63
|
+
var expectedAmountPayable = 3600;
|
|
64
|
+
var expectedTotalRefundedAmount = 0;
|
|
65
|
+
var expectedCouponCode = "100PHU";
|
|
66
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
67
|
+
var expectedTotalBookingHours = 4;
|
|
68
|
+
if (currentChargeModel)
|
|
69
|
+
currentChargeModel = currentChargeModel.modify({
|
|
70
|
+
oldBookingCode: initialBookingCode2,
|
|
71
|
+
newBookingCode: modify1ExtendBookingCode,
|
|
72
|
+
});
|
|
73
|
+
expect(currentChargeModel).not.toBeNull();
|
|
74
|
+
if (currentChargeModel) {
|
|
75
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
76
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
77
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
78
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
79
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
80
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
81
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
82
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
83
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
84
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
85
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
86
|
+
expect(currentChargeModel.totalBookingHours).toEqual(expectedTotalBookingHours);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
it("2. extension", function () {
|
|
90
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
91
|
+
var expectedAdditionalBookingGrossAmount = 1000 + 500;
|
|
92
|
+
var expectedCancellationGrossAmount = 0;
|
|
93
|
+
var expectedTotalCancellationCharges = 0;
|
|
94
|
+
var expectedRefundPayable = 0;
|
|
95
|
+
var expectedNetTotal = 3600 + 450;
|
|
96
|
+
var expectedAmountPaid = 0;
|
|
97
|
+
var expectedAmountPayable = 3600 + 450;
|
|
98
|
+
var expectedTotalRefundedAmount = 0;
|
|
99
|
+
var expectedCouponCode = "100PHU";
|
|
100
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
101
|
+
var expectedTotalBookingHours = 4.5;
|
|
102
|
+
if (currentChargeModel)
|
|
103
|
+
currentChargeModel = currentChargeModel.extension(modify2ExtensionBookingCode);
|
|
104
|
+
expect(currentChargeModel).not.toBeNull();
|
|
105
|
+
if (currentChargeModel) {
|
|
106
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
107
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
108
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
109
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
110
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
111
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
112
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
113
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
114
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
115
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
116
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
117
|
+
expect(currentChargeModel.totalBookingHours).toEqual(expectedTotalBookingHours);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
it("3. modify reduce", function () {
|
|
121
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
122
|
+
var expectedAdditionalBookingGrossAmount = 1500;
|
|
123
|
+
var expectedCancellationGrossAmount = 0 + 1500;
|
|
124
|
+
var expectedTotalCancellationCharges = 0 + 100;
|
|
125
|
+
var expectedRefundPayable = 0;
|
|
126
|
+
var expectedNetTotal = 3000;
|
|
127
|
+
var expectedAmountPaid = 0;
|
|
128
|
+
var expectedAmountPayable = 3000 + 100;
|
|
129
|
+
var expectedTotalRefundedAmount = 0;
|
|
130
|
+
var expectedCouponCode = "";
|
|
131
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
132
|
+
if (currentChargeModel)
|
|
133
|
+
currentChargeModel = currentChargeModel.modify({
|
|
134
|
+
oldBookingCode: modify3ReduceOldBookingCode,
|
|
135
|
+
newBookingCode: modify3ReduceNewBookingCode,
|
|
136
|
+
cancellationUnit: "100U",
|
|
137
|
+
});
|
|
138
|
+
expect(currentChargeModel).not.toBeNull();
|
|
139
|
+
if (currentChargeModel) {
|
|
140
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
141
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
142
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
143
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
144
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
145
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
146
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
147
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
148
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
149
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
150
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
it("4. extension", function () {
|
|
154
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
155
|
+
var expectedAdditionalBookingGrossAmount = 1500 + 1000;
|
|
156
|
+
var expectedCancellationGrossAmount = 1500;
|
|
157
|
+
var expectedTotalCancellationCharges = 100;
|
|
158
|
+
var expectedRefundPayable = 0;
|
|
159
|
+
var expectedNetTotal = 3000 + 1000;
|
|
160
|
+
var expectedAmountPaid = 0;
|
|
161
|
+
var expectedAmountPayable = 3100 + 1000;
|
|
162
|
+
var expectedTotalRefundedAmount = 0;
|
|
163
|
+
var expectedCouponCode = "";
|
|
164
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
165
|
+
if (currentChargeModel)
|
|
166
|
+
currentChargeModel = currentChargeModel.extension(modify4ExtensionBookingCode);
|
|
167
|
+
expect(currentChargeModel).not.toBeNull();
|
|
168
|
+
if (currentChargeModel) {
|
|
169
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
170
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
171
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
172
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
173
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
174
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
175
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
176
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
177
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
178
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
179
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
it("5. delete", function () {
|
|
183
|
+
var expectedInitialBookingGrossAmount = 3000;
|
|
184
|
+
var expectedAdditionalBookingGrossAmount = 2500;
|
|
185
|
+
var expectedCancellationGrossAmount = 1500 + 2000;
|
|
186
|
+
var expectedTotalCancellationCharges = 100 + 100;
|
|
187
|
+
var expectedRefundPayable = 0;
|
|
188
|
+
var expectedNetTotal = 4000 - 2000;
|
|
189
|
+
var expectedAmountPaid = 0;
|
|
190
|
+
var expectedAmountPayable = 4100 + 100 - 2000;
|
|
191
|
+
var expectedTotalRefundedAmount = 0;
|
|
192
|
+
var expectedCouponCode = "";
|
|
193
|
+
var expectedDiscountPolicy = _enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL;
|
|
194
|
+
if (currentChargeModel) {
|
|
195
|
+
currentChargeModel = currentChargeModel.modify({
|
|
196
|
+
oldBookingCode: modify5DeleteNewBookingCode,
|
|
197
|
+
cancellationUnit: "100U",
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
expect(currentChargeModel).not.toBeNull();
|
|
201
|
+
if (currentChargeModel) {
|
|
202
|
+
expect(currentChargeModel.initialBookingGrossAmount).toEqual(expectedInitialBookingGrossAmount);
|
|
203
|
+
expect(currentChargeModel.additionalBookingGrossAmount).toEqual(expectedAdditionalBookingGrossAmount);
|
|
204
|
+
expect(currentChargeModel.cancelledBookingGrossAmount).toEqual(expectedCancellationGrossAmount);
|
|
205
|
+
expect(currentChargeModel.totalCancellationCharges).toEqual(expectedTotalCancellationCharges);
|
|
206
|
+
expect(currentChargeModel.refundPayable).toEqual(expectedRefundPayable);
|
|
207
|
+
expect(currentChargeModel.netTotal).toEqual(expectedNetTotal);
|
|
208
|
+
expect(currentChargeModel.amountPaid).toEqual(expectedAmountPaid);
|
|
209
|
+
expect(currentChargeModel.amountPayable).toEqual(expectedAmountPayable);
|
|
210
|
+
expect(currentChargeModel.totalRefundedAmount).toEqual(expectedTotalRefundedAmount);
|
|
211
|
+
expect(currentChargeModel.couponCode).toEqual(expectedCouponCode);
|
|
212
|
+
expect(currentChargeModel.discountPolicy).toEqual(expectedDiscountPolicy);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -153,7 +153,7 @@ describe("AppController (e2e)", function () {
|
|
|
153
153
|
for (var _l = 0, expectedBillingCycleKeys_3 = expectedBillingCycleKeys; _l < expectedBillingCycleKeys_3.length; _l++) {
|
|
154
154
|
var billingCycleKey = expectedBillingCycleKeys_3[_l];
|
|
155
155
|
var subscribedPricingPlanModelV2 = new _model_1.SubscribedPricingPlanModelV2(pricingPlanModelV2, pitchCount, billingCycleKey);
|
|
156
|
-
console.log(
|
|
156
|
+
// console.log(`---- Pitch Count: '${subscribedPricingPlanModelV2.pitchCount}', Billing: '${subscribedPricingPlanModelV2.billingCycle}'`)
|
|
157
157
|
// TODO: Need to check the usability of the below method
|
|
158
158
|
// console.log(`subscribedPricingPlanModelV2.getMonths() : ${subscribedPricingPlanModelV2.getMonths()}`)
|
|
159
159
|
// TODO: Needs to change the name to getBasePriceByPitchSlab for Monthly
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turf-common",
|
|
3
|
-
"version": "1.4.2-beta.
|
|
3
|
+
"version": "1.4.2-beta.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
|
|
15
15
|
"version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
|
|
16
16
|
"test": "jest",
|
|
17
|
-
"test:pattern": "jest -i
|
|
17
|
+
"test:pattern": "jest -i unit/charges/discount-relative",
|
|
18
18
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
|
|
19
19
|
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
|
|
20
20
|
},
|