diff --git a/common/model/staff_salary.go b/common/model/staff_salary.go index 6d76001..0e4dc1f 100644 --- a/common/model/staff_salary.go +++ b/common/model/staff_salary.go @@ -1,5 +1,7 @@ package model +import butil "enterprise/base/util" + var ( StaffSalaryStatusNormal = 1 StaffSalaryStatusDisable = 2 @@ -22,3 +24,7 @@ type StaffSalary struct { UpdateTime int64 Extra string } + +func (s *StaffSalary) GetRealSalary() float64 { + return butil.FloatCut(s.AttendSalary + s.AwardSalary - s.SocialInsurence - s.PersonalTax) +} diff --git a/server/service/staff_salary.go b/server/service/staff_salary.go index e89ab4d..bff6320 100644 --- a/server/service/staff_salary.go +++ b/server/service/staff_salary.go @@ -56,7 +56,7 @@ func (s *StaffSalary) Agent(month string, ctx *gin.Context) { item = append(item, cast.ToString(staff.AwardSalary)) item = append(item, cast.ToString(staff.SocialInsurence)) item = append(item, cast.ToString(staff.PersonalTax)) - item = append(item, cast.ToString(butil.FloatCut(staff.RealSalary))) + item = append(item, cast.ToString(staff.GetRealSalary())) datas = append(datas, item) } @@ -112,7 +112,7 @@ func (s *StaffSalary) Bank(month string, ctx *gin.Context) { item := make([]string, 0) item = append(item, baseInfo.BankCard) item = append(item, baseInfo.Realname) - item = append(item, cast.ToString(butil.FloatCut(staff.RealSalary))) + item = append(item, cast.ToString(staff.GetRealSalary())) item = append(item, cast.ToString(baseInfo.BankName)) item = append(item, "重庆市") item = append(item, fmt.Sprintf("%s工资", month)) @@ -181,7 +181,7 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) { item = append(item, cast.ToString(staff.RealDay)) item = append(item, cast.ToString(extra["approvalCheckinDay"])) item = append(item, cast.ToString(staff.Holiday)) - item = append(item, cast.ToString(butil.FloatCut(staff.RealSalary))) + item = append(item, cast.ToString(staff.GetRealSalary())) if staff.TotalDay != cast.ToFloat64(staff.RealDay)+cast.ToFloat64(staff.Holiday) { item = append(item, "【异常】") } else { @@ -195,7 +195,6 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) { summary.SocialInsurence += staff.SocialInsurence summary.PersonalTax += staff.PersonalTax summary.Holiday += staff.Holiday - summary.RealSalary += staff.RealSalary } summary.Holiday = butil.FloatCut(summary.Holiday) summary.BaseSalary = butil.FloatCut(summary.BaseSalary) @@ -206,7 +205,7 @@ func (s *StaffSalary) Summary(month string, ctx *gin.Context) { datas = append(datas, []string{"合计", "-", "-", "-", cast.ToString(summary.BaseSalary), cast.ToString(summary.AttendSalary), cast.ToString(summary.AwardSalary), cast.ToString(summary.SocialInsurence), cast.ToString(summary.PersonalTax), "-", "-", "-", cast.ToString(summary.Holiday), - cast.ToString(butil.FloatCut(summary.RealSalary)), "-"}) + cast.ToString(butil.FloatCut(summary.GetRealSalary())), "-"}) if xls != "" { filename := fmt.Sprintf("summary_%s.xlsx", time.Now().Format("20060102_150405")) diff --git a/worker/staff.go b/worker/staff.go index 314d770..59abdf5 100644 --- a/worker/staff.go +++ b/worker/staff.go @@ -37,7 +37,7 @@ func (s *Staff) SendStaffSalaryBill(month string) { } message = append(message, fmt.Sprintf("社保扣除:%.2f", staffSalary.SocialInsurence)) message = append(message, fmt.Sprintf("个税扣除:%.2f", staffSalary.PersonalTax)) - message = append(message, fmt.Sprintf("实发工资:%.2f", staffSalary.RealSalary)) + message = append(message, fmt.Sprintf("实发工资:%.2f", staffSalary.GetRealSalary())) if err := global.SendMessage([]string{"jiangyong"}, strings.Join(message, "\n")); err != nil { log.Errorf("send message error :%s", err.Error()) @@ -199,7 +199,7 @@ func (s *Staff) SyncStaffSalary(month string) { extra["surplusHoliday"] = surplusHoliday salary.AttendSalary = butil.FloatCut(attendSalary) - salary.RealSalary = butil.FloatCut(attendSalary + salary.AwardSalary - salary.SocialInsurence - salary.PersonalTax) + salary.RealSalary = salary.GetRealSalary() salary.SocialInsurence = socialInsurence salary.Holiday = holiday salary.TotalDay = float64(totalDays)