public VendorPaymentViewModel AddVendorPayment(VendorPaymentViewModel entity) { var data = new tbl_VendorPayment { VendorPaymentId = entity.vendorPaymentId, VendorId = entity.vendorId, PurchaseOrderId = entity.purchaseOrderId, PurchaseOrderDetailId = entity.purchaseOrderDetailId, InvoiceNo = entity.invoiceNo, InvoiceTotalCost = entity.invoiceTotalCost, AmountAlreadyPaid = entity.amountAlreadyPaid, AmountToPay = entity.amountToPay, Balance = entity.balance, PaymentModeId = entity.paymentModeId, PaymentDate = entity.paymentDate, CreatedBy = "admin", CreatedOn = entity.createdOn, ModifiedBy = "admin", ModifiedOn = entity.modifiedOn }; context.tbl_VendorPayment.Add(data); context.SaveChanges(); return(entity); }
public PartialViewResult Payment(long Id) { ViewBag.Title = Constant.VENDOR_PAYMENT; var AnnualBudgetId = new BaseController(_repAnnualBudget).budgetList; var vpvm = new VendorPaymentViewModel(); vpvm.VendorInfo = _repPurchaseAsset.GetAssetPurchaseDetails().Where(x => x.Id == Id).SingleOrDefault(); var PaidAmtObj = _repPurchaseAsset.VendorPaymentDetails() .Where(x => x.AssetPurchaseId == Id) .Where(x => x.AnnualBudgetId == AnnualBudgetId).ToList(); var lstVendorPayment = new List <VendorPaymentViewModel>(); vpvm.AlreadyPaidAmount = 0; vpvm.PaymentConfirmedBy = ""; if (PaidAmtObj != null) { for (int i = 0; i < PaidAmtObj.Count; i++) { var vpv = new VendorPaymentViewModel(); vpv.AlreadyPaidAmount = PaidAmtObj[i].PaidAmount; vpv.PaymentConfirmedBy = PaidAmtObj[i].PaymentConfirmedBy; lstVendorPayment.Add(vpv); } } vpvm.AlreadyPaidList = lstVendorPayment; return(PartialView(vpvm)); }
/// <summary> /// Gets pending payment details /// </summary> /// <param name="vendorId">Vendor ID</param> /// <param name="annualBudgetId">Annual Budget ID</param> /// <returns>VendorPaymentViewModel list</returns> public IList <VendorPaymentViewModel> PendingPaymentDetails(long vendorId, long annualBudgetId) { var arrAssetPurchaseIds = DistinctAssetPurchaseId(vendorId, annualBudgetId); PurchaseAssetService pas = new PurchaseAssetService(); List <VendorPaymentViewModel> lstPayment = new List <VendorPaymentViewModel>(); for (int i = 0; i < arrAssetPurchaseIds.Count; i++) { VendorPaymentViewModel vpvm = new VendorPaymentViewModel(); vpvm.PendingPayments = pas.VendorPaymentDetails() .Where(x => x.VendorId == vendorId) .Where(x => x.AnnualBudgetId == annualBudgetId) .Where(x => x.AssetPurchaseId == arrAssetPurchaseIds[i].AssetPurchaseId) .OrderByDescending(x => x.Id) .Take(1) .SingleOrDefault(); //Get Asset Name vpvm.PendingPayments.AssetName = AssetNameFromVendorPayment(arrAssetPurchaseIds[i].AssetPurchaseId, annualBudgetId); lstPayment.Add(vpvm.PendingPayments); } return(lstPayment); }
/// <summary> /// Makes Vendor Payment /// </summary> /// <param name="vpvm">VendorPaymentViewModel object</param> public void VendorPayment(VendorPaymentViewModel vpvm) { using (SqlConnection con = new SqlConnection(TableConstant.CONNECTION_STRING)) { using (SqlCommand cmd = new SqlCommand("dbo.usp_VendorPayment")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@VendorId", vpvm.VendorId); cmd.Parameters.AddWithValue("@AssetPurchaseId", vpvm.AssetPurchaseId); cmd.Parameters.AddWithValue("@AnnualBudgetId", vpvm.AnnualBudgetId); cmd.Parameters.AddWithValue("@PaymentAmount", vpvm.PaymentAmount); cmd.Parameters.AddWithValue("@PaidAmount", vpvm.PaidAmount); cmd.Parameters.AddWithValue("@RemainingAmount", vpvm.RemainingAmount); cmd.Parameters.AddWithValue("@PaymentStatus", vpvm.PaymentStatus); cmd.Parameters.AddWithValue("@PaymentDate", vpvm.PaymentDate); cmd.Parameters.AddWithValue("@PaymentConfirmedBy", vpvm.PaymentConfirmedBy); cmd.Parameters.AddWithValue("@UserId", vpvm.UserId); cmd.Parameters.AddWithValue("@Username", vpvm.Username); //var returnParameter = cmd.Parameters.Add("@RollBackFlag", SqlDbType.Int); //returnParameter.Direction = ParameterDirection.ReturnValue; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } }
public bool UpdateVendorPayment(VendorPaymentViewModel entity) { var data = (from c in context.tbl_VendorPayment where c.VendorPaymentId == entity.vendorPaymentId select c).SingleOrDefault(); if (data != null) { data.VendorPaymentId = entity.vendorPaymentId; data.VendorId = entity.vendorId; data.PurchaseOrderId = entity.purchaseOrderId; data.PurchaseOrderDetailId = entity.purchaseOrderDetailId; data.InvoiceNo = entity.invoiceNo; data.InvoiceTotalCost = entity.invoiceTotalCost; data.AmountAlreadyPaid = entity.amountAlreadyPaid; data.AmountToPay = entity.amountToPay; data.Balance = entity.balance; data.PaymentModeId = entity.paymentModeId; data.PaymentDate = entity.paymentDate; data.CreatedBy = "admin"; data.CreatedOn = entity.createdOn; data.ModifiedBy = "admin"; data.ModifiedOn = entity.modifiedOn; } return(context.SaveChanges() > 0); }
public CommonResponseViewModel SaveVendorPayment(VendorPaymentViewModel vendorPaymentVM) { var vendorPayment = ConstructVendorPaymentVModelToContext(vendorPaymentVM); AddVendorPaymentToDb(vendorPayment); return(null); }
private EfDbContext.VendorPayments ConstructVendorPaymentVModelToContext(VendorPaymentViewModel vendorPaymentVM) { return(new EfDbContext.VendorPayments { StockInId = HelperUtility.ConvertLongToInt(vendorPaymentVM.StockInId), VendorId = HelperUtility.ConvertLongToInt(vendorPaymentVM.VendorId), AmountPaid = vendorPaymentVM.AmountPaid, }); }
public PartialViewResult PendingPaymentDetail(long Id) { var currentAnnualBudgetId = new BaseController(_repAnnualBudget).budgetList; var vpvm = new VendorPaymentViewModel(); vpvm.PendingPaymentList = _repVendor.PendingPaymentDetails(Id, currentAnnualBudgetId).ToList(); vpvm.VendorName = _repVendor.GetVendorList().Where(x => x.Id == Id).SingleOrDefault().Name; return(PartialView(vpvm)); }
public HttpResponseMessage UpdateVendorPayment([FromBody] VendorPaymentViewModel model) { try { var data = repo.UpdateVendorPayment(model); return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = model, message = "The record has successfully been updated" })); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, result = model, message = $"There was error updating this record {e.Message}" })); } }
public ActionResult AddPayment() { var Vendors = _context.TableVendors.ToList(); var viewModel = new VendorPaymentViewModel { VendorPayments = new VendorPayments { datePaid = DateTime.Now }, Vendor = Vendors }; return(View(viewModel)); }
/// <summary> /// Gets Vendor Asset Purchase /// </summary> /// <param name="vendorId">Vendor ID</param> /// <param name="annualBudgetId">Annual Budget ID</param> /// <returns>VendorPaymentViewModel list</returns> public List <VendorPaymentViewModel> GetVendorAssetPurchase(long vendorId, long annualBudgetId) { PurchaseAssetService pas = new PurchaseAssetService(); IQueryable <VendorPaymentViewModel> paymentDetailByVendor = pas.VendorPaymentDetails() .Where(x => x.VendorId == vendorId) .Where(x => x.AnnualBudgetId == annualBudgetId); List <VendorPaymentViewModel> paymentDtl = paymentDetailByVendor.ToList(); for (int i = 0; i < paymentDtl.Count; i++) { VendorPaymentViewModel vpvm = new VendorPaymentViewModel(); vpvm.AssetPurchaseId = paymentDtl[i].AssetPurchaseId; paymentDtl.Add(vpvm); } return(paymentDtl); }
public ActionResult Save(VendorPayments vendorPayments) { if (!ModelState.IsValid) { var vendorPayment = new VendorPaymentViewModel() { VendorPayments = vendorPayments, Vendor = _context.TableVendors.ToList() }; return(View("AddPayment", vendorPayment)); } _context.TableVendorPayments.Add(vendorPayments); var vendorInDb = _context.TableVendors.Single(c => c.id == vendorPayments.VendorsId); vendorInDb.balance = vendorInDb.balance + vendorPayments.amountPaid; _context.SaveChanges(); return(RedirectToAction("Index", "VendorPayments")); }
public ActionResult Payment(FormCollection fc, long Id) { ViewBag.Title = Constant.VENDOR_PAYMENT; var vpvm = new VendorPaymentViewModel(); try { vpvm.VendorInfo = _repPurchaseAsset.GetAssetPurchaseDetails().Where(x => x.Id == Id).SingleOrDefault(); vpvm.VendorId = vpvm.VendorInfo.VendorId; vpvm.AssetPurchaseId = vpvm.VendorInfo.Id; vpvm.AnnualBudgetId = new BaseController(_repAnnualBudget).budgetList; vpvm.PaymentAmount = (vpvm.VendorInfo.PricePerUnit + vpvm.VendorInfo.VAT) * vpvm.VendorInfo.Quantity; vpvm.PaidAmount = Decimal.Parse(fc["PaidAmount"]); vpvm.RemainingAmount = Decimal.Parse(fc["RemainingAmount"]); var alreadyPaidAmt = _repPurchaseAsset.VendorPaymentDetails() .Where(x => x.AssetPurchaseId == vpvm.AssetPurchaseId) .Where(x => x.AnnualBudgetId == vpvm.AnnualBudgetId).ToList(); decimal totalPaidAmt = 0; for (int i = 0; i < alreadyPaidAmt.Count; i++) { totalPaidAmt += alreadyPaidAmt[i].PaidAmount; } vpvm.PaymentStatus = 0; if (vpvm.PaidAmount == vpvm.PaymentAmount || (totalPaidAmt + vpvm.PaidAmount) == vpvm.PaymentAmount) { vpvm.PaymentStatus = 2; //Fully Paid } else if (vpvm.PaidAmount < vpvm.PaymentAmount && vpvm.PaidAmount > 0) { vpvm.PaymentStatus = 1; //Partially Paid } else if (vpvm.PaidAmount == 0) { vpvm.PaymentStatus = 0; //Not Paid } vpvm.PaymentDate = fc["PaymentDate"]; vpvm.PaymentConfirmedBy = fc["PaymentConfirmedBy"]; vpvm.UserId = SessionHelper.UserId; vpvm.Username = SessionHelper.Username; if (ModelState.IsValid) { _repVendor.VendorPayment(vpvm); return(RedirectToAction("AssetPurchaseDetails", "Asset")); } } catch (IOException e) { if (e.Source != null) { Console.WriteLine("IOException source: {0}", e.Source); throw; } } return(PartialView(vpvm)); }