@zauru-sdk/hooks 1.0.110 → 1.0.116

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.
@@ -186,7 +186,6 @@ const getPesadasByForm = (formInput, stocks_only_integer = false) => {
186
186
  const discount = isNaN(Number(formInput[`discount${index}`]))
187
187
  ? 0
188
188
  : Number(formInput[`discount${index}`]);
189
- console.log("ARMADO: ", baskets, totalWeight, discount);
190
189
  // Realizar los cálculos necesarios
191
190
  const basketWeight = 5;
192
191
  let netWeight = totalWeight - baskets * basketWeight;
@@ -321,7 +320,9 @@ const getBasketDetailsByForm = (formInput) => {
321
320
  // Comprobar si la clave es un campo "rec" y extraer el color y la cantidad
322
321
  if ((match = recPattern.exec(key))) {
323
322
  const color = match[1];
324
- const total = Number(formInput[key] || 0);
323
+ const total = isNaN(Number(formInput[key]))
324
+ ? 0
325
+ : Number(formInput[key]);
325
326
  const existingBasket = basketDetailsArray.find((item) => item.color === color);
326
327
  if (existingBasket) {
327
328
  existingBasket.total += total;
@@ -340,7 +341,7 @@ const getBasketDetailsByForm = (formInput) => {
340
341
  // Comprobar si la clave es un campo "qC" y actualizar el campo cc correspondiente
341
342
  if ((match = qCPattern.exec(key))) {
342
343
  const color = match[1];
343
- const cc = Number(formInput[key] || 0);
344
+ const cc = isNaN(Number(formInput[key])) ? 0 : Number(formInput[key]);
344
345
  const existingBasket = basketDetailsArray.find((item) => item.color === color);
345
346
  if (existingBasket) {
346
347
  existingBasket.cc += cc;
@@ -351,11 +352,8 @@ const getBasketDetailsByForm = (formInput) => {
351
352
  // Calcular los totales para footerBasketsDetails
352
353
  const totales = {
353
354
  id: "",
354
- total: basketDetailsArray
355
- .map((x) => x.total)
356
- .reduce((acc, val) => acc + val, 0)
357
- .toFixed(2),
358
- cc: basketDetailsArray.map((x) => x.cc).reduce((acc, val) => acc + val, 0),
355
+ total: (0, common_1.toFixedIfNeeded)(basketDetailsArray.map((x) => x.total).reduce(common_1.reduceAdd, 0))?.toString(),
356
+ cc: basketDetailsArray.map((x) => x.cc).reduce(common_1.reduceAdd, 0),
359
357
  };
360
358
  // Definir los encabezados de la tabla
361
359
  const headers = [
@@ -186,7 +186,6 @@ const getPesadasByForm = (formInput, stocks_only_integer = false) => {
186
186
  const discount = isNaN(Number(formInput[`discount${index}`]))
187
187
  ? 0
188
188
  : Number(formInput[`discount${index}`]);
189
- console.log("ARMADO: ", baskets, totalWeight, discount);
190
189
  // Realizar los cálculos necesarios
191
190
  const basketWeight = 5;
192
191
  let netWeight = totalWeight - baskets * basketWeight;
@@ -321,7 +320,9 @@ const getBasketDetailsByForm = (formInput) => {
321
320
  // Comprobar si la clave es un campo "rec" y extraer el color y la cantidad
322
321
  if ((match = recPattern.exec(key))) {
323
322
  const color = match[1];
324
- const total = Number(formInput[key] || 0);
323
+ const total = isNaN(Number(formInput[key]))
324
+ ? 0
325
+ : Number(formInput[key]);
325
326
  const existingBasket = basketDetailsArray.find((item) => item.color === color);
326
327
  if (existingBasket) {
327
328
  existingBasket.total += total;
@@ -340,7 +341,7 @@ const getBasketDetailsByForm = (formInput) => {
340
341
  // Comprobar si la clave es un campo "qC" y actualizar el campo cc correspondiente
341
342
  if ((match = qCPattern.exec(key))) {
342
343
  const color = match[1];
343
- const cc = Number(formInput[key] || 0);
344
+ const cc = isNaN(Number(formInput[key])) ? 0 : Number(formInput[key]);
344
345
  const existingBasket = basketDetailsArray.find((item) => item.color === color);
345
346
  if (existingBasket) {
346
347
  existingBasket.cc += cc;
@@ -351,11 +352,8 @@ const getBasketDetailsByForm = (formInput) => {
351
352
  // Calcular los totales para footerBasketsDetails
352
353
  const totales = {
353
354
  id: "",
354
- total: basketDetailsArray
355
- .map((x) => x.total)
356
- .reduce((acc, val) => acc + val, 0)
357
- .toFixed(2),
358
- cc: basketDetailsArray.map((x) => x.cc).reduce((acc, val) => acc + val, 0),
355
+ total: (0, common_1.toFixedIfNeeded)(basketDetailsArray.map((x) => x.total).reduce(common_1.reduceAdd, 0))?.toString(),
356
+ cc: basketDetailsArray.map((x) => x.cc).reduce(common_1.reduceAdd, 0),
359
357
  };
360
358
  // Definir los encabezados de la tabla
361
359
  const headers = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/hooks",
3
- "version": "1.0.110",
3
+ "version": "1.0.116",
4
4
  "description": "Hooks reutilizables dentro de las webapps de Zauru.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@remix-run/react": "^2.8.1",
30
- "@zauru-sdk/common": "^1.0.110",
30
+ "@zauru-sdk/common": "^1.0.116",
31
31
  "@zauru-sdk/icons": "^1.0.60",
32
- "@zauru-sdk/redux": "^1.0.109",
33
- "@zauru-sdk/types": "^1.0.109",
32
+ "@zauru-sdk/redux": "^1.0.116",
33
+ "@zauru-sdk/types": "^1.0.116",
34
34
  "react": "^18.2.0",
35
35
  "react-dom": "^18.2.0"
36
36
  },
37
- "gitHead": "15d8ecf97b16b9c4bd50b8a5984435b451a846e5"
37
+ "gitHead": "9626d12f4ce2db9df58e992711879cacdfdb9c6e"
38
38
  }