@zauru-sdk/utils 6.9.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.
|
@@ -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
|
}
|
|
@@ -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.9.
|
|
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",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@zauru-sdk/types": "^6.14.0",
|
|
33
33
|
"moment": "^2.30.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "5dc9d6f6bc39767594df95dfeacf7d198b6362d8"
|
|
36
36
|
}
|