bdpformulas 1.0.102 → 1.0.103

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.
@@ -169,18 +169,54 @@ class FlujoConstructor {
169
169
  }
170
170
  rowAcumulado.MontoTotal = rowAcumulado[`Monto${this.rango}`];
171
171
  };
172
+ // calcularTotal = (
173
+ // sumandosArray: string[],
174
+ // total: string,
175
+ // data = this.array
176
+ // ) => {
177
+ // const rows = data.filter(
178
+ // (item: any) =>
179
+ // item.IndicadorABM !== 'B' &&
180
+ // sumandosArray.includes(item.RubroId)
181
+ // )
182
+ // const destino = this.mapObject.get(`${total}_0`)
183
+ // rows.map((item: any) => {
184
+ // for (let i = 1; i <= this.rango; i++) {
185
+ // destino[`Monto${i}`] += parseFloat(item[`Monto${i}`])
186
+ // // destino[`Monto${i}`] =
187
+ // // Math.round(destino[`Monto${i}`] * 100) / 100
188
+ // destino[`Monto${i}`] = Math.round(destino[`Monto${i}`])
189
+ // }
190
+ // })
191
+ // }
172
192
  calcularTotal = (sumandosArray, total, data = this.array) => {
173
193
  const rows = data.filter((item) => item.IndicadorABM !== 'B' &&
174
194
  sumandosArray.includes(item.RubroId));
175
- const destino = this.mapObject.get(`${total}_0`);
176
- rows.map((item) => {
195
+ const destinoKey = `${total}_0`;
196
+ const destino = this.mapObject.get(destinoKey);
197
+ if (!destino) {
198
+ console.error(` NO SE ENCONTRÓ EL DESTINO: ${destinoKey}`);
199
+ return;
200
+ }
201
+ for (let i = 1; i <= this.rango; i++) {
202
+ const montoKey = `Monto${i}`;
203
+ if (destino[montoKey] === null ||
204
+ destino[montoKey] === undefined ||
205
+ isNaN(destino[montoKey])) {
206
+ destino[montoKey] = 0;
207
+ }
208
+ }
209
+ rows.forEach((item) => {
177
210
  for (let i = 1; i <= this.rango; i++) {
178
- destino[`Monto${i}`] += parseFloat(item[`Monto${i}`]);
179
- // destino[`Monto${i}`] =
180
- // Math.round(destino[`Monto${i}`] * 100) / 100
181
- destino[`Monto${i}`] = Math.round(destino[`Monto${i}`]);
211
+ const montoKey = `Monto${i}`;
212
+ const montoValor = (0, utils_1.ourParseFloat)(item[montoKey]) || 0; // Asegurar que sea número
213
+ destino[montoKey] += montoValor;
182
214
  }
183
215
  });
216
+ // Redondear al final
217
+ for (let i = 1; i <= this.rango; i++) {
218
+ destino[`Monto${i}`] = Math.round(destino[`Monto${i}`]);
219
+ }
184
220
  };
185
221
  replicarCuenta = (cuentaOrigen, cuentaDestino) => {
186
222
  const rows = this.array.filter((item) => item.RubroId === cuentaOrigen);
@@ -264,37 +300,71 @@ class FlujoConstructor {
264
300
  }
265
301
  };
266
302
  agregarQuitarClones = () => {
267
- const filter = this.data.FlujoProyectadoMensual.filter((item) => item.IndicadorABM !== 'B' &&
268
- (item.Clasificador == 'DETL' || item.Clasificador == 'HABM'));
303
+ const filter = this.data.FlujoProyectadoMensual.filter((item) =>
304
+ // item.IndicadorABM !== 'B' &&
305
+ item.Clasificador == 'DETL' || item.Clasificador == 'HABM');
306
+ const borrados = this.data.FlujoProyectadoMensual.filter((item) => item.IndicadorABM === 'B' &&
307
+ (item.Clasificador == 'DETL' || item.Clasificador == 'HABM')).map((item) => `CLONE_${item.UUID}`);
308
+ if (borrados.length > 0) {
309
+ this.data.FlujoProyectadoAnual =
310
+ this.data.FlujoProyectadoAnual.filter((item) => !borrados.includes(item.UUID));
311
+ this.array = this.array.filter((item) => !borrados.includes(item.UUID));
312
+ borrados.forEach((uuid) => {
313
+ const key = Object.keys(this.mapObject).find((key) => this.mapObject.get(key)?.UUID === uuid);
314
+ if (key) {
315
+ this.mapObject.delete(key);
316
+ }
317
+ });
318
+ }
269
319
  filter.forEach((item) => {
270
320
  const key = `${item.RubroId}_CLONE_${item.UUID}`;
271
321
  const UUID = `CLONE_${item.UUID}`;
272
- // 12/08/2025 ROLANDO: EDICION PARA LOS RUBROS 61001 Y 73000 GASTOS FINANCIEROS
322
+ if (item.IndicadorABM === 'B') {
323
+ return;
324
+ }
273
325
  let totalMensual = 0;
274
326
  for (let i = 1; i <= this.rango; i++) {
275
327
  totalMensual += (0, utils_1.ourParseFloat)(item[`Monto${i}`] || 0);
276
328
  }
277
329
  const existingClone = this.array.find((el) => el.UUID === UUID);
278
- if (item.RubroId === 'ACT_CNFL_61001' ||
279
- (item.RubroId === 'ACT_CNFL_73000' && existingClone)) {
280
- const clone = {
330
+ if (item.IndicadorABM === 'A' && !existingClone) {
331
+ const newClone = {
332
+ ...item,
333
+ UUID: UUID,
334
+ Clasificador: 'DETL',
335
+ IndicadorABM: 'A',
336
+ Monto1: totalMensual,
337
+ ...Array.from({ length: this.rango - 1 }, (_, i) => ({
338
+ [`Monto${i + 2}`]: 0
339
+ })).reduce((acc, curr) => ({ ...acc, ...curr }), {}),
340
+ MontoTotal: totalMensual
341
+ };
342
+ this.array.push(newClone);
343
+ this.mapObject.set(key, newClone);
344
+ return;
345
+ }
346
+ if (existingClone &&
347
+ (item.RubroId === 'ACT_CNFL_61001' ||
348
+ item.RubroId === 'ACT_CNFL_73000')) {
349
+ const updatedClone = {
281
350
  ...existingClone,
351
+ Descripcion: item.Descripcion,
282
352
  Comprar: item.Comprar,
283
353
  Operacion: item.Operacion,
354
+ IndicadorABM: item.IndicadorABM,
284
355
  Monto1: totalMensual
285
356
  };
286
357
  let nuevoTotal = totalMensual;
287
358
  for (let i = 2; i <= this.rango; i++) {
288
359
  nuevoTotal += (0, utils_1.ourParseFloat)(existingClone[`Monto${i}`] || 0);
289
360
  }
290
- clone.MontoTotal = nuevoTotal;
361
+ updatedClone.MontoTotal = nuevoTotal;
291
362
  const index = this.array.findIndex((el) => el.UUID === UUID);
292
363
  if (index >= 0)
293
- this.array[index] = clone;
294
- this.mapObject.set(key, clone);
364
+ this.array[index] = updatedClone;
365
+ this.mapObject.set(key, updatedClone);
295
366
  return;
296
367
  }
297
- // FIN EDICION
298
368
  const clone = {
299
369
  ...item,
300
370
  UUID
@@ -316,12 +386,21 @@ class FlujoConstructor {
316
386
  }
317
387
  this.mapObject.set(key, clone);
318
388
  });
319
- const borrados = this.data.FlujoProyectadoMensual.filter((item) => item.IndicadorABM === 'B' &&
320
- (item.Clasificador == 'DETL' || item.Clasificador == 'HABM')).map((item) => `CLONE_${item.UUID}`);
321
- this.data.FlujoProyectadoMensual =
322
- this.data.FlujoProyectadoMensual.filter((item) => item.IndicadorABM !== 'B');
323
- this.array = this.array.filter((item) => !borrados.includes(item.UUID));
324
- this.data.FlujoProyectadoAnual = this.data.FlujoProyectadoAnual.filter((item) => !borrados.includes(item.UUID));
389
+ // const borrados = this.data.FlujoProyectadoMensual.filter(
390
+ // (item: any) =>
391
+ // item.IndicadorABM === 'B' &&
392
+ // (item.Clasificador == 'DETL' || item.Clasificador == 'HABM')
393
+ // ).map((item: any) => `CLONE_${item.UUID}`)
394
+ // this.data.FlujoProyectadoMensual =
395
+ // this.data.FlujoProyectadoMensual.filter(
396
+ // (item: any) => item.IndicadorABM !== 'B'
397
+ // )
398
+ // this.array = this.array.filter(
399
+ // (item: any) => !borrados.includes(item.UUID)
400
+ // )
401
+ // this.data.FlujoProyectadoAnual = this.data.FlujoProyectadoAnual.filter(
402
+ // (item: any) => !borrados.includes(item.UUID)
403
+ // )
325
404
  const anuales = this.array.filter((item) => item.Clasificador == 'DETL' || item.Clasificador == 'HABM');
326
405
  for (const anualItem of anuales) {
327
406
  const key = `${anualItem.RubroId}_${anualItem.UUID}`.replace('_CLONE', '');
@@ -130,6 +130,15 @@ const addGastosM = (actividad, data) => {
130
130
  data.FlujoProyectadoMensual.push(row);
131
131
  }
132
132
  };
133
+ const obtenerValorPorMes = (objeto, mes) => {
134
+ const patrones = [`C-${mes}`, `Gestion${mes}`, `Monto${mes}`, `Valor${mes}`];
135
+ for (const patron of patrones) {
136
+ if (objeto[patron] !== undefined && objeto[patron] !== null) {
137
+ return Math.round(parseFloat(objeto[patron]) || 0);
138
+ }
139
+ }
140
+ return 0;
141
+ };
133
142
  const otrosIngresoM = (actividad, data) => {
134
143
  const rubro = data.FlujoProyectadoMensualMap.get(`${RUBRO_OTROS_INGRESOS}_0`);
135
144
  const otrosIngresos = actividad.Ventas.OtrosIngresos;
@@ -151,10 +160,11 @@ const otrosIngresoM = (actividad, data) => {
151
160
  }
152
161
  }
153
162
  else {
163
+ const ingreso = otrosIngresos[0];
154
164
  for (let i = 1; i <= 12; i++) {
155
165
  // row[`Monto${i}`] =
156
166
  // Math.round(parseFloat(otrosIngresos[`C-${i}`]) * 100) / 100
157
- row[`Monto${i}`] = Math.round(parseFloat(otrosIngresos[`C-${i}`]));
167
+ row[`Monto${i}`] = obtenerValorPorMes(ingreso, i);
158
168
  }
159
169
  }
160
170
  const existente = data.FlujoProyectadoMensual.findIndex((el) => el.UUID === row.UUID);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bdpformulas",
3
- "version": "1.0.102",
3
+ "version": "1.0.103",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",