@zauru-sdk/utils 6.26.0 → 6.27.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.
|
@@ -11,6 +11,7 @@ import { getProgramaciones } from "./programaciones.utils.js";
|
|
|
11
11
|
import { getShipmentsToMyAgency } from "./shipments.utils.js";
|
|
12
12
|
import { getTemplates } from "./templates.utils.js";
|
|
13
13
|
import { getTipoMuestras } from "./tiposMuestra.utils.js";
|
|
14
|
+
import { getProviderReceptionBlockRules, getProviderReceptionExceptions, } from "./providerReceptionMatrix.utils.js";
|
|
14
15
|
import { getReceptionTypes } from "./webapp-tables.utils.js";
|
|
15
16
|
const missingQueryParam = (param) => {
|
|
16
17
|
console.warn({
|
|
@@ -88,6 +89,8 @@ const sdkCatalogHandlers = {
|
|
|
88
89
|
motivosRechazo: ({ headers, session }) => getMotivosRechazo(headers, session),
|
|
89
90
|
ccPorcentajesDeRechazo: ({ headers, session }) => getCCPorcentajesDeRechazo(headers, session),
|
|
90
91
|
programaciones4pinos: ({ headers, session }) => getProgramaciones(headers, session),
|
|
92
|
+
providerReceptionBlockRules: ({ headers, session }) => getProviderReceptionBlockRules(headers, session),
|
|
93
|
+
providerReceptionExceptions: ({ headers, session }) => getProviderReceptionExceptions(headers, session),
|
|
91
94
|
solicitudesEliminacionPO: ({ headers, session }) => get4pinosSolicitudEliminacionPO(headers, session),
|
|
92
95
|
pesoMaximoPorCanasta: ({ headers, session }) => get4pinosWeightLimitPerBasket(headers, session),
|
|
93
96
|
poDiscountHistory: ({ headers, session }) => get4pinosPoDiscountHistory(headers, session),
|
|
@@ -5,6 +5,21 @@ import { applyPriceAdjustmentRules, filterActivePriceAdjustmentRules, formatPric
|
|
|
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;
|
|
8
|
+
export const pickProviderCategoryId = (payee, payees, payeeId) => {
|
|
9
|
+
const fromPayee = payee?.payee_category_id;
|
|
10
|
+
if (fromPayee != null && Number.isFinite(Number(fromPayee))) {
|
|
11
|
+
return Number(fromPayee);
|
|
12
|
+
}
|
|
13
|
+
if (payeeId == null || !payees?.length) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const match = payees.find((item) => item.id === payeeId);
|
|
17
|
+
const fromList = match?.payee_category_id;
|
|
18
|
+
if (fromList == null || !Number.isFinite(Number(fromList))) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return Number(fromList);
|
|
22
|
+
};
|
|
8
23
|
const isSpecialItemRow = (item) => typeof item.id === "number" &&
|
|
9
24
|
Boolean(item.data);
|
|
10
25
|
const isWeekday = (value) => value === 0 ||
|
|
@@ -190,15 +205,13 @@ export const resolveItemPriceFromLatestWeeklyMatrix = (headers, session, params)
|
|
|
190
205
|
let providerCategoryId;
|
|
191
206
|
if (params.payeeId != null) {
|
|
192
207
|
const payeeResponse = await getPayee(session, params.payeeId);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
208
|
+
providerCategoryId = pickProviderCategoryId(payeeResponse.data);
|
|
209
|
+
if (providerCategoryId == null) {
|
|
197
210
|
const payeesResponse = await getPayees(session);
|
|
198
211
|
if (payeesResponse.error || !payeesResponse.data) {
|
|
199
212
|
throw new Error(`Error al obtener el proveedor para aplicar las reglas de ajuste: ${payeeResponse.userMsg ?? payeesResponse.userMsg ?? ""}`);
|
|
200
213
|
}
|
|
201
|
-
providerCategoryId = payeesResponse.data
|
|
214
|
+
providerCategoryId = pickProviderCategoryId(undefined, payeesResponse.data, params.payeeId);
|
|
202
215
|
}
|
|
203
216
|
}
|
|
204
217
|
return calculateItemPriceFromWeeklyMatrix({
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { Session } from "@remix-run/node";
|
|
2
2
|
import { AxiosUtilsResponse, BitacoraCostosItems, CalculateItemPriceFromWeeklyMatrixInput, CalculateItemPriceFromWeeklyMatrixResult, CostoSemanal, CostoSemanalSpecialItem, SpecialItem, WebAppRowGraphQL, WeeklyCostMatrix, WeeklyCostPeriod } from "@zauru-sdk/types";
|
|
3
3
|
export declare const MASSIVE_VEGETABLE_COST_ACCION = "Costos masivamente";
|
|
4
|
+
export declare const pickProviderCategoryId: (payee?: {
|
|
5
|
+
payee_category_id?: number | null;
|
|
6
|
+
} | null, payees?: Array<{
|
|
7
|
+
id?: number;
|
|
8
|
+
payee_category_id?: number | null;
|
|
9
|
+
}> | null, payeeId?: number) => number | undefined;
|
|
4
10
|
export declare const parseWeeklyCostDate: (value: string) => Date | null;
|
|
5
11
|
export declare const getMondayOfWeeklyCostDate: (date: string) => string | null;
|
|
6
12
|
export declare const getWeeklyCostPeriod: (date: string) => WeeklyCostPeriod;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.0",
|
|
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",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"@remix-run/node": "^2.8.1",
|
|
74
74
|
"@zauru-sdk/common": "^6.12.0",
|
|
75
75
|
"@zauru-sdk/config": "^6.0.0",
|
|
76
|
-
"@zauru-sdk/graphql": "^6.9.
|
|
76
|
+
"@zauru-sdk/graphql": "^6.9.1",
|
|
77
77
|
"@zauru-sdk/services": "^6.15.1",
|
|
78
78
|
"@zauru-sdk/types": "^6.28.0",
|
|
79
79
|
"moment": "^2.30.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "34f97528fce5cce75e12b18732bdccd7f172a927"
|
|
82
82
|
}
|