I want to generate payroll for employees those are getting weekly salary.
Salary distributed at end of the month. So month end i have to calculate the salary based on each and every week. one week can assume from Mon to Sun(7 days) .
For ex,July month salary has to calculate
sal= 01-07-16 to 03-07-16(friday to sun) +
04-07-16 to 10-07-16(mon to sun) +
11-07-16 to 17-07-16(Mon to sun) +
18-07-16 to 24-07-16(mon to sun) +
25-07-16 to 31-07-16(mon to sun).
Each and every week their will be OT ,Allowance, Deductions,Paid Leave.
Here How to Split the week (Monday to Sunday) for the given salary date? Then only I can salary and OT for each and every week. I tried a code. It’s good for monthly salary but not correct for weekly salary..
I used Employee clocker punches as input. Based on that am calculating the working days.
- Private void calculatePayroll(string ID, DateTime FromDate, DateTime ToDate)
- {
- float cworkedDay = 0, cPaidLeave = 0, cAbsent = 0;
- TimeSpan vWorkHr, vweekOT, vsatOT, vsunOT;
- while (FromDate <= ToDate)
- {
- var objAttMas = getAttendance(EmpID, FromDate);
- var objLeaveMas = getLeave(empID, FromDate)if (objAttMas != null)
- {
- if (FromDate.DayOfWeek.ToString() == "Sunday")
- {
- sunOT = sunOT + sunOT
- }
-
- if (FromDate.DayOfWeek.ToString() == "Saturday")
- {
- if (totalHour < new TimeSpan(5, 0, 0))
- {
- totalHour = WorkHr + totalHour )
- ;
- }
- else
- {
- satOT = satOT + totalHour - new TimeSpan(5, 0, 0) )
- ;
- WorkHr = WorkHr + TimeSpan(5, 0, 0) )
- ;
- }
- }
- else
- {
- WorkHr = WorkHr + totalHour
- }
-
- cworkedDay += float.Parse(noOfDay.ToString());
- }
-
- if (objLeaveMas != null)
- {
- var objleaveType = getLeaveType(leaveType)if (objleaveType != null)
- {
- if (FromDate.DayOfWeek.ToString() == "Saturday")
- {
- if (objleaveType.incWeekend == 1)
- {
- cPaidLeave += float.Parse(objLeaveMas.noOfDay.ToString());
- }
- else
- {
- cAbsent += float.Parse(objLeaveMas.noOfDay.ToString());
- }
- }
- else
- {
- if (objleaveType.paidLeave == 1)
- {
- cPaidLeave += float.Parse(objLeaveMas.noOfDay.ToString());
- }
- else
- {
- cAbsent += float.Parse(objLeaveMas.noOfDay.ToString());
- }
- }
- }
- }
-
- if (objAttMas != null && objLeaveMas != null)
- {
- if (FromDate.DayOfWeek.ToString() != "Sunday)
- {
- cAbsent += 1;
- }
- }
-
- FromDate = FromDate.AddDays(1);
- }
- }