From 9c7fa8f5171da4ac00b6a41f692553574ed7a87e Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 5 Jan 2023 11:46:52 +0530 Subject: [PATCH] fix: dateRanges on PnL, Bal Sheet --- reports/AccountReport.ts | 42 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/reports/AccountReport.ts b/reports/AccountReport.ts index 66d886b9..1e293c39 100644 --- a/reports/AccountReport.ts +++ b/reports/AccountReport.ts @@ -230,7 +230,7 @@ export abstract class AccountReport extends LedgerReport { const toDate = dr.toDate.toMillis(); const fromDate = dr.fromDate.toMillis(); - if (fromDate < entryDate && entryDate <= toDate) { + if (entryDate >= fromDate && entryDate < toDate) { return dr; } } @@ -278,9 +278,9 @@ export abstract class AccountReport extends LedgerReport { let fromDate: string; if (this.basedOn === 'Until Date') { - toDate = this.toDate!; + toDate = DateTime.fromISO(this.toDate!).plus({ days: 1 }).toISODate(); const months = monthsMap[this.periodicity] * Math.max(this.count ?? 1, 1); - fromDate = DateTime.fromISO(toDate).minus({ months }).toISODate(); + fromDate = DateTime.fromISO(this.toDate!).minus({ months }).toISODate(); } else { const fy = await getFiscalEndpoints( this.toYear!, @@ -299,7 +299,7 @@ export abstract class AccountReport extends LedgerReport { const { fromDate, toDate } = await this._getFromAndToDates(); const dateFilter: string[] = []; - dateFilter.push('<=', toDate); + dateFilter.push('<', toDate); dateFilter.push('>=', fromDate); filters.date = dateFilter; @@ -342,17 +342,17 @@ export abstract class AccountReport extends LedgerReport { let dateFilters = [ { fieldtype: 'Int', - fieldname: 'toYear', - placeholder: t`To Year`, - label: t`To Year`, + fieldname: 'fromYear', + placeholder: t`From Year`, + label: t`From Year`, minvalue: 2000, required: true, }, { fieldtype: 'Int', - fieldname: 'fromYear', - placeholder: t`From Year`, - label: t`From Year`, + fieldname: 'toYear', + placeholder: t`To Year`, + label: t`To Year`, minvalue: 2000, required: true, }, @@ -407,16 +407,18 @@ export abstract class AccountReport extends LedgerReport { const dateColumns = this._dateRanges!.sort( (a, b) => b.toDate.toMillis() - a.toDate.toMillis() - ).map( - (d) => - ({ - label: this.fyo.format(d.toDate.toJSDate(), 'Date'), - fieldtype: 'Data', - fieldname: 'toDate', - align: 'right', - width: ACC_BAL_WIDTH, - } as ColumnField) - ); + ).map((d) => { + const toDate = d.toDate.minus({ days: 1 }); + const label = this.fyo.format(toDate.toJSDate(), 'Date'); + + return { + label, + fieldtype: 'Data', + fieldname: 'toDate', + align: 'right', + width: ACC_BAL_WIDTH, + } as ColumnField; + }); return [columns, dateColumns].flat(); }