jurgendn commited on
Commit
888971b
·
1 Parent(s): 1748405

[Fix] Return 0 with invalid records, fix wrong time

Browse files
Files changed (2) hide show
  1. .gitignore +5 -0
  2. hr_utils/entities.py +13 -3
.gitignore CHANGED
@@ -6,6 +6,11 @@ __pycache__/
6
  # C extensions
7
  *.so
8
 
 
 
 
 
 
9
  # Distribution / packaging
10
  .Python
11
  build/
 
6
  # C extensions
7
  *.so
8
 
9
+ # Test/Draft files
10
+ test*
11
+ draft*
12
+
13
+
14
  # Distribution / packaging
15
  .Python
16
  build/
hr_utils/entities.py CHANGED
@@ -76,9 +76,13 @@ class WorkingTime(object):
76
 
77
  def morning_shift(self):
78
  if self.error:
79
- return -1
80
  if self.checkin > self.MORNING_OUT:
81
  return 0
 
 
 
 
82
  late_checkin_penalty = self.get_late_checkin(time=self.checkin,
83
  mode='morning_in')
84
  early_checkout_penalty = self.get_early_checkout(time=self.checkout,
@@ -88,13 +92,19 @@ class WorkingTime(object):
88
 
89
  def afternoon_shift(self):
90
  if self.error:
91
- return -1
92
  if self.checkout < self.AFTERNOON_IN:
93
  return 0
 
 
 
 
94
  late_checkin_penalty = self.get_late_checkin(time=self.checkin,
95
  mode='afternoon_in')
96
  early_checkout_penalty = self.get_early_checkout(time=self.checkout,
97
  mode='afternoon_out')
 
 
98
  return (self.AFTERNOON_OUT - self.AFTERNOON_IN
99
  ).seconds // 60 - late_checkin_penalty - early_checkout_penalty
100
 
@@ -107,7 +117,7 @@ class WorkingTime(object):
107
 
108
  def to_tuple(self):
109
  if self.error:
110
- return self.date, -1
111
  return self.date, self.normalize(self.working_time())
112
 
113
 
 
76
 
77
  def morning_shift(self):
78
  if self.error:
79
+ return 0
80
  if self.checkin > self.MORNING_OUT:
81
  return 0
82
+ if self.checkin > self.AFTERNOON_OUT:
83
+ return 0
84
+ if self.checkout < self.MORNING_IN:
85
+ return 0
86
  late_checkin_penalty = self.get_late_checkin(time=self.checkin,
87
  mode='morning_in')
88
  early_checkout_penalty = self.get_early_checkout(time=self.checkout,
 
92
 
93
  def afternoon_shift(self):
94
  if self.error:
95
+ return 0
96
  if self.checkout < self.AFTERNOON_IN:
97
  return 0
98
+ if self.checkin > self.AFTERNOON_OUT:
99
+ return 0
100
+ if self.checkin < self.AFTERNOON_OUT:
101
+ return 0
102
  late_checkin_penalty = self.get_late_checkin(time=self.checkin,
103
  mode='afternoon_in')
104
  early_checkout_penalty = self.get_early_checkout(time=self.checkout,
105
  mode='afternoon_out')
106
+ print(late_checkin_penalty)
107
+ print(early_checkout_penalty)
108
  return (self.AFTERNOON_OUT - self.AFTERNOON_IN
109
  ).seconds // 60 - late_checkin_penalty - early_checkout_penalty
110
 
 
117
 
118
  def to_tuple(self):
119
  if self.error:
120
+ return self.date, 0
121
  return self.date, self.normalize(self.working_time())
122
 
123