Skip to content

Commit

Permalink
Merge pull request Bahmni#794 from Bahmni/BAH-3049_Reports
Browse files Browse the repository at this point in the history
BAH-3049 | Fix. getTime error when format is changed.
  • Loading branch information
riyaTw authored Dec 5, 2023
2 parents 8cb47d7 + b7f0d14 commit adf3759
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/app/reports/controllers/reportsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ angular.module('bahmni.reports')
$scope.enableReportQueue = appService.getAppDescriptor().getConfigValue("enableReportQueue");
$scope.setDefault = function (item, header) {
var setToChange = header === 'reportsRequiringDateRange' ? $rootScope.reportsRequiringDateRange : $rootScope.reportsNotRequiringDateRange;
var isPreviousMonth = $rootScope.default[header][item] && $rootScope.default[header][item].getTime() === dateRange[2].getTime();
var isPreviousMonth = $rootScope.default[header][item] && $rootScope.default[header][item] === dateRange[2];
setToChange.forEach(function (report) {
if (item == 'dateRangeType') {
$rootScope.default.reportsRequiringDateRange.startDate = $rootScope.default[header][item];
Expand Down
9 changes: 5 additions & 4 deletions ui/test/unit/reports/controllers/reportsController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,21 @@ describe("ReportsController", function () {
return mockedDate;
}
});
var previousMonthStartDate = new originalDate(expectedStartDate);
reportServiceMock.getAvailableDateRange.and.returnValue({
"Today": mockedDate,
"This Month": new originalDate('1-Jan-2023'),
"Previous Month": new originalDate(expectedStartDate)
"Previous Month": previousMonthStartDate
});
setupController();

rootScope.default.reportsRequiringDateRange = {
dateRangeType: new originalDate(expectedStartDate),
dateRangeType: previousMonthStartDate,
};
scope.setDefault('dateRangeType', 'reportsRequiringDateRange');

expect(rootScope.reportsRequiringDateRange[0].startDate.getTime()).toBe(new originalDate(expectedStartDate).getTime());
expect(rootScope.reportsRequiringDateRange[0].stopDate.getTime()).toBe(new originalDate(expectedStopDate).getTime());
expect(rootScope.reportsRequiringDateRange[0].startDate).toEqual(new originalDate(expectedStartDate));
expect(rootScope.reportsRequiringDateRange[0].stopDate).toEqual(new originalDate(expectedStopDate));
});
});

Expand Down

0 comments on commit adf3759

Please sign in to comment.