public ActionResult LoadR4P(Guid id) { Models.Request4Payment model = UserSession.CurrentSession.R4Pmodel; model.paymentDetais = paymentD((Guid)id, model); model.ReferenceId = id; return(View("LoadRequst4P", model)); }
public ActionResult SaveR4P(Models.Request4Payment model) { try { model.EntityPaymentRqst.PurchaseOrderId = model.ReferenceId; //model.EntityPaymentRqst.RequestForAdvanceId = Guid.Empty; //model.EntityPaymentRqst.TravelAuthorisationId = Guid.Empty; model.EntityPaymentRqst.Id = Guid.NewGuid(); model.EntityPaymentRqst.PreparedBy = currentStaff.Id; model.EntityPaymentRqst.PreparedOn = DateTime.Now; model.EntityPaymentRqst.CountryProgrammeId = countryProg.Id; model.EntityPaymentRqst.RequestDate = model.EntityPaymentRqst.PreparedOn; model.EntityPaymentRqst.IsSubmitted = true; model.EntityPaymentRqst.IsAuthorized = false; model.EntityPaymentRqst.IsReviewed = false; PaymentRequestBudgetLine m; EntityCollection <Model.PaymentRequestBudgetLine> RABlineList = new EntityCollection <PaymentRequestBudgetLine>(); foreach (Models.R4PpaymentDetails item in model.paymentDetais) { m = new PaymentRequestBudgetLine(); m.Id = Guid.NewGuid(); m.PaymentRequestId = model.EntityPaymentRqst.Id; m.BudgetLineId = item.BudgetLineId; m.Amount = item.Amount; m.PurchaseOrderItemId = item.PoItemId; RABlineList.Add(m); } string usmsge; bool issaved = false; model.EntityPaymentRqst.RefNumber = R4PSevice.GenerateUniquNumber(countryProg); if (R4PSevice.SaveRequest4Payment(model.EntityPaymentRqst, RABlineList)) { usmsge = Resources.Global_String_SavedSuccessfully; issaved = true; } else { usmsge = Resources.Global_String_AnErrorOccurred; } ModelState.Clear(); //return LoadR4P(model.EntityPaymentRqst.PaymentRqstType, usmsge, issaved); return(ViewR4P()); } catch (Exception ex) { return(LoadR4P(model.EntityPaymentRqst.PaymentRqstType, ex.Message, false)); } }
private List <Models.R4PpaymentDetails> paymentD(Guid id, Models.Request4Payment model) { Models.R4PpaymentDetails pd; List <Models.R4PpaymentDetails> pdList = new List <R4PpaymentDetails>(); using (var context = new SCMSEntities()) { Model.PurchaseOrder po = context.PurchaseOrders.SingleOrDefault(p => p.Id == id); bool poHasRFP = R4PSevice.PurchaseOrderHasRFP(po.Id); ICollection <PurchaseOrderItem> poitem = po.PurchaseOrderItems; foreach (PurchaseOrderItem item in poitem) { if (item.BudgetCommitments.Count < 1) { continue; } var pb = context.ProjectBudgets.SingleOrDefault(p => p.Id == item.BudgetLineId); pd = new R4PpaymentDetails(); //var commitAmt = exchangeRateService.GetForeignCurrencyValue(po.Currency, pb.BudgetCategory.ProjectDonor.Currency, itemBLCommit.AmountCommitted, countryProg.Id); if (!poHasRFP) { pd.Amount = Math.Round(item.TotalPrice, 2); } else { pd.Amount = Math.Round(R4PSevice.GetPOItemRemainingBalance(item.Id), 2); } pd.BudgetLineId = (Guid)item.BudgetLineId; pd.BudgetLine = pb.LineNumber; pd.BudgetLineDescription = pb.Description; pd.PorjectNoId = (Guid)item.PurchaseOrder.ProjectDonorId; //.ProjectNoId; pd.PoItemId = item.Id; pd.projectNo = item.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber; // context.ProjectDonors.SingleOrDefault(p => p.Id == item.ProjectNoId).ProjectNumber; pdList.Add(pd); } model.EntityPaymentRqst.CurrencyId = po.CurrencyId; model.EntityPaymentRqst.SupplierId = po.SupplierId; } return(pdList); }