@zauru-sdk/services 6.10.0 → 6.11.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.
@@ -1,8 +1,7 @@
1
- import { arrayToObject, applyRejectionPercentageRulesToFinancials, convertToFormData, filterActiveRejectionPercentageAdjustmentRules, formatDateToUTC, getBasketsSchema, getRejectionPercentage, handlePossibleAxiosErrors, parseJsonMemo, reduceAdd, } from "@zauru-sdk/common";
1
+ import { arrayToObject, convertToFormData, formatDateToUTC, getBasketsSchema, handlePossibleAxiosErrors, reduceAdd, } from "@zauru-sdk/common";
2
2
  import { httpZauru } from "./httpZauru.js";
3
3
  import { getGraphQLAPIHeaders, getVariablesByName } from "../common.js";
4
4
  import { httpGraphQLAPI } from "./httpGraphQL.js";
5
- import { getRejectionPercentageAdjustmentRulesByHeaders } from "./zauru-web-app-tables.js";
6
5
  import { getLast100ReceptionsStringQuery, getPurchaseOrderByIdNumberStringQuery, getPurchaseOrderStringQuery, getPurchaseOrdersBetweenDatesStringQuery, } from "@zauru-sdk/graphql";
7
6
  /**
8
7
  * markAsReceivePurchaseOrder
@@ -24,47 +23,14 @@ export const markAsReceivePurchaseOrder = (headers, body) => {
24
23
  return true;
25
24
  });
26
25
  };
27
- const applyRejectionRulesToPurchaseOrderBody = async (headers, body) => {
28
- const originPercentage = getRejectionPercentage(body.memo);
29
- const details = body.purchase_order_details ?? [];
30
- const parsedMemo = parseJsonMemo(body.memo);
31
- if (parsedMemo.rejectionPercentage == null || details.length === 0) {
32
- return body;
33
- }
34
- const rulesResponse = await getRejectionPercentageAdjustmentRulesByHeaders(headers);
35
- const rules = filterActiveRejectionPercentageAdjustmentRules(rulesResponse.error ? [] : rulesResponse.data);
36
- if (rules.length === 0) {
37
- return body;
38
- }
39
- const payee = body.payee;
40
- const adjusted = applyRejectionPercentageRulesToFinancials({
41
- memo: body.memo,
42
- originPercentage,
43
- details,
44
- rules,
45
- ctx: {
46
- itemIds: details
47
- .map((detail) => Number(detail.item_id))
48
- .filter((itemId) => Number.isFinite(itemId)),
49
- tipo: body.reference ?? undefined,
50
- providerCategoryId: payee?.payee_category_id,
51
- },
52
- });
53
- return {
54
- ...body,
55
- memo: adjusted.memo,
56
- discount: adjusted.discount,
57
- };
58
- };
59
26
  export const createNewPurchaseOrder = (headers, body) => {
60
27
  return handlePossibleAxiosErrors(async () => {
61
- const adjustedBody = await applyRejectionRulesToPurchaseOrderBody(headers, body);
62
28
  let sendBody = {
63
- ...adjustedBody,
64
- purchase_order_details_attributes: arrayToObject(adjustedBody?.purchase_order_details),
29
+ ...body,
30
+ purchase_order_details_attributes: arrayToObject(body?.purchase_order_details),
65
31
  tag_ids: [
66
32
  "",
67
- ...(adjustedBody?.taggings?.map((x) => x?.tag_id?.toString()) ?? []),
33
+ ...(body?.taggings?.map((x) => x?.tag_id?.toString()) ?? []),
68
34
  ],
69
35
  };
70
36
  delete sendBody.__rvfInternalFormId;
@@ -1,9 +1,8 @@
1
- import { handlePossibleAxiosErrors, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, } from "@zauru-sdk/common";
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
2
  import { getGraphQLAPIHeaders, getVariablesByName } from "../common.js";
3
3
  import { httpGraphQLAPI } from "./httpGraphQL.js";
4
4
  import { getWebAppRowStringQuery, getWebAppRowsByWebAppTableIdStringQuery, } from "@zauru-sdk/graphql";
5
5
  import { httpZauru } from "./httpZauru.js";
6
- import { getVariables } from "./zauru-variables.js";
7
6
  /**
8
7
  * getWebAppRow
9
8
  * @param headers
@@ -66,24 +65,6 @@ export async function getWebAppTableRegistersRest(headers, id_web_app_table) {
66
65
  return Array.isArray(response.data) ? response.data : [];
67
66
  });
68
67
  }
69
- export const getRejectionPercentageAdjustmentRulesByHeaders = (headers) => {
70
- return handlePossibleAxiosErrors(async () => {
71
- const varsResponse = await getVariables(headers);
72
- if (varsResponse.error || !varsResponse.data) {
73
- return [];
74
- }
75
- const tableId = varsResponse.data.find((variable) => variable.name === REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR)?.value;
76
- if (!tableId) {
77
- return [];
78
- }
79
- const rowsResponse = await getWebAppTableRegistersRest(headers, tableId);
80
- if (rowsResponse.error) {
81
- throw new Error(rowsResponse.userMsg ??
82
- "No se pudieron leer las reglas de porcentaje de rechazo");
83
- }
84
- return rowsResponse.data ?? [];
85
- });
86
- };
87
68
  /**
88
69
  * createWebAppTableRegister function for create a new web app table register
89
70
  * @param headers
@@ -1,5 +1,5 @@
1
1
  import type { Session } from "@remix-run/node";
2
- import { AxiosUtilsResponse, RejectionPercentageAdjustmentRule, RejectionWebAppTableObject, WebAppRowAssociateBody, WebAppRowAssociateResponse, WebAppRowDissociateBody, WebAppRowDissociateResponse, WebAppRowGraphQL, WebAppTableCreateBody, WebAppTableGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
2
+ import { AxiosUtilsResponse, RejectionWebAppTableObject, WebAppRowAssociateBody, WebAppRowAssociateResponse, WebAppRowDissociateBody, WebAppRowDissociateResponse, WebAppRowGraphQL, WebAppTableCreateBody, WebAppTableGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
3
3
  import { type GetWebAppRowsByTableIdOptions } from "@zauru-sdk/graphql";
4
4
  /**
5
5
  * getWebAppRow
@@ -27,7 +27,6 @@ export declare function deleteWebAppTableRegister(headers: any, id_web_app_table
27
27
  * REST listing of webapp table rows (no GraphQL session token required).
28
28
  */
