kcommons 8.1.0 → 8.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -60,6 +60,7 @@ export * from "./utils/permission.utils";
60
60
  export * from "./utils/taxes.util";
61
61
  export * from "./utils/parseQueryParams.util";
62
62
  export * from "./utils/getContactPerson.util";
63
+ export * from "./utils/quote.util";
63
64
  export * from "./templates/notifications/rfq.notifications";
64
65
  export * from "./templates/notifications/po.notifications";
65
66
  export * from "./templates/notifications/quote.notifications";
package/build/index.js CHANGED
@@ -80,6 +80,7 @@ __exportStar(require("./utils/permission.utils"), exports);
80
80
  __exportStar(require("./utils/taxes.util"), exports);
81
81
  __exportStar(require("./utils/parseQueryParams.util"), exports);
82
82
  __exportStar(require("./utils/getContactPerson.util"), exports);
83
+ __exportStar(require("./utils/quote.util"), exports);
83
84
  // Templates
84
85
  __exportStar(require("./templates/notifications/rfq.notifications"), exports);
85
86
  __exportStar(require("./templates/notifications/po.notifications"), exports);
@@ -0,0 +1,2 @@
1
+ import { IQuoteItems } from "../typings/quote.typings";
2
+ export declare function getInitialDiscountedPerUnitRate(quoteItem: IQuoteItems): null | number;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInitialDiscountedPerUnitRate = getInitialDiscountedPerUnitRate;
4
+ const taxes_util_1 = require("./taxes.util");
5
+ function getInitialDiscountedPerUnitRate(quoteItem) {
6
+ if (quoteItem.per_unit_rate === quoteItem.initial_per_unit_rate &&
7
+ quoteItem.initial_discount_type === quoteItem.discount_type &&
8
+ quoteItem.initial_discount_value === quoteItem.discount_value)
9
+ return null;
10
+ return (0, taxes_util_1.getDiscountedPerUnitRate)(Object.assign(Object.assign({}, quoteItem), { per_unit_rate: quoteItem.initial_per_unit_rate, discount_type: quoteItem.initial_discount_type, discount_value: quoteItem.initial_discount_value }));
11
+ }
@@ -1,2 +1,2 @@
1
1
  import { ITaxRelatedItemInputs } from "../typings/docItems.typings";
2
- export declare function getDiscountedPerUnitRate(item: ITaxRelatedItemInputs): number | null | undefined;
2
+ export declare function getDiscountedPerUnitRate(item: ITaxRelatedItemInputs): number | null;
@@ -3,17 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDiscountedPerUnitRate = getDiscountedPerUnitRate;
4
4
  const documentTaxes_typings_1 = require("../typings/documentTaxes.typings");
5
5
  function getDiscountedPerUnitRate(item) {
6
- if (!item.per_unit_rate)
7
- return item.per_unit_rate;
6
+ if (isNaN(Number(item.per_unit_rate)) ||
7
+ item.per_unit_rate === null ||
8
+ item.per_unit_rate === undefined)
9
+ return null;
8
10
  if (item.discount_value && item.discount_type) {
9
11
  if (item.discount_type === documentTaxes_typings_1.TAX_TYPE.FIXED) {
10
- return item.per_unit_rate - item.discount_value;
12
+ const res = item.per_unit_rate - item.discount_value;
13
+ if (isNaN(Number(res)))
14
+ return null;
15
+ return res;
11
16
  }
12
17
  else if (item.discount_type === documentTaxes_typings_1.TAX_TYPE.PERCENTAGE) {
13
- return item.per_unit_rate * (1 - item.discount_value / 100);
18
+ const res = item.per_unit_rate * (1 - item.discount_value / 100);
19
+ if (isNaN(Number(res)))
20
+ return null;
21
+ return res;
14
22
  }
15
23
  }
16
24
  else {
17
25
  return item.per_unit_rate;
18
26
  }
27
+ return null;
19
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kcommons",
3
- "version": "8.1.0",
3
+ "version": "8.1.2",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.js",