Example #1
0
        private bool AccionGuardar()
        {
            if (!this.Validar())
                return false;

            // Se borran los "devengados", si hay
            foreach (int iDevBorrarID in this.EgresosDevBorrados)
                ContaProc.DevengadoEliminar(iDevBorrarID);
            // Se borran los especials, si hay
            foreach (int iDevID in this.DevEspecialBorrados)
                ContaProc.DevengadoEspecialEliminar(iDevID);

            // Se procesan los nuevos
            foreach (DataGridViewRow oFila in this.dgvDetalle.Rows)
            {
                if (oFila.Cells["RegistroID"].Value != null)
                    continue;

                // Se genera el "devengado", según corresponda
                if (((TipoDev)oFila.Cells["colTipoDev"].Value) == TipoDev.Sucursal)
                {
                    var oEgresoDev = new ContaEgresoDevengado()
                    {
                        ContaEgresoID = this.oEgreso.ContaEgresoID,
                        Fecha = Util.FechaHora(oFila.Cells["Fecha"].Value),
                        Importe = Util.Decimal(oFila.Cells["Importe"].Value),
                        SucursalID = Util.Entero(oFila.Cells["SelID"].Value),
                    };
                    // Se obtiene el detalle, si aplica
                    var oDetalleDev = (oFila.Tag as List<ContaEgresoDetalleDevengado>);

                    // Se manda guardar los datos
                    ContaProc.GastoDevengar(oEgresoDev, oDetalleDev);
                }
                else
                {
                    var oDevEsp = new ContaEgresoDevengadoEspecial()
                    {
                        ContaEgresoID = this.oEgreso.ContaEgresoID,
                        Fecha = Util.FechaHora(oFila.Cells["Fecha"].Value),
                        DuenioID = Util.Entero(oFila.Cells["SelID"].Value),
                        Importe = Util.Decimal(oFila.Cells["Importe"].Value)
                    };
                    // Datos.Guardar<ContaEgresoDevengadoEspecial>(oDevEsp);

                    // Se obtiene el detalle, si aplica
                    var oDetalleDev = (oFila.Tag as List<ContaEgresoDetalleDevengadoEspecial>);

                    // Se manda guardar los datos
                    ContaProc.GastoDevengarEspecial(oDevEsp, oDetalleDev);
                }
            }

            // Se muestra una notificación
            UtilLocal.MostrarNotificacion("Proceso completado correctamente.");

            return true;
        }
Example #2
0
        private bool AccionGuardar()
        {
            if (!this.Validar())
            {
                return(false);
            }

            // Se borran los "devengados", si hay
            foreach (int iDevBorrarID in this.EgresosDevBorrados)
            {
                ContaProc.DevengadoEliminar(iDevBorrarID);
            }
            // Se borran los especials, si hay
            foreach (int iDevID in this.DevEspecialBorrados)
            {
                ContaProc.DevengadoEspecialEliminar(iDevID);
            }

            // Se procesan los nuevos
            foreach (DataGridViewRow oFila in this.dgvDetalle.Rows)
            {
                if (oFila.Cells["RegistroID"].Value != null)
                {
                    continue;
                }

                // Se genera el "devengado", según corresponda
                if (((TipoDev)oFila.Cells["colTipoDev"].Value) == TipoDev.Sucursal)
                {
                    var oEgresoDev = new ContaEgresoDevengado()
                    {
                        ContaEgresoID = this.oEgreso.ContaEgresoID,
                        Fecha         = Util.FechaHora(oFila.Cells["Fecha"].Value),
                        Importe       = Util.Decimal(oFila.Cells["Importe"].Value),
                        SucursalID    = Util.Entero(oFila.Cells["SelID"].Value),
                    };
                    // Se obtiene el detalle, si aplica
                    var oDetalleDev = (oFila.Tag as List <ContaEgresoDetalleDevengado>);

                    // Se manda guardar los datos
                    ContaProc.GastoDevengar(oEgresoDev, oDetalleDev);
                }
                else
                {
                    var oDevEsp = new ContaEgresoDevengadoEspecial()
                    {
                        ContaEgresoID = this.oEgreso.ContaEgresoID,
                        Fecha         = Util.FechaHora(oFila.Cells["Fecha"].Value),
                        DuenioID      = Util.Entero(oFila.Cells["SelID"].Value),
                        Importe       = Util.Decimal(oFila.Cells["Importe"].Value)
                    };
                    // Datos.Guardar<ContaEgresoDevengadoEspecial>(oDevEsp);

                    // Se obtiene el detalle, si aplica
                    var oDetalleDev = (oFila.Tag as List <ContaEgresoDetalleDevengadoEspecial>);

                    // Se manda guardar los datos
                    ContaProc.GastoDevengarEspecial(oDevEsp, oDetalleDev);
                }
            }

            // Se muestra una notificación
            UtilLocal.MostrarNotificacion("Proceso completado correctamente.");

            return(true);
        }
