@zauru-sdk/utils 6.17.0 → 6.18.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.
@@ -210,11 +210,11 @@ const extractPurchaseOrderItemIds = (purchase) => {
210
210
  * updateOchAndDis
211
211
  * Updates rejectionPercentage in purchase_order.memo and the monetary
212
212
  * purchase_orders.discount (qty × unit_cost × % / 100). Optionally other_charges.
213
+ * Prefer `rejectionApplication` (delta + mode) so successive layers are preserved.
213
214
  * `data.discount` is a legacy alias for the rejection percentage, not money.
214
215
  */
215
216
  export const updateOchAndDis = async (headers, data, purchase_id, session) => {
216
217
  return handlePossibleAxiosErrors(async () => {
217
- const rejectionPercentage = Number(data?.rejectionPercentage ?? data?.discount ?? 0);
218
218
  let currentMemo = data.memo;
219
219
  let liveMemo;
220
220
  let details = [];
@@ -265,10 +265,20 @@ export const updateOchAndDis = async (headers, data, purchase_id, session) => {
265
265
  const tipo = purchaseRecord?.reference;
266
266
  const memoForOrigin = liveMemo ?? currentMemo;
267
267
  const previousCalculations = parseJsonMemo(memoForOrigin).rejectionCalculations;
268
+ const hasExplicitLayers = data.rejectionLayers != null;
269
+ const hasApplication = data.rejectionApplication != null;
268
270
  const financials = calculatePurchaseOrderFinancials({
269
271
  details,
270
- rejectionPercentage,
271
272
  memo: memoForOrigin,
273
+ ...(hasExplicitLayers ? { rejectionLayers: data.rejectionLayers } : {}),
274
+ ...(hasApplication
275
+ ? { rejectionApplication: data.rejectionApplication }
276
+ : {}),
277
+ ...(!hasExplicitLayers && !hasApplication
278
+ ? {
279
+ rejectionPercentage: Number(data?.rejectionPercentage ?? data?.discount ?? 0),
280
+ }
281
+ : {}),
272
282
  rules,
273
283
  ctx: {
274
284
  itemIds,
@@ -284,6 +294,7 @@ export const updateOchAndDis = async (headers, data, purchase_id, session) => {
284
294
  memo: mergeJsonMemo(memoForOrigin, {
285
295
  rejectionPercentage: financials.rejectionPercentage,
286
296
  rejectionCalculations: financials.rejectionCalculations,
297
+ rejectionLayers: financials.rejectionLayers,
287
298
  }),
288
299
  discount: financials.discount,
289
300
  },
@@ -297,6 +308,7 @@ export const updateOchAndDis = async (headers, data, purchase_id, session) => {
297
308
  }
298
309
  return {
299
310
  rejectionPercentage: financials.rejectionPercentage,
311
+ rejectionLayers: financials.rejectionLayers,
300
312
  rejectionCalculations: financials.rejectionCalculations,
301
313
  newlyAppliedSteps,
302
314
  };
@@ -1,6 +1,6 @@
1
1
  import { filterActiveRejectionPercentageAdjustmentRules, handlePossibleAxiosErrors, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, } from "@zauru-sdk/common";
2
2
  import { createWebAppTableRegister, getVariables, getVariablesByName, getWebAppTableRegisters, getWebAppTableRegistersRest, updateWebAppTableRegister, } from "@zauru-sdk/services";
3
- export { applyRejectionPercentageAdjustmentRules, filterActiveRejectionPercentageAdjustmentRules, formatAutomaticRejectionRuleHistoryDescription, formatRejectionPercentageAdjustmentDescription, getNewlyAppliedRejectionRuleSteps, isAutomaticRejectionRuleHistoryType, rejectionPercentageAdjustmentRuleMatches, resolveRejectionPercentageBase, resolveRejectionPercentageOrigin, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, REJECTION_PERCENTAGE_RULE_HISTORY_TYPE, } from "@zauru-sdk/common";
3
+ export { applyRejectionPercentageAdjustmentRules, applyRejectionPercentageLayers, computeEffectiveRejectionPercentage, filterActiveRejectionPercentageAdjustmentRules, formatAutomaticRejectionRuleHistoryDescription, formatRejectionPercentageAdjustmentDescription, getNewlyAppliedRejectionRuleSteps, hasSuccessiveRejectionLayers, isAutomaticRejectionRuleHistoryType, normalizeRejectionPercentageLayers, rejectionPercentageAdjustmentRuleMatches, resolveRejectionPercentageBase, resolveRejectionPercentageOrigin, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, REJECTION_PERCENTAGE_RULE_HISTORY_TYPE, } from "@zauru-sdk/common";
4
4
  const getTableId = async (headers, session) => {
5
5
  const vars = await getVariablesByName(headers, session, [
6
6
  REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR,
@@ -1,5 +1,5 @@
1
1
  import type { Session } from "@remix-run/node";
2
- import { AxiosUtilsResponse, LoteWithPurchaseFormatedSchema, PurchaseOrderGraphQL, PurchasesDataTableListFormatedSchema, PurchasesListResponseSchema, UpdateOchAndDisResult } from "@zauru-sdk/types";
2
+ import { AxiosUtilsResponse, LoteWithPurchaseFormatedSchema, PurchaseOrderGraphQL, PurchasesDataTableListFormatedSchema, PurchasesListResponseSchema, RejectionPercentageApplication, RejectionPercentageLayers, UpdateOchAndDisResult } from "@zauru-sdk/types";
3
3
  /**
4
4
  * Obtiene el listado de ordenes de compra, formateado especialmente para armar la tabla de edición de porcentajes y tolerancia
5
5
  * @param headers
@@ -40,9 +40,12 @@ export declare const updatePurchaseItemPrice: (headers: any, data: {
40
40
  * updateOchAndDis
41
41
  * Updates rejectionPercentage in purchase_order.memo and the monetary
42
42
  * purchase_orders.discount (qty × unit_cost × % / 100). Optionally other_charges.
43
+ * Prefer `rejectionApplication` (delta + mode) so successive layers are preserved.
43
44
  * `data.discount` is a legacy alias for the rejection percentage, not money.
44
45
  */
45
46
  export declare const updateOchAndDis: (headers: any, data: {
47
+ rejectionApplication?: RejectionPercentageApplication;
48
+ rejectionLayers?: RejectionPercentageLayers;
46
49
  rejectionPercentage?: number | string;
47
50
  discount?: number | string;
48
51
  other_charges?: number | string;
@@ -1,6 +1,6 @@
1
1
  import type { Session } from "@remix-run/node";
2
2
  import { AxiosUtilsResponse, RejectionPercentageAdjustmentRule, WebAppRowGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
3
- export { applyRejectionPercentageAdjustmentRules, filterActiveRejectionPercentageAdjustmentRules, formatAutomaticRejectionRuleHistoryDescription, formatRejectionPercentageAdjustmentDescription, getNewlyAppliedRejectionRuleSteps, isAutomaticRejectionRuleHistoryType, rejectionPercentageAdjustmentRuleMatches, resolveRejectionPercentageBase, resolveRejectionPercentageOrigin, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, REJECTION_PERCENTAGE_RULE_HISTORY_TYPE, } from "@zauru-sdk/common";
3
+ export { applyRejectionPercentageAdjustmentRules, applyRejectionPercentageLayers, computeEffectiveRejectionPercentage, filterActiveRejectionPercentageAdjustmentRules, formatAutomaticRejectionRuleHistoryDescription, formatRejectionPercentageAdjustmentDescription, getNewlyAppliedRejectionRuleSteps, hasSuccessiveRejectionLayers, isAutomaticRejectionRuleHistoryType, normalizeRejectionPercentageLayers, rejectionPercentageAdjustmentRuleMatches, resolveRejectionPercentageBase, resolveRejectionPercentageOrigin, REJECTION_PERCENTAGE_ADJUSTMENT_RULES_TABLE_VAR, REJECTION_PERCENTAGE_RULE_HISTORY_TYPE, } from "@zauru-sdk/common";
4
4
  export declare const getRejectionPercentageAdjustmentRules: (headers: any, session: Session) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<RejectionPercentageAdjustmentRule>[]>>;
5
5
  /**
6
6
  * Same listing without a Remix session: resolves the table id over REST, for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/utils",
3
- "version": "6.17.0",
3
+ "version": "6.18.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",
@@ -71,12 +71,12 @@
71
71
  "dependencies": {
72
72
  "@aws-sdk/client-cloudwatch-logs": "^3.1123.0",
73
73
  "@remix-run/node": "^2.8.1",
74
- "@zauru-sdk/common": "^6.7.0",
74
+ "@zauru-sdk/common": "^6.8.0",
75
75
  "@zauru-sdk/config": "^6.0.0",
76
76
  "@zauru-sdk/graphql": "^6.7.0",
77
- "@zauru-sdk/services": "^6.11.1",
78
- "@zauru-sdk/types": "^6.17.0",
77
+ "@zauru-sdk/services": "^6.11.2",
78
+ "@zauru-sdk/types": "^6.18.0",
79
79
  "moment": "^2.30.1"
80
80
  },
81
- "gitHead": "d3483aa3b55a9a692f955e6a56d13f33b70db1c4"
81
+ "gitHead": "c5b785baa29fdd2ab7f42a9077ba5cbe5c7c9707"
82
82
  }