From 7a138e5cd693ad4b8f599245a4d1f4e28a2cac6e Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:52:12 +0530 Subject: [PATCH] made current month visibility optioanal --- frontend/mgramseva/lib/providers/reports_provider.dart | 2 +- frontend/mgramseva/lib/utils/common_methods.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/mgramseva/lib/providers/reports_provider.dart b/frontend/mgramseva/lib/providers/reports_provider.dart index eeb74b83d..b0d702262 100644 --- a/frontend/mgramseva/lib/providers/reports_provider.dart +++ b/frontend/mgramseva/lib/providers/reports_provider.dart @@ -166,7 +166,7 @@ class ReportsProvider with ChangeNotifier { ytd = DatePeriod(fromDate,toDate,DateType.YTD); /// Get months based on selected billing year - var months = CommonMethods.getPastMonthUntilFinancialYTD(ytd); + var months = CommonMethods.getPastMonthUntilFinancialYTD(ytd,showCurrentMonth: true); /// if selected year is future year means all the months will be removed if(fromDate.year > ytd.endDate.year) months.clear(); diff --git a/frontend/mgramseva/lib/utils/common_methods.dart b/frontend/mgramseva/lib/utils/common_methods.dart index b35a50527..95c94184d 100644 --- a/frontend/mgramseva/lib/utils/common_methods.dart +++ b/frontend/mgramseva/lib/utils/common_methods.dart @@ -57,7 +57,7 @@ class CommonMethods { * * */ - static List getPastMonthUntilFinancialYTD(DatePeriod ytd) { + static List getPastMonthUntilFinancialYTD(DatePeriod ytd,{bool showCurrentMonth = false}) { var monthList = []; final currentTime = DateTime.now(); if(currentTime.year < ytd.startDate.year){ @@ -65,7 +65,7 @@ class CommonMethods { } if (currentTime.year == ytd.startDate.year) { //when current year is same as start year of financial year - for (int i = ytd.startDate.month; i < currentTime.month; i++) { + for (int i = ytd.startDate.month; i <= (showCurrentMonth?currentTime.month:currentTime.month-1); i++) { monthList.add(DateTime(currentTime.year, i)); } } else if(currentTime.year == ytd.endDate.year){ @@ -74,7 +74,7 @@ class CommonMethods { monthList.add(DateTime(ytd.startDate.year, i)); } for (int i = 1; - i <= (currentTime.month <= ytd.endDate.month ? currentTime.month-1: ytd.endDate.month); + i <= (currentTime.month <= ytd.endDate.month ? showCurrentMonth?currentTime.month:currentTime.month-1: ytd.endDate.month); /* * if current month is less than or equal to end month of financial year * we are using months less than current month and if it is more than