From 5daa7b8b50a1bbd98fb06ccebb6ae6424ee2b86f Mon Sep 17 00:00:00 2001 From: Thamara Andrade Date: Mon, 9 Nov 2020 00:08:14 -0300 Subject: [PATCH] When counting today is enabled, move the balance row after current day Closes #574 --- js/classes/BaseCalendar.js | 3 ++- js/classes/FlexibleMonthCalendar.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js/classes/BaseCalendar.js b/js/classes/BaseCalendar.js index 8828497e5..7cfad1d41 100644 --- a/js/classes/BaseCalendar.js +++ b/js/classes/BaseCalendar.js @@ -104,7 +104,8 @@ class BaseCalendar } let balanceRowPosition = 0; - for (let day = 1; day < this._getTodayDate(); ++day) + const lastDay = this._getCountToday() ? this._getTodayDate() + 1 : this._getTodayDate(); + for (let day = 1; day < lastDay; ++day) { if (this._showDay(this._getCalendarYear(), this._getCalendarMonth(), day)) { diff --git a/js/classes/FlexibleMonthCalendar.js b/js/classes/FlexibleMonthCalendar.js index c21bd8ecd..a573772bf 100644 --- a/js/classes/FlexibleMonthCalendar.js +++ b/js/classes/FlexibleMonthCalendar.js @@ -513,6 +513,11 @@ class FlexibleMonthCalendar extends BaseCalendar let monthTotal = '00:00'; let workingDays = 0; let stopCountingMonthStats = false; + let lastDateToCount = new Date(this._getCalendarYear(), this._getCalendarMonth(), this._getCalendarDate()); + if (this._getCountToday()) + { + lastDateToCount.setDate(lastDateToCount.getDate() + 1); + } for (let day = 1; day <= monthLength; ++day) { if (!this._showDay(this._getCalendarYear(), this._getCalendarMonth(), day)) @@ -536,7 +541,7 @@ class FlexibleMonthCalendar extends BaseCalendar this._colorErrorLine(dateKey); } - stopCountingMonthStats |= (this._getTodayDate() === day && this._getTodayMonth() === this._getCalendarMonth() && this._getTodayYear() === this._getCalendarYear()); + stopCountingMonthStats |= (lastDateToCount.getDate() === day && lastDateToCount.getMonth() === this._getCalendarMonth() && lastDateToCount.getFullYear() === this._getCalendarYear()); if (stopCountingMonthStats) { continue;