Skip to content

Commit

Permalink
Merge pull request #328 from framgia/hris-425
Browse files Browse the repository at this point in the history
[HRIS-425] - [Improvements] Additional Function for Export: Cut-off Filter for DTR
  • Loading branch information
Fontilllas authored Nov 18, 2024
2 parents 34d0340 + a5f9414 commit a0fab50
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 105 deletions.
4 changes: 2 additions & 2 deletions api/Schema/Queries/TimeSheetQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public TimeSheetQuery(TimeSheetService timeSheetService)
}

[AdminUser]
public async Task<List<TimeEntryDTO>> GetTimeEntries(String? date, String? status)
public async Task<List<TimeEntryDTO>> GetTimeEntries(String? startDate, String? endDate, String? status)
{
return await _timeSheetService.GetAll(date, status);
return await _timeSheetService.GetAll(startDate, endDate, status);
}

[AdminUser]
Expand Down
14 changes: 6 additions & 8 deletions api/Services/TimeSheetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static TimeEntryDTO ToTimeEntryDTO(TimeEntry timeEntry, List<Leave> leave
}
}

public async Task<List<TimeEntryDTO>> GetAll(String? date = null, String? status = null)
public async Task<List<TimeEntryDTO>> GetAll(String? startDate = null, String? endDate = null, String? status = null)
{
var domain = _httpService.getDomainURL();
using (HrisContext context = _contextFactory.CreateDbContext())
Expand All @@ -159,16 +159,14 @@ public async Task<List<TimeEntryDTO>> GetAll(String? date = null, String? status
.Select(entry => ToTimeEntryDTO(entry, leaves, domain, null, null))
.ToListAsync();

if (date != null)
if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate))
{
var filterDate = from entry in entries
where DateOnly.Parse(date).CompareTo(entry.Date) == 0
select entry;

entries = filterDate.ToList();

var start = DateOnly.Parse(startDate);
var end = DateOnly.Parse(endDate);
entries = entries.Where(entry => entry.Date >= start && entry.Date <= end).ToList();
}


if (status != null)
{
var filterStatus = from entry in entries
Expand Down
121 changes: 120 additions & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"apexcharts": "^3.36.3",
"classnames": "^2.3.2",
"cookies-next": "^2.1.1",
"date-fns": "^4.1.0",
"emoji-mart": "^5.5.2",
"framer-motion": "^10.0.1",
"graphql": "^16.6.0",
Expand All @@ -34,10 +35,11 @@
"next-auth": "^4.18.8",
"nextjs-progressbar": "^0.0.16",
"rc-tooltip": "^5.2.2",
"react": "18.2.0",
"react": "^18.2.0",
"react-apexcharts": "^1.4.0",
"react-confirm-alert": "^3.0.6",
"react-csv": "^2.2.2",
"react-date-range": "^2.0.1",
"react-dom": "18.2.0",
"react-feather": "^2.0.10",
"react-file-icon": "^1.3.0",
Expand All @@ -58,6 +60,7 @@
"@types/node": "18.11.3",
"@types/react": "18.0.21",
"@types/react-csv": "^1.1.10",
"@types/react-date-range": "^1.4.9",
"@types/react-dom": "18.0.6",
"@types/react-file-icon": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^5.47.1",
Expand Down
Loading

0 comments on commit a0fab50

Please sign in to comment.