@zauru-sdk/utils 6.11.0 → 6.12.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,
|
|
1
|
+
import { CURRENCY_PREFIX, calculatePurchaseOrderFinancials, getNewDateByFormat, getStringFullDate, getZauruDateByText, handlePossibleAxiosErrors, mergeJsonMemo, } from "@zauru-sdk/common";
|
|
2
2
|
import { commitSession, createNewPurchaseOrder, deleteDelivery, deletePurchaseOrder, deleteReception, getLotesWithPurchaseFormated, getPurchase, getPurchaseOrder, getPurchasesListDataTables, getVariablesByName, inactivarLote, updateReceivedPurchaseOrder, } from "@zauru-sdk/services";
|
|
3
3
|
import { getActiveRejectionPercentageAdjustmentRules } from "./rejectionPercentageAdjustmentRules.utils.js";
|
|
4
4
|
/**
|
|
@@ -258,32 +258,26 @@ export const updateOchAndDis = async (headers, data, purchase_id, session) => {
|
|
|
258
258
|
const payee = purchaseRecord?.payee;
|
|
259
259
|
const itemIds = extractPurchaseOrderItemIds(loadedPurchase);
|
|
260
260
|
const tipo = purchaseRecord?.reference;
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
})
|
|
275
|
-
: {
|
|
276
|
-
memo: setRejectionPercentage(currentMemo, rejectionPercentage),
|
|
277
|
-
discount: calculatePurchaseOrderFinancials({
|
|
278
|
-
details,
|
|
279
|
-
rejectionPercentage,
|
|
280
|
-
}).discount,
|
|
281
|
-
finalPercentage: rejectionPercentage,
|
|
282
|
-
};
|
|
261
|
+
const financials = calculatePurchaseOrderFinancials({
|
|
262
|
+
details,
|
|
263
|
+
rejectionPercentage,
|
|
264
|
+
memo: currentMemo,
|
|
265
|
+
rules,
|
|
266
|
+
ctx: {
|
|
267
|
+
itemIds,
|
|
268
|
+
tipo,
|
|
269
|
+
providerCategoryId: payee?.payee_category_id ??
|
|
270
|
+
purchaseRecord
|
|
271
|
+
?.payee_category_id,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
283
274
|
const body = {
|
|
284
275
|
purchase_order: {
|
|
285
|
-
memo:
|
|
286
|
-
|
|
276
|
+
memo: mergeJsonMemo(currentMemo, {
|
|
277
|
+
rejectionPercentage: financials.rejectionPercentage,
|
|
278
|
+
rejectionCalculations: financials.rejectionCalculations,
|
|
279
|
+
}),
|
|
280
|
+
discount: financials.discount,
|
|
287
281
|
},
|
|
288
282
|
};
|
|
289
283
|
if (data.other_charges !== undefined && data.other_charges !== null) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
-
import { createWebAppTableRegister,
|
|
3
|
-
export { applyRejectionPercentageAdjustmentRules,
|
|
4
|
-
import { filterActiveRejectionPercentageAdjustmentRules, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, } from "@zauru-sdk/common";
|
|
1
|
+
import { filterActiveRejectionPercentageAdjustmentRules, handlePossibleAxiosErrors, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, } from "@zauru-sdk/common";
|
|
2
|
+
import { createWebAppTableRegister, getVariables, getVariablesByName, getWebAppTableRegisters, getWebAppTableRegistersRest, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
|
+
export { applyRejectionPercentageAdjustmentRules, filterActiveRejectionPercentageAdjustmentRules, formatRejectionPercentageAdjustmentDescription, rejectionPercentageAdjustmentRuleMatches, resolveRejectionPercentageBase, resolveRejectionPercentageOrigin, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, } from "@zauru-sdk/common";
|
|
5
4
|
const getTableId = async (headers, session) => {
|
|
6
5
|
const vars = await getVariablesByName(headers, session, [
|
|
7
6
|
REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR,
|
|
@@ -18,6 +17,24 @@ export const getRejectionPercentageAdjustmentRules = (headers, session) => {
|
|
|
18
17
|
return response.data ?? [];
|
|
19
18
|
});
|
|
20
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Same listing without a Remix session: resolves the table id over REST, for
|
|
22
|
+
* background flows that only carry the Zauru headers.
|
|
23
|
+
*/
|
|
24
|
+
export const getRejectionPercentageAdjustmentRulesByHeaders = (headers) => {
|
|
25
|
+
return handlePossibleAxiosErrors(async () => {
|
|
26
|
+
const varsResponse = await getVariables(headers);
|
|
27
|
+
const tableId = varsResponse.data?.find((variable) => variable.name === REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR)?.value;
|
|
28
|
+
if (varsResponse.error || !tableId) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const rowsResponse = await getWebAppTableRegistersRest(headers, tableId);
|
|
32
|
+
if (rowsResponse.error) {
|
|
33
|
+
throw new Error(`Ocurrió un error al consultar las reglas de ajuste de porcentaje de rechazo: ${rowsResponse.userMsg}`);
|
|
34
|
+
}
|
|
35
|
+
return rowsResponse.data ?? [];
|
|
36
|
+
});
|
|
37
|
+
};
|
|
21
38
|
export const getActiveRejectionPercentageAdjustmentRules = async (headers, session) => {
|
|
22
39
|
try {
|
|
23
40
|
if (session) {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Session } from "@remix-run/node";
|
|
2
2
|
import { AxiosUtilsResponse, RejectionPercentageAdjustmentRule, WebAppRowGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
|
|
3
|
-
export { applyRejectionPercentageAdjustmentRules,
|
|
3
|
+
export { applyRejectionPercentageAdjustmentRules, filterActiveRejectionPercentageAdjustmentRules, formatRejectionPercentageAdjustmentDescription, rejectionPercentageAdjustmentRuleMatches, resolveRejectionPercentageBase, resolveRejectionPercentageOrigin, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, } from "@zauru-sdk/common";
|
|
4
4
|
export declare const getRejectionPercentageAdjustmentRules: (headers: any, session: Session) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<RejectionPercentageAdjustmentRule>[]>>;
|
|
5
|
+
/**
|
|
6
|
+
* Same listing without a Remix session: resolves the table id over REST, for
|
|
7
|
+
* background flows that only carry the Zauru headers.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getRejectionPercentageAdjustmentRulesByHeaders: (headers: any) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<RejectionPercentageAdjustmentRule>[]>>;
|
|
5
10
|
export declare const getActiveRejectionPercentageAdjustmentRules: (headers: any, session?: Session) => Promise<WebAppRowGraphQL<RejectionPercentageAdjustmentRule>[]>;
|
|
6
11
|
export declare const createRejectionPercentageAdjustmentRule: (headers: any, session: Session, body: RejectionPercentageAdjustmentRule) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
7
12
|
export declare const updateRejectionPercentageAdjustmentRule: (headers: any, session: Session, id: string, body: Partial<RejectionPercentageAdjustmentRule>) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.12.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.6.0",
|
|
29
29
|
"@zauru-sdk/config": "^6.0.0",
|
|
30
30
|
"@zauru-sdk/graphql": "^6.7.0",
|
|
31
|
-
"@zauru-sdk/services": "^6.
|
|
32
|
-
"@zauru-sdk/types": "^6.
|
|
31
|
+
"@zauru-sdk/services": "^6.11.0",
|
|
32
|
+
"@zauru-sdk/types": "^6.16.0",
|
|
33
33
|
"moment": "^2.30.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "9e840d01a540f2ab49233dda2cb2b0c916ffba0b"
|
|
36
36
|
}
|