public static dynamic GetPaymentSheet(PayrunDetail_Dto curDetail, IJsonSerializer jsonSerializer) { List <PayrunAllowanceSummary_Dto> payrunAllowances = curDetail.PayrunAllowancesSummaries.ToList(); PayrunAllowanceSummary_Dto housingAllowance = payrunAllowances.LastOrDefault(x => x.AllowanceType.Value == "Housing"); string otherAllowancesSum = "" + (payrunAllowances.Sum(x => x.Value) - (housingAllowance == null ? 0 : housingAllowance.Value)).ToString("N2"); DateTime curPeriod = new DateTime(curDetail.Year, curDetail.Month, 1); dynamic paymentSlipDSRow = new ExpandoObject(); paymentSlipDSRow.payrunId = curDetail.PayrunId; paymentSlipDSRow.getEmpRefCode = curDetail.Employee.GetReferenceId; paymentSlipDSRow.getEmpName = curDetail.Employee.Name; FinancialDetails financialDetails = jsonSerializer.Deserialize <FinancialDetails>(curDetail.Employee.ExtraProperties["financialDetails"].ToString()); BanksRDTO curBank = financialDetails.Banks.Last();//financialDetails.Banks.SingleOrDefault(x => DateTime.Parse(x.FromDate).Month >= curPeriod.Month && DateTime.Parse(x.ToDate).Month <= curPeriod.Month); paymentSlipDSRow.getBankName = curBank.GetBankName; paymentSlipDSRow.getBankIBAN = curBank.BankIBAN; paymentSlipDSRow.getBasicSalary = "" + curDetail.BasicSalary.ToString("N2"); paymentSlipDSRow.getAllowanceHousing = housingAllowance == null ? "—" : "" + housingAllowance.Value.ToString("N2"); paymentSlipDSRow.getOtherIncome = otherAllowancesSum; paymentSlipDSRow.getDeductions = "" + curDetail.GrossDeductions.ToString("N2"); paymentSlipDSRow.getPayment = "" + curDetail.NetAmount.ToString("N2"); paymentSlipDSRow.month = curDetail.Month; paymentSlipDSRow.year = curDetail.Year; return(paymentSlipDSRow); }
public SocialInsuranceReport_Dto GetSIReport(PayrunDetail_Dto detail) { double upperLimit = SocialInsuranceAppService.GetCurrentSetup().SI_UpperLimit; List <PayrunAllowanceSummary_Dto> payrunAllowances = detail.PayrunAllowancesSummaries.Where(x => x.AllowanceType.Dimension_1_Value.ToUpper() == "TRUE").ToList(); GeneralInfo generalInfo = JsonSerializer.Deserialize <GeneralInfo>(detail.Employee.ExtraProperties["generalInfo"].ToString()); PhysicalId <Guid> currentPhysicalId = generalInfo.PhysicalIds.Last(x => x.GetIDTypeValue == "Iqama" && x.EndDate <= DateTime.Now); string empPhysicalIdNumber = currentPhysicalId.IDNumber; SocialInsuranceReport_Dto siDSRow = new SocialInsuranceReport_Dto(); siDSRow.Payrun = detail.Payrun; siDSRow.PayrunId = detail.PayrunId; siDSRow.Employee = detail.Employee; siDSRow.EmployeeId = detail.EmployeeId; siDSRow.EmpID = empPhysicalIdNumber; siDSRow.EmpSIId = detail.Employee.SocialInsuranceId; double curBasicSalary = (double)detail.BasicSalary; siDSRow.BasicSalary = curBasicSalary; siDSRow.PayrunDate = new DateTime(detail.Year, detail.Month, detail.CreationTime.Day); siDSRow.PayrunSIAllowancesSummaries = payrunAllowances;//payrunAllowances.Select(x => x.a); siDSRow.TotalSISalary = (double)siDSRow.PayrunSIAllowancesSummaries.Sum(x => x.Value); siDSRow.TotalSISalary += curBasicSalary; siDSRow.TotalSISalary = Math.Min(upperLimit, siDSRow.TotalSISalary); return(siDSRow); }
private IActionResult GetPayrun(int month, int year) { Payrun_Dto payrun = null; if (year != 0 && month != 0) { payrun = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Year == year && x.Month == month)); } List <PayrunDetail_Dto> payrunDetails = payrun == null ? new List <PayrunDetail_Dto>() : payrun.PayrunDetails.ToList(); List <dynamic> dynamicDS = new List <dynamic>(); for (int i = 0; i < payrunDetails.Count; i++) { PayrunDetail_Dto payrunDetail = payrunDetails[i]; dynamic dynamicDSRow = new ExpandoObject(); dynamic employeeDynamic = new ExpandoObject(); dynamicDSRow.employeeId = payrunDetail.EmployeeId; dynamicDSRow.getEmployeeReferenceId = payrunDetail.Employee.GetReferenceId; dynamicDSRow.getEmployeeName = payrunDetail.Employee.Name; dynamicDSRow.getEmployeeDepartmentName = payrunDetail.Employee.Department.Name; dynamicDSRow.getEmployeePositionTitle = payrunDetail.Employee.Position.Title; dynamicDSRow.basicSalary = payrunDetail.BasicSalary; foreach (PayrunAllowanceSummary_Dto allowanceSummary in payrunDetail.PayrunAllowancesSummaries) { DictionaryValue_Dto allowance = allowanceSummary.AllowanceType; string camelCaseName = allowance.Value; camelCaseName = camelCaseName.Replace(" ", ""); camelCaseName = char.ToLowerInvariant(camelCaseName[0]) + camelCaseName.Substring(1); DynamicHelper.AddProperty(dynamicDSRow, $"{camelCaseName}_Value", allowanceSummary.Value); } dynamicDSRow.grossEarnings = payrunDetail.GrossEarnings; dynamicDSRow.gosiValue = payrunDetail.GOSIAmount; dynamicDSRow.loansValue = payrunDetail.Loan; dynamicDSRow.leavesValue = payrunDetail.Leaves; dynamicDSRow.grossDeductions = payrunDetail.GrossDeductions; dynamicDSRow.netAmount = payrunDetail.NetAmount; dynamicDS.Add(dynamicDSRow); } if (payrunDetails == null || payrunDetails.Count == 0) { return(StatusCode(500)); } else { return(new JsonResult(new { dataSource = dynamicDS, isPosted = payrun.IsPosted })); } }
public async Task <IActionResult> OnGet() { payrun = await PayrunAppService.GetAsync(payrunId.Value); if (payrun != null) { List <PayrunDetail_Dto> payrunDetails = payrun.PayrunDetails.ToList(); for (int i = 0; i < payrunDetails.Count; i++) { PayrunDetail_Dto curDetail = payrunDetails[i]; dynamic paymentSlipDSRow = PayrollService.GetPaymentSheet(curDetail, JsonSerializer); paymentSlipDSRow.isPosted = payrun.IsPSPosted; dynamicDS.Add(paymentSlipDSRow); dynamicDSS = JsonSerializer.Serialize(dynamicDS); } } return(Page()); }
public IActionResult OnGet() { EOSBAllowances = DicValuesRepo.Where(x => x.ValueType.ValueTypeFor == ValueTypeModules.AllowanceType && x.Dimension_1_Value.ToUpper() == "TRUE").ToList(); payrun = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Id == payrunId)); Payrun_Dto payrunLast = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Month == payrun.Month - 1 && x.Year == payrun.Year)); if (payrun != null) { List <PayrunDetail_Dto> payrunDetails = payrun.PayrunDetails.ToList(); List <dynamic> dynamicDS = new List <dynamic>(); for (int i = 0; i < payrunDetails.Count; i++) { PayrunDetail_Dto curDetail = payrunDetails[i]; if (curDetail.Employee.IndemnityType == null || curDetail.Employee.IndemnityType.Value != "Eligible") { continue; } PayrunDetailIndemnity_Dto employeeIndemnity = null; if (curDetail.Indemnity != null) { employeeIndemnity = curDetail.Indemnity; } else { employeeIndemnity = curDetail.GetIndemnity(); } PayrunDetail_Dto curDetailLast = payrunLast == null ? null : payrunLast.PayrunDetails.FirstOrDefault(x => x.EmployeeId == curDetail.EmployeeId); PayrunDetailIndemnity_Dto employeeIndemnityLast = curDetailLast != null?curDetailLast.GetIndemnity() : null; if (employeeIndemnityLast != null) { employeeIndemnity.LastMonthEOSB = employeeIndemnityLast.TotalEOSB; employeeIndemnity.Difference = employeeIndemnity.LastMonthEOSB - employeeIndemnity.TotalEOSB; } dynamic indemnityDSRow = new ExpandoObject(); indemnityDSRow.payrunId = payrunId; indemnityDSRow.sNo = i + 1; indemnityDSRow.Id = employeeIndemnity.Id; indemnityDSRow.EmployeeId = employeeIndemnity.EmployeeId; indemnityDSRow.getEmpRefCode = employeeIndemnity.Employee.GetReferenceId; indemnityDSRow.getEmpName = employeeIndemnity.Employee.Name; indemnityDSRow.getEmpDepartment = employeeIndemnity.Employee.Department.Name; indemnityDSRow.getEmpDOJ = employeeIndemnity.Employee.JoiningDate; indemnityDSRow.BasicSalary = "" + employeeIndemnity.BasicSalary.ToString("N2"); foreach (PayrunAllowanceSummary_Dto eosbAllowance in employeeIndemnity.PayrunEOSBAllowancesSummaries) { DynamicHelper.AddProperty(indemnityDSRow, $"{eosbAllowance.AllowanceType.Value}_Value", "" + eosbAllowance.Value.ToString("N2")); } indemnityDSRow.GrossSalary = "" + employeeIndemnity.GrossSalary.ToString("N2"); indemnityDSRow.TotalEmploymentDays = employeeIndemnity.TotalEmploymentDays; indemnityDSRow.TotalPre5EmploymentDays = employeeIndemnity.TotalPre5EmploymentDays; indemnityDSRow.TotalPost5EmploymentDays = employeeIndemnity.TotalPost5EmploymentDays; indemnityDSRow.TotalEOSB = "" + employeeIndemnity.TotalEOSB.ToString("N2"); indemnityDSRow.LastMonthEOSB = "" + employeeIndemnity.LastMonthEOSB.ToString("N2"); indemnityDSRow.ActuarialEvaluation = "" + employeeIndemnity.ActuarialEvaluation.ToString("N2"); indemnityDSRow.Difference = "" + employeeIndemnity.Difference.ToString("N2"); indemnityDSRow.PayrunDetailId = curDetail.Id; indemnityDSRow.month = curDetail.Month; indemnityDSRow.year = curDetail.Year; dynamicDS.Add(indemnityDSRow); } //JsonResult eosbDSJson = new JsonResult(dynamicDS); _dynamicDS = new ExpandoObject(); _dynamicDS.EOSBDS = JsonSerializer.Serialize(dynamicDS); _dynamicDS.month = payrun.Month; _dynamicDS.year = payrun.Year; _dynamicDS.isPosted = payrun.IsIndemnityPosted; } return(Page()); }
public IActionResult OnGet(int P1Year, int P1Month, int P2Year, int P2Month, bool isAjax) { bool isOnGet = P1Year != 0 && P2Year != 0; if (!isOnGet) { return(Page()); } try { bool isPeriodValid = true; Payrun_Dto fromPayrun = null; Payrun_Dto toPayrun = null; fromPayrun = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Year == P1Year && x.Month == P1Month)); toPayrun = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Year == P2Year && x.Month == P2Month)); if (fromPayrun == null || toPayrun == null) { isPeriodValid = false; } if (!isPeriodValid) { return(BadRequest(new { type = "period" })); } List <dynamic> payrunReconSummaryDynamicDS = new List <dynamic>(); if (fromPayrun != null && toPayrun != null) { Allowances = DicValuesRepo.WithDetails(x => x.ValueType).Where(x => x.ValueType.ValueTypeFor == ValueTypeModules.AllowanceType).ToList(); List <PayrunDetail_Dto> fromPDetails = fromPayrun.PayrunDetails.ToList(); List <PayrunDetail_Dto> toPDetails = toPayrun.PayrunDetails.ToList(); List <(PayrunDetail_Dto fromPDetail, PayrunDetail_Dto toPDetail)> payrunReconDetails = new List <(PayrunDetail_Dto fromPDetail, PayrunDetail_Dto toPDetail)>(); var toExplicits = toPDetails.Where(x => !fromPDetails.Any(x1 => x1.EmployeeId == x.EmployeeId)) .Select(x => { return((PayrunDetail_Dto)null, x); }); payrunReconDetails.AddRange(toExplicits); payrunReconDetails.AddRange(fromPDetails.Select(x => { if (toPDetails.Exists(x1 => x1.EmployeeId == x.EmployeeId)) { return(x, toPDetails.Single(x1 => x1.EmployeeId == x.EmployeeId)); } else { return(x, null); } })); for (int i = 0; i < payrunReconDetails.Count; i++) { var reconDetail = payrunReconDetails[i]; PayrunDetail_Dto fromD = reconDetail.fromPDetail; PayrunDetail_Dto toD = reconDetail.toPDetail; dynamic payrunReconEmpDDSRow = new ExpandoObject(); if (fromD != null || toD != null) { bool isFromD = fromD != null; bool isToD = toD != null; bool both = isToD && isFromD; Employee_Dto emp = isFromD ? fromD.Employee : toD.Employee; payrunReconEmpDDSRow.getCompanyName = emp.Department.Company.CompanyName; payrunReconEmpDDSRow.getCompanyAddress = emp.Department.Company.CompanyLocations[0].Location.LocationName; payrunReconEmpDDSRow.getEmployeeReferenceId = emp.GetReferenceId; payrunReconEmpDDSRow.getEmployeeName = emp.Name; payrunReconEmpDDSRow.getEmployeeDepartmentName = emp.Department.Name; payrunReconEmpDDSRow.getEmployeePositionTitle = emp.Position.Title; if (both) { List <(PayrunAllowanceSummary_Dto fromAllowance, PayrunAllowanceSummary_Dto toAllowance)> allowancesReconDetails = new List <(PayrunAllowanceSummary_Dto fromAllowance, PayrunAllowanceSummary_Dto toAllowance)>(); var toAllowancesExplicits = toD.PayrunAllowancesSummaries.Where(x => !fromD.PayrunAllowancesSummaries.Any(x1 => x1.AllowanceTypeId == x.AllowanceTypeId)) .Select(x => { return((PayrunAllowanceSummary_Dto)null, x); }); allowancesReconDetails.AddRange(toAllowancesExplicits); allowancesReconDetails.AddRange(fromD.PayrunAllowancesSummaries.Select(x => { if (toD.PayrunAllowancesSummaries.Any(x1 => x1.AllowanceTypeId == x.AllowanceTypeId)) { return(x, toD.PayrunAllowancesSummaries.First(x1 => x1.AllowanceTypeId == x.AllowanceTypeId)); } else { return(x, null); } })); decimal bsDiffValue = (toD.BasicSalary - fromD.BasicSalary); string bsDiff = bsDiffValue < 0? $"({Math.Abs(bsDiffValue).ToString("N2")})" : bsDiffValue.ToString("N2"); DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"basicSalary", bsDiff); if (bsDiffValue > 0) { payrunReconEmpDDSRow.category = "Increment"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned);; payrunReconEmpDDSRow.category = ""; } else if (bsDiffValue < 0) { payrunReconEmpDDSRow.category = "Deduction"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); payrunReconEmpDDSRow.category = ""; } payrunReconEmpDDSRow.basicSalary = "—"; for (int j = 0; j < allowancesReconDetails.Count; j++) { PayrunAllowanceSummary_Dto fromAllowance = allowancesReconDetails[j].fromAllowance; PayrunAllowanceSummary_Dto toAllowance = allowancesReconDetails[j].toAllowance; bool isFromDAllowance = fromAllowance != null; bool isToDAllowance = toAllowance != null; bool bothAllowance = isFromDAllowance && isToDAllowance; if (bothAllowance) { DictionaryValue_Dto allowance = fromAllowance.AllowanceType; string camelCaseName = allowance.Value; camelCaseName = camelCaseName.Replace(" ", ""); camelCaseName = char.ToLowerInvariant(camelCaseName[0]) + camelCaseName.Substring(1); double difference = (double)(toAllowance.Value - fromAllowance.Value); string difValue = difference >= 0 ? difference.ToString("N2") : $"({Math.Abs(difference).ToString("N2")})"; DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value", difValue); if (difference > 0) { payrunReconEmpDDSRow.category = $"{allowance.Value} Increased"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); DynamicHelper.RemoveProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value"); payrunReconEmpDDSRow.category = ""; } else if (difference < 0) { payrunReconEmpDDSRow.category = $"{allowance.Value} Decreased"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); DynamicHelper.RemoveProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value"); payrunReconEmpDDSRow.category = ""; } } else { if (isFromDAllowance) { DictionaryValue_Dto allowance = fromAllowance.AllowanceType; string camelCaseName = allowance.Value; camelCaseName = camelCaseName.Replace(" ", ""); camelCaseName = char.ToLowerInvariant(camelCaseName[0]) + camelCaseName.Substring(1); double allowanceValue = (double)fromAllowance.Value; string value = $"({allowanceValue.ToString("N2")})"; DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value", value); payrunReconEmpDDSRow.category = $"{allowance.Value} Removed"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); DynamicHelper.RemoveProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value"); payrunReconEmpDDSRow.category = ""; } else if (isToDAllowance) { DictionaryValue_Dto allowance = toAllowance.AllowanceType; string camelCaseName = allowance.Value; camelCaseName = camelCaseName.Replace(" ", ""); camelCaseName = char.ToLowerInvariant(camelCaseName[0]) + camelCaseName.Substring(1); double allowanceValue = (double)toAllowance.Value; string value = allowanceValue >= 0 ? allowanceValue.ToString("N2") : $"({allowanceValue.ToString("N2")})"; DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value", value); payrunReconEmpDDSRow.category = $"{allowance.Value} Added"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); DynamicHelper.RemoveProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value"); payrunReconEmpDDSRow.category = ""; } } } payrunReconEmpDDSRow.grossEarnings = toD.GrossEarnings - fromD.GrossEarnings; decimal gosiDiffValue = (toD.GOSIAmount - fromD.GOSIAmount); payrunReconEmpDDSRow.gosiValue = gosiDiffValue > 0? gosiDiffValue.ToString("N2") : $"({Math.Abs(gosiDiffValue).ToString("N2")})"; if (gosiDiffValue != 0) { payrunReconEmpDDSRow.category = gosiDiffValue > 0? "GOSI Increased" : "GOSI Decreased"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); payrunReconEmpDDSRow.gosiValue = "—"; payrunReconEmpDDSRow.category = ""; } decimal loansDiffValue = (toD.Loan - fromD.Loan); payrunReconEmpDDSRow.loansValue = loansDiffValue > 0? loansDiffValue.ToString("N2") : $"({Math.Abs(loansDiffValue).ToString("N2")})"; if (loansDiffValue != 0) { payrunReconEmpDDSRow.category = loansDiffValue > 0? "Loans Increased" : "Loans Decreased"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); payrunReconEmpDDSRow.gosiValue = "—"; payrunReconEmpDDSRow.category = ""; } decimal leavesDiffValue = (toD.Leaves - fromD.Leaves); payrunReconEmpDDSRow.leavesValue = leavesDiffValue > 0? leavesDiffValue.ToString("N2") : $"({Math.Abs(leavesDiffValue).ToString("N2")})"; if (loansDiffValue != 0) { payrunReconEmpDDSRow.category = leavesDiffValue > 0? "Leaves Increased" : "Leaves Decreased"; var cloned = JsonConvert.DeserializeObject <dynamic>(JsonConvert.SerializeObject(payrunReconEmpDDSRow)); payrunReconSummaryDynamicDS.Add(cloned); payrunReconEmpDDSRow.gosiValue = "—"; payrunReconEmpDDSRow.category = ""; } payrunReconEmpDDSRow.grossDeduction = toD.GrossDeductions - fromD.GrossDeductions; payrunReconEmpDDSRow.netAmount = (payrunReconEmpDDSRow.grossEarnings - payrunReconEmpDDSRow.grossDeduction).ToString("N2"); } else { if (isFromD) { string bs = fromD.BasicSalary.ToString("N2"); DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"basicSalary", bs); var fromAllowances = fromD.PayrunAllowancesSummaries.ToList(); for (int j = 0; j < fromAllowances.Count; j++) { PayrunAllowanceSummary_Dto fromAllowance = fromAllowances[i]; DictionaryValue_Dto allowance = fromAllowance.AllowanceType; string camelCaseName = allowance.Value; camelCaseName = camelCaseName.Replace(" ", ""); camelCaseName = char.ToLowerInvariant(camelCaseName[0]) + camelCaseName.Substring(1); double allowanceValue = (double)fromAllowance.Value; string value = allowanceValue > 0 ? allowanceValue.ToString("N2") : $"({allowanceValue.ToString("N2")})"; DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value", value); } payrunReconEmpDDSRow.grossEarnings = fromD.GrossEarnings; payrunReconEmpDDSRow.gosiValue = fromD.GOSIAmount; payrunReconEmpDDSRow.loansValue = fromD.Loan; payrunReconEmpDDSRow.leavesValue = fromD.Leaves; payrunReconEmpDDSRow.grossDeduction = fromD.GrossDeductions; payrunReconEmpDDSRow.netAmount = (payrunReconEmpDDSRow.grossEarnings - payrunReconEmpDDSRow.grossDeduction).ToString("N2"); payrunReconEmpDDSRow.category = "Left"; payrunReconSummaryDynamicDS.Add(payrunReconEmpDDSRow); payrunReconEmpDDSRow.category = ""; } else if (isToD) { string bs = toD.BasicSalary.ToString("N2"); DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"basicSalary", bs); var toAllowances = toD.PayrunAllowancesSummaries.ToList(); for (int j = 0; j < toAllowances.Count; j++) { PayrunAllowanceSummary_Dto toAllowance = toAllowances[i]; DictionaryValue_Dto allowance = toAllowance.AllowanceType; string camelCaseName = allowance.Value; camelCaseName = camelCaseName.Replace(" ", ""); camelCaseName = char.ToLowerInvariant(camelCaseName[0]) + camelCaseName.Substring(1); double allowanceValue = (double)toAllowance.Value; string value = allowanceValue > 0 ? allowanceValue.ToString("N2") : $"({allowanceValue.ToString("N2")})"; DynamicHelper.AddProperty(payrunReconEmpDDSRow, $"{camelCaseName}_Value", value); } payrunReconEmpDDSRow.grossEarnings = toD.GrossEarnings; payrunReconEmpDDSRow.gosiValue = toD.GOSIAmount; payrunReconEmpDDSRow.loansValue = toD.Loan; payrunReconEmpDDSRow.leavesValue = toD.Leaves; payrunReconEmpDDSRow.grossDeduction = toD.GrossDeductions; payrunReconEmpDDSRow.netAmount = (payrunReconEmpDDSRow.grossEarnings - payrunReconEmpDDSRow.grossDeduction).ToString("N2"); payrunReconEmpDDSRow.category = "New Employee"; payrunReconSummaryDynamicDS.Add(payrunReconEmpDDSRow); payrunReconEmpDDSRow.category = ""; } } } //if(payrunReconEmpDDSRow.netAmount != "0.00") // payrunReconSummaryDynamicDS.Add(payrunReconEmpDDSRow); } if (!isAjax) { ViewData["Payruns_DS"] = JsonSerializer.Serialize(payrunReconSummaryDynamicDS); return(Page()); } else { return(new JsonResult(payrunReconSummaryDynamicDS)); } } else { return(BadRequest(new { type = "payrun" })); } } catch (Exception ex) { return(BadRequest(new { type = "exception" })); } }
public IActionResult OnGetSIReport(int payrunId) { Payrun_Dto payrun = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Id == payrunId)); List <SIContributionCategory_Dto> SIContributionCategories = ObjectMapper.Map <List <SIContributionCategory>, List <SIContributionCategory_Dto> >(SocialInsuranceAppService.Repository.WithDetails().First().ContributionCategories.ToList()); if (payrun != null) { List <PayrunDetail_Dto> payrunDetails = payrun.PayrunDetails.ToList(); List <dynamic> dynamicDS = new List <dynamic>(); for (int i = 0; i < payrunDetails.Count; i++) { PayrunDetail_Dto curDetail = payrunDetails[i]; if (curDetail.Employee.SIType == null || curDetail.Employee.SIType.Value != "Eligible") { continue; } SocialInsuranceReport_Dto employeeSIReport = GetSIReport(curDetail); dynamic siDSRow = new ExpandoObject(); siDSRow.payrunId = employeeSIReport.PayrunId; siDSRow.sNo = i + 1; siDSRow.getEmpName = employeeSIReport.Employee.Name; siDSRow.getEmpIdentityNumber = employeeSIReport.EmpID; siDSRow.getEmpNationality = employeeSIReport.Employee.Nationality.Value; siDSRow.getEmpSIID = employeeSIReport.EmpSIId; siDSRow.getBasicSalary = "" + employeeSIReport.BasicSalary.ToString("N2"); foreach (PayrunAllowanceSummary_Dto siAllowance in employeeSIReport.PayrunSIAllowancesSummaries) { DynamicHelper.AddProperty(siDSRow, $"{siAllowance.AllowanceType.Value}_Value", "" + siAllowance.Value.ToString("N2")); } double totalSISalary = employeeSIReport.TotalSISalary; siDSRow.getEmpTotalSalaryForSI = "" + totalSISalary.ToString("N2"); List <(string title, double value)> Contributions = new List <(string title, double value)>(); foreach (SIContributionCategory_Dto SIC in SIContributionCategories) { foreach (SIContribution_Dto SICC in SIC.SIContributions) { double SICCCV = SICC.IsPercentage ? totalSISalary * (SICC.Value / 100) : SICC.Value; int contribIndex = Contributions.FindIndex(x => x.title == SICC.Title); if (contribIndex != -1) { Contributions[contribIndex] = (SICC.Title, Contributions[contribIndex].value + SICCCV); } else { Contributions.Add((SICC.Title, SICCCV)); } DynamicHelper.AddProperty(siDSRow, $"{SIC.Title}_{SICC.Title}_Value", $"{SICCCV.ToString("N2")}"); } } foreach ((string title, double value)SICC in Contributions) { List <SIContribution_Dto> sIContributions = SIContributionCategories.SelectMany(x => x.SIContributions).ToList(); DynamicHelper.AddProperty(siDSRow, $"Overall_{SICC.title}_Value", $"{SICC.value.ToString("N2")}"); } siDSRow.month = curDetail.Month; siDSRow.year = curDetail.Year; dynamicDS.Add(siDSRow); } //JsonResult eosbDSJson = new JsonResult(dynamicDS); dynamic Model = new ExpandoObject(); Model.SIDS = dynamicDS; Model.month = payrun.Month; Model.year = payrun.Year; Model.isPosted = payrun.IsSIPosted; return(new JsonResult(Model)); } return(StatusCode(500)); }