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 IActionResult OnGetPaymentsSheet(int payrunId) { Payrun payrun = PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Id == payrunId); if (payrun != null) { List <PayrunDetail> payrunDetails = payrun.PayrunDetails.ToList(); List <dynamic> dynamicDS = new List <dynamic>(); for (int i = 0; i < payrunDetails.Count; i++) { PayrunDetail curDetail = payrunDetails[i]; List <PayrunAllowanceSummary> payrunAllowances = curDetail.PayrunAllowancesSummaries.ToList(); PayrunAllowanceSummary 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 = payrunId; paymentSlipDSRow.sNo = i + 1; 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; paymentSlipDSRow.isPosted = payrun.IsPSPosted; dynamicDS.Add(paymentSlipDSRow); } return(new JsonResult(dynamicDS)); } return(StatusCode(500)); }