Skip to content

Commit

Permalink
Merge pull request Bahmni#798 from Bahmni/BAH-3049_Reports3
Browse files Browse the repository at this point in the history
BAH-3049 | Fixed Header StopDate not having min value.
  • Loading branch information
riyaTw authored Dec 8, 2023
2 parents bb56ce5 + e44cf06 commit 0bf0b65
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ui/app/reports/controllers/reportsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,25 @@ angular.module('bahmni.reports')
$scope.setDefault = function (item, header) {
var setToChange = (header === 'reportsRequiringDateRange') ? $rootScope.reportsRequiringDateRange : $rootScope.reportsNotRequiringDateRange;
var isPreviousMonth = $rootScope.default[header][item] === dateRange[2];
angular.forEach(setToChange, function (report) {
for (var i = 0; i < setToChange.length; i++) {
var report = setToChange[i];
if (item === 'dateRangeType') {
$rootScope.default.reportsRequiringDateRange.startDate = $rootScope.default[header][item];
$rootScope.default.reportsRequiringDateRange.stopDate = isPreviousMonth ? getPreviousMonthEndDate() : dateRange[0];
report.startDate = $rootScope.default[header][item];
report.stopDate = isPreviousMonth ? getPreviousMonthEndDate() : dateRange[0];
} else if (_.isUndefined($rootScope.default[header][item])) {
report.startDate = $filter('date')(dateRange[0], 'yyyy-MM-dd');
report.stopDate = isPreviousMonth ? getPreviousMonthEndDate() : dateRange[0];
report.responseType = format[1];
$rootScope.default.reportsRequiringDateRange.startDate = dateRange[0];
$rootScope.reportsRequiringDateRange.forEach(function (report) {
report.startDate = $filter('date')(dateRange[0], 'yyyy-MM-dd');
report.stopDate = isPreviousMonth ? getPreviousMonthEndDate() : dateRange[0];
report.responseType = format[1];
});
break;
} else {
report[item] = $rootScope.default[header][item];
}
});
}
};

var getPreviousMonthEndDate = function () {
Expand Down

0 comments on commit 0bf0b65

Please sign in to comment.