Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #548 from egovernments/PFM-4079
Browse files Browse the repository at this point in the history
made current month visibility optioanal
  • Loading branch information
rahuldevgarg authored Sep 8, 2023
2 parents e071328 + 7a138e5 commit e84880e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/mgramseva/lib/providers/reports_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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();
Expand Down
6 changes: 3 additions & 3 deletions frontend/mgramseva/lib/utils/common_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class CommonMethods {
*
* */

static List<DatePeriod> getPastMonthUntilFinancialYTD(DatePeriod ytd) {
static List<DatePeriod> getPastMonthUntilFinancialYTD(DatePeriod ytd,{bool showCurrentMonth = false}) {
var monthList = <DateTime>[];
final currentTime = DateTime.now();
if(currentTime.year < ytd.startDate.year){
return <DatePeriod>[];
}
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){
Expand All @@ -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
Expand Down

0 comments on commit e84880e

Please sign in to comment.