Skip to content

Commit

Permalink
fix: handle null & empty shift ('') values in Monthly Attendance Sheet (
Browse files Browse the repository at this point in the history
#1123)

* fix: handle null & empty shift ('') values in Monthly Attendance Sheet

* test: empty shift check
  • Loading branch information
ruchamahabal authored Nov 29, 2023
1 parent e802cf9 commit 39eb9c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def get_attendance_map(filters: Filters) -> Dict:
leave_map.setdefault(d.employee, []).append(d.day_of_month)
continue

if d.shift is None:
d.shift = ""

attendance_map.setdefault(d.employee, {}).setdefault(d.shift, {})
attendance_map[d.employee][d.shift][d.day_of_month] = d.status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_detailed_view(self):
self.assertEqual(day_shift_row[1], "A") # absent on the 1st day of the month
self.assertEqual(day_shift_row[2], "P") # present on the 2nd day

self.assertEqual(row_without_shift["shift"], None)
self.assertEqual(row_without_shift["shift"], "")
self.assertEqual(row_without_shift[4], "P") # present on the 4th day

# leave should be shown against every shift
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_attendance_with_group_by_filter(self):
self.assertEqual(day_shift_row[1], "A") # absent on the 1st day of the month
self.assertEqual(day_shift_row[2], "P") # present on the 2nd day

self.assertEqual(row_without_shift["shift"], None)
self.assertEqual(row_without_shift["shift"], "")
self.assertEqual(row_without_shift[3], "L") # on leave on the 3rd day
self.assertEqual(row_without_shift[4], "P") # present on the 4th day

Expand Down

0 comments on commit 39eb9c4

Please sign in to comment.