TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prem Anandh J
NA
492
30.6k
Calculate salary for week based & distributed Month end
Jul 29 2016 12:19 AM
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
)
//Present
{
if
(FromDate.DayOfWeek.ToString() ==
"Sunday"
)
//Allowance for Sunday work
{
sunOT = sunOT + sunOT
}
if
(FromDate.DayOfWeek.ToString() ==
"Saturday"
)
//Saturday 5 hr work
{
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
//Week day work
{
WorkHr = WorkHr + totalHour
}
cworkedDay +=
float
.Parse(noOfDay.ToString());
}
if
(objLeaveMas !=
null
)
//Leave
{
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
)
//Absent
{
if
(FromDate.DayOfWeek.ToString() != "Sunday)
{
cAbsent += 1;
}
}
FromDate = FromDate.AddDays(1);
}
//End of For loop
}
Reply
Answers (
6
)
Dictionary Error
WMF To Base64String