@zauru-sdk/utils 6.3.7 → 6.4.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CURRENCY_PREFIX, getNewDateByFormat, getStringFullDate, getZauruDateByText, handlePossibleAxiosErrors, } from "@zauru-sdk/common";
|
|
1
|
+
import { CURRENCY_PREFIX, getNewDateByFormat, getStringFullDate, getZauruDateByText, handlePossibleAxiosErrors, setRejectionPercentage, } from "@zauru-sdk/common";
|
|
2
2
|
import { commitSession, createNewPurchaseOrder, deleteDelivery, deletePurchaseOrder, deleteReception, getLotesWithPurchaseFormated, getPurchaseOrder, getPurchasesListDataTables, getVariablesByName, inactivarLote, updateReceivedPurchaseOrder, } from "@zauru-sdk/services";
|
|
3
3
|
/**
|
|
4
4
|
* Obtiene el listado de ordenes de compra, formateado especialmente para armar la tabla de edición de porcentajes y tolerancia
|
|
@@ -173,18 +173,34 @@ export const updatePurchaseItemPrice = async (headers, data, purchase_id) => {
|
|
|
173
173
|
};
|
|
174
174
|
/**
|
|
175
175
|
* updateOchAndDis
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* @returns
|
|
176
|
+
* Updates rejectionPercentage in purchase_order.memo (not the financial discount column)
|
|
177
|
+
* and optionally other_charges (tolerancia).
|
|
179
178
|
*/
|
|
180
|
-
export const updateOchAndDis = async (headers, data, purchase_id) => {
|
|
179
|
+
export const updateOchAndDis = async (headers, data, purchase_id, session) => {
|
|
181
180
|
return handlePossibleAxiosErrors(async () => {
|
|
181
|
+
const rejectionPercentage = Number(data?.rejectionPercentage ?? data?.discount ?? 0);
|
|
182
|
+
let currentMemo = data.memo;
|
|
183
|
+
if (currentMemo === undefined && session) {
|
|
184
|
+
const purchaseOrderResponse = await getPurchaseOrder(session, purchase_id, {
|
|
185
|
+
withLotStocksToMyAgency: false,
|
|
186
|
+
withPayee: false,
|
|
187
|
+
withReceptions: false,
|
|
188
|
+
});
|
|
189
|
+
if (purchaseOrderResponse.error || !purchaseOrderResponse.data) {
|
|
190
|
+
throw new Error(purchaseOrderResponse.userMsg ||
|
|
191
|
+
"No se pudo obtener la orden de compra para actualizar el porcentaje de rechazo");
|
|
192
|
+
}
|
|
193
|
+
currentMemo = purchaseOrderResponse.data.memo;
|
|
194
|
+
}
|
|
195
|
+
if (currentMemo === undefined) {
|
|
196
|
+
throw new Error("memo or session is required to update rejectionPercentage");
|
|
197
|
+
}
|
|
182
198
|
const body = {
|
|
183
199
|
purchase_order: {
|
|
184
|
-
|
|
200
|
+
memo: setRejectionPercentage(currentMemo, rejectionPercentage),
|
|
185
201
|
},
|
|
186
202
|
};
|
|
187
|
-
if (data.other_charges) {
|
|
203
|
+
if (data.other_charges !== undefined && data.other_charges !== null) {
|
|
188
204
|
body.purchase_order.other_charges = Number(data.other_charges);
|
|
189
205
|
}
|
|
190
206
|
const responseUpdate = await updateReceivedPurchaseOrder(headers, body, purchase_id);
|
|
@@ -36,14 +36,15 @@ export declare const updatePurchaseItemPrice: (headers: any, data: {
|
|
|
36
36
|
}, purchase_id: number) => Promise<AxiosUtilsResponse<boolean>>;
|
|
37
37
|
/**
|
|
38
38
|
* updateOchAndDis
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @returns
|
|
39
|
+
* Updates rejectionPercentage in purchase_order.memo (not the financial discount column)
|
|
40
|
+
* and optionally other_charges (tolerancia).
|
|
42
41
|
*/
|
|
43
42
|
export declare const updateOchAndDis: (headers: any, data: {
|
|
43
|
+
rejectionPercentage?: number | string;
|
|
44
44
|
discount?: number | string;
|
|
45
45
|
other_charges?: number | string;
|
|
46
|
-
|
|
46
|
+
memo?: string;
|
|
47
|
+
}, purchase_id: number, session?: Session) => Promise<AxiosUtilsResponse<boolean>>;
|
|
47
48
|
/**
|
|
48
49
|
* Obtengo los id's de las órdenes de compra en un arreglo numérico
|
|
49
50
|
* @param headers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.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",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@remix-run/node": "^2.8.1",
|
|
28
|
-
"@zauru-sdk/common": "^6.
|
|
28
|
+
"@zauru-sdk/common": "^6.3.0",
|
|
29
29
|
"@zauru-sdk/config": "^6.0.0",
|
|
30
30
|
"@zauru-sdk/graphql": "^6.4.0",
|
|
31
|
-
"@zauru-sdk/services": "^6.6.
|
|
32
|
-
"@zauru-sdk/types": "^6.
|
|
31
|
+
"@zauru-sdk/services": "^6.6.2",
|
|
32
|
+
"@zauru-sdk/types": "^6.9.0",
|
|
33
33
|
"moment": "^2.30.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "2cc49202c68f74f1ef031322b108b1461b9c9ad7"
|
|
36
36
|
}
|