@zauru-sdk/utils 6.8.0 → 6.9.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.
- package/dist/esm/zauru/bitacora-edicion-masiva.utils.js +1 -1
- package/dist/esm/zauru/discharges-histsory.utils.js +1 -1
- package/dist/esm/zauru/priceAdjustmentRules.utils.js +11 -3
- package/dist/esm/zauru/programaciones.utils.js +1 -1
- package/dist/esm/zauru/weeklyItemPrice.utils.js +3 -2
- package/dist/zauru/priceAdjustmentRules.utils.d.ts +5 -0
- package/package.json +4 -4
|
@@ -26,7 +26,7 @@ export const getBitacorasPOMassive = (headers, session) => {
|
|
|
26
26
|
const { bitacora_ediciones_masivas_web_app_table_id } = await getVariablesByName(headers, session, [
|
|
27
27
|
"bitacora_ediciones_masivas_web_app_table_id",
|
|
28
28
|
]);
|
|
29
|
-
const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id, 1000);
|
|
29
|
+
const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id, { limit: 1000 });
|
|
30
30
|
if (response.error || !response.data) {
|
|
31
31
|
throw new Error(response.userMsg);
|
|
32
32
|
}
|
|
@@ -9,7 +9,7 @@ import { createWebAppTableRegister, getVariablesByName, getWebAppTableRegisters,
|
|
|
9
9
|
export const getDischargeHistories = (headers, session) => {
|
|
10
10
|
return handlePossibleAxiosErrors(async () => {
|
|
11
11
|
const { discharge_history_web_app_table_id } = await getVariablesByName(headers, session, ["discharge_history_web_app_table_id"]);
|
|
12
|
-
const response = await getWebAppTableRegisters(session, discharge_history_web_app_table_id, 1000);
|
|
12
|
+
const response = await getWebAppTableRegisters(session, discharge_history_web_app_table_id, { limit: 1000 });
|
|
13
13
|
if (response.error) {
|
|
14
14
|
throw new Error(`Ocurrió un error al consultar el historial de discharges: ${response.userMsg}`);
|
|
15
15
|
}
|
|
@@ -44,17 +44,25 @@ export const updatePriceAdjustmentRule = (headers, session, id, body) => {
|
|
|
44
44
|
return updateWebAppTableRegister(headers, tableId, Number(id), body);
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
+
export const normalizeComparableValue = (value) => String(value ?? "").replace(/\s+/g, " ").trim();
|
|
48
|
+
export const formatReceptionTypeValue = (type) => [type?.Nombre, type?.Codigo]
|
|
49
|
+
.map((part) => String(part ?? "").trim())
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.join(" ");
|
|
47
52
|
const matchesFilter = (mode, selected, value) => {
|
|
48
53
|
const normalizedMode = mode ?? "all";
|
|
49
54
|
const values = selected ?? [];
|
|
50
55
|
if (normalizedMode === "all") {
|
|
51
56
|
return true;
|
|
52
57
|
}
|
|
53
|
-
if (value === undefined || value === null
|
|
58
|
+
if (value === undefined || value === null) {
|
|
54
59
|
return false;
|
|
55
60
|
}
|
|
56
|
-
const asString =
|
|
57
|
-
|
|
61
|
+
const asString = normalizeComparableValue(value);
|
|
62
|
+
if (!asString) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const included = values.some((item) => normalizeComparableValue(item) === asString);
|
|
58
66
|
if (normalizedMode === "include") {
|
|
59
67
|
return values.length > 0 && included;
|
|
60
68
|
}
|
|
@@ -47,7 +47,7 @@ export const getProgramaciones = (headers, session, options) => {
|
|
|
47
47
|
limit: options?.limit ?? PROGRAMACIONES_FILTERED_DEFAULT_LIMIT,
|
|
48
48
|
}
|
|
49
49
|
: options?.limit != null
|
|
50
|
-
? options.limit
|
|
50
|
+
? { limit: options.limit }
|
|
51
51
|
: undefined;
|
|
52
52
|
const response = await getWebAppTableRegisters(session, programaciones_webapp_table_id, queryOptions);
|
|
53
53
|
if (response.error) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
2
|
import { getPayee, getPayees } from "@zauru-sdk/services";
|
|
3
3
|
import { getCostosBitacora } from "./costos-items.utils.js";
|
|
4
|
-
import { applyPriceAdjustmentRules, filterActivePriceAdjustmentRules, formatPriceAdjustmentDescription, getPriceAdjustmentRules, } from "./priceAdjustmentRules.utils.js";
|
|
4
|
+
import { applyPriceAdjustmentRules, filterActivePriceAdjustmentRules, formatPriceAdjustmentDescription, getPriceAdjustmentRules, normalizeComparableValue, } from "./priceAdjustmentRules.utils.js";
|
|
5
5
|
import { getSpecialItems } from "./specialItem.utils.js";
|
|
6
6
|
export const MASSIVE_VEGETABLE_COST_ACCION = "Costos masivamente";
|
|
7
7
|
const FALLBACK_UNIT_COST = 1;
|
|
@@ -90,7 +90,8 @@ export const filterActiveSpecialItems = (specialItems) => (specialItems ?? [])
|
|
|
90
90
|
.sort((a, b) => a.id - b.id);
|
|
91
91
|
export const matchSpecialItemForWeeklyPrice = (specialItems, params) => filterActiveSpecialItems(specialItems).find((specialItem) => specialItem.data.item === params.itemId &&
|
|
92
92
|
specialItem.data.region === params.region &&
|
|
93
|
-
specialItem.data.tipo ===
|
|
93
|
+
normalizeComparableValue(specialItem.data.tipo) ===
|
|
94
|
+
normalizeComparableValue(params.tipo));
|
|
94
95
|
export const pickLatestMassiveCostBitacora = (rows, date) => {
|
|
95
96
|
const masivas = (rows ?? [])
|
|
96
97
|
.filter((row) => row.data?.accion === MASSIVE_VEGETABLE_COST_ACCION)
|
|
@@ -5,6 +5,11 @@ export declare const filterActivePriceAdjustmentRules: (rules?: WebAppRowGraphQL
|
|
|
5
5
|
export declare const getPriceAdjustmentRules: (headers: any, session: Session) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<PriceAdjustmentRule>[]>>;
|
|
6
6
|
export declare const createPriceAdjustmentRule: (headers: any, session: Session, body: PriceAdjustmentRule) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
7
7
|
export declare const updatePriceAdjustmentRule: (headers: any, session: Session, id: string, body: Partial<PriceAdjustmentRule>) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
8
|
+
export declare const normalizeComparableValue: (value: string | number | undefined | null) => string;
|
|
9
|
+
export declare const formatReceptionTypeValue: (type?: {
|
|
10
|
+
Nombre?: string;
|
|
11
|
+
Codigo?: string;
|
|
12
|
+
} | null) => string;
|
|
8
13
|
export declare const priceAdjustmentRuleMatches: (rule: PriceAdjustmentRule, ctx: PriceAdjustmentContext) => boolean;
|
|
9
14
|
export declare const formatPriceAdjustmentDescription: (result: Pick<PriceAdjustmentResult, "basePrice" | "finalPrice" | "steps">, baseLabel?: string) => string;
|
|
10
15
|
export declare const applyPriceAdjustmentRules: (basePrice: number, rules: Array<PriceAdjustmentRule | WebAppRowGraphQL<PriceAdjustmentRule>>, ctx: PriceAdjustmentContext) => PriceAdjustmentResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.1",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@remix-run/node": "^2.8.1",
|
|
28
28
|
"@zauru-sdk/common": "^6.4.0",
|
|
29
29
|
"@zauru-sdk/config": "^6.0.0",
|
|
30
|
-
"@zauru-sdk/graphql": "^6.
|
|
31
|
-
"@zauru-sdk/services": "^6.
|
|
30
|
+
"@zauru-sdk/graphql": "^6.7.0",
|
|
31
|
+
"@zauru-sdk/services": "^6.9.0",
|
|
32
32
|
"@zauru-sdk/types": "^6.14.0",
|
|
33
33
|
"moment": "^2.30.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "5dc9d6f6bc39767594df95dfeacf7d198b6362d8"
|
|
36
36
|
}
|