public ActionResult AgregarPago(VentasAgregarPagoViewModel apVM) { apVM.FormasDePago = null; apVM.FormasDePago = new SelectList(_formasDePagoServicios.GetAll(), "Id", "Nombre", 1); if (apVM.FormaDePagoID != 0) { apVM.Items = (List <VentaItem>)System.Web.HttpContext.Current.Session["ListaItemsVentaActual"]; var formaDePago = _formasDePagoServicios.GetOne(apVM.FormaDePagoID); if (apVM.Pagos.Any(a => a.FormaDePagoID == formaDePago.Id)) { ViewBag.Error = "La forma de pago ya está agregada."; return(View(apVM)); } Pago pago = new Pago(); pago.FormaDePago = _formasDePagoServicios.GetOne(formaDePago.Id); pago.FormaDePagoID = pago.FormaDePago.Id; apVM.Pagos.Add(pago); if (apVM.Pagos.Count == 1) { apVM.Pagos.First().Monto = apVM.Total; } } else { Pago pago = new Pago(); pago.FormaDePago = _formasDePagoServicios.GetOne(1); pago.FormaDePagoID = pago.FormaDePago.Id; apVM.Pagos.Add(pago); if (apVM.Pagos.Count == 1) { apVM.Pagos.First().Monto = apVM.Total; } //Agregao la forma de pago Devolución if (System.Web.HttpContext.Current.Session["SaldoAFavor"] != null) { decimal SaldoAFavor = decimal.Parse(System.Web.HttpContext.Current.Session["SaldoAFavor"].ToString()); Pago pagoDev = new Pago(); pagoDev.FormaDePago = _formasDePagoServicios.GetOne(4); pagoDev.FormaDePagoID = pagoDev.FormaDePago.Id; apVM.Pagos.Add(pagoDev); apVM.Pagos[0].Monto = apVM.Total - SaldoAFavor; apVM.Pagos[1].Monto = SaldoAFavor; } System.Web.HttpContext.Current.Session["ListaItemsVentaActual"] = apVM.Items; } return(View(apVM)); }
public ActionResult Agregar() { if (!ValidarUsuario(1, 3)) { return(RedirectToAction("ErrorPermisos", "Base")); } MovimientoEfectivoAgregarViewModel MovimientoVM = new MovimientoEfectivoAgregarViewModel(); ViewBag.TiposMovimientos = _tipoMovimientosServicios.GetAll(); ViewBag.FormasDePago = _formasDePagoServicios.GetAll(); return(View(MovimientoVM)); }
public IHttpActionResult GetAllFormasDePago() { IList <FormaDePago> formasDePago = null; formasDePago = _formasDePagoServicios.GetAll().ToList(); if (formasDePago.Count == 0) { return(NotFound()); } else { return(Ok(formasDePago)); } }