turf-common 1.4.1-beta.9 → 1.4.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,20 +1,20 @@
1
- ## 1 npm init -y
2
-
3
- ## 2 npm login
4
-
5
- ## 3 npm version patch
6
-
7
- # //it increase version
8
-
9
- ## 3 npm publish --access public
10
-
11
- # //npm publish by default --access public
12
-
13
- ## 4 npm run version:deploy
14
-
15
- ### deploy version
16
-
17
- ## Client side
18
-
19
- update package command <br />
20
- npm update turf-comman
1
+ ## 1 npm init -y
2
+
3
+ ## 2 npm login
4
+
5
+ ## 3 npm version patch
6
+
7
+ # //it increase version
8
+
9
+ ## 3 npm publish --access public
10
+
11
+ # //npm publish by default --access public
12
+
13
+ ## 4 npm run version:deploy
14
+
15
+ ### deploy version
16
+
17
+ ## Client side
18
+
19
+ update package command <br />
20
+ npm update turf-comman
@@ -32,14 +32,12 @@ export interface IGetPricingPlanByDateResponseV2 {
32
32
  [key: string]: {
33
33
  from: number;
34
34
  to: number;
35
- discount: string;
36
35
  };
37
36
  };
38
37
  billing_cycle: {
39
38
  [key: string]: {
40
39
  from: number;
41
40
  to: number;
42
- discount: string;
43
41
  name: string;
44
42
  key: string;
45
43
  };
@@ -1,3 +1,5 @@
1
- import { IGetPricingPlanByDateResponse } from './get-pricing-plan-by-date-response.interface';
1
+ import { IGetPricingPlanByDateResponse, IGetPricingPlanByDateResponseV2 } from './get-pricing-plan-by-date-response.interface';
2
2
  export interface IGetPricingPlanByIdResponse extends IGetPricingPlanByDateResponse {
3
3
  }
4
+ export interface IGetPricingPlanByIdResponseV2 extends IGetPricingPlanByDateResponseV2 {
5
+ }
@@ -1,4 +1,14 @@
1
1
  "use strict";
2
+ // import { PricingPlanStatus } from "../../enums/pricing-plan-status.enum";
3
+ // import { IBillingCycleModel, IBillingCycleModelV2 } from "../../interface/billing-cycle.interface";
4
+ // import { GetPricingPlanByDateResponse, GetPricingPlanByDateResponseV2 } from "../../interface/get-pricing-plan-by-date-response.interface";
5
+ // import { IPitchSlab, IPitchSlabV2 } from "../../interface/pitch-slab.interface";
6
+ // import { IPricingPlanEntityModel, IPricingPlanEntityModelV2 } from "../../interface/model/pricing-plan-entity-model.interface";
7
+ // import { IPricingPlanEntity, IPricingPlanEntityV2 } from "../../interface/entity/pricing-plan-entity.interface";
8
+ // import { BillingCycleModel, BillingCycleModelV2 } from "../billing-cycle-model";
9
+ // import { BookingCode } from "../booking-code-model";
10
+ // import { PitchSlabModel, PitchSlabModelV2 } from "../pitch-slab-model";
11
+ // import { PricingPlanModel, PricingPlanModelV2 } from "../pricing-plan-model";
2
12
  Object.defineProperty(exports, "__esModule", { value: true });
3
13
  exports.BillingCycleCodeParserV2 = exports.PricingPlanEntityModelV2 = exports.BillingCycleCodeParser = exports.PitchSlabParserV2 = exports.PitchSlabParser = exports.PricingPlanEntityModel = void 0;
4
14
  var billing_cycle_model_1 = require("../billing-cycle-model");
@@ -99,8 +109,8 @@ var PitchSlabParserV2 = /** @class */ (function () {
99
109
  this.code = code;
100
110
  }
101
111
  PitchSlabParserV2.prototype.parseToModel = function () {
102
- var costCodeComponents = this.code.split("#");
103
- costCodeComponents = costCodeComponents[0].split("_");
112
+ var costCodeComponents = this.code.split("_");
113
+ // costCodeComponents = costCodeComponents[0].split("_");
104
114
  return new pitch_slab_model_1.PitchSlabModelV2({
105
115
  // discount: costCodeComponents[1],
106
116
  from: parseInt(costCodeComponents[0]),
@@ -253,7 +263,11 @@ var PricingPlanEntityModelV2 = /** @class */ (function () {
253
263
  // return responseObj;
254
264
  // }
255
265
  PricingPlanEntityModelV2.prototype.toPitchSlabs = function () {
256
- return this.billingCostCode
266
+ var codes = this.billingCostCode
267
+ .split(",").map(function (code) { return code.split("#")[0]; }).join(",");
268
+ // Remove duplicates from codes
269
+ codes = codes.split(",").filter(function (value, index, self) { return self.indexOf(value) === index; }).join(",");
270
+ return codes
257
271
  .split(",")
258
272
  .map(function (cost_code) { return new PitchSlabParserV2(cost_code).parseToModel(); });
259
273
  };
@@ -110,10 +110,7 @@ var PricingPlanModelV2 = /** @class */ (function () {
110
110
  PricingPlanModelV2.prototype.getPitchSlab = function (pitchCount) {
111
111
  var pitchRangesMap = this.pitch_slab;
112
112
  var pitchRanges = Object.values(pitchRangesMap);
113
- var selectedPitchSlab = pitchRanges.filter(function (pitchRange) {
114
- return pitchRange.from <= pitchCount && pitchCount <= pitchRange.to;
115
- })[0];
116
- return selectedPitchSlab;
113
+ return pitchRanges[this.getPitchSlabIndex(pitchCount)];
117
114
  };
118
115
  PricingPlanModelV2.prototype.getBillingCycle = function (billingCycleKey) {
119
116
  var billingCycleMap = this.billing_cycle;
@@ -57,6 +57,7 @@ export declare class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
57
57
  }[];
58
58
  getMonths(): number;
59
59
  getBasePrice(): number;
60
+ getBasePriceV2(): number;
60
61
  getGrossAmount(config?: {
61
62
  roundDown: boolean;
62
63
  }): number;
@@ -1,4 +1,12 @@
1
1
  "use strict";
2
+ // import { IGetPricingPlanByDateResponse, IGetPricingPlanByDateResponseV2 } from "../@type";
3
+ // import { IPricingPlanModel, IPricingPlanModelV2 } from "../interface/pricing-plan.interface";
4
+ // import { dateUtilService } from "../utils/date-util";
5
+ // import { mathUtil } from "../utils/math-util";
6
+ // import { BillingCycleModel, BillingCycleModelV2 } from "./billing-cycle-model";
7
+ // import { SubscriptionModel, SubscriptionModelV2 } from "./entity";
8
+ // import { PitchSlabModel, PitchSlabModelV2 } from "./pitch-slab-model";
9
+ // import { PricingPlanModel, PricingPlanModelV2 } from "./pricing-plan-model";
2
10
  var __extends = (this && this.__extends) || (function () {
3
11
  var extendStatics = function (d, b) {
4
12
  extendStatics = Object.setPrototypeOf ||
@@ -69,12 +77,14 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
69
77
  SubscribedPricingPlanModel.prototype.getMonthDifference = function (that) {
70
78
  return that.getMonths() - this.getMonths();
71
79
  };
80
+ // Not used
72
81
  SubscribedPricingPlanModel.prototype.getGrossAmountByMonth = function (month) {
73
82
  return Math.round(this.selectedPitchSlabBasePrice *
74
83
  this.pitchCount *
75
84
  this.hourInMonth *
76
85
  month);
77
86
  };
87
+ // Not used
78
88
  SubscribedPricingPlanModel.prototype.getNetAmountByMonth = function (month) {
79
89
  return Math.round(this.selectedPitchSlabBasePrice *
80
90
  (1 - this.getBillingDiscount() / 100) *
@@ -85,6 +95,7 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
85
95
  SubscribedPricingPlanModel.prototype.getGrossAmountByPitchDays = function (pitchCount, days) {
86
96
  return Math.round(this.selectedPitchSlabBasePrice * pitchCount * days * 24);
87
97
  };
98
+ // Not used
88
99
  SubscribedPricingPlanModel.prototype.getNetAmountByPitchDays = function (pitchCount, days) {
89
100
  return Math.round(this.selectedPitchSlabBasePrice *
90
101
  (1 - this.getBillingDiscount() / 100) *
@@ -92,6 +103,7 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
92
103
  days *
93
104
  24);
94
105
  };
106
+ // Used in backend
95
107
  SubscribedPricingPlanModel.prototype.getGrossAmountByPitchDaysBasePrice = function (basePrice, pitchCount, days) {
96
108
  return Math.round(basePrice * pitchCount * days * 24);
97
109
  };
@@ -110,9 +122,10 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
110
122
  SubscribedPricingPlanModel.prototype.getSelectedPitchSlabBasePrice = function () {
111
123
  return this.selectedPitchSlabBasePrice;
112
124
  };
125
+ // Used in frontend
113
126
  SubscribedPricingPlanModel.prototype.getBasePriceBySelectedBillingCycleDiscount = function () {
114
- return (this.selectedPitchSlabBasePrice -
115
- math_util_1.mathUtil.getDiscountAmount(this.selectedBillingCycle.discount, this.selectedPitchSlabBasePrice));
127
+ return parseFloat((this.selectedPitchSlabBasePrice -
128
+ math_util_1.mathUtil.getDiscountAmount(this.selectedBillingCycle.discount, this.selectedPitchSlabBasePrice)).toFixed(2));
116
129
  };
117
130
  SubscribedPricingPlanModel.prototype.getTotalHours = function () {
118
131
  return this.hourInMonth * this.selectedBillingCycle.to;
@@ -135,6 +148,7 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
135
148
  // );
136
149
  _this.selectedPitchSlabBasePrice = _this.getBasePriceByPitchSlab();
137
150
  return _this;
151
+ // this.selectedPitchSlabBasePrice = this.base_price;
138
152
  }
139
153
  SubscribedPricingPlanModelV2.prototype.getCodeByPitchCountCycle = function () {
140
154
  var _this = this;
@@ -147,7 +161,7 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
147
161
  codes.sort();
148
162
  // Filter by billing cycle
149
163
  codes = codes.filter(function (code) {
150
- return _this.selectedBillingCycle.key === _this.billingCycle;
164
+ return _this.selectedBillingCycle.to === parseInt(code.split("#")[1]);
151
165
  });
152
166
  return codes ? codes[0] : "";
153
167
  };
@@ -182,12 +196,7 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
182
196
  return codes ? codes[0].split("#")[3] : "";
183
197
  };
184
198
  SubscribedPricingPlanModelV2.prototype.getBasePriceByPitchSlab = function () {
185
- var _this = this;
186
- var codes = this.billing_cost_code.split(",");
187
- var code = codes.filter(function (code) {
188
- var _a = code.split("_"), from = _a[0], to = _a[1];
189
- return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
190
- });
199
+ var code = this.getCodesByPitchSlab();
191
200
  code.sort();
192
201
  if (code) {
193
202
  var _a = code[0].split("#"), from = _a[0], to = _a[1], price = _a[2];
@@ -223,12 +232,18 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
223
232
  };
224
233
  });
225
234
  };
235
+ // Tested
226
236
  SubscribedPricingPlanModelV2.prototype.getMonths = function () {
227
237
  return this.selectedBillingCycle.to;
228
238
  };
239
+ // Tested
229
240
  SubscribedPricingPlanModelV2.prototype.getBasePrice = function () {
230
241
  return this.selectedPitchSlabBasePrice;
231
242
  };
243
+ SubscribedPricingPlanModelV2.prototype.getBasePriceV2 = function () {
244
+ return this.base_price;
245
+ };
246
+ // Tested
232
247
  SubscribedPricingPlanModelV2.prototype.getGrossAmount = function (config) {
233
248
  if (config === void 0) { config = { roundDown: false }; }
234
249
  var roundDown = config.roundDown;
@@ -239,39 +254,57 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
239
254
  return Math.round(this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours());
240
255
  }
241
256
  };
257
+ // Tested
242
258
  SubscribedPricingPlanModelV2.prototype.getNetAmount = function (config) {
259
+ var _this = this;
243
260
  if (config === void 0) { config = { roundDown: false }; }
244
261
  var roundDown = config.roundDown;
262
+ var codesByBillingCycle = this.getCodeByCycle();
263
+ var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
264
+ var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
265
+ return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
266
+ })[0];
267
+ var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
245
268
  if (roundDown) {
246
- return Math.floor(parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
269
+ return Math.floor(this.base_price *
270
+ basePriceByPitchCycle *
247
271
  this.pitchCount *
248
272
  this.getTotalHours());
249
273
  }
250
274
  else {
251
- return Math.round(parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
275
+ return Math.round(this.base_price *
276
+ basePriceByPitchCycle *
252
277
  this.pitchCount *
253
278
  this.getTotalHours());
254
279
  }
255
280
  };
281
+ // Tested
256
282
  SubscribedPricingPlanModelV2.prototype.getBillingDiscount = function () {
257
- var selectedCode = this.getCodeByPitchCountCycle();
258
- var selectedCodesByCycle = this.getCodeByCycle();
259
- selectedCodesByCycle.sort();
260
- var basePrice = parseFloat(selectedCodesByCycle[0].split("#")[2]);
261
- var actualPrice = parseFloat(selectedCode.split("#")[2]);
262
- return (basePrice - actualPrice) / basePrice * 100;
263
- // 6_10#1#97,6_10#6#90
264
- // return this.selectedBillingCycle.getDiscount();
283
+ var _this = this;
284
+ // const codesByPitchCount = this.getCodesByPitchSlab();
285
+ var basePriceByPitchSlab = this.getBasePriceByPitchSlab();
286
+ // console.log(`basePriceByPitchSlab: ${basePriceByPitchSlab}`)
287
+ var codesByBillingCycle = this.getCodeByCycle();
288
+ // console.log(`codesByBillingCycle: ${codesByBillingCycle}`)
289
+ var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
290
+ var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
291
+ return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
292
+ })[0];
293
+ // console.log(`codeByPitchCycle: ${codeByPitchCycle}`)
294
+ var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
295
+ return parseFloat(((basePriceByPitchSlab - basePriceByPitchCycle) / basePriceByPitchSlab * 100).toFixed(2));
265
296
  };
266
297
  SubscribedPricingPlanModelV2.prototype.getMonthDifference = function (that) {
267
298
  return that.getMonths() - this.getMonths();
268
299
  };
300
+ // Tested
269
301
  SubscribedPricingPlanModelV2.prototype.getGrossAmountByMonth = function (month) {
270
302
  return Math.round(this.selectedPitchSlabBasePrice *
271
303
  this.pitchCount *
272
304
  this.hourInMonth *
273
305
  month);
274
306
  };
307
+ // Tested
275
308
  SubscribedPricingPlanModelV2.prototype.getNetAmountByMonth = function (month) {
276
309
  return Math.round(this.selectedPitchSlabBasePrice *
277
310
  (1 - this.getBillingDiscount() / 100) *
@@ -279,9 +312,11 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
279
312
  this.hourInMonth *
280
313
  month);
281
314
  };
315
+ // Tested
282
316
  SubscribedPricingPlanModelV2.prototype.getGrossAmountByPitchDays = function (pitchCount, days) {
283
317
  return Math.round(this.selectedPitchSlabBasePrice * pitchCount * days * 24);
284
318
  };
319
+ // Tested
285
320
  SubscribedPricingPlanModelV2.prototype.getNetAmountByPitchDays = function (pitchCount, days) {
286
321
  return Math.round(this.selectedPitchSlabBasePrice *
287
322
  (1 - this.getBillingDiscount() / 100) *
@@ -289,12 +324,15 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
289
324
  days *
290
325
  24);
291
326
  };
327
+ // Not Tested
292
328
  SubscribedPricingPlanModelV2.prototype.getGrossAmountByPitchDaysBasePrice = function (basePrice, pitchCount, days) {
293
329
  return Math.round(basePrice * pitchCount * days * 24);
294
330
  };
331
+ // Not Tested
295
332
  SubscribedPricingPlanModelV2.prototype.getNetAmountByPitchDaysBasePrice = function (basePrice, pitchCount, days) {
296
333
  return Math.round(basePrice * (1 - this.getBillingDiscount() / 100) * pitchCount * days * 24);
297
334
  };
335
+ // Not Tested
298
336
  SubscribedPricingPlanModelV2.prototype.getNextBillingCycleDateRange = function (date) {
299
337
  // const dateService = new DateUtilService();
300
338
  var startDate = date_util_1.dateUtilService.addNDaysToDate(date, 1);
@@ -304,22 +342,260 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
304
342
  SubscribedPricingPlanModelV2.getInstanceBySubscriptionData = function (data, subscriptionDataModel) {
305
343
  return new SubscribedPricingPlanModelV2(data, subscriptionDataModel.noOfPitches, subscriptionDataModel.type);
306
344
  };
345
+ // Tested
307
346
  SubscribedPricingPlanModelV2.prototype.getSelectedPitchSlabBasePrice = function () {
308
347
  return this.selectedPitchSlabBasePrice;
309
348
  };
349
+ // Tested
310
350
  SubscribedPricingPlanModelV2.prototype.getBasePriceBySelectedBillingCycleDiscount = function () {
311
- return this.selectedPitchSlabBasePrice;
312
- // return (
313
- // this.selectedPitchSlabBasePrice -
314
- // mathUtil.getDiscountAmount(
315
- // this.selectedBillingCycle.discount,
316
- // this.selectedPitchSlabBasePrice
317
- // )
318
- // );
351
+ var _this = this;
352
+ var codesByBillingCycle = this.getCodeByCycle();
353
+ var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
354
+ var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
355
+ return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
356
+ })[0];
357
+ var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
358
+ return parseFloat(basePriceByPitchCycle.toFixed(2));
319
359
  };
360
+ // Tested
320
361
  SubscribedPricingPlanModelV2.prototype.getTotalHours = function () {
321
362
  return this.hourInMonth * this.selectedBillingCycle.to;
322
363
  };
323
364
  return SubscribedPricingPlanModelV2;
324
365
  }(pricing_plan_model_1.PricingPlanModelV2));
325
366
  exports.SubscribedPricingPlanModelV2 = SubscribedPricingPlanModelV2;
367
+ // export class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
368
+ // pitchCount: number;
369
+ // billingCycle: string;
370
+ // selectedPitchSlab: PitchSlabModelV2;
371
+ // selectedBillingCycle: BillingCycleModelV2;
372
+ // selectedPitchSlabBasePrice: number;
373
+ // hourInMonth: number = 24 * 30;
374
+ // months: number | undefined;
375
+ // constructor(
376
+ // data: IPricingPlanModelV2,
377
+ // pitchCount: number,
378
+ // billingCycle: string
379
+ // ) {
380
+ // super(data);
381
+ // this.pitchCount = pitchCount;
382
+ // this.billingCycle = billingCycle;
383
+ // this.selectedPitchSlab = this.getPitchSlab(this.pitchCount);
384
+ // this.selectedBillingCycle = this.getBillingCycle(this.billingCycle);
385
+ // // this.selectedPitchSlabBasePrice = this.selectedPitchSlab.getBasePrice(
386
+ // // this.base_price
387
+ // // );
388
+ // this.selectedPitchSlabBasePrice = this.getBasePriceByPitchSlab();
389
+ // }
390
+ // getCodeByPitchCountCycle(): string {
391
+ // let codes = this.billing_cost_code.split(",");
392
+ // // Filter by pitch count
393
+ // codes = codes.filter((code) => {
394
+ // const [from, to] = code.split("_");
395
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
396
+ // });
397
+ // codes.sort();
398
+ // // Filter by billing cycle
399
+ // codes = codes.filter((code) => {
400
+ // return this.selectedBillingCycle.key === this.billingCycle;
401
+ // });
402
+ // return codes ? codes[0] : "";
403
+ // }
404
+ // getCodeByCycle(): string[] {
405
+ // let codes = this.billing_cost_code.split(",");
406
+ // // Filter by pitch count
407
+ // // codes = codes.filter((code) => {
408
+ // // const [from, to] = code.split("_");
409
+ // // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
410
+ // // });
411
+ // // codes.sort();
412
+ // // Filter by billing cycle
413
+ // return codes.filter((code) => {
414
+ // return this.selectedBillingCycle.to === parseInt(code.split("#")[1]);
415
+ // });
416
+ // // return codes ? codes[0] : "";
417
+ // }
418
+ // getDiscount(){
419
+ // let codes = this.billing_cost_code.split(",");
420
+ // // Filter by pitch count
421
+ // codes = codes.filter((code) => {
422
+ // const [from, to] = code.split("_");
423
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
424
+ // });
425
+ // codes.sort();
426
+ // // Filter by billing cycle
427
+ // codes = codes.filter((code) => {
428
+ // return this.selectedBillingCycle.to === Number(code.split("#")[1]);
429
+ // });
430
+ // return codes ? codes[0].split("#")[3] : "";
431
+ // }
432
+ // getBasePriceByPitchSlab() {
433
+ // const codes = this.billing_cost_code.split(",");
434
+ // const code = codes.filter((code) => {
435
+ // const [from, to] = code.split("_");
436
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
437
+ // });
438
+ // code.sort();
439
+ // if (code) {
440
+ // const [from, to, price] = code[0].split("#");
441
+ // return parseFloat(price);
442
+ // }
443
+ // return 0;
444
+ // }
445
+ // getCodesByPitchSlab(): string[] {
446
+ // const codes = this.billing_cost_code.split(",");
447
+ // return codes.filter((code) => {
448
+ // const [from, to] = code.split("_");
449
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
450
+ // });
451
+ // // code.sort();
452
+ // // if (code) {
453
+ // // const [from, to, price] = code[0].split("#");
454
+ // // return parseFloat(price);
455
+ // // }
456
+ // // return 0;
457
+ // }
458
+ // parseCode(code:string) {
459
+ // // 1_5#1#100,1_5#6#98,6_10#1#97,6_10#6#90
460
+ // const codes = code.split(",");
461
+ // return codes.map((code) => {
462
+ // const [pitch, month, price] = code.split("#");
463
+ // const [from, to] = pitch.split("_");
464
+ // return {
465
+ // from: parseInt(from),
466
+ // to: parseInt(to),
467
+ // month: parseInt(month),
468
+ // price: parseFloat(price),
469
+ // };
470
+ // });
471
+ // }
472
+ // getMonths(): number {
473
+ // return this.selectedBillingCycle.to;
474
+ // }
475
+ // getBasePrice(): number {
476
+ // return this.selectedPitchSlabBasePrice;
477
+ // }
478
+ // getGrossAmount(
479
+ // config: { roundDown: boolean } = { roundDown: false }
480
+ // ): number {
481
+ // const { roundDown } = config;
482
+ // if (roundDown) {
483
+ // return Math.floor(
484
+ // this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours()
485
+ // );
486
+ // } else {
487
+ // return Math.round(
488
+ // this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours()
489
+ // );
490
+ // }
491
+ // }
492
+ // getNetAmount(config: { roundDown: boolean } = { roundDown: false }): number {
493
+ // const { roundDown } = config;
494
+ // if (roundDown) {
495
+ // return Math.floor(
496
+ // parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
497
+ // this.pitchCount *
498
+ // this.getTotalHours()
499
+ // );
500
+ // } else {
501
+ // return Math.round(
502
+ // parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
503
+ // this.pitchCount *
504
+ // this.getTotalHours()
505
+ // );
506
+ // }
507
+ // }
508
+ // getBillingDiscount(): number {
509
+ // const selectedCode = this.getCodeByPitchCountCycle()
510
+ // const selectedCodesByCycle = this.getCodeByCycle();
511
+ // selectedCodesByCycle.sort();
512
+ // const basePrice = parseFloat(selectedCodesByCycle[0].split("#")[2]);
513
+ // const actualPrice = parseFloat(selectedCode.split("#")[2]);
514
+ // return (basePrice - actualPrice) / basePrice * 100;
515
+ // // 6_10#1#97,6_10#6#90
516
+ // // return this.selectedBillingCycle.getDiscount();
517
+ // }
518
+ // getMonthDifference(that: SubscribedPricingPlanModelV2): number {
519
+ // return that.getMonths() - this.getMonths();
520
+ // }
521
+ // getGrossAmountByMonth(month: number): number {
522
+ // return Math.round(
523
+ // this.selectedPitchSlabBasePrice *
524
+ // this.pitchCount *
525
+ // this.hourInMonth *
526
+ // month
527
+ // );
528
+ // }
529
+ // getNetAmountByMonth(month: number): number {
530
+ // return Math.round(
531
+ // this.selectedPitchSlabBasePrice *
532
+ // (1 - this.getBillingDiscount() / 100) *
533
+ // this.pitchCount *
534
+ // this.hourInMonth *
535
+ // month
536
+ // );
537
+ // }
538
+ // getGrossAmountByPitchDays(pitchCount: number, days: number): number {
539
+ // return Math.round(this.selectedPitchSlabBasePrice * pitchCount * days * 24);
540
+ // }
541
+ // getNetAmountByPitchDays(pitchCount: number, days: number): number {
542
+ // return Math.round(
543
+ // this.selectedPitchSlabBasePrice *
544
+ // (1 - this.getBillingDiscount() / 100) *
545
+ // pitchCount *
546
+ // days *
547
+ // 24
548
+ // );
549
+ // }
550
+ // getGrossAmountByPitchDaysBasePrice(
551
+ // basePrice: number,
552
+ // pitchCount: number,
553
+ // days: number
554
+ // ): number {
555
+ // return Math.round(basePrice * pitchCount * days * 24);
556
+ // }
557
+ // getNetAmountByPitchDaysBasePrice(
558
+ // basePrice: number,
559
+ // pitchCount: number,
560
+ // days: number
561
+ // ): number {
562
+ // return Math.round(
563
+ // basePrice * (1 - this.getBillingDiscount() / 100) * pitchCount * days * 24
564
+ // );
565
+ // }
566
+ // getNextBillingCycleDateRange(date: Date): [Date, Date] {
567
+ // // const dateService = new DateUtilService();
568
+ // const startDate = dateUtilService.addNDaysToDate(date, 1);
569
+ // const endDate = dateUtilService.addNDaysToDate(
570
+ // date,
571
+ // this.selectedBillingCycle.to * 30
572
+ // );
573
+ // return [startDate, endDate];
574
+ // }
575
+ // static getInstanceBySubscriptionData(
576
+ // data: IGetPricingPlanByDateResponseV2,
577
+ // subscriptionDataModel: SubscriptionModelV2
578
+ // ) {
579
+ // return new SubscribedPricingPlanModelV2(
580
+ // data,
581
+ // subscriptionDataModel.noOfPitches,
582
+ // subscriptionDataModel.type
583
+ // );
584
+ // }
585
+ // getSelectedPitchSlabBasePrice(): number {
586
+ // return this.selectedPitchSlabBasePrice;
587
+ // }
588
+ // getBasePriceBySelectedBillingCycleDiscount(): number {
589
+ // return this.selectedPitchSlabBasePrice;
590
+ // // return (
591
+ // // this.selectedPitchSlabBasePrice -
592
+ // // mathUtil.getDiscountAmount(
593
+ // // this.selectedBillingCycle.discount,
594
+ // // this.selectedPitchSlabBasePrice
595
+ // // )
596
+ // // );
597
+ // }
598
+ // getTotalHours(): number {
599
+ // return this.hourInMonth * this.selectedBillingCycle.to;
600
+ // }
601
+ // }
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _enum_1 = require("../../../@enum");
4
+ var _model_1 = require("../../../@model");
5
+ describe("AppController (e2e)", function () {
6
+ it("Pricing and Subscription related methods values assertion", function () {
7
+ var pricingPlanEntityV2 = {
8
+ id: 1,
9
+ effectiveFrom: new Date(),
10
+ effectiveTo: new Date(),
11
+ status: _enum_1.PricingPlanStatus.ACTIVE,
12
+ createdBy: 1,
13
+ createdOn: new Date(),
14
+ updatedBy: 1,
15
+ updatedOn: new Date(),
16
+ basePrice: 1,
17
+ unit: "unit",
18
+ subscriptionCycle: "000001_0P_Monthly,000003_0P_Quarterly,000006_0P_Half-Yearly,000012_0P_Yearly",
19
+ billingCostCode: "1_5#1#1.0000#0P,1_5#3#0.9500#5P,1_5#6#0.9300#7P,1_5#12#0.9000#10P,6_10#1#0.9800#2P,6_10#3#0.9300#7P,6_10#6#0.9100#9P,6_10#12#0.8800#12P,11_99#1#0.9500#5P,11_99#3#0.9000#10P,11_99#6#0.8800#12P,11_99#12#0.8600#14P",
20
+ // costCode: "001005_0P_1,006010_2P_1,011999_5P_1",
21
+ // billingCycle: "000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly"
22
+ };
23
+ var pricingPlanEntityModel2 = new _model_1.PricingPlanEntityModelV2(pricingPlanEntityV2);
24
+ // console.log(pricingPlanEntityModel2.toPitchSlabs())
25
+ // console.log(pricingPlanEntityModel2.toBillingCycles())
26
+ var expectedBillingCycles = [
27
+ {
28
+ to: 1,
29
+ name: 'Monthly',
30
+ key: 'monthly'
31
+ },
32
+ {
33
+ to: 3,
34
+ name: 'Quarterly',
35
+ key: 'quarterly'
36
+ },
37
+ {
38
+ to: 6,
39
+ name: 'Half-Yearly',
40
+ key: 'half-yearly'
41
+ },
42
+ {
43
+ to: 12,
44
+ name: 'Yearly',
45
+ key: 'yearly'
46
+ }
47
+ ];
48
+ var expectedBillingCycleKeys = expectedBillingCycles.map(function (billingCycle) { return billingCycle.key; });
49
+ var expectedbillingCycles = pricingPlanEntityModel2.toBillingCycles();
50
+ expectedbillingCycles.forEach(function (billingCycle, index) {
51
+ expect(billingCycle.to).toEqual(expectedBillingCycles[index].to);
52
+ expect(billingCycle.name).toEqual(expectedBillingCycles[index].name);
53
+ expect(billingCycle.key).toEqual(expectedBillingCycles[index].key);
54
+ });
55
+ var pricingPlanModelV2 = new _model_1.PricingPlanModelV2(pricingPlanEntityModel2.toModel());
56
+ expect(pricingPlanModelV2.formatPitchSlab(0)).toEqual("1-5");
57
+ expect(pricingPlanModelV2.formatPitchSlab(1)).toEqual("6-10");
58
+ expect(pricingPlanModelV2.formatPitchSlab(2)).toEqual("10+");
59
+ // console.log(pricingPlanModel.getPitchSlab(1))
60
+ // console.log(pricingPlanModelV2.getPitchSlab(1) )
61
+ var pitchCounts = [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 70];
62
+ var pitchSlabs = [
63
+ { from: 1, to: 5 },
64
+ { from: 6, to: 10 },
65
+ { from: 11, to: 99 },
66
+ ];
67
+ var expectedPitchSlabsByPitchCount = [
68
+ pitchSlabs[0],
69
+ pitchSlabs[0],
70
+ pitchSlabs[0],
71
+ pitchSlabs[0],
72
+ pitchSlabs[1],
73
+ pitchSlabs[1],
74
+ pitchSlabs[1],
75
+ pitchSlabs[1],
76
+ pitchSlabs[1],
77
+ pitchSlabs[2],
78
+ pitchSlabs[2],
79
+ pitchSlabs[2],
80
+ ];
81
+ var pitchSlab = pricingPlanModelV2.getPitchSlab(1);
82
+ pitchCounts.forEach(function (pitchCount, index) {
83
+ pitchSlab = pricingPlanModelV2.getPitchSlab(pitchCount);
84
+ expect(pitchSlab.from).toEqual(expectedPitchSlabsByPitchCount[index].from);
85
+ expect(pitchSlab.to).toEqual(expectedPitchSlabsByPitchCount[index].to);
86
+ });
87
+ var _loop_1 = function (billingCycleKey) {
88
+ expect(pricingPlanModelV2.getBillingCycle(billingCycleKey)).toEqual(expectedbillingCycles.filter(function (billingCycle) { return billingCycle.key === billingCycleKey; })[0]);
89
+ };
90
+ for (var _i = 0, expectedBillingCycleKeys_1 = expectedBillingCycleKeys; _i < expectedBillingCycleKeys_1.length; _i++) {
91
+ var billingCycleKey = expectedBillingCycleKeys_1[_i];
92
+ _loop_1(billingCycleKey);
93
+ }
94
+ var monthsByBillingCycle = {
95
+ monthly: 1,
96
+ quarterly: 3,
97
+ "half-yearly": 6,
98
+ yearly: 12,
99
+ };
100
+ for (var _a = 0, expectedBillingCycleKeys_2 = expectedBillingCycleKeys; _a < expectedBillingCycleKeys_2.length; _a++) {
101
+ var billingCycleKey = expectedBillingCycleKeys_2[_a];
102
+ expect(pricingPlanModelV2.getMonth(billingCycleKey)).toEqual(monthsByBillingCycle[billingCycleKey]);
103
+ }
104
+ var noOfSubscriptionDaysByBillingCycle = {
105
+ monthly: 30,
106
+ quarterly: 90,
107
+ "half-yearly": 180,
108
+ yearly: 360,
109
+ };
110
+ // TODO: Need to check the logic of the below method as it returning 1 less than the expected value
111
+ // for (let billingCycleKey of expectedBillingCycleKeys) {
112
+ // expect(pricingPlanModelV2.getNoOfSubscriptionDays(billingCycleKey)).toEqual(noOfSubscriptionDaysByBillingCycle[billingCycleKey]);
113
+ // }
114
+ var daysByBillingCycle = {
115
+ monthly: [1, 3, 29, 30],
116
+ quarterly: [31, 90],
117
+ "half-yearly": [91, 180],
118
+ yearly: [181, 360],
119
+ };
120
+ for (var _b = 0, _c = Object.entries(daysByBillingCycle); _b < _c.length; _b++) {
121
+ var _d = _c[_b], billingCycleKey = _d[0], days = _d[1];
122
+ for (var _e = 0, days_1 = days; _e < days_1.length; _e++) {
123
+ var day = days_1[_e];
124
+ var billingCycle = pricingPlanModelV2.getBillingCycleByDay(day);
125
+ expect(billingCycle).toBeDefined();
126
+ expect(billingCycle === null || billingCycle === void 0 ? void 0 : billingCycle.key).toEqual(billingCycleKey);
127
+ }
128
+ }
129
+ var noOfMonthsByBillingCycle = {
130
+ 0: [1],
131
+ 1: [3, 2],
132
+ 2: [4, 5, 6],
133
+ 3: [7, 8, 9, 10, 11, 12],
134
+ };
135
+ for (var _f = 0, _g = Object.entries(noOfMonthsByBillingCycle); _f < _g.length; _f++) {
136
+ var _h = _g[_f], billingCycleKeyIndex = _h[0], months = _h[1];
137
+ for (var _j = 0, months_1 = months; _j < months_1.length; _j++) {
138
+ var month = months_1[_j];
139
+ expect(pricingPlanModelV2.getBillingCycleIndexByMonths(month)).toEqual(parseInt(billingCycleKeyIndex));
140
+ }
141
+ }
142
+ // const pitchCount = 11;
143
+ // const billingCycleKey = 'quarterly';
144
+ // const billingCycleKeys = ["monthly", "quarterly", "half-yearly", "yearly"];
145
+ var basePriceMatrix = [
146
+ [1, 0.95, 0.93, 0.9],
147
+ [0.98, 0.93, 0.91, 0.88],
148
+ [0.95, 0.9, 0.88, 0.86],
149
+ ];
150
+ pitchCounts = [2, 6, 70];
151
+ for (var _k = 0, pitchCounts_1 = pitchCounts; _k < pitchCounts_1.length; _k++) {
152
+ var pitchCount = pitchCounts_1[_k];
153
+ for (var _l = 0, expectedBillingCycleKeys_3 = expectedBillingCycleKeys; _l < expectedBillingCycleKeys_3.length; _l++) {
154
+ var billingCycleKey = expectedBillingCycleKeys_3[_l];
155
+ var subscribedPricingPlanModelV2 = new _model_1.SubscribedPricingPlanModelV2(pricingPlanModelV2, pitchCount, billingCycleKey);
156
+ console.log("---- Pitch Count: '".concat(subscribedPricingPlanModelV2.pitchCount, "', Billing: '").concat(subscribedPricingPlanModelV2.billingCycle, "'"));
157
+ // TODO: Need to check the usability of the below method
158
+ // console.log(`subscribedPricingPlanModelV2.getMonths() : ${subscribedPricingPlanModelV2.getMonths()}`)
159
+ // TODO: Needs to change the name to getBasePriceByPitchSlab for Monthly
160
+ // console.log(`subscribedPricingPlanModelV2.getBasePrice(): ${subscribedPricingPlanModelV2.getBasePrice()}`)
161
+ // TODO: Neede removal
162
+ // console.log(`subscribedPricingPlanModelV2.getBillingDiscount(): ${subscribedPricingPlanModelV2.getBillingDiscount()}`)
163
+ // expect(subscribebPricingPlanModel.getBillingDiscount()).toEqual(
164
+ // subscribedPricingPlanModelV2.getBillingDiscount()
165
+ // );
166
+ // TODO: Needs to change the logic based on base price and discount
167
+ // console.log(`subscribedPricingPlanModelV2.getGrossAmount(): ${subscribedPricingPlanModelV2.getGrossAmount()}`)
168
+ // TODO: Needs to change the logic based on base price and discount
169
+ // console.log(`subscribedPricingPlanModelV2.getNetAmount(): ${subscribedPricingPlanModelV2.getNetAmount()}`)
170
+ // console.log(`subscribedPricingPlanModelV2.getGrossAmountByPitchDays(): ${subscribedPricingPlanModelV2.getGrossAmountByPitchDays(11, 3)}`)
171
+ // console.log(`subscribedPricingPlanModelV2.getNetAmountByPitchDays(): ${subscribedPricingPlanModelV2.getNetAmountByPitchDays(11, 3)}`)
172
+ var pitchSlabIndex = subscribedPricingPlanModelV2.getPitchSlabIndex(pitchCount);
173
+ var billingCycleIndex = subscribedPricingPlanModelV2.getBillingCycleIndexByMonths(subscribedPricingPlanModelV2.selectedBillingCycle.to);
174
+ expect(subscribedPricingPlanModelV2.getBasePriceBySelectedBillingCycleDiscount()).toEqual(basePriceMatrix[pitchSlabIndex][billingCycleIndex]);
175
+ // const months = [1, 2, 3, 5, 6, 7, 11, 12];
176
+ // for (let month of months) {
177
+ // console.log(`subscribedPricingPlanModelV2.getGrossAmountByMonth(${month}): ${subscribedPricingPlanModelV2.getGrossAmountByMonth(month)}`)
178
+ // console.log(`subscribedPricingPlanModelV2.getNetAmountByMonth(${month}): ${subscribedPricingPlanModelV2.getNetAmountByMonth(month)}`)
179
+ // }
180
+ }
181
+ }
182
+ });
183
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _enum_1 = require("../../../@enum");
4
+ var _model_1 = require("../../../@model");
5
+ // 001005_0P_1,006010_2P_1,011999_5P_1
6
+ // 000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly
7
+ // 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
8
+ describe("AppController (e2e)", function () {
9
+ it("Pricing and subscriptions related version 2 models method values verification ", function () {
10
+ var pricingPlanEntity = {
11
+ id: 1,
12
+ effectiveFrom: new Date(),
13
+ effectiveTo: new Date(),
14
+ status: _enum_1.PricingPlanStatus.ACTIVE,
15
+ createdBy: 1,
16
+ createdOn: new Date(),
17
+ updatedBy: 1,
18
+ updatedOn: new Date(),
19
+ basePrice: 1,
20
+ unit: "unit",
21
+ subscriptionCycle: "cycle",
22
+ billingCostCode: "code",
23
+ costCode: "001005_0P_1,006010_2P_1,011999_5P_1",
24
+ billingCycle: "000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly",
25
+ };
26
+ var pricingPlanEntityV2 = {
27
+ id: 1,
28
+ effectiveFrom: new Date(),
29
+ effectiveTo: new Date(),
30
+ status: _enum_1.PricingPlanStatus.ACTIVE,
31
+ createdBy: 1,
32
+ createdOn: new Date(),
33
+ updatedBy: 1,
34
+ updatedOn: new Date(),
35
+ basePrice: 1,
36
+ unit: "unit",
37
+ subscriptionCycle: "000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly",
38
+ billingCostCode: "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",
39
+ // costCode: "001005_0P_1,006010_2P_1,011999_5P_1",
40
+ // billingCycle: "000001_0P_Monthly,000003_5P_Quarterly,000006_7P_Half-Yearly,000012_10P_Yearly"
41
+ };
42
+ var pricingPlanEntityModel = new _model_1.PricingPlanEntityModel(pricingPlanEntity);
43
+ var pricingPlanEntityModel2 = new _model_1.PricingPlanEntityModelV2(pricingPlanEntityV2);
44
+ // console.log(pricingPlanEntityModel.toPitchSlabs())
45
+ // console.log(pricingPlanEntityModel2.toPitchSlabs())
46
+ // console.log(pricingPlanEntityModel.toBillingCycles())
47
+ // console.log(pricingPlanEntityModel2.toBillingCycles())
48
+ // console.log(pricingPlanEntityModel.getBillingCycleKeys())
49
+ // console.log(pricingPlanEntityModel2.getBillingCycleKeys())
50
+ // console.log(pricingPlanEntityModel.toModel())
51
+ // console.log(pricingPlanEntityModel2.toModel())
52
+ // console.log(pricingPlanEntityModel.arrayToIndexedObject([]))
53
+ // console.log(pricingPlanEntityModel.toObject())
54
+ // console.log(pricingPlanEntityModel2.toObject())
55
+ var pricingPlanModel = new _model_1.PricingPlanModel(pricingPlanEntityModel.toModel());
56
+ var pricingPlanModelV2 = new _model_1.PricingPlanModelV2(pricingPlanEntityModel2.toModel());
57
+ // console.log(pricingPlanModel.formatPitchSlab(0))
58
+ // console.log(pricingPlanModelV2.formatPitchSlab(0))
59
+ // console.log(pricingPlanModel.formatPitchSlab(1))
60
+ // console.log(pricingPlanModelV2.formatPitchSlab(1))
61
+ // console.log(pricingPlanModel.formatPitchSlab(2))
62
+ // console.log(pricingPlanModelV2.formatPitchSlab(2))
63
+ // console.log(pricingPlanModel.getPitchSlab(1))
64
+ // console.log(pricingPlanModelV2.getPitchSlab(1))
65
+ // console.log(pricingPlanModel.getPitchSlab(4))
66
+ // console.log(pricingPlanModelV2.getPitchSlab(4))
67
+ // console.log(pricingPlanModel.getPitchSlab(6))
68
+ // console.log(pricingPlanModelV2.getPitchSlab(6))
69
+ // console.log(pricingPlanModel.getPitchSlab(10))
70
+ // console.log(pricingPlanModelV2.getPitchSlab(10))
71
+ // console.log(pricingPlanModel.getPitchSlab(11))
72
+ // console.log(pricingPlanModelV2.getPitchSlab(11))
73
+ // console.log(pricingPlanModel.getBillingCycle("half-yearly"))
74
+ // console.log(pricingPlanModelV2.getBillingCycle("half-yearly"))
75
+ // console.log(pricingPlanModel.getBillingCycle("quarterly"))
76
+ // console.log(pricingPlanModelV2.getBillingCycle("quarterly"))
77
+ // console.log(pricingPlanModel.getMonth("half-yearly"))
78
+ // console.log(pricingPlanModelV2.getMonth("half-yearly"))
79
+ // console.log(pricingPlanModel.getMonth("quarterly"))
80
+ // console.log(pricingPlanModelV2.getMonth("quarterly"))
81
+ // console.log(pricingPlanModel.getNoOfSubscriptionDays("half-yearly"))
82
+ // console.log(pricingPlanModelV2.getNoOfSubscriptionDays("half-yearly"))
83
+ // console.log(pricingPlanModel.getNoOfSubscriptionDays("quarterly"))
84
+ // console.log(pricingPlanModelV2.getNoOfSubscriptionDays("quarterly"))
85
+ // console.log(pricingPlanModel.getBillingCycleKeys())
86
+ // console.log(pricingPlanModelV2.getBillingCycleKeys())
87
+ // pricingPlanModel.validateBillingCycleKey("half-yearly")
88
+ // pricingPlanModelV2.validateBillingCycleKey("half-yearly")
89
+ // console.log(pricingPlanModel.getBillingCycleByDay(3))
90
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(3))
91
+ // console.log(pricingPlanModel.getBillingCycleByDay(30))
92
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(30))
93
+ // console.log(pricingPlanModel.getBillingCycleByDay(31))
94
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(31))
95
+ // console.log(pricingPlanModel.getBillingCycleByDay(90))
96
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(90))
97
+ // console.log(pricingPlanModel.getBillingCycleByDay(91))
98
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(91))
99
+ // console.log(pricingPlanModel.getBillingCycleByDay(180))
100
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(180))
101
+ // console.log(pricingPlanModel.getBillingCycleByDay(181))
102
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(181))
103
+ // console.log(pricingPlanModel.getBillingCycleByDay(360))
104
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(360))
105
+ // console.log(pricingPlanModel.getBillingCycleByDay(361))
106
+ // console.log(pricingPlanModelV2.getBillingCycleByDay(361))
107
+ // Remaining
108
+ // console.log(pricingPlanModel.getPitchSlabIndex(1))
109
+ // console.log(pricingPlanModelV2.getPitchSlabIndex(1))
110
+ // console.log(pricingPlanModel.getPitchSlabIndex(4))
111
+ // console.log(pricingPlanModelV2.getPitchSlabIndex(4))
112
+ // console.log(pricingPlanModel.getPitchSlabIndex(6))
113
+ // console.log(pricingPlanModelV2.getPitchSlabIndex(6))
114
+ // console.log(pricingPlanModel.getPitchSlabIndex(10))
115
+ // console.log(pricingPlanModelV2.getPitchSlabIndex(10))
116
+ // console.log(pricingPlanModel.getPitchSlabIndex(11))
117
+ // console.log(pricingPlanModelV2.getPitchSlabIndex(11))
118
+ // console.log(pricingPlanModel.getBillingCycleIndexByMonths(1))
119
+ // console.log(pricingPlanModelV2.getBillingCycleIndexByMonths(1))
120
+ // console.log(pricingPlanModel.getBillingCycleIndexByMonths(3))
121
+ // console.log(pricingPlanModelV2.getBillingCycleIndexByMonths(3))
122
+ // console.log(pricingPlanModel.getBillingCycleIndexByMonths(5))
123
+ // console.log(pricingPlanModelV2.getBillingCycleIndexByMonths(5))
124
+ // console.log(pricingPlanModel.getBillingCycleIndexByMonths(6))
125
+ // console.log(pricingPlanModelV2.getBillingCycleIndexByMonths(6))
126
+ // console.log(pricingPlanModel.getBillingCycleIndexByMonths(9))
127
+ // console.log(pricingPlanModelV2.getBillingCycleIndexByMonths(9))
128
+ // console.log(pricingPlanModel.getBillingCycleIndexByMonths(12))
129
+ // console.log(pricingPlanModelV2.getBillingCycleIndexByMonths(12))
130
+ // const pitchCount = 11;
131
+ // const billingCycleKey = 'quarterly';
132
+ var pitchCounts = [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 70];
133
+ var billingCycleKeys = ["monthly", "quarterly", "half-yearly", "yearly"];
134
+ for (var _i = 0, pitchCounts_1 = pitchCounts; _i < pitchCounts_1.length; _i++) {
135
+ var pitchCount = pitchCounts_1[_i];
136
+ for (var _a = 0, billingCycleKeys_1 = billingCycleKeys; _a < billingCycleKeys_1.length; _a++) {
137
+ var billingCycleKey = billingCycleKeys_1[_a];
138
+ var subscribebPricingPlanModel = new _model_1.SubscribedPricingPlanModel(pricingPlanModel, pitchCount, billingCycleKey);
139
+ var subscribedPricingPlanModelV2 = new _model_1.SubscribedPricingPlanModelV2(pricingPlanModelV2, pitchCount, billingCycleKey);
140
+ // const subscribebPricingPlanModel = new SubscribedPricingPlanModel(pricingPlanModel, pitchCount, billingCycleKey);
141
+ // const subscribedPricingPlanModelV2 =new SubscribedPricingPlanModelV2(pricingPlanModelV2, pitchCount, billingCycleKey);
142
+ // console.log(`subscribebPricingPlanModel.getMonths() : ${subscribebPricingPlanModel.getMonths()}`)
143
+ // console.log(`subscribedPricingPlanModelV2.getMonths() : ${subscribedPricingPlanModelV2.getMonths()}`)
144
+ expect(subscribebPricingPlanModel.getMonths()).toEqual(subscribedPricingPlanModelV2.getMonths());
145
+ // console.log(`subscribebPricingPlanModel.getBasePrice(): ${subscribebPricingPlanModel.getBasePrice()}`)
146
+ // console.log(`subscribedPricingPlanModelV2.getBasePrice(): ${subscribedPricingPlanModelV2.getBasePrice()}`)
147
+ expect(subscribebPricingPlanModel.getBasePrice()).toEqual(subscribedPricingPlanModelV2.getBasePrice());
148
+ // console.log(`subscribebPricingPlanModel.getBillingDiscount(): ${subscribebPricingPlanModel.getBillingDiscount()}`)
149
+ // console.log(`subscribedPricingPlanModelV2.getBillingDiscount(): ${subscribedPricingPlanModelV2.getBillingDiscount()}`)
150
+ expect(subscribebPricingPlanModel.getBillingDiscount()).toEqual(subscribedPricingPlanModelV2.getBillingDiscount());
151
+ // console.log(`subscribebPricingPlanModel.getGrossAmount(): ${subscribebPricingPlanModel.getGrossAmount()}`)
152
+ // console.log(`subscribedPricingPlanModelV2.getGrossAmount(): ${subscribedPricingPlanModelV2.getGrossAmount()}`)
153
+ expect(subscribebPricingPlanModel.getGrossAmount()).toEqual(subscribedPricingPlanModelV2.getGrossAmount());
154
+ // console.log(`subscribebPricingPlanModel.getNetAmount(): ${subscribebPricingPlanModel.getNetAmount()}`)
155
+ // console.log(`subscribedPricingPlanModelV2.getNetAmount(): ${subscribedPricingPlanModelV2.getNetAmount()}`)
156
+ expect(subscribebPricingPlanModel.getNetAmount()).toEqual(subscribedPricingPlanModelV2.getNetAmount());
157
+ // console.log(`subscribebPricingPlanModel.getGrossAmountByPitchDays(): ${subscribebPricingPlanModel.getGrossAmountByPitchDays(11, 3)}`)
158
+ // console.log(`subscribedPricingPlanModelV2.getGrossAmountByPitchDays(): ${subscribedPricingPlanModelV2.getGrossAmountByPitchDays(11, 3)}`)
159
+ expect(subscribebPricingPlanModel.getGrossAmountByPitchDays(11, 3)).toEqual(subscribedPricingPlanModelV2.getGrossAmountByPitchDays(11, 3));
160
+ // console.log(`subscribebPricingPlanModel.getNetAmountByPitchDays(): ${subscribebPricingPlanModel.getNetAmountByPitchDays(11, 3)}`)
161
+ // console.log(`subscribedPricingPlanModelV2.getNetAmountByPitchDays(): ${subscribedPricingPlanModelV2.getNetAmountByPitchDays(11, 3)}`)
162
+ expect(subscribebPricingPlanModel.getNetAmountByPitchDays(11, 3)).toEqual(subscribedPricingPlanModelV2.getNetAmountByPitchDays(11, 3));
163
+ // console.log(`subscribebPricingPlanModel.getBasePriceBySelectedBillingCycleDiscount(): ${subscribebPricingPlanModel.getBasePriceBySelectedBillingCycleDiscount()}`)
164
+ // console.log(`subscribedPricingPlanModelV2.getBasePriceBySelectedBillingCycleDiscount(): ${subscribedPricingPlanModelV2.getBasePriceBySelectedBillingCycleDiscount()}`)
165
+ expect(subscribebPricingPlanModel.getBasePriceBySelectedBillingCycleDiscount()).toEqual(subscribedPricingPlanModelV2.getBasePriceBySelectedBillingCycleDiscount());
166
+ var months = [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12];
167
+ for (var _b = 0, months_1 = months; _b < months_1.length; _b++) {
168
+ var month = months_1[_b];
169
+ // console.log(`subscribebPricingPlanModel.getGrossAmountByMonth(${month}): ${subscribebPricingPlanModel.getGrossAmountByMonth(month)}`)
170
+ // console.log(`subscribedPricingPlanModelV2.getGrossAmountByMonth(${month}): ${subscribedPricingPlanModelV2.getGrossAmountByMonth(month)}`)
171
+ expect(subscribebPricingPlanModel.getGrossAmountByMonth(month)).toEqual(subscribedPricingPlanModelV2.getGrossAmountByMonth(month));
172
+ // console.log(`subscribebPricingPlanModel.getNetAmountByMonth(${month}): ${subscribebPricingPlanModel.getNetAmountByMonth(month)}`)
173
+ // console.log(`subscribedPricingPlanModelV2.getNetAmountByMonth(${month}): ${subscribedPricingPlanModelV2.getNetAmountByMonth(month)}`)
174
+ expect(subscribebPricingPlanModel.getNetAmountByMonth(month)).toEqual(subscribedPricingPlanModelV2.getNetAmountByMonth(month));
175
+ }
176
+ // console.log(`subscribebPricingPlanModel.getSelectedPitchSlabBasePrice(): ${subscribebPricingPlanModel.getSelectedPitchSlabBasePrice()}`)
177
+ // console.log(`subscribedPricingPlanModelV2.getSelectedPitchSlabBasePrice(): ${subscribedPricingPlanModelV2.getSelectedPitchSlabBasePrice()}`)
178
+ expect(subscribebPricingPlanModel.getSelectedPitchSlabBasePrice()).toEqual(subscribedPricingPlanModelV2.getSelectedPitchSlabBasePrice());
179
+ // console.log(`subscribebPricingPlanModel.getTotalHours(): ${subscribebPricingPlanModel.getTotalHours()}`)
180
+ // console.log(`subscribedPricingPlanModelV2.getTotalHours(): ${subscribedPricingPlanModelV2.getTotalHours()}`)
181
+ expect(subscribebPricingPlanModel.getTotalHours()).toEqual(subscribedPricingPlanModelV2.getTotalHours());
182
+ }
183
+ }
184
+ });
185
+ });
package/package.json CHANGED
@@ -1,42 +1,43 @@
1
- {
2
- "name": "turf-common",
3
- "version": "1.4.1-beta.9",
4
- "description": "",
5
- "main": "./build/index.js",
6
- "types": "./build/index.d.ts",
7
- "files": [
8
- "build/**/*"
9
- ],
10
- "scripts": {
11
- "clean": "rm -rf build",
12
- "build": "npm run clean && tsc",
13
- "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
14
- "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
15
- "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
16
- "test": "jest",
17
- "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
18
- "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "github__bellex-dev__turf-common:bellex-dev/turf-common.git"
23
- },
24
- "keywords": [],
25
- "author": "",
26
- "license": "ISC",
27
- "devDependencies": {
28
- "@types/jest": "^29.5.11",
29
- "@types/node": "^20.8.9",
30
- "@typescript-eslint/eslint-plugin": "^6.7.2",
31
- "@typescript-eslint/parser": "^6.7.2",
32
- "del-cli": "^5.1.0",
33
- "eslint": "^8.50.0",
34
- "jest": "^29.7.0",
35
- "ts-jest": "^29.1.1",
36
- "ts-node": "^10.9.2",
37
- "typescript": "^5.2.2"
38
- },
39
- "dependencies": {
40
- "date-fns": "^2.30.0"
41
- }
42
- }
1
+ {
2
+ "name": "turf-common",
3
+ "version": "1.4.2-beta.1",
4
+ "description": "",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "files": [
8
+ "build/**/*"
9
+ ],
10
+ "scripts": {
11
+ "clean": "rm -rf build",
12
+ "build": "npm run clean && tsc",
13
+ "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
14
+ "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
15
+ "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
16
+ "test": "jest",
17
+ "test:pattern": "jest -i TURF-533",
18
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
19
+ "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "github__bellex-dev__turf-common:bellex-dev/turf-common.git"
24
+ },
25
+ "keywords": [],
26
+ "author": "",
27
+ "license": "ISC",
28
+ "devDependencies": {
29
+ "@types/jest": "^29.5.11",
30
+ "@types/node": "^20.8.9",
31
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
32
+ "@typescript-eslint/parser": "^6.7.2",
33
+ "del-cli": "^5.1.0",
34
+ "eslint": "^8.50.0",
35
+ "jest": "^29.7.0",
36
+ "ts-jest": "^29.1.1",
37
+ "ts-node": "^10.9.2",
38
+ "typescript": "^5.2.2"
39
+ },
40
+ "dependencies": {
41
+ "date-fns": "^2.30.0"
42
+ }
43
+ }