Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Acreedores acreedores = db.Acreedores.Find(id);

            db.Acreedores.Remove(acreedores);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "id,Nombre,Apellido,Telefono")] Acreedores acreedores)
 {
     if (ModelState.IsValid)
     {
         db.Entry(acreedores).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(acreedores));
 }
Example #3
0
        public ActionResult Create([Bind(Include = "id,Nombre,Apellido,Telefono")] Acreedores acreedores)
        {
            if (ModelState.IsValid)
            {
                db.Acreedores.Add(acreedores);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(acreedores));
        }
Example #4
0
        // GET: Acreedores/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acreedores acreedores = db.Acreedores.Find(id);

            if (acreedores == null)
            {
                return(HttpNotFound());
            }
            return(View(acreedores));
        }
Example #5
0
        private void ValidarCabecera(PresupuestosCompras model)
        {
            if (model.fechadocumento == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestosCompras.Fechadocumento));
            }
            if (model.fkproveedores == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestosCompras.Fkproveedores));
            }
            if (!model.fkmonedas.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPresupuestosCompras.Fkmonedas));
            }
            if (!model.fkformaspago.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RPedidos.Fkformaspago));
            }

            var        clienteObj   = _db.Proveedores.SingleOrDefault(f => f.empresa == model.empresa && f.fkcuentas == model.fkproveedores);
            Acreedores prospectoObj = null;

            if (clienteObj == null)
            {
                prospectoObj = _db.Acreedores.Single(f => f.empresa == model.empresa && f.fkcuentas == model.fkproveedores);
            }
            var fkmonedacliente = clienteObj?.fkmonedas ?? Funciones.Qint(prospectoObj.fkmonedas);
            var serieObj        =
                _db.Series.Single(f => f.empresa == model.empresa && f.tipodocumento == "PRC" && f.id == model.fkseries);

            if (serieObj.fkmonedas.HasValue && serieObj.fkmonedas != fkmonedacliente)
            {
                throw new ValidationException(RPresupuestosCompras.ErrorMonedaClienteSerie);
            }

            if (!FlagActualizarCantidadesPedidas && !ValidaRangoEjercicio(model))
            {
                throw new ValidationException(RPresupuestosCompras.ErrorFechaEjercicio);
            }
            if (!FlagActualizarCantidadesPedidas)
            {
                if (!ValidarLineasPresupuesto(model))
                {
                    throw new ValidationException(RPresupuestosCompras.ErrorLineasAsociadasAPedidos);
                }
            }
        }
Example #6
0
        private void ValidarCabecera(FacturasCompras model)
        {
            if (model.fechadocumento == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Fechadocumento));
            }
            if (model.fkproveedores == null)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Fkproveedores));
            }
            if (!model.fkmonedas.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Fkmonedas));
            }
            if (!model.fkformaspago.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Fkformaspago));
            }
            if (!model.fechadocumentoproveedor.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Fechadocumentoproveedor));
            }
            // if (string.IsNullOrEmpty(model.numerodocumentoproveedor))
            //     throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Numerodocumentoproveedor));
            if (!model.importefacturaproveedor.HasValue)
            {
                throw new ValidationException(string.Format(General.ErrorCampoObligatorio, RFacturasCompras.Importefacturaproveedor));
            }
            var serieObj =
                _db.Series.Single(f => f.empresa == model.empresa && f.tipodocumento == "FRC" && f.id == model.fkseries);

            var        clienteObj   = _db.Proveedores.SingleOrDefault(f => f.empresa == model.empresa && f.fkcuentas == model.fkproveedores);
            Acreedores prospectoObj = null;

            if (clienteObj == null)
            {
                prospectoObj = _db.Acreedores.Single(f => f.empresa == model.empresa && f.fkcuentas == model.fkproveedores);
            }
            var fkmonedacliente = clienteObj?.fkmonedas ?? Funciones.Qint(prospectoObj.fkmonedas);

            if (serieObj.fkmonedas.HasValue && serieObj.fkmonedas != fkmonedacliente)
            {
                throw new ValidationException(RFacturasCompras.ErrorMonedaClienteSerie);
            }

            if (!ValidaRangoEjercicio(model))
            {
                throw new ValidationException(RFacturasCompras.ErrorFechaEjercicio);
            }

            var formapagoobj = _db.FormasPago.Single(f => f.id == model.fkformaspago);

            if (formapagoobj.mandato.HasValue && formapagoobj.mandato.Value && string.IsNullOrEmpty(model.fkbancosmandatos))
            {
                var mandato = _db.BancosMandatos.SingleOrDefault(
                    f => f.fkcuentas == model.fkproveedores && f.defecto == true && !string.IsNullOrEmpty(f.idmandato));
                var vector     = model.fkestados.Split('-');
                var tipoestado = Funciones.Qint(vector[0]);
                var idestado   = vector[1];
                var estadoObj  = _db.Estados.Single(f => f.documento == tipoestado && f.id == idestado);
                //if (mandato == null && estadoObj.tipoestado == (int)TipoEstado.Finalizado)
                //{
                //    throw new ValidationException(RFacturasCompras.ErrorFormaPagoMandatoRequerido);
                //}
                //else
                //{
                //    WarningList.Add(RFacturasCompras.WarningFormaPagoMandatoRequerido);
                //}
                if (mandato != null && estadoObj.tipoestado == (int)TipoEstado.Finalizado)
                {
                    WarningList.Add(RFacturasCompras.WarningFormaPagoMandatoRequerido);
                }

                model.fkbancosmandatos = mandato?.id;
            }


            CalcularComisiones(model);
        }