@zauru-sdk/common 6.2.4 → 6.3.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.3.0](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/common@6.2.5...@zauru-sdk/common@6.3.0) (2026-09-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * store purchase order rejection percentage in memo ([65d77c1](https://github.com/intuitiva/zauru-typescript-sdk/commit/65d77c156ebd17cf599767ccc6cc9653170165f9))
12
+
13
+
14
+
15
+
16
+
17
+ ## [6.2.5](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/common@6.2.4...@zauru-sdk/common@6.2.5) (2026-08-31)
18
+
19
+ **Note:** Version bump only for package @zauru-sdk/common
20
+
21
+
22
+
23
+
24
+
6
25
  ## [6.2.4](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/common@6.2.3...@zauru-sdk/common@6.2.4) (2026-07-27)
7
26
 
8
27
  **Note:** Version bump only for package @zauru-sdk/common
package/dist/common.d.ts CHANGED
@@ -2,6 +2,12 @@ import "moment-timezone";
2
2
  import type { PayeeGraphQL, AxiosUtilsResponse, BasketSchema, SelectFieldOption, JsonMemoType } from "@zauru-sdk/types";
3
3
  export declare const DESTINOS_MUESTRA_OPTIONS: SelectFieldOption[];
4
4
  export declare const parseJsonMemo: (memo?: string) => JsonMemoType;
5
+ export declare const stringifyJsonMemo: (memo: JsonMemoType) => string;
6
+ export declare const mergeJsonMemo: (memo: string | undefined, patch: Partial<JsonMemoType>) => string;
7
+ export declare const getRejectionPercentage: (source: string | {
8
+ memo?: string;
9
+ } | JsonMemoType | undefined) => number;
10
+ export declare const setRejectionPercentage: (memo: string | undefined, percentage: number) => string;
5
11
  /**
6
12
  * Obtener el objeto de canastas en base al memo
7
13
  * @param memo
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parsedObject = exports.sortByProperty = exports.labFormPatter = exports.labServicePattern = exports.getRandomNum = exports.CURRENCY_PREFIX = exports.truncateDecimals = exports.ZAURU_REGEX = exports.priceToText = exports.arrayToObject = exports.isNumeric = exports.toFixedIfNeeded = exports.formatTimeToTimePicker = exports.formatDateToDatePicker = exports.getFormattedDate = exports.parsedBaculoFormValue = exports.getPayeeInfoOptions = exports.getPayeeInfoIdOptions = exports.getPayeeFormated = exports.getDateAfterDays = exports.getTimePickerCurrentTime = exports.obtenerFechaActualConZonaHoraria = exports.getDatePickerCurrentDate = exports.stringDateToParsedUTCDate = exports.localDateToUSDate = exports.getStringFullDate = exports.getTodayMinutesDifference = exports.getTodayDaysDifference = exports.getStringDate = exports.getZauruDateByText = exports.getNewDateByFormat = exports.getFechaJuliana = exports.getBasketsSchema = exports.parseJsonMemo = exports.DESTINOS_MUESTRA_OPTIONS = void 0;
6
+ exports.parsedObject = exports.sortByProperty = exports.labFormPatter = exports.labServicePattern = exports.getRandomNum = exports.CURRENCY_PREFIX = exports.truncateDecimals = exports.ZAURU_REGEX = exports.priceToText = exports.arrayToObject = exports.isNumeric = exports.toFixedIfNeeded = exports.formatTimeToTimePicker = exports.formatDateToDatePicker = exports.getFormattedDate = exports.parsedBaculoFormValue = exports.getPayeeInfoOptions = exports.getPayeeInfoIdOptions = exports.getPayeeFormated = exports.getDateAfterDays = exports.getTimePickerCurrentTime = exports.obtenerFechaActualConZonaHoraria = exports.getDatePickerCurrentDate = exports.stringDateToParsedUTCDate = exports.localDateToUSDate = exports.getStringFullDate = exports.getTodayMinutesDifference = exports.getTodayDaysDifference = exports.getStringDate = exports.getZauruDateByText = exports.getNewDateByFormat = exports.getFechaJuliana = exports.getBasketsSchema = exports.setRejectionPercentage = exports.getRejectionPercentage = exports.mergeJsonMemo = exports.stringifyJsonMemo = exports.parseJsonMemo = exports.DESTINOS_MUESTRA_OPTIONS = void 0;
7
7
  exports.generateClientUUID = generateClientUUID;
8
8
  exports.extractValueBetweenTags = extractValueBetweenTags;
9
9
  exports.isJsonArray = isJsonArray;
@@ -44,6 +44,29 @@ const parseJsonMemo = (memo) => {
44
44
  }
45
45
  };
46
46
  exports.parseJsonMemo = parseJsonMemo;
47
+ const stringifyJsonMemo = (memo) => JSON.stringify(memo);
48
+ exports.stringifyJsonMemo = stringifyJsonMemo;
49
+ const mergeJsonMemo = (memo, patch) => (0, exports.stringifyJsonMemo)({ ...(0, exports.parseJsonMemo)(memo), ...patch });
50
+ exports.mergeJsonMemo = mergeJsonMemo;
51
+ const getRejectionPercentage = (source) => {
52
+ if (source == null || source === "")
53
+ return 0;
54
+ let parsed;
55
+ if (typeof source === "string") {
56
+ parsed = (0, exports.parseJsonMemo)(source);
57
+ }
58
+ else if (typeof source.memo === "string") {
59
+ parsed = (0, exports.parseJsonMemo)(source.memo);
60
+ }
61
+ else {
62
+ parsed = source;
63
+ }
64
+ const value = Number(parsed.rejectionPercentage);
65
+ return Number.isFinite(value) ? value : 0;
66
+ };
67
+ exports.getRejectionPercentage = getRejectionPercentage;
68
+ const setRejectionPercentage = (memo, percentage) => (0, exports.mergeJsonMemo)(memo, { rejectionPercentage: percentage });
69
+ exports.setRejectionPercentage = setRejectionPercentage;
47
70
  /**
48
71
  * Obtener el objeto de canastas en base al memo
49
72
  * @param memo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/common",
3
- "version": "6.2.4",
3
+ "version": "6.3.0",
4
4
  "description": "Funciones de uso común en el desarrollo de webapps en Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -21,9 +21,9 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@remix-run/node": "^2.8.1",
24
- "@zauru-sdk/types": "^6.7.0",
24
+ "@zauru-sdk/types": "^6.9.0",
25
25
  "moment": "^2.30.1",
26
26
  "moment-timezone": "^0.5.45"
27
27
  },
28
- "gitHead": "2950c31a115494a2beefde49d411be7983d57982"
28
+ "gitHead": "2cc49202c68f74f1ef031322b108b1461b9c9ad7"
29
29
  }
package/src/common.ts CHANGED
@@ -30,6 +30,37 @@ export const parseJsonMemo = (memo?: string): JsonMemoType => {
30
30
  }
31
31
  };
32
32
 
33
+ export const stringifyJsonMemo = (memo: JsonMemoType): string =>
34
+ JSON.stringify(memo);
35
+
36
+ export const mergeJsonMemo = (
37
+ memo: string | undefined,
38
+ patch: Partial<JsonMemoType>,
39
+ ): string => stringifyJsonMemo({ ...parseJsonMemo(memo), ...patch });
40
+
41
+ export const getRejectionPercentage = (
42
+ source: string | { memo?: string } | JsonMemoType | undefined,
43
+ ): number => {
44
+ if (source == null || source === "") return 0;
45
+
46
+ let parsed: JsonMemoType;
47
+ if (typeof source === "string") {
48
+ parsed = parseJsonMemo(source);
49
+ } else if (typeof (source as { memo?: unknown }).memo === "string") {
50
+ parsed = parseJsonMemo((source as { memo: string }).memo);
51
+ } else {
52
+ parsed = source as JsonMemoType;
53
+ }
54
+
55
+ const value = Number(parsed.rejectionPercentage);
56
+ return Number.isFinite(value) ? value : 0;
57
+ };
58
+
59
+ export const setRejectionPercentage = (
60
+ memo: string | undefined,
61
+ percentage: number,
62
+ ): string => mergeJsonMemo(memo, { rejectionPercentage: percentage });
63
+
33
64
  /**
34
65
  * Obtener el objeto de canastas en base al memo
35
66
  * @param memo