ia-common 1.0.1-beta.63 → 1.0.1-beta.66

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.
@@ -12,4 +12,6 @@ export declare class PricingPlanModel implements IPricingPlanModel {
12
12
  validateBillingCycleKey(key: string): void;
13
13
  getNoOfSubscriptionDays(type: string): number;
14
14
  getBillCycleByKey(type: string): ISelectedBillingCycle;
15
+ getToDateCode(fromDateCode: number, billingCycleKey: string): number;
16
+ validateGetToDateCode(fromDateCode: number, toDateCode: number, billingCycleKey: string): number;
15
17
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PricingPlanModel = void 0;
4
4
  var _model_1 = require("../@model");
5
+ var _utils_1 = require("../@utils");
5
6
  var PricingPlanModel = /** @class */ (function () {
6
7
  function PricingPlanModel(data) {
7
8
  Object.assign(this, data);
@@ -28,6 +29,26 @@ var PricingPlanModel = /** @class */ (function () {
28
29
  this.validateBillingCycleKey(type);
29
30
  return Object.values(this.billingCycle).filter(function (billingCycleObj) { return billingCycleObj.key === type; })[0];
30
31
  };
32
+ PricingPlanModel.prototype.getToDateCode = function (fromDateCode, billingCycleKey) {
33
+ this.validateBillingCycleKey(billingCycleKey);
34
+ var copyFromDateCode = fromDateCode;
35
+ var newSubscriptionToDate = new Date(_utils_1.dateUtil.convertStringToDate(String(copyFromDateCode)));
36
+ newSubscriptionToDate.setDate(newSubscriptionToDate.getDate() +
37
+ this.getNoOfSubscriptionDays(billingCycleKey));
38
+ return Number(_utils_1.dateUtil.getDateCode(newSubscriptionToDate));
39
+ };
40
+ PricingPlanModel.prototype.validateGetToDateCode = function (fromDateCode, toDateCode, billingCycleKey) {
41
+ var calculatedToDateCode = this.getToDateCode(fromDateCode, billingCycleKey);
42
+ if (calculatedToDateCode != Number(toDateCode)) {
43
+ throw new _model_1.AppBadRequestException({
44
+ key: "to",
45
+ message: [
46
+ "calculated to Date:'".concat(calculatedToDateCode, "' is not matches with to date you entered"),
47
+ ],
48
+ });
49
+ }
50
+ return calculatedToDateCode;
51
+ };
31
52
  return PricingPlanModel;
32
53
  }());
33
54
  exports.PricingPlanModel = PricingPlanModel;
@@ -17,4 +17,10 @@ export declare class SubscribedPricingPlanModel {
17
17
  roundDown: boolean;
18
18
  }): number;
19
19
  getBillingDiscount(): number;
20
+ validateGrossAmount(grossAmount: number, config?: {
21
+ roundDown: boolean;
22
+ }): number;
23
+ validateNetAmount(netAmount: number, config?: {
24
+ roundDown: boolean;
25
+ }): number;
20
26
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SubscribedPricingPlanModel = void 0;
4
+ var _model_1 = require("../@model");
4
5
  var _utils_1 = require("../@utils");
5
6
  var SubscribedPricingPlanModel = /** @class */ (function () {
6
7
  function SubscribedPricingPlanModel(data, billingCycleKey) {
@@ -40,6 +41,30 @@ var SubscribedPricingPlanModel = /** @class */ (function () {
40
41
  }
41
42
  return 0;
42
43
  };
44
+ SubscribedPricingPlanModel.prototype.validateGrossAmount = function (grossAmount, config) {
45
+ var calculatedGrossAmount = this.getGrossAmount(config);
46
+ if (Math.abs(calculatedGrossAmount - grossAmount) > 1) {
47
+ throw new _model_1.AppBadRequestException({
48
+ key: "grossAmount",
49
+ message: [
50
+ "calculated gross amount:'".concat(calculatedGrossAmount, "' is not matches with grossAmount you entered"),
51
+ ],
52
+ });
53
+ }
54
+ return calculatedGrossAmount;
55
+ };
56
+ SubscribedPricingPlanModel.prototype.validateNetAmount = function (netAmount, config) {
57
+ var calculatedNetAmount = this.getNetAmount(config);
58
+ if (calculatedNetAmount !== netAmount) {
59
+ throw new _model_1.AppBadRequestException({
60
+ key: "netAmount",
61
+ message: [
62
+ "calculated net amount:'".concat(calculatedNetAmount, "' is not matches with netAmount ").concat(netAmount, " you entered"),
63
+ ],
64
+ });
65
+ }
66
+ return calculatedNetAmount;
67
+ };
43
68
  return SubscribedPricingPlanModel;
44
69
  }());
45
70
  exports.SubscribedPricingPlanModel = SubscribedPricingPlanModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ia-common",
3
- "version": "1.0.1-beta.63",
3
+ "version": "1.0.1-beta.66",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",