turf-common 1.4.2-beta.2 → 1.4.2-beta.21
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/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 +2 -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/models/booking-code-model.d.ts +8 -2
- package/build/src/models/booking-code-model.js +28 -33
- package/build/src/models/charge-model.d.ts +2 -0
- package/build/src/models/charge-model.js +34 -11
- 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 +2 -0
- package/build/src/models/subscribed-pricing-plan-model.js +13 -2
- package/build/src/models/time-slot-model.d.ts +1 -0
- package/build/src/models/time-slot-model.js +3 -0
- package/build/src/utils/constant.d.ts +1 -0
- package/build/src/utils/constant.js +2 -1
- package/build/src/utils/date-util.d.ts +2 -1
- package/build/src/utils/date-util.js +7 -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
package/build/jest.config.js
CHANGED
|
@@ -7,6 +7,7 @@ export declare enum BookingHistoryOperationType {
|
|
|
7
7
|
REFUND = "refund",
|
|
8
8
|
PAYMENT = "payment",
|
|
9
9
|
MERGED = "merged",
|
|
10
|
-
DELETE_SLOT_EVENT = "delete_slot_event"
|
|
10
|
+
DELETE_SLOT_EVENT = "delete_slot_event",
|
|
11
|
+
EXTENSION = "extension"
|
|
11
12
|
}
|
|
12
13
|
export declare const OPERATION_TYPES: BookingHistoryOperationType[];
|
|
@@ -12,6 +12,7 @@ var BookingHistoryOperationType;
|
|
|
12
12
|
BookingHistoryOperationType["PAYMENT"] = "payment";
|
|
13
13
|
BookingHistoryOperationType["MERGED"] = "merged";
|
|
14
14
|
BookingHistoryOperationType["DELETE_SLOT_EVENT"] = "delete_slot_event";
|
|
15
|
+
BookingHistoryOperationType["EXTENSION"] = "extension";
|
|
15
16
|
})(BookingHistoryOperationType || (exports.BookingHistoryOperationType = BookingHistoryOperationType = {}));
|
|
16
17
|
exports.OPERATION_TYPES = [
|
|
17
18
|
BookingHistoryOperationType.DELETE,
|
|
@@ -8,3 +8,21 @@ var ValidCouponType;
|
|
|
8
8
|
ValidCouponType["PER_HOUR_UNIT"] = "per hour unit";
|
|
9
9
|
ValidCouponType["PER_HOUR_PERCENTAGE"] = "per hour percentage";
|
|
10
10
|
})(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
|
|
11
|
+
// Create namespace for the enum and add method UILabel to get the label of the enum value.
|
|
12
|
+
(function (ValidCouponType) {
|
|
13
|
+
function UILabel(value) {
|
|
14
|
+
switch (value) {
|
|
15
|
+
case ValidCouponType.PERCENTAGE:
|
|
16
|
+
return "Percentage";
|
|
17
|
+
case ValidCouponType.UNIT:
|
|
18
|
+
return "Price";
|
|
19
|
+
case ValidCouponType.PER_HOUR_UNIT:
|
|
20
|
+
return "Price Hour Unit";
|
|
21
|
+
case ValidCouponType.PER_HOUR_PERCENTAGE:
|
|
22
|
+
return "Per Hour Percentage";
|
|
23
|
+
default:
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
ValidCouponType.UILabel = UILabel;
|
|
28
|
+
})(ValidCouponType || (exports.ValidCouponType = ValidCouponType = {}));
|
|
@@ -19,6 +19,7 @@ export interface ICreateRecurringSlotsBookingDetailsRequest {
|
|
|
19
19
|
turf_slot?: {
|
|
20
20
|
availability_details: IGetAvailabilityByTurf;
|
|
21
21
|
};
|
|
22
|
+
deleteIntermediateBookings: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare class IRecurringSlot {
|
|
24
25
|
fromDate: number;
|
|
@@ -26,4 +27,5 @@ export declare class IRecurringSlot {
|
|
|
26
27
|
weekdays: number[];
|
|
27
28
|
from: string;
|
|
28
29
|
to: string;
|
|
30
|
+
pitchNo: number;
|
|
29
31
|
}
|
|
@@ -12,6 +12,7 @@ export interface ICreateOneSlotBookingDetailsRequest {
|
|
|
12
12
|
discountedCost: number;
|
|
13
13
|
amountPaid: number;
|
|
14
14
|
pitchId: number;
|
|
15
|
+
pitchIds?: number[];
|
|
15
16
|
status: BookingDetailsStatus;
|
|
16
17
|
sport: string;
|
|
17
18
|
remarks?: string | null;
|
|
@@ -21,4 +22,5 @@ export interface ICreateOneSlot {
|
|
|
21
22
|
date: number;
|
|
22
23
|
from: string;
|
|
23
24
|
to: string;
|
|
25
|
+
pitchNo: number;
|
|
24
26
|
}
|
|
@@ -34,6 +34,7 @@ export interface IUpdateRecurringBookingResponse extends IModifyEntity<IBookingD
|
|
|
34
34
|
discountPolicy?: string;
|
|
35
35
|
delete_slot?: IDeleteBookingByCodesDto;
|
|
36
36
|
update_slot?: IUpdateBookingByCodesDto;
|
|
37
|
+
extension_booking_codes?: string[];
|
|
37
38
|
}
|
|
38
39
|
export interface IUpdateRecurringSlotBookingDetailsRequest {
|
|
39
40
|
customerName?: string;
|
|
@@ -20,7 +20,7 @@ export declare class BookingCode {
|
|
|
20
20
|
getHalfHourTimeCodes(): string[];
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
|
-
* @returns
|
|
23
|
+
* @returns ['00000030','00300100','01000130']: string[] - List of half hour time slot codes between start time & end time inclusive
|
|
24
24
|
* @example fromTime: 0000; toTime: 0130
|
|
25
25
|
* // returns ['00000030','00300100','01000130']
|
|
26
26
|
*/
|
|
@@ -31,6 +31,11 @@ export declare class BookingCode {
|
|
|
31
31
|
getMonthCode(): string;
|
|
32
32
|
getDateWithFromTimeCode(): string;
|
|
33
33
|
getCodeWithoutTurfCode(): string;
|
|
34
|
+
getPriceByPriceEntities(priceEntities?: {
|
|
35
|
+
[date: string]: {
|
|
36
|
+
[time: string]: number;
|
|
37
|
+
};
|
|
38
|
+
}): number;
|
|
34
39
|
static sortByCode(bookingCodes: BookingCode[]): void;
|
|
35
40
|
static getOneSlotBookingCode(turfId: string, bookingDate: string, fhfm: string, thtm: string, pitchCode: string): string;
|
|
36
41
|
static getDiscountedCost(couponCode: string, totalCost: number, validationApply?: boolean, totalBookingHours?: number): number;
|
|
@@ -40,7 +45,7 @@ export declare class BookingCode {
|
|
|
40
45
|
static getWeekday(dateCode: number): number;
|
|
41
46
|
static convertToDate(str: string): Date;
|
|
42
47
|
static previousDateChecker(fromDate: number, index: number, errorKey?: string): void;
|
|
43
|
-
static previousTimeChecker(fromTime: string, fromDate: number, index: number): void;
|
|
48
|
+
static previousTimeChecker(fromTime: string, fromDate: number, index: number, bookingDelayInMinutes?: number, date?: Date): void;
|
|
44
49
|
static getDateCodesByWeek(fromDate: number, toDate: number, selectedWeekday: number): string[];
|
|
45
50
|
static getDatesByWeek(fromDate: number, toDate: number, selectedWeekday: number): Date[];
|
|
46
51
|
static isValidTimeRange(timeSlot: string): boolean;
|
|
@@ -136,4 +141,5 @@ export declare class BookingCode {
|
|
|
136
141
|
* Additionally, the pitch number and turf ID must match between the two codes.
|
|
137
142
|
*/
|
|
138
143
|
isAdjacentBookingCode(nextBookingCode: BookingCode): boolean;
|
|
144
|
+
static getInstanceByComponents(turfId: number, pitchCode: number, dateCode: number, fromTimeCode: string, toTimeCode: string, priceCsv: string): BookingCode;
|
|
139
145
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.BookingCode = void 0;
|
|
15
4
|
var time_slot_model_1 = require("./time-slot-model");
|
|
@@ -60,7 +49,7 @@ var BookingCode = /** @class */ (function () {
|
|
|
60
49
|
};
|
|
61
50
|
/**
|
|
62
51
|
*
|
|
63
|
-
* @returns
|
|
52
|
+
* @returns ['00000030','00300100','01000130']: string[] - List of half hour time slot codes between start time & end time inclusive
|
|
64
53
|
* @example fromTime: 0000; toTime: 0130
|
|
65
54
|
* // returns ['00000030','00300100','01000130']
|
|
66
55
|
*/
|
|
@@ -105,6 +94,18 @@ var BookingCode = /** @class */ (function () {
|
|
|
105
94
|
BookingCode.prototype.getCodeWithoutTurfCode = function () {
|
|
106
95
|
return "".concat(this.dateCode).concat(this.slot).concat(this.pitchCode);
|
|
107
96
|
};
|
|
97
|
+
BookingCode.prototype.getPriceByPriceEntities = function (priceEntities) {
|
|
98
|
+
var halfHourTimeRangeCodes = this.getHalfHourTimeRangeCodes();
|
|
99
|
+
var weekDay = this.getWeekday();
|
|
100
|
+
var monthCode = this.getMonthCode();
|
|
101
|
+
var price = 0;
|
|
102
|
+
for (var _i = 0, halfHourTimeRangeCodes_1 = halfHourTimeRangeCodes; _i < halfHourTimeRangeCodes_1.length; _i++) {
|
|
103
|
+
var halfHourTimeRangeCode = halfHourTimeRangeCodes_1[_i];
|
|
104
|
+
price +=
|
|
105
|
+
priceEntities[monthCode + weekDay][halfHourTimeRangeCode] < 0 ? 0 : priceEntities[monthCode + weekDay][halfHourTimeRangeCode];
|
|
106
|
+
}
|
|
107
|
+
return price;
|
|
108
|
+
};
|
|
108
109
|
BookingCode.sortByCode = function (bookingCodes) {
|
|
109
110
|
bookingCodes.sort(function (_a, _b) {
|
|
110
111
|
var code1 = _a.code;
|
|
@@ -157,7 +158,7 @@ var BookingCode = /** @class */ (function () {
|
|
|
157
158
|
discount = parseFloat(couponCode) * totalBookingHours;
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
|
-
discountedCost = totalCost - discount;
|
|
161
|
+
discountedCost = totalCost - Math.round(discount);
|
|
161
162
|
return Math.round(discountedCost);
|
|
162
163
|
};
|
|
163
164
|
BookingCode.getDiscountAmount = function (couponCode, totalCost) {
|
|
@@ -221,26 +222,17 @@ var BookingCode = /** @class */ (function () {
|
|
|
221
222
|
}
|
|
222
223
|
};
|
|
223
224
|
//---------------------
|
|
224
|
-
BookingCode.previousTimeChecker = function (fromTime, fromDate, index) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
};
|
|
236
|
-
var timeFormat = new Intl.DateTimeFormat("en-US", __assign(__assign({}, options), { hour: "2-digit", minute: "2-digit", hour12: false }));
|
|
237
|
-
var currentTimeObj = timeFormat.format(now).replace(/:/g, "");
|
|
238
|
-
if (fromTime < currentTimeObj) {
|
|
239
|
-
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
240
|
-
key: "slot.".concat(index),
|
|
241
|
-
message: ["Booking time should be in future"],
|
|
242
|
-
});
|
|
243
|
-
}
|
|
225
|
+
BookingCode.previousTimeChecker = function (fromTime, fromDate, index, bookingDelayInMinutes, date) {
|
|
226
|
+
if (bookingDelayInMinutes === void 0) { bookingDelayInMinutes = _utils_1.DEFAULT_BOOKING_DELAY_IN_MINUTES; }
|
|
227
|
+
if (date === void 0) { date = date_util_1.dateUtilService.getIndianDate(); }
|
|
228
|
+
var now = date;
|
|
229
|
+
var bookingDate = date_util_1.dateUtilService.convertStringToDate(fromDate.toString() + fromTime, "yyMMddHHmm");
|
|
230
|
+
var difference = bookingDate.getTime() - now.getTime() + bookingDelayInMinutes * 60 * 1000;
|
|
231
|
+
if (difference < 0) {
|
|
232
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
233
|
+
key: "slot.".concat(index),
|
|
234
|
+
message: ["Booking time should be in future"],
|
|
235
|
+
});
|
|
244
236
|
}
|
|
245
237
|
};
|
|
246
238
|
//---------------------
|
|
@@ -608,6 +600,9 @@ var BookingCode = /** @class */ (function () {
|
|
|
608
600
|
this.pitchNumber === nextBookingCode.pitchNumber &&
|
|
609
601
|
this.turfId === nextBookingCode.turfId);
|
|
610
602
|
};
|
|
603
|
+
BookingCode.getInstanceByComponents = function (turfId, pitchCode, dateCode, fromTimeCode, toTimeCode, priceCsv) {
|
|
604
|
+
return new BookingCode("".concat(turfId.toString().padStart(4, "0")).concat(dateCode.toString().padStart(6, "0")).concat(fromTimeCode).concat(toTimeCode).concat(pitchCode.toString().padStart(2, "0")), priceCsv);
|
|
605
|
+
};
|
|
611
606
|
/**
|
|
612
607
|
* Extracts the numeric part of a bookingCode, excluding a predefined deleted slot separator.
|
|
613
608
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BookingCode } from "./booking-code-model";
|
|
1
2
|
import { IBookingModification } from "../types/booking-modification.type";
|
|
2
3
|
import { ModificationDiscountPolicy } from "../enums/modification-discount-policy.enum";
|
|
3
4
|
import { IChargeModel } from "../interface/model/charge-model.interface";
|
|
@@ -27,6 +28,7 @@ export declare class ChargesModel implements IChargeModel {
|
|
|
27
28
|
private modifyMove;
|
|
28
29
|
clone(): ChargesModel;
|
|
29
30
|
private modifyDelete;
|
|
31
|
+
extension(extensionBookingCode: BookingCode): ChargesModel;
|
|
30
32
|
static getInstance(chargeData: IChargeModel, discountPolicy?: ModificationDiscountPolicy): ChargesModel;
|
|
31
33
|
getTotalAmount(): number;
|
|
32
34
|
getPaymentStatus(): "Refund" | "Paid" | "Pending";
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.ChargesModel = void 0;
|
|
4
15
|
var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
|
|
@@ -9,15 +20,15 @@ var ChargesModel = /** @class */ (function () {
|
|
|
9
20
|
this.initialBookingGrossAmount = initialGrossAmount;
|
|
10
21
|
this.amountPaid = paidAmount;
|
|
11
22
|
this.couponCode = couponCode;
|
|
23
|
+
this.totalBookingHours = totalBookingHours;
|
|
24
|
+
this.discountPolicy = discountPolicy;
|
|
12
25
|
this.additionalBookingGrossAmount = 0;
|
|
13
26
|
this.cancelledBookingGrossAmount = 0;
|
|
14
27
|
this.totalCancellationCharges = 0;
|
|
15
28
|
this.refundPayable = 0;
|
|
16
29
|
this.totalRefundedAmount = 0;
|
|
17
|
-
this.totalBookingHours = totalBookingHours;
|
|
18
30
|
this.netTotal = this.getNetAmount();
|
|
19
31
|
this.amountPayable = this.getPayableRefundAmount();
|
|
20
|
-
this.discountPolicy = discountPolicy;
|
|
21
32
|
}
|
|
22
33
|
ChargesModel.prototype.getGrossAmount = function () {
|
|
23
34
|
return (this.initialBookingGrossAmount +
|
|
@@ -35,6 +46,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
35
46
|
this.cancelledBookingGrossAmount > 0) {
|
|
36
47
|
this.couponCode = "";
|
|
37
48
|
}
|
|
49
|
+
// console.log("getDiscountAmount", this.couponCode);
|
|
38
50
|
return ChargesModel.getDiscountAmount(this.couponCode, this.getGrossAmount(), false, this.totalBookingHours);
|
|
39
51
|
};
|
|
40
52
|
ChargesModel.prototype.getPayableRefundAmount = function () {
|
|
@@ -102,10 +114,6 @@ var ChargesModel = /** @class */ (function () {
|
|
|
102
114
|
};
|
|
103
115
|
ChargesModel.prototype.modify = function (bookingModification) {
|
|
104
116
|
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);
|
|
109
117
|
if (!newBookingCode) {
|
|
110
118
|
return this.modifyDelete(oldBookingCode, cancellationUnit !== null && cancellationUnit !== void 0 ? cancellationUnit : "");
|
|
111
119
|
}
|
|
@@ -150,9 +158,7 @@ var ChargesModel = /** @class */ (function () {
|
|
|
150
158
|
(newBookingCode ? newBookingCode.getTotalTime("hr") : 0);
|
|
151
159
|
var newChargeModel = this.clone();
|
|
152
160
|
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
153
|
-
newChargeModel.couponCode = "";
|
|
154
161
|
var costDifference = oldBookingCode.getCost() - newBookingCode.getCost();
|
|
155
|
-
// console.log(`costDifference ${costDifference}`);
|
|
156
162
|
newChargeModel.cancelledBookingGrossAmount += costDifference;
|
|
157
163
|
var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
|
|
158
164
|
// console.log(`cancellationCharges ${cancellationCharges}`);
|
|
@@ -208,7 +214,6 @@ var ChargesModel = /** @class */ (function () {
|
|
|
208
214
|
var newTotalBookingHours = this.totalBookingHours - bookingCode.getTotalTime("hr");
|
|
209
215
|
var newChargeModel = this.clone();
|
|
210
216
|
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
211
|
-
newChargeModel.couponCode = "";
|
|
212
217
|
var costDifference = bookingCode.getCost();
|
|
213
218
|
newChargeModel.cancelledBookingGrossAmount += costDifference;
|
|
214
219
|
var cancellationCharges = ChargesModel.getDiscountAmount(cancellationUnit, costDifference);
|
|
@@ -224,10 +229,28 @@ var ChargesModel = /** @class */ (function () {
|
|
|
224
229
|
}
|
|
225
230
|
return newChargeModel;
|
|
226
231
|
};
|
|
232
|
+
ChargesModel.prototype.extension = function (extensionBookingCode) {
|
|
233
|
+
var newTotalBookingHours = this.totalBookingHours + (extensionBookingCode ? extensionBookingCode.getTotalTime("hr") : 0);
|
|
234
|
+
var newChargeModel = this.clone();
|
|
235
|
+
newChargeModel.totalBookingHours = newTotalBookingHours;
|
|
236
|
+
newChargeModel.additionalBookingGrossAmount += extensionBookingCode.getCost();
|
|
237
|
+
newChargeModel.netTotal = newChargeModel.getNetAmount();
|
|
238
|
+
newChargeModel.amountPayable = newChargeModel.getPayableRefundAmount();
|
|
239
|
+
// console.log(newChargeModel.payableAmount);
|
|
240
|
+
if (newChargeModel.amountPayable > 0) {
|
|
241
|
+
newChargeModel.refundPayable = 0;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
newChargeModel.refundPayable = Math.abs(newChargeModel.amountPayable);
|
|
245
|
+
newChargeModel.amountPayable = 0;
|
|
246
|
+
}
|
|
247
|
+
return newChargeModel;
|
|
248
|
+
};
|
|
227
249
|
ChargesModel.getInstance = function (chargeData, discountPolicy) {
|
|
228
250
|
if (discountPolicy === void 0) { discountPolicy = modification_discount_policy_enum_1.ModificationDiscountPolicy.DISCOUNT_CONDITIONAL; }
|
|
229
|
-
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, chargeData.totalBookingHours, discountPolicy);
|
|
230
|
-
|
|
251
|
+
var chargesModel = new ChargesModel(chargeData.initialBookingGrossAmount, chargeData.amountPaid, chargeData.couponCode, parseFloat(chargeData.totalBookingHours.toString()), discountPolicy);
|
|
252
|
+
var initialBookingGrossAmount = chargeData.initialBookingGrossAmount, amountPaid = chargeData.amountPaid, couponCode = chargeData.couponCode, totalBookingHours = chargeData.totalBookingHours, rest = __rest(chargeData, ["initialBookingGrossAmount", "amountPaid", "couponCode", "totalBookingHours"]);
|
|
253
|
+
Object.assign(chargesModel, rest);
|
|
231
254
|
return chargesModel;
|
|
232
255
|
};
|
|
233
256
|
// static assignByInterface(
|
|
@@ -27,6 +27,21 @@ var PitchSlabModelV2 = /** @class */ (function () {
|
|
|
27
27
|
this.to = data.to;
|
|
28
28
|
// this.discount = data.discount;
|
|
29
29
|
}
|
|
30
|
+
// public getDiscount(): number {
|
|
31
|
+
// if (this.discount.indexOf("P") > -1) {
|
|
32
|
+
// return parseFloat(this.discount.replace("P", ""));
|
|
33
|
+
// }
|
|
34
|
+
// return 0;
|
|
35
|
+
// }
|
|
36
|
+
// public getBasePrice(basePrice: number): number {
|
|
37
|
+
// return basePrice * (1 - this.getDiscount() / 100);
|
|
38
|
+
// }
|
|
39
|
+
PitchSlabModelV2.prototype.getRange = function () {
|
|
40
|
+
if (this.to >= 99) {
|
|
41
|
+
return "".concat(this.from - 1, "+");
|
|
42
|
+
}
|
|
43
|
+
return "".concat(this.from, "-").concat(this.to);
|
|
44
|
+
};
|
|
30
45
|
return PitchSlabModelV2;
|
|
31
46
|
}());
|
|
32
47
|
exports.PitchSlabModelV2 = PitchSlabModelV2;
|
|
@@ -44,6 +44,7 @@ export declare class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
|
|
|
44
44
|
hourInMonth: number;
|
|
45
45
|
months: number | undefined;
|
|
46
46
|
constructor(data: IPricingPlanModelV2, pitchCount: number, billingCycle: string);
|
|
47
|
+
getPlanBasePriceFormatted(): string;
|
|
47
48
|
getCodeByPitchCountCycle(): string;
|
|
48
49
|
getCodeByCycle(): string[];
|
|
49
50
|
getDiscount(): string;
|
|
@@ -72,6 +73,7 @@ export declare class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
|
|
|
72
73
|
}): number;
|
|
73
74
|
getBillingDiscount(): number;
|
|
74
75
|
getBillingDiscountV2(): number;
|
|
76
|
+
getDiscountBasePrice(): number;
|
|
75
77
|
getMonthDifference(that: SubscribedPricingPlanModelV2): number;
|
|
76
78
|
getGrossAmountByMonth(month: number): number;
|
|
77
79
|
getNetAmountByMonth(month: number): number;
|
|
@@ -150,6 +150,13 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
150
150
|
return _this;
|
|
151
151
|
// this.selectedPitchSlabBasePrice = this.base_price;
|
|
152
152
|
}
|
|
153
|
+
SubscribedPricingPlanModelV2.prototype.getPlanBasePriceFormatted = function () {
|
|
154
|
+
// Format -> #.##
|
|
155
|
+
return parseFloat((this.getBasePriceV2()).toFixed(2)).toLocaleString('en-IN', {
|
|
156
|
+
minimumFractionDigits: 2,
|
|
157
|
+
maximumFractionDigits: 2,
|
|
158
|
+
});
|
|
159
|
+
};
|
|
153
160
|
SubscribedPricingPlanModelV2.prototype.getCodeByPitchCountCycle = function () {
|
|
154
161
|
var _this = this;
|
|
155
162
|
var codes = this.billing_cost_code.split(",");
|
|
@@ -292,7 +299,7 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
292
299
|
SubscribedPricingPlanModelV2.prototype.getNetAmountV2 = function (config) {
|
|
293
300
|
if (config === void 0) { config = { roundDown: false }; }
|
|
294
301
|
var roundDown = config.roundDown;
|
|
295
|
-
var netAmount = this.base_price *
|
|
302
|
+
var netAmount = this.base_price * this.getDiscountBasePrice() * this.pitchCount * this.getTotalHours();
|
|
296
303
|
if (roundDown) {
|
|
297
304
|
return Math.floor(netAmount);
|
|
298
305
|
}
|
|
@@ -317,6 +324,10 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
317
324
|
return parseFloat(((basePriceByPitchSlab - basePriceByPitchCycle) / basePriceByPitchSlab * 100).toFixed(2));
|
|
318
325
|
};
|
|
319
326
|
SubscribedPricingPlanModelV2.prototype.getBillingDiscountV2 = function () {
|
|
327
|
+
var discountBasePrice = this.getDiscountBasePrice();
|
|
328
|
+
return parseFloat(((this.base_price - discountBasePrice) / this.base_price * 100).toFixed(2));
|
|
329
|
+
};
|
|
330
|
+
SubscribedPricingPlanModelV2.prototype.getDiscountBasePrice = function () {
|
|
320
331
|
var _this = this;
|
|
321
332
|
var codesByBillingCycle = this.getCodeByCycle();
|
|
322
333
|
var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
|
|
@@ -379,7 +390,7 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
|
|
|
379
390
|
};
|
|
380
391
|
// Tested
|
|
381
392
|
SubscribedPricingPlanModelV2.prototype.getBasePriceBySelectedBillingCycleDiscount = function () {
|
|
382
|
-
return
|
|
393
|
+
return this.getDiscountBasePrice();
|
|
383
394
|
};
|
|
384
395
|
// Tested
|
|
385
396
|
SubscribedPricingPlanModelV2.prototype.getTotalHours = function () {
|
|
@@ -12,6 +12,7 @@ export declare class TimeSlot {
|
|
|
12
12
|
getHalfHourTimeCodes(): string[];
|
|
13
13
|
getHalfHourTimeRangeCodes(): string[];
|
|
14
14
|
getTotalMinutes(): number;
|
|
15
|
+
isInclusive(timeSlot: TimeSlot): boolean;
|
|
15
16
|
static convertToCode(minute: number): string;
|
|
16
17
|
static _getMinutes(timeCode: string): number;
|
|
17
18
|
static getHalfHourTimeCodes(): string[];
|
|
@@ -64,6 +64,9 @@ var TimeSlot = /** @class */ (function () {
|
|
|
64
64
|
TimeSlot.prototype.getTotalMinutes = function () {
|
|
65
65
|
return this.getEndMinutes() - this.getStartMinutes();
|
|
66
66
|
};
|
|
67
|
+
TimeSlot.prototype.isInclusive = function (timeSlot) {
|
|
68
|
+
return this.fromTime <= timeSlot.fromTime && timeSlot.toTime <= this.toTime;
|
|
69
|
+
};
|
|
67
70
|
// static padStart(timeCode: string, length: number, padString: string): string {
|
|
68
71
|
// return timeCode.padStart(length, padString);
|
|
69
72
|
// }
|
|
@@ -3,3 +3,4 @@ export declare const DEFAULT_PASSWORD = "turf@#123";
|
|
|
3
3
|
export declare const DELETED_SLOT_SEPARATOR = "d_";
|
|
4
4
|
export declare const START_OF_DAY_TIME_CODE = "0000";
|
|
5
5
|
export declare const END_OF_DAY_TIME_CODE = "2400";
|
|
6
|
+
export declare const DEFAULT_BOOKING_DELAY_IN_MINUTES = 60;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.END_OF_DAY_TIME_CODE = exports.START_OF_DAY_TIME_CODE = exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
|
|
3
|
+
exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = exports.END_OF_DAY_TIME_CODE = exports.START_OF_DAY_TIME_CODE = exports.DELETED_SLOT_SEPARATOR = exports.DEFAULT_PASSWORD = exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = void 0;
|
|
4
4
|
exports.SUBSCRIPTION_RENEWAL_THRESHOLD_DAYS = 7;
|
|
5
5
|
exports.DEFAULT_PASSWORD = "turf@#123";
|
|
6
6
|
exports.DELETED_SLOT_SEPARATOR = "d_";
|
|
7
7
|
exports.START_OF_DAY_TIME_CODE = "0000";
|
|
8
8
|
exports.END_OF_DAY_TIME_CODE = "2400";
|
|
9
|
+
exports.DEFAULT_BOOKING_DELAY_IN_MINUTES = 60;
|
|
@@ -5,7 +5,8 @@ export declare class DateUtilService {
|
|
|
5
5
|
getNDaysCode(n: number): string;
|
|
6
6
|
getDateCode(date: Date): string;
|
|
7
7
|
addNDaysToDate(date: Date, n: number): Date;
|
|
8
|
-
convertStringToDate(dateString: string, format: string): Date;
|
|
8
|
+
convertStringToDate(dateString: string, format: string, offset?: number): Date;
|
|
9
|
+
getIndianDate(date?: Date): Date;
|
|
9
10
|
isInPast(date: Date): boolean;
|
|
10
11
|
getDateFromDatabaseDate: (date: string) => Date;
|
|
11
12
|
noOfDaysBetweenDates: (date1: Date, date2: Date) => number;
|
|
@@ -31,12 +31,17 @@ 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.convertStringToDate = function (dateString, format) {
|
|
34
|
+
DateUtilService.prototype.convertStringToDate = function (dateString, format, offset) {
|
|
35
|
+
if (offset === void 0) { offset = 330 * 60 * 1000; }
|
|
35
36
|
var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
|
|
36
37
|
// IST has a fixed offset of UTC+5:30
|
|
37
|
-
var indianDate = new Date(parsedDate.getTime() +
|
|
38
|
+
var indianDate = new Date(parsedDate.getTime() + offset);
|
|
38
39
|
return indianDate;
|
|
39
40
|
};
|
|
41
|
+
DateUtilService.prototype.getIndianDate = function (date) {
|
|
42
|
+
if (date === void 0) { date = new Date(); }
|
|
43
|
+
return new Date(date.getTime() + 330 * 60 * 1000);
|
|
44
|
+
};
|
|
40
45
|
DateUtilService.prototype.isInPast = function (date) {
|
|
41
46
|
return date < new Date();
|
|
42
47
|
};
|
|
@@ -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 {};
|
|
@@ -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.21",
|
|
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
|
},
|