NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

private PR480PayrollHrsExcelModel Create480PRPayrollExcelModel(CandidatesRecordModel item, DateTime parsedStartDate, DateTime parsedEndDate, List<Deductions> deductions, List<Reimbursement> reimbursements,
List<EmployeeTimesheet> employeeTimesheets, List<PR480PayrollHelper> pr480PayrollHelper, SendData getRegularHoursDate)
{
try
{
PR480PayrollHrsExcelModel pr480PayrollHrsExcelModel = new();

string billRates = string.Empty;
pr480PayrollHrsExcelModel.LastName = item.LastName;
pr480PayrollHrsExcelModel.FirstName = item.FirstName;
pr480PayrollHrsExcelModel.FullName = $"{item.FirstName} {item.LastName}";
pr480PayrollHrsExcelModel.Email = item.Email;

pr480PayrollHrsExcelModel.StartId = item.SalaryStartId;
pr480PayrollHrsExcelModel.RecId = item.SalaryRecId;
pr480PayrollHrsExcelModel.TypeOfBankDeposit = item.BankTypeACH;

var billingStartDate = DateTime.Parse(item.BillingStartDate);
pr480PayrollHrsExcelModel.StartDate = billingStartDate.ToString(AppConstants.DateFormatMDY);
pr480PayrollHrsExcelModel.EmployeeId = item.CandidateId;
pr480PayrollHrsExcelModel.CoCode = AppConstants.CoCodeY1C;

if (item.SalaryPer != null && item.EmpSalary != null)
{
decimal payRate = Convert.ToDecimal(objectCalculation.GetPayRate(item.SalaryPer, item.EmpSalary));
if (payRate != 0 && payRate != 1)
{
pr480PayrollHrsExcelModel.PayRate = $"${payRate.ToString(AppConstants.DefaultTwoDigits)}";
pr480PayrollHrsExcelModel.getPayRate = payRate.ToString();
}
}
if (item.BillRatePer != null && item.BillRate != null)
{
decimal billRate = Convert.ToDecimal(objectCalculation.GetBillRate(item.BillRatePer, item.BillRate));
if (billRate != 0 && item.CompanyId != AppConstants.CompanyId && item.SalaryPer == "H")
{
billRates = billRate.ToString();
}
}
var pr480Helper = pr480PayrollHelper.Where(x => x.StartId == item.SalaryStartId).FirstOrDefault();
pr480PayrollHrsExcelModel.PR480HelperTableId = pr480Helper?.Id;

if (pr480Helper != null)
{
pr480PayrollHrsExcelModel.RegistrationCode = pr480Helper.RegistrationCode;
pr480PayrollHrsExcelModel.ExpirationDate = pr480Helper.ExpirationDate;
pr480PayrollHrsExcelModel.AssociateID = pr480Helper.AssociateID;
decimal variableHours = Convert.ToDecimal(pr480Helper.VariableHours);
if (variableHours != 0)
{
pr480PayrollHrsExcelModel.VariableHours = variableHours.ToString(AppConstants.DefaultFiveDigits);
}
decimal otherEarning = Convert.ToDecimal(pr480Helper.OtherEarning);
if (otherEarning != 0)
{
pr480PayrollHrsExcelModel.OtherEarning = $"${otherEarning.ToString(AppConstants.DefaultFiveDigits)}";
}
decimal bonus = Convert.ToDecimal(pr480Helper.Bonus);
if (bonus != 0)
{
pr480PayrollHrsExcelModel.Bonus = $"${bonus.ToString(AppConstants.DefaultFiveDigits)}";
}
pr480PayrollHrsExcelModel.Memo = pr480Helper.Memo;
}

var deduction = deductions.Where(x => x.EmpStartId == item.SalaryStartId).ToList();
if (deduction.Any())
{
decimal totalDeduction = deduction.Sum(x => Convert.ToDecimal(x.DeductionAmount));
if (totalDeduction != 0)
{
pr480PayrollHrsExcelModel.Deductions = $"${totalDeduction.ToString(AppConstants.DefaultFiveDigits)}";
}
}
var reimbursement = reimbursements.Where(x => x.EmployeeStartId == item.SalaryStartId).ToList();
if (reimbursement.Any() == true)
{
decimal totalReimbursements = reimbursement.Sum(x => Convert.ToDecimal(x.ReimbursementAmount));
if (totalReimbursements != 0)
{
pr480PayrollHrsExcelModel.Reimbursements = $"${totalReimbursements.ToString(AppConstants.DefaultFiveDigits)}";
}
}
DateTime firstStartDate = getRegularHoursDate.Regular0hrs.FirstOrDefault();
DateTime firstEndDate = getRegularHoursDate.Regular0hrs.LastOrDefault();

DateTime secondStartDate = getRegularHoursDate.Regular1hrs.FirstOrDefault();
DateTime secondEndDate = getRegularHoursDate.Regular1hrs.LastOrDefault();

DateTime thirdStartDate = getRegularHoursDate.Regular2hrs.FirstOrDefault();
DateTime thirdEndDate = getRegularHoursDate.Regular2hrs.LastOrDefault();

DateTime fourthStartDate = getRegularHoursDate.Regular3hrs.FirstOrDefault();
DateTime fourthEndDate = getRegularHoursDate.Regular3hrs.LastOrDefault();

DateTime fifthStartDate = getRegularHoursDate.Regular4hrs.FirstOrDefault();
DateTime fifthEndDate = getRegularHoursDate.Regular4hrs.LastOrDefault();

DateTime sixthStartDate = getRegularHoursDate.Regular5hrs.FirstOrDefault();
DateTime sixthEndDate = getRegularHoursDate.Regular5hrs.LastOrDefault();

DateTime seventhStartDate = getRegularHoursDate.Regular6hrs.FirstOrDefault();
DateTime seventhEndDate = getRegularHoursDate.Regular6hrs.LastOrDefault();

DateTime eighthStartDate = getRegularHoursDate.Regular7hrs.FirstOrDefault();
DateTime eighthEndDate = getRegularHoursDate.Regular7hrs.LastOrDefault();

var employeeTimesheet = employeeTimesheets.Where(x => x.StartId == item.SalaryStartId && x.BillRate == billRates).ToList();
decimal totalRegHours0 = employeeTimesheet.Where(x => x.TDATE >= firstStartDate && x.TDATE <= firstEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours1 = employeeTimesheet.Where(x => x.TDATE >= secondStartDate && x.TDATE <= secondEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours2 = employeeTimesheet.Where(x => x.TDATE >= thirdStartDate && x.TDATE <= thirdEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours3 = employeeTimesheet.Where(x => x.TDATE >= fourthStartDate && x.TDATE <= fourthEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours4 = employeeTimesheet.Where(x => x.TDATE >= fifthStartDate && x.TDATE <= fifthEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours5 = employeeTimesheet.Where(x => x.TDATE >= sixthStartDate && x.TDATE <= sixthEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours6 = employeeTimesheet.Where(x => x.TDATE >= seventhStartDate && x.TDATE <= seventhEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));
decimal totalRegHours7 = employeeTimesheet.Where(x => x.TDATE >= eighthStartDate && x.TDATE <= eighthEndDate).Sum(x => Convert.ToDecimal(x.RegHours) + Convert.ToDecimal(x.OtHours));

pr480PayrollHrsExcelModel.TotalRegularHours = (totalRegHours0 + totalRegHours1 + totalRegHours2 + totalRegHours3 + totalRegHours4 + totalRegHours5 + totalRegHours6 + totalRegHours7).ToString(AppConstants.DefaultTwoDigits);

decimal subTotalHours = (Convert.ToDecimal(pr480PayrollHrsExcelModel.TotalRegularHours) + Convert.ToDecimal(pr480PayrollHrsExcelModel.VariableHours));
pr480PayrollHrsExcelModel.TotalHours = subTotalHours.ToString(AppConstants.DefaultFiveDigits);

decimal grossPay = subTotalHours * Convert.ToDecimal(pr480PayrollHrsExcelModel.getPayRate);
pr480PayrollHrsExcelModel.GrossPay = $"${grossPay.ToString(AppConstants.DefaultFiveDigits)}";

decimal wh10Percent = CalculateWH10Percent(grossPay, parsedEndDate);
pr480PayrollHrsExcelModel.WH10Payroll = $"${wh10Percent.ToString(AppConstants.DefaultFiveDigits)}";

decimal totalEarning = (Convert.ToDecimal(pr480PayrollHrsExcelModel.GrossPay?.Replace(@"$", string.Empty)) + Convert.ToDecimal(pr480PayrollHrsExcelModel.Reimbursements?.Replace(@"$", string.Empty))) - Convert.ToDecimal(pr480PayrollHrsExcelModel.Deductions?.Replace(@"$", string.Empty));
pr480PayrollHrsExcelModel.TotalEarnings = $"${totalEarning.ToString(AppConstants.DefaultFiveDigits)}";

decimal netPayroll = Convert.ToDecimal(pr480PayrollHrsExcelModel.GrossPay?.Replace(@"$", string.Empty)) + Convert.ToDecimal(pr480PayrollHrsExcelModel.OtherEarning?.Replace(@"$", string.Empty)) + Convert.ToDecimal(pr480PayrollHrsExcelModel.Bonus?.Replace(@"$", string.Empty)) - Convert.ToDecimal(pr480PayrollHrsExcelModel.Deductions?.Replace(@"$", string.Empty)) + Convert.ToDecimal(pr480PayrollHrsExcelModel.Reimbursements?.Replace(@"$", string.Empty)) - Convert.ToDecimal(pr480PayrollHrsExcelModel.WH10Payroll?.Replace(@"$", string.Empty));
pr480PayrollHrsExcelModel.TotalPayroll = $"${netPayroll.ToString(AppConstants.DefaultFiveDigits)}";

return pr480PayrollHrsExcelModel;
}
catch (Exception exception)
{
Log.Error($"Error in Create480PRPayrollExcelModel: {exception.Message}");
throw;
}
}

private decimal CalculateWH10Percent(decimal grossPay, DateTime endDate)
{
decimal wh10Percent = 0;
if (grossPay > 500 && endDate.Month == 1 && endDate.Day <= 15)
{
wh10Percent = ((grossPay - 500) * 10) / 100;
}
else
{
wh10Percent = (10 * grossPay) / 100;
}
return wh10Percent;
}

this is my code and please write code for WH10Percent calculations on the basis of this above code
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.