turf-common 1.4.1-beta.9 → 1.4.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.
@@ -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
  };
@@ -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
  };
@@ -186,8 +200,11 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
186
200
  var codes = this.billing_cost_code.split(",");
187
201
  var code = codes.filter(function (code) {
188
202
  var _a = code.split("_"), from = _a[0], to = _a[1];
203
+ to = to.split("#")[0];
204
+ // console.log(from, to)
189
205
  return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
190
206
  });
207
+ // console.log(code)
191
208
  code.sort();
192
209
  if (code) {
193
210
  var _a = code[0].split("#"), from = _a[0], to = _a[1], price = _a[2];
@@ -223,12 +240,15 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
223
240
  };
224
241
  });
225
242
  };
243
+ // Tested
226
244
  SubscribedPricingPlanModelV2.prototype.getMonths = function () {
227
245
  return this.selectedBillingCycle.to;
228
246
  };
247
+ // Tested
229
248
  SubscribedPricingPlanModelV2.prototype.getBasePrice = function () {
230
249
  return this.selectedPitchSlabBasePrice;
231
250
  };
251
+ // Tested
232
252
  SubscribedPricingPlanModelV2.prototype.getGrossAmount = function (config) {
233
253
  if (config === void 0) { config = { roundDown: false }; }
234
254
  var roundDown = config.roundDown;
@@ -239,39 +259,54 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
239
259
  return Math.round(this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours());
240
260
  }
241
261
  };
262
+ // Tested
242
263
  SubscribedPricingPlanModelV2.prototype.getNetAmount = function (config) {
264
+ var _this = this;
243
265
  if (config === void 0) { config = { roundDown: false }; }
244
266
  var roundDown = config.roundDown;
267
+ var codesByBillingCycle = this.getCodeByCycle();
268
+ var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
269
+ var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
270
+ return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
271
+ })[0];
272
+ var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
245
273
  if (roundDown) {
246
- return Math.floor(parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
274
+ return Math.floor(this.base_price *
275
+ basePriceByPitchCycle *
247
276
  this.pitchCount *
248
277
  this.getTotalHours());
249
278
  }
250
279
  else {
251
- return Math.round(parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
280
+ return Math.round(this.base_price *
281
+ basePriceByPitchCycle *
252
282
  this.pitchCount *
253
283
  this.getTotalHours());
254
284
  }
255
285
  };
286
+ // Tested
256
287
  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();
288
+ var _this = this;
289
+ // const codesByPitchCount = this.getCodesByPitchSlab();
290
+ var basePriceByPitchSlab = this.getBasePriceByPitchSlab();
291
+ var codesByBillingCycle = this.getCodeByCycle();
292
+ var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
293
+ var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
294
+ return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
295
+ })[0];
296
+ var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
297
+ return parseFloat(((basePriceByPitchSlab - basePriceByPitchCycle) / basePriceByPitchSlab * 100).toFixed(2));
265
298
  };
266
299
  SubscribedPricingPlanModelV2.prototype.getMonthDifference = function (that) {
267
300
  return that.getMonths() - this.getMonths();
268
301
  };
302
+ // Tested
269
303
  SubscribedPricingPlanModelV2.prototype.getGrossAmountByMonth = function (month) {
270
304
  return Math.round(this.selectedPitchSlabBasePrice *
271
305
  this.pitchCount *
272
306
  this.hourInMonth *
273
307
  month);
274
308
  };
309
+ // Tested
275
310
  SubscribedPricingPlanModelV2.prototype.getNetAmountByMonth = function (month) {
276
311
  return Math.round(this.selectedPitchSlabBasePrice *
277
312
  (1 - this.getBillingDiscount() / 100) *
@@ -279,9 +314,11 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
279
314
  this.hourInMonth *
280
315
  month);
281
316
  };
317
+ // Tested
282
318
  SubscribedPricingPlanModelV2.prototype.getGrossAmountByPitchDays = function (pitchCount, days) {
283
319
  return Math.round(this.selectedPitchSlabBasePrice * pitchCount * days * 24);
284
320
  };
321
+ // Tested
285
322
  SubscribedPricingPlanModelV2.prototype.getNetAmountByPitchDays = function (pitchCount, days) {
286
323
  return Math.round(this.selectedPitchSlabBasePrice *
287
324
  (1 - this.getBillingDiscount() / 100) *
@@ -289,12 +326,15 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
289
326
  days *
290
327
  24);
291
328
  };