29
29
  export declare function getWebAppTableRegistersRest<T>(headers: any, id_web_app_table: string): Promise<AxiosUtilsResponse<WebAppRowGraphQL<T>[]>>;
30
- export declare const getRejectionPercentageAdjustmentRulesByHeaders: (headers: any) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<RejectionPercentageAdjustmentRule>[]>>;
31
30
  /**
32
31
  * createWebAppTableRegister function for create a new web app table register
33
32
  * @param headers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "6.10.0",
3
+ "version": "6.11.1",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -26,13 +26,13 @@
26
26
  "dependencies": {
27
27
  "@remix-run/node": "^2.8.1",
28
28
  "@upstash/redis": "^1.34.5",
29
- "@zauru-sdk/common": "^6.5.0",
29
+ "@zauru-sdk/common": "^6.7.0",
30
30
  "@zauru-sdk/config": "^6.0.0",
31
31
  "@zauru-sdk/graphql": "^6.7.0",
32
- "@zauru-sdk/types": "^6.15.0",
32
+ "@zauru-sdk/types": "^6.17.0",
33
33
  "axios": "^1.6.7",
34
34
  "chalk": "5.3.0",
35
35
  "moment": "^2.30.1"
36
36
  },
37
- "gitHead": "2dceb781cae3f4c45ceecb915977c6d142bca6b9"
37
+ "gitHead": "d3483aa3b55a9a692f955e6a56d13f33b70db1c4"
38
38
  }