def get_salary_stat(self):
     db = EMS_db_model()
     logs = db.get_salary_log()[::-1]
     if len(logs) == 0:
         QtGui.QMessageBox.information(self, 'Note',
                                       'There are no salary logs to plot',
                                       None)
         return None
     period = []
     salary = []
     for k, v in groupby(logs, key=lambda x: x['period']):
         if k is None:
             continue
         vlistA = []
         splitter = k.split('/')
         whole_n_part = int(splitter[2].split(' ')[2][2:])
         decimal_part = float(splitter[3] + splitter[4]) * 0.01 / 12
         k = float(whole_n_part + decimal_part)
         k = round(k, 2)
         for i in list(v):
             vlistA.append(i['net_pay'])
         vlistA = sum(vlistA) / len(vlistA)
         period.append(k)
         salary.append(vlistA)
     logs_dict = {
         'key': period,
         'salary_ave': salary,
     }
     return logs_dict
 def get_attendance_stat(self):
     db = EMS_db_model()
     logs = db.get_salary_log()
     if len(logs) == 0:
         QtGui.QMessageBox.information(
             self, 'Note', 'There are no attendance logs to plot', None)
         return None
     period = []
     attendances = []
     absences = []
     for k, v in groupby(logs, key=lambda x: x['period']):
         if k is None:
             continue
         vlistA = []
         vlistB = []
         splitter = k.split('/')
         whole_n_part = int(splitter[2].split(' ')[2])
         decimal_part = float(splitter[3] + splitter[4]) * 0.01 / 12
         k = float(whole_n_part + decimal_part)
         k = round(k, 2)
         for i in list(v):
             vlistA.append(i['days_present'])
             vlistB.append(i['days_absent'])
         vlistA = sum(vlistA) / len(vlistA)
         vlistB = sum(vlistB) / len(vlistB)
         period.append(k)
         attendances.append(vlistA)
         absences.append(vlistB)
     logs_dict = {
         'key': period,
         'attendance_ave': attendances,
         'absence_ave': absences
     }
     return logs_dict
예제 #3
0
 def fetch_salary_logs(self):
     db = EMS_db_model()
     all_logs = db.get_salary_log()
     emp_log = []
     for i in all_logs:
         if i['user'] == self.user_id:
             emp_log.append(i)
     return emp_log