329
+ // Not Tested
292
330
  SubscribedPricingPlanModelV2.prototype.getGrossAmountByPitchDaysBasePrice = function (basePrice, pitchCount, days) {
293
331
  return Math.round(basePrice * pitchCount * days * 24);
294
332
  };
333
+ // Not Tested
295
334
  SubscribedPricingPlanModelV2.prototype.getNetAmountByPitchDaysBasePrice = function (basePrice, pitchCount, days) {
296
335
  return Math.round(basePrice * (1 - this.getBillingDiscount() / 100) * pitchCount * days * 24);
297
336
  };
337
+ // Not Tested
298
338
  SubscribedPricingPlanModelV2.prototype.getNextBillingCycleDateRange = function (date) {
299
339
  // const dateService = new DateUtilService();
300
340
  var startDate = date_util_1.dateUtilService.addNDaysToDate(date, 1);
@@ -304,22 +344,260 @@ var SubscribedPricingPlanModelV2 = /** @class */ (function (_super) {
304
344
  SubscribedPricingPlanModelV2.getInstanceBySubscriptionData = function (data, subscriptionDataModel) {
305
345
  return new SubscribedPricingPlanModelV2(data, subscriptionDataModel.noOfPitches, subscriptionDataModel.type);
306
346
  };
347
+ // Tested
307
348
  SubscribedPricingPlanModelV2.prototype.getSelectedPitchSlabBasePrice = function () {
308
349
  return this.selectedPitchSlabBasePrice;
309
350
  };
351
+ // Tested
310
352
  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
- // );
353
+ var _this = this;
354
+ var codesByBillingCycle = this.getCodeByCycle();
355
+ var codeByPitchCycle = codesByBillingCycle.filter(function (code) {
356
+ var _a = code.split("#")[0].split("_"), from = _a[0], to = _a[1];
357
+ return _this.pitchCount >= parseInt(from) && _this.pitchCount <= parseInt(to);
358
+ })[0];
359
+ var basePriceByPitchCycle = parseFloat(codeByPitchCycle.split("#")[2]);
360
+ return parseFloat(basePriceByPitchCycle.toFixed(2));
319
361
  };
362
+ // Tested
320
363
  SubscribedPricingPlanModelV2.prototype.getTotalHours = function () {
321
364
  return this.hourInMonth * this.selectedBillingCycle.to;
322
365
  };
323
366
  return SubscribedPricingPlanModelV2;
324
367
  }(pricing_plan_model_1.PricingPlanModelV2));
325
368
  exports.SubscribedPricingPlanModelV2 = SubscribedPricingPlanModelV2;