Example #3
0
        public static ResAcc<int> GastoDevengar(int iEgresoID, int iSucursalID, decimal mImporte, DateTime dFecha)
        {
            var oDev = Datos.GetEntity<ContaEgresoDevengado>(c => c.ContaEgresoID == iEgresoID && c.SucursalID == iSucursalID);
            if (oDev == null)
            {
                oDev = new ContaEgresoDevengado()
                {
                    ContaEgresoID = iEgresoID,
                    SucursalID = iSucursalID,
                    Fecha = dFecha
                };
            }
            oDev.Importe = mImporte;

            return ContaProc.GastoDevengar(oDev, null);
        }
Example #4
0
        public static ResAcc<int> GastoDevengar(ContaEgresoDevengado oDev, List<ContaEgresoDetalleDevengado> oDetalleDev)
        {
            // Se llenan datos calculables
            oDev.RealizoUsuarioID = (oDev.RealizoUsuarioID > 0 ? oDev.RealizoUsuarioID : Theos.UsuarioID);
            //
            Datos.Guardar<ContaEgresoDevengado>(oDev);

            // Se llena el detalle, si hay
            if (oDetalleDev != null && oDetalleDev.Count > 0)
            {
                foreach (var oReg in oDetalleDev)
                {
                    oReg.ContaEgresoDevengadoID = oDev.ContaEgresoDevengadoID;
                    Datos.Guardar<ContaEgresoDetalleDevengado>(oReg);
                }

                // Se verifica si ya se completaron las cantidades del detalle, en cuyo caso, se hace que el importe cuadre con el total
                var oEgresoV = Datos.GetEntity<ContaEgresosView>(c => c.ContaEgresoID == oDev.ContaEgresoID);
                if (oEgresoV.Importe != oEgresoV.ImporteDev) {
                    var oEgresosDetV = Datos.GetListOf<ContaEgresosDetalleView>(c => c.ContaEgresoID == oDev.ContaEgresoID);
                    if (oEgresosDetV.Sum(c => c.Cantidad) == oEgresosDetV.Sum(c => c.CantidadDev))
                    {
                        oDev.Importe += (oEgresoV.Importe - oEgresoV.ImporteDev.Valor());
                        Datos.Guardar<ContaEgresoDevengado>(oDev);
                    }
                }
            }

            // Se editan los gastos fijos, si aplican
            var oEgreso = Datos.GetEntity<ContaEgreso>(c => c.ContaEgresoID == oDev.ContaEgresoID);
            var oCuentaAux = Datos.GetEntity<ContaCuentaAuxiliar>(c => c.ContaCuentaAuxiliarID == oEgreso.ContaCuentaAuxiliarID);
            if (oCuentaAux.AfectaMetas.Valor() && oCuentaAux.SumaGastosFijos.Valor())
            {
                var oGastoFijo = Datos.GetEntity<SucursalGastoFijo>(c => c.SucursalID == oDev.SucursalID && c.ContaCuentaAuxiliarID == oCuentaAux.ContaCuentaAuxiliarID);
                if (oGastoFijo == null)
                {
                    oGastoFijo = new SucursalGastoFijo();
                    oGastoFijo.SucursalID = oDev.SucursalID;
                    oGastoFijo.ContaCuentaAuxiliarID = oCuentaAux.ContaCuentaAuxiliarID;
                }

                // Se calcula el importe según el caso
                // decimal mImporte = ((oDev.Importe / oCuentaAux.DivisorDia.Valor()) * 7);
                decimal mImporte = 0;
                if (oCuentaAux.CalculoSemanal.Valor())
                {
                    mImporte = UtilTheos.GastoCalcularImporteDiario(oDev.Fecha, oDev.Importe, oCuentaAux.PeriodicidadMes.Valor());
                    oGastoFijo.Importe = (mImporte * 7);
                }
                else
                {
                    oGastoFijo.Importe = oDev.Importe;
                }

                Datos.Guardar<SucursalGastoFijo>(oGastoFijo);
            }

            return new ResAcc<int>(true, oDev.ContaEgresoDevengadoID);
        }