feat: ajustar el manejo de meses en filtros y cálculos de balances para compatibilidad 0-indexada

This commit is contained in:
2026-10-19 10:18:26 -03:00
parent 215a5b28f4
commit 7a97e278a2
4 changed files with 12 additions and 4 deletions
@@ -99,7 +99,9 @@ export class CashFlowAdapterMongoose implements ICashFlowAdapter {
searchCriteria.year = filters.year;
}
if (filters.month) {
// month 0 = enero: no usar truthy check, si no se dropea el filtro y enero
// queda sin filtrar (devolvería todos los meses del año).
if (typeof filters.month === "number") {
searchCriteria.month = filters.month;
}
@@ -45,7 +45,8 @@ export class CashFlowBalanceAdapterMongoose implements ICashFlowBalanceAdapter {
searchCriteria.companyId = filters.companyId;
}
if (filters.month) {
// month 0 = enero: no usar truthy check, si no se dropea el filtro.
if (typeof filters.month === "number") {
searchCriteria.month = filters.month;
}
@@ -231,7 +231,10 @@ class CashFlowBalanceManager implements ICashFlowBalanceManager {
const userSession = await this.validateSessionUser(data.sessionUser);
await this.validatePermissions(String(userSession.id), data.companyId);
const months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
// Los balances se guardan con month 0-indexado (0 = enero ... 11 = diciembre),
// igual que dayjs.month(). No iterar de 1 a 12: eso saltea enero (key 0)
// y consultaba un mes 12 inexistente que el cliente renderiza como enero del año siguiente.
const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
const year = data.year;
const companyId = data.companyId;