approvalCheckinDay

This commit is contained in:
jiangyong27 2024-03-01 17:52:24 +08:00
parent 2f678ed714
commit 2fe3f01c00
2 changed files with 13 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package service
import (
"encoding/json"
butil "enterprise/base/util"
"enterprise/common/config"
"enterprise/common/dao"
@ -152,7 +153,7 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
panic(config.ErrDb.New().Append(err))
}
header := []string{"姓名", "身份证号", "入职日期", "转正日期", "基本工资", "出勤工资", "奖金", "社保扣除", "个税扣除", "应出勤天数", "实际出勤天数", "请假天数", "实发工资"}
header := []string{"姓名", "身份证号", "入职日期", "转正日期", "基本工资", "出勤工资", "奖金", "社保扣除", "个税扣除", "应出勤天数", "实际出勤天数", "补卡天数", "请假天数", "实发工资"}
datas := make([][]string, 0)
summary := new(model.StaffSalary)
for _, staff := range staffSalarys {
@ -164,7 +165,8 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
if baseInfo == nil {
continue
}
extra := make(map[string]interface{})
json.Unmarshal([]byte(staff.Extra), &extra)
item := make([]string, 0)
item = append(item, baseInfo.Realname)
item = append(item, cast.ToString(baseInfo.Idno))
@ -177,6 +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(staff.Holiday))
item = append(item, cast.ToString(butil.FloatCut(staff.RealSalary+staff.AwardSalary-staff.SocialInsurence-staff.PersonalTax)))
@ -196,8 +199,7 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) {
summary.PersonalTax = butil.FloatCut(summary.PersonalTax)
datas = append(datas, []string{"合计", "-", "-", "-",
cast.ToString(summary.BaseSalary), cast.ToString(summary.RealSalary), cast.ToString(summary.AwardSalary), cast.ToString(summary.SocialInsurence),
"-", "-",
cast.ToString(summary.PersonalTax), cast.ToString(summary.Holiday),
cast.ToString(summary.PersonalTax), "-", "-", "-", cast.ToString(summary.Holiday),
cast.ToString(butil.FloatCut(summary.RealSalary + summary.AwardSalary - summary.SocialInsurence - summary.PersonalTax))})
if xls != "" {

View File

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