Skip to content

Commit

Permalink
BAH-3049|Deepti,Sweety|Fix. Header StopDate not having min value.
Browse files Browse the repository at this point in the history
  • Loading branch information
deeptirawat1510 committed Dec 7, 2023
1 parent bb56ce5 commit e44cf06
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 e44cf06

Please sign in to comment.