getApprovalCheckinDay

This commit is contained in:
jiangyong27 2024-03-01 18:04:58 +08:00
parent 2fe3f01c00
commit 46196d16a8
2 changed files with 25 additions and 6 deletions

View File

@ -179,7 +179,7 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
item = append(item, cast.ToString(staff.PersonalTax))
item = append(item, cast.ToString(staff.TotalDay))
item = append(item, cast.ToString(staff.RealDay))
item = append(item, cast.ToString(cast.ToInt(extra["approvalCheckinDay"])))
item = append(item, cast.ToString(extra["approvalCheckinDay"]))
item = append(item, cast.ToString(staff.Holiday))
item = append(item, cast.ToString(butil.FloatCut(staff.RealSalary+staff.AwardSalary-staff.SocialInsurence-staff.PersonalTax)))

View File

@ -163,7 +163,8 @@ func (s *Staff) SyncStaffSalary(month string) {
}
// 打卡正常天数+补卡天数 为正常出勤天数
realWorkDays, approvalCheckinDay := s.getRealWorkDay(staff.Username, month)
realWorkDays := s.getRealWorkDay(staff.Username, month)
approvalCheckinDay := s.getApprovalCheckinDay(staff.Username, month)
extra := make(map[string]interface{})
salary.BaseSalary = cast.ToFloat64(staff.Salary)
salary.Holiday = holiday
@ -183,7 +184,7 @@ func (s *Staff) SyncStaffSalary(month string) {
}
extra["discount"] = discount
extra["approvalCheckinDay"] = approvalCheckinDay
extra["approvalCheckinDay"] = approvalCheckinDay //展示依赖
extra["socialInsurence"] = socialInsurence
extra["days"] = endDate - startDate + 1
extra["startDate"] = startDate
@ -216,12 +217,30 @@ func (s *Staff) SyncStaffSalary(month string) {
}
func (s *Staff) getRealWorkDay(username, month string) (float64, int) {
func (s *Staff) getApprovalCheckinDay(username, month string) int {
approvalDay := int(0)
userCheckins, err := dao.NewCheckinDao().Query(username, month, false)
if err != nil {
log.Errorf("db error :%s", err.Error())
return approvalDay
}
for _, checkin := range userCheckins {
approvalCheckin, _ := dao.NewApprovalCheckinDao().GetByUsernameDay(username, checkin.Day)
if approvalCheckin != nil {
approvalDay += 1
}
}
return approvalDay
}
func (s *Staff) getRealWorkDay(username, month string) float64 {
realWorkdays := float64(0)
userCheckins, err := dao.NewCheckinDao().Query(username, month, false)
if err != nil {
log.Errorf("db error :%s", err.Error())
return realWorkdays, 0
return realWorkdays
}
approvalCheckinDay := 0
for _, checkin := range userCheckins {
@ -244,7 +263,7 @@ func (s *Staff) getRealWorkDay(username, month string) (float64, int) {
continue
}
}
return realWorkdays, approvalCheckinDay
return realWorkdays
}
func (s *Staff) getTotalWorkDay(month string) int64 {