369
+ // export class SubscribedPricingPlanModelV2 extends PricingPlanModelV2 {
370
+ // pitchCount: number;
371
+ // billingCycle: string;
372
+ // selectedPitchSlab: PitchSlabModelV2;
373
+ // selectedBillingCycle: BillingCycleModelV2;
374
+ // selectedPitchSlabBasePrice: number;
375
+ // hourInMonth: number = 24 * 30;
376
+ // months: number | undefined;
377
+ // constructor(
378
+ // data: IPricingPlanModelV2,
379
+ // pitchCount: number,
380
+ // billingCycle: string
381
+ // ) {
382
+ // super(data);
383
+ // this.pitchCount = pitchCount;
384
+ // this.billingCycle = billingCycle;
385
+ // this.selectedPitchSlab = this.getPitchSlab(this.pitchCount);
386
+ // this.selectedBillingCycle = this.getBillingCycle(this.billingCycle);
387
+ // // this.selectedPitchSlabBasePrice = this.selectedPitchSlab.getBasePrice(
388
+ // // this.base_price
389
+ // // );
390
+ // this.selectedPitchSlabBasePrice = this.getBasePriceByPitchSlab();
391
+ // }
392
+ // getCodeByPitchCountCycle(): string {
393
+ // let codes = this.billing_cost_code.split(",");
394
+ // // Filter by pitch count
395
+ // codes = codes.filter((code) => {
396
+ // const [from, to] = code.split("_");
397
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
398
+ // });
399
+ // codes.sort();
400
+ // // Filter by billing cycle
401
+ // codes = codes.filter((code) => {
402
+ // return this.selectedBillingCycle.key === this.billingCycle;
403
+ // });
404
+ // return codes ? codes[0] : "";
405
+ // }
406
+ // getCodeByCycle(): string[] {
407
+ // let codes = this.billing_cost_code.split(",");
408
+ // // Filter by pitch count
409
+ // // codes = codes.filter((code) => {
410
+ // // const [from, to] = code.split("_");
411
+ // // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
412
+ // // });
413
+ // // codes.sort();
414
+ // // Filter by billing cycle
415
+ // return codes.filter((code) => {
416
+ // return this.selectedBillingCycle.to === parseInt(code.split("#")[1]);
417
+ // });
418
+ // // return codes ? codes[0] : "";
419
+ // }
420
+ // getDiscount(){
421
+ // let codes = this.billing_cost_code.split(",");
422
+ // // Filter by pitch count
423
+ // codes = codes.filter((code) => {
424
+ // const [from, to] = code.split("_");
425
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
426
+ // });
427
+ // codes.sort();
428
+ // // Filter by billing cycle
429
+ // codes = codes.filter((code) => {
430
+ // return this.selectedBillingCycle.to === Number(code.split("#")[1]);
431
+ // });
432
+ // return codes ? codes[0].split("#")[3] : "";
433
+ // }
434
+ // getBasePriceByPitchSlab() {
435
+ // const codes = this.billing_cost_code.split(",");
436
+ // const code = codes.filter((code) => {
437
+ // const [from, to] = code.split("_");
438
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
439
+ // });
440
+ // code.sort();
441
+ // if (code) {
442
+ // const [from, to, price] = code[0].split("#");
443
+ // return parseFloat(price);
444
+ // }
445
+ // return 0;
446
+ // }
447
+ // getCodesByPitchSlab(): string[] {
448
+ // const codes = this.billing_cost_code.split(",");
449
+ // return codes.filter((code) => {
450
+ // const [from, to] = code.split("_");
451
+ // return this.pitchCount >= parseInt(from) && this.pitchCount <= parseInt(to);
452
+ // });
453
+ // // code.sort();
454
+ // // if (code) {
455
+ // // const [from, to, price] = code[0].split("#");
456
+ // // return parseFloat(price);
457
+ // // }
458
+ // // return 0;
459
+ // }
460
+ // parseCode(code:string) {
461
+ // // 1_5#1#100,1_5#6#98,6_10#1#97,6_10#6#90
462
+ // const codes = code.split(",");
463
+ // return codes.map((code) => {
464
+ // const [pitch, month, price] = code.split("#");
465
+ // const [from, to] = pitch.split("_");
466
+ // return {
467
+ // from: parseInt(from),
468
+ // to: parseInt(to),
469
+ // month: parseInt(month),
470
+ // price: parseFloat(price),
471
+ // };
472
+ // });
473
+ // }
474
+ // getMonths(): number {
475
+ // return this.selectedBillingCycle.to;
476
+ // }
477
+ // getBasePrice(): number {
478
+ // return this.selectedPitchSlabBasePrice;
479
+ // }
480
+ // getGrossAmount(
481
+ // config: { roundDown: boolean } = { roundDown: false }
482
+ // ): number {
483
+ // const { roundDown } = config;
484
+ // if (roundDown) {
485
+ // return Math.floor(
486
+ // this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours()
487
+ // );
488
+ // } else {
489
+ // return Math.round(
490
+ // this.selectedPitchSlabBasePrice * this.pitchCount * this.getTotalHours()
491
+ // );
492
+ // }
493
+ // }
494
+ // getNetAmount(config: { roundDown: boolean } = { roundDown: false }): number {
495
+ // const { roundDown } = config;
496
+ // if (roundDown) {
497
+ // return Math.floor(
498
+ // parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
499
+ // this.pitchCount *
500
+ // this.getTotalHours()
501
+ // );
502
+ // } else {
503
+ // return Math.round(
504
+ // parseFloat(this.getCodeByPitchCountCycle().split("#")[2]) *
505
+ // this.pitchCount *
506
+ // this.getTotalHours()
507
+ // );
508
+ // }
509
+ // }
510
+ // getBillingDiscount(): number {
511
+ // const selectedCode = this.getCodeByPitchCountCycle()
512
+ // const selectedCodesByCycle = this.getCodeByCycle();
513
+ // selectedCodesByCycle.sort();
514
+ // const basePrice = parseFloat(selectedCodesByCycle[0].split("#")[2]);
515
+ // const actualPrice = parseFloat(selectedCode.split("#")[2]);
516
+ // return (basePrice - actualPrice) / basePrice * 100;
517
+ // // 6_10#1#97,6_10#6#90
518
+ // // return this.selectedBillingCycle.getDiscount();
519
+ // }
520
+ // getMonthDifference(that: SubscribedPricingPlanModelV2): number {
521
+ // return that.getMonths() - this.getMonths();
522
+ // }
523
+ // getGrossAmountByMonth(month: number): number {
524
+ // return Math.round(
525
+ // this.selectedPitchSlabBasePrice *
526
+ // this.pitchCount *
527
+ // this.hourInMonth *
528
+ // month
529
+ // );
530
+ // }
531
+ // getNetAmountByMonth(month: number): number {
532
+ // return Math.round(
533
+ // this.selectedPitchSlabBasePrice *
534
+ // (1 - this.getBillingDiscount() / 100) *
535
+ // this.pitchCount *
536
+ // this.hourInMonth *
537
+ // month
538
+ // );
539
+ // }
540
+ // getGrossAmountByPitchDays(pitchCount: number, days: number): number {
541
+ // return Math.round(this.selectedPitchSlabBasePrice * pitchCount * days * 24);
542
+ // }
543
+ // getNetAmountByPitchDays(pitchCount: number, days: number): number {
544
+ // return Math.round(
545
+ // this.selectedPitchSlabBasePrice *
546
+ // (1 - this.getBillingDiscount() / 100) *
547
+ // pitchCount *
548
+ // days *
549
+ // 24
550
+ // );
551
+ // }
552
+ // getGrossAmountByPitchDaysBasePrice(
553
+ // basePrice: number,
554
+ // pitchCount: number,
555
+ // days: number
556
+ // ): number {
557
+ // return Math.round(basePrice * pitchCount * days * 24);
558
+ // }
559
+ // getNetAmountByPitchDaysBasePrice(
560
+ // basePrice: number,
561
+ // pitchCount: number,
562
+ // days: number
563
+ // ): number {
564
+ // return Math.round(
565
+ // basePrice * (1 - this.getBillingDiscount() / 100) * pitchCount * days * 24
566
+ // );
567
+ // }
568
+ // getNextBillingCycleDateRange(date: Date): [Date, Date] {
569
+ // // const dateService = new DateUtilService();
570
+ // const startDate = dateUtilService.addNDaysToDate(date, 1);
571
+ // const endDate = dateUtilService.addNDaysToDate(
572
+ // date,
573
+ // this.selectedBillingCycle.to * 30
574
+ // );
575
+ // return [startDate, endDate];
576
+ // }
577
+ // static getInstanceBySubscriptionData(
578
+ // data: IGetPricingPlanByDateResponseV2,
579
+ // subscriptionDataModel: SubscriptionModelV2
580
+ // ) {
581
+ // return new SubscribedPricingPlanModelV2(
582
+ // data,
583
+ // subscriptionDataModel.noOfPitches,
584
+ // subscriptionDataModel.type
585
+ // );
586
+ // }
587
+ // getSelectedPitchSlabBasePrice(): number {
588
+ // return this.selectedPitchSlabBasePrice;
589
+ // }
590
+ // getBasePriceBySelectedBillingCycleDiscount(): number {
591
+ // return this.selectedPitchSlabBasePrice;
592
+ // // return (
593
+ // // this.selectedPitchSlabBasePrice -
594
+ // // mathUtil.getDiscountAmount(
595
+ // // this.selectedBillingCycle.discount,
596
+ // // this.selectedPitchSlabBasePrice
597
+ // // )
598
+ // // );
599
+ // }
600
+ // getTotalHours(): number {
601
+ // return this.hourInMonth * this.selectedBillingCycle.to;
602
+ // }
603
+ // }
@@ -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("exceute all methods of pricingPlanEntityModel", 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,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.4.1-beta.9",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",