turf-common 1.1.1-beta.52 → 1.1.1-beta.54

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
@@ -72,3 +72,4 @@ export * from "./get-configuration.interface";
72
72
  export * from "./get-cancelled-booking.interface";
73
73
  export * from "./get-sports.interface";
74
74
  export * from "../entity/sports-entity.interface";
75
+ export * from "../api/update-sports-interface";
@@ -90,3 +90,4 @@ __exportStar(require("./get-configuration.interface"), exports);
90
90
  __exportStar(require("./get-cancelled-booking.interface"), exports);
91
91
  __exportStar(require("./get-sports.interface"), exports);
92
92
  __exportStar(require("../entity/sports-entity.interface"), exports);
93
+ __exportStar(require("../api/update-sports-interface"), exports);
@@ -0,0 +1,3 @@
1
+ export interface UpdateSportsRequest {
2
+ sports: string[];
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -32,4 +32,6 @@ export declare class SubscribedPricingPlanModel extends PricingPlanModel {
32
32
  getNextBillingCycleDateRange(date: Date): [Date, Date];
33
33
  static getInstanceBySubscriptionData(data: IGetPricingPlanByDateResponse, subscriptionDataModel: SubscriptionModel): SubscribedPricingPlanModel;
34
34
  getSelectedPitchSlabBasePrice(): number;
35
+ getBasePriceBySelectedBillingCycleDiscount(): number;
36
+ getTotalHours(): number;
35
37
  }
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.SubscribedPricingPlanModel = void 0;
19
19
  var date_util_1 = require("../utils/date-util");
20
+ var math_util_1 = require("../utils/math-util");
20
21
  var pricing_plan_model_1 = require("./pricing-plan-model");
21
22
  var SubscribedPricingPlanModel = /** @class */ (function (_super) {
22
23
  __extends(SubscribedPricingPlanModel, _super);
@@ -42,14 +43,12 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
42
43
  if (!roundDown) {
43
44
  return Math.round(this.selectedPitchSlabBasePrice *
44
45
  this.pitchCount *
45
- this.hourInMonth *
46
- this.selectedBillingCycle.to);
46
+ this.getTotalHours());
47
47
  }
48
48
  else {
49
49
  return Math.floor(this.selectedPitchSlabBasePrice *
50
50
  this.pitchCount *
51
- this.hourInMonth *
52
- this.selectedBillingCycle.to);
51
+ this.getTotalHours());
53
52
  }
54
53
  };
55
54
  SubscribedPricingPlanModel.prototype.getNetAmount = function (config) {
@@ -59,15 +58,13 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
59
58
  return Math.round(this.selectedPitchSlabBasePrice *
60
59
  (1 - this.getBillingDiscount() / 100) *
61
60
  this.pitchCount *
62
- this.hourInMonth *
63
- this.selectedBillingCycle.to);
61
+ this.getTotalHours());
64
62
  }
65
63
  else {
66
64
  return Math.floor(this.selectedPitchSlabBasePrice *
67
65
  (1 - this.getBillingDiscount() / 100) *
68
66
  this.pitchCount *
69
- this.hourInMonth *
70
- this.selectedBillingCycle.to);
67
+ this.getTotalHours());
71
68
  }
72
69
  };
73
70
  SubscribedPricingPlanModel.prototype.getBillingDiscount = function () {
@@ -117,6 +114,13 @@ var SubscribedPricingPlanModel = /** @class */ (function (_super) {
117
114
  SubscribedPricingPlanModel.prototype.getSelectedPitchSlabBasePrice = function () {
118
115
  return this.selectedPitchSlabBasePrice;
119
116
  };
117
+ SubscribedPricingPlanModel.prototype.getBasePriceBySelectedBillingCycleDiscount = function () {
118
+ return (this.selectedPitchSlabBasePrice -
119
+ math_util_1.mathUtil.getDiscountAmount(this.selectedBillingCycle.discount, this.selectedPitchSlabBasePrice));
120
+ };
121
+ SubscribedPricingPlanModel.prototype.getTotalHours = function () {
122
+ return this.hourInMonth * this.selectedBillingCycle.to;
123
+ };
120
124
  return SubscribedPricingPlanModel;
121
125
  }(pricing_plan_model_1.PricingPlanModel));
122
126
  exports.SubscribedPricingPlanModel = SubscribedPricingPlanModel;
@@ -0,0 +1,14 @@
1
+ declare class MathUtil {
2
+ /**
3
+ * Calculates the discount amount based on the provided coupon code and total cost.
4
+ *
5
+ * @param {string} couponCode - The coupon code used for the discount. If the code ends with "P", it's treated as a percentage discount. If it ends with "U", it's treated as a unit discount.
6
+ * @param {number} totalCost - The total cost before any discounts are applied.
7
+ * @param {boolean} [validationApply=false] - Decides whether to validate if the percentage discount is more than 90 or not.
8
+ * @returns {number} The calculated discount amount. If the couponCode ends with "P", the discount amount is the percentage of the totalCost. If the couponCode ends with "U", the discount amount is the parsed float value of the couponCode. If no couponCode is provided, the method returns 0. If the validationApply is true and the percentage discount is more than 90, it throws an AppBadRequestException with a message "Discount should not be more than 90P".
9
+ * @throws {AppBadRequestException} If validationApply is true and the percentage discount is more than 90.
10
+ */
11
+ getDiscountAmount(couponCode: string, totalCost: number, validationApply?: boolean): number;
12
+ }
13
+ export declare const mathUtil: MathUtil;
14
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mathUtil = void 0;
4
+ var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
5
+ var MathUtil = /** @class */ (function () {
6
+ function MathUtil() {
7
+ }
8
+ /**
9
+ * Calculates the discount amount based on the provided coupon code and total cost.
10
+ *
11
+ * @param {string} couponCode - The coupon code used for the discount. If the code ends with "P", it's treated as a percentage discount. If it ends with "U", it's treated as a unit discount.
12
+ * @param {number} totalCost - The total cost before any discounts are applied.
13
+ * @param {boolean} [validationApply=false] - Decides whether to validate if the percentage discount is more than 90 or not.
14
+ * @returns {number} The calculated discount amount. If the couponCode ends with "P", the discount amount is the percentage of the totalCost. If the couponCode ends with "U", the discount amount is the parsed float value of the couponCode. If no couponCode is provided, the method returns 0. If the validationApply is true and the percentage discount is more than 90, it throws an AppBadRequestException with a message "Discount should not be more than 90P".
15
+ * @throws {AppBadRequestException} If validationApply is true and the percentage discount is more than 90.
16
+ */
17
+ MathUtil.prototype.getDiscountAmount = function (couponCode, totalCost, validationApply) {
18
+ if (validationApply === void 0) { validationApply = false; }
19
+ var discountAmount = 0;
20
+ if (couponCode) {
21
+ if (couponCode.slice(-1) === "P") {
22
+ var percentDiscount = parseFloat(couponCode);
23
+ if (validationApply && percentDiscount > 90) {
24
+ throw new app_badrequest_exception_1.AppBadRequestException({
25
+ key: "couponCode",
26
+ message: ["Discount should not be more than 90P"],
27
+ });
28
+ }
29
+ discountAmount = totalCost * (percentDiscount / 100);
30
+ }
31
+ else if (couponCode.slice(-1) === "U") {
32
+ discountAmount = parseFloat(couponCode);
33
+ }
34
+ }
35
+ return discountAmount;
36
+ };
37
+ return MathUtil;
38
+ }());
39
+ exports.mathUtil = new MathUtil();
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
- {
2
- "name": "turf-common",
3
- "version": "1.1.1-beta.52",
4
- "description": "",
5
- "main": "./build/index.js",
6
- "types": "./build/index.d.ts",
7
- "files": [
8
- "build/**/*"
9
- ],
10
- "scripts": {
11
- "clean": "del build",
12
- "build": "npm run clean && tsc",
13
- "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
14
- "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
15
- "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
16
- "test": "echo \"Error: no test specified\" && exit 1",
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/node": "^20.8.9",
29
- "@typescript-eslint/eslint-plugin": "^6.7.2",
30
- "@typescript-eslint/parser": "^6.7.2",
31
- "del-cli": "^5.1.0",
32
- "eslint": "^8.50.0",
33
- "typescript": "^5.2.2"
34
- },
35
- "dependencies": {
36
- "date-fns": "^2.30.0"
37
- }
38
- }
1
+ {
2
+ "name": "turf-common",
3
+ "version": "1.1.1-beta.54",
4
+ "description": "",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "files": [
8
+ "build/**/*"
9
+ ],
10
+ "scripts": {
11
+ "clean": "del build",
12
+ "build": "npm run clean && tsc",
13
+ "version:deploy:patch": "npm version patch && git push && npm run build && npm publish",
14
+ "version:deploy:minor": "npm version minor && git push && npm run build && npm publish",
15
+ "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
16
+ "test": "echo \"Error: no test specified\" && exit 1",
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/node": "^20.8.9",
29
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
30
+ "@typescript-eslint/parser": "^6.7.2",
31
+ "del-cli": "^5.1.0",
32
+ "eslint": "^8.50.0",
33
+ "typescript": "^5.2.2"
34
+ },
35
+ "dependencies": {
36
+ "date-fns": "^2.30.0"
37
+ }
38
+ }