Beispiel #1
0
        public Boolean AnularPrestamo(ro_prestamo_Info _Info)
        {
            try
            {
                using (EntitiesRoles Entity = new EntitiesRoles())
                {
                    ro_prestamo cabecera = Entity.ro_prestamo.First(v => v.IdPrestamo == _Info.IdPrestamo && v.IdEmpresa == _Info.IdEmpresa);

                    // Entity.ro_prestamo.Remove(cabecera);
                    cabecera.IdUsuarioUltAnu = _Info.IdUsuarioUltAnu;
                    cabecera.Fecha_UltAnu    = _Info.Fecha_UltAnu;
                    cabecera.MotiAnula       = _Info.MotiAnula;

                    cabecera.Estado = "I";
                    Entity.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                string array = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", array, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #2
0
        public bool Abono(ro_prestamo_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdPrestamo == info.IdPrestamo);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    foreach (var item in info.lst_detalle)
                    {
                        ro_prestamo_detalle Entity_det = Context.ro_prestamo_detalle.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdPrestamo == info.IdPrestamo &&
                                                                                                    q.NumCuota == item.NumCuota);
                        Entity_det.EstadoPago = item.EstadoPago;
                        Entity_det.Saldo      = Entity_det.Saldo - item.ValorAplicado;
                        Context.SaveChanges();
                    }
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public Boolean Guardar_DB(ro_prestamo_Info Item, ref decimal Id, ref string mensaje)
        {
            try
            {
                using (EntitiesRoles Context = new EntitiesRoles())
                {
                    ro_prestamo Cabe = new ro_prestamo();

                    Cabe.IdEmpresa          = Item.IdEmpresa;
                    Cabe.IdPrestamo         = Id = GetIdPrestamo();
                    Cabe.descuento_men_quin = Item.descuento_men_quin;
                    Cabe.descuento_mensual  = Item.descuento_mensual;
                    Cabe.descuento_quincena = Item.descuento_quincena;
                    Cabe.IdEmpleado         = Item.IdEmpleado;
                    Cabe.IdRubro            = Item.IdRubro;
                    Cabe.IdEmpleado_Aprueba = Item.IdEmpleado_Aprueba;
                    Cabe.Estado             = Item.Estado;
                    Cabe.Fecha         = Convert.ToDateTime(Item.Fecha.ToShortDateString());
                    Cabe.MontoSol      = Item.MontoSol;
                    Cabe.TasaInteres   = Item.TasaInteres;
                    Cabe.TotalPrestamo = Item.TotalPrestamo;
                    Cabe.NumCuotas     = Item.NumCuotas;
                    Cabe.Fecha_PriPago = Item.Fecha_PriPago;
                    Cabe.Observacion   = Item.Observacion;
                    Cabe.Tipo_Calculo  = Item.Tipo_Calculo;

                    Cabe.IdUsuario          = Item.IdUsuario;
                    Cabe.Fecha_Transac      = Item.Fecha_Transac;
                    Cabe.nom_pc             = Item.nom_pc;
                    Cabe.ip                 = Item.ip;
                    Cabe.descuento_men_quin = Item.descuento_men_quin;
                    Cabe.descuento_mensual  = Item.descuento_mensual;
                    Cabe.descuento_quincena = Item.descuento_quincena; Context.ro_prestamo.Add(Cabe);
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                string array = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", array, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
        public ro_prestamo_Info get_info(int IdEmpresa, decimal IdEmpleado, decimal IdPrestamo)
        {
            try
            {
                ro_prestamo_Info info = new ro_prestamo_Info();

                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdEmpleado == IdEmpleado && q.IdPrestamo == IdPrestamo);
                    if (Entity == null)
                    {
                        return(null);
                    }

                    info = new ro_prestamo_Info
                    {
                        IdEmpresa          = Entity.IdEmpresa,
                        IdPrestamo         = Entity.IdPrestamo,
                        descuento_mensual  = Entity.descuento_mensual,
                        descuento_men_quin = Entity.descuento_men_quin,
                        descuento_quincena = Entity.descuento_quincena,
                        IdEmpleado         = Entity.IdEmpleado,
                        IdRubro            = Entity.IdRubro,
                        IdEmpleado_Aprueba = Entity.IdEmpleado_Aprueba,
                        Estado             = Entity.Estado,
                        Fecha         = Entity.Fecha,
                        MontoSol      = Entity.MontoSol,
                        TasaInteres   = Entity.TasaInteres,
                        TotalPrestamo = Entity.TotalPrestamo,
                        NumCuotas     = Entity.NumCuotas,
                        Fecha_PriPago = Entity.Fecha_PriPago,
                        Observacion   = Entity.Observacion,
                        Tipo_Calculo  = Entity.Tipo_Calculo,
                        IdTipoCbte    = Entity.IdTipoCbte,
                        IdCbteCble    = Entity.IdCbteCble,
                        IdOrdenPago   = Entity.IdOrdenPago
                    };
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public bool guardarDB(ro_prestamo_Info info)
 {
     try
     {
         var ro_parametro = odata.get_info(info.IdEmpresa);
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_prestamo Entity = new ro_prestamo
             {
                 IdEmpresa          = info.IdEmpresa,
                 IdPrestamo         = info.IdPrestamo = get_id(info.IdEmpresa),
                 descuento_mensual  = info.descuento_mensual,
                 descuento_men_quin = info.descuento_men_quin,
                 descuento_quincena = info.descuento_quincena,
                 IdEmpleado         = info.IdEmpleado,
                 IdRubro            = info.IdRubro,
                 Fecha         = info.Fecha.Date,
                 MontoSol      = info.MontoSol,
                 NumCuotas     = info.NumCuotas,
                 Fecha_PriPago = info.Fecha_PriPago.Date,
                 Observacion   = info.Observacion,
                 GeneraOP      = info.GeneraOP,
                 Estado        = info.Estado = true,
                 EstadoAprob   = ro_parametro.EstadoCreacionPrestamos,
                 IdUsuario     = info.IdUsuario,
                 Fecha_Transac = info.Fecha_Transac = DateTime.Now
             };
             Context.ro_prestamo.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         tb_LogError_Data LogData = new tb_LogError_Data();
         LogData.GuardarDB(new tb_LogError_Info {
             Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_prestamo_Data", Metodo = "guardarDB", IdUsuario = info.IdUsuario
         });
         return(false);
     }
 }
        public bool modificarDB(ro_prestamo_Info info)
        {
            try
            {
                var ro_parametro = odata.get_info(info.IdEmpresa);
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdPrestamo == info.IdPrestamo);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.descuento_mensual  = info.descuento_mensual;
                    Entity.descuento_men_quin = info.descuento_men_quin;
                    Entity.descuento_quincena = info.descuento_quincena;
                    Entity.IdEmpleado         = info.IdEmpleado;
                    Entity.IdRubro            = info.IdRubro;
                    Entity.Fecha           = info.Fecha.Date;
                    Entity.MontoSol        = info.MontoSol;
                    Entity.NumCuotas       = info.NumCuotas;
                    Entity.Fecha_PriPago   = info.Fecha_PriPago.Date;
                    Entity.Observacion     = info.Observacion;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Entity.EstadoAprob     = ro_parametro.EstadoCreacionPrestamos;
                    Entity.GeneraOP        = info.GeneraOP;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                tb_LogError_Data LogData = new tb_LogError_Data();
                LogData.GuardarDB(new tb_LogError_Info {
                    Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_prestamo_Data", Metodo = "modificarDB", IdUsuario = info.IdUsuario
                });
                return(false);
            }
        }
 public bool guardarDB(ro_prestamo_Info info)
 {
     try
     {
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_prestamo Entity = new ro_prestamo
             {
                 IdEmpresa          = info.IdEmpresa,
                 IdPrestamo         = info.IdPrestamo = get_id(info.IdEmpresa),
                 descuento_mensual  = info.descuento_mensual,
                 descuento_men_quin = info.descuento_men_quin,
                 descuento_quincena = info.descuento_quincena,
                 IdEmpleado         = info.IdEmpleado,
                 IdRubro            = info.IdRubro,
                 IdEmpleado_Aprueba = info.IdEmpleado_Aprueba,
                 Fecha         = info.Fecha.Date,
                 MontoSol      = info.MontoSol,
                 TasaInteres   = info.TasaInteres,
                 TotalPrestamo = info.TotalPrestamo,
                 NumCuotas     = info.NumCuotas,
                 Fecha_PriPago = info.Fecha_PriPago.Date,
                 Observacion   = info.Observacion,
                 Tipo_Calculo  = info.Tipo_Calculo,
                 Estado        = info.Estado = "A",
                 IdUsuario     = info.IdUsuario,
                 Fecha_Transac = info.Fecha_Transac = DateTime.Now
             };
             Context.ro_prestamo.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #8
0
 public bool guardarDB(ro_prestamo_Info info)
 {
     try
     {
         var ro_parametro = odata.get_info(info.IdEmpresa);
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_prestamo Entity = new ro_prestamo
             {
                 IdEmpresa          = info.IdEmpresa,
                 IdPrestamo         = info.IdPrestamo = get_id(info.IdEmpresa),
                 descuento_mensual  = info.descuento_mensual,
                 descuento_men_quin = info.descuento_men_quin,
                 descuento_quincena = info.descuento_quincena,
                 IdEmpleado         = info.IdEmpleado,
                 IdRubro            = info.IdRubro,
                 Fecha         = info.Fecha.Date,
                 MontoSol      = info.MontoSol,
                 NumCuotas     = info.NumCuotas,
                 Fecha_PriPago = info.Fecha_PriPago.Date,
                 Observacion   = info.Observacion,
                 GeneraOP      = info.GeneraOP,
                 Estado        = info.Estado = true,
                 EstadoAprob   = ro_parametro.EstadoCreacionPrestamos,
                 IdUsuario     = info.IdUsuario,
                 Fecha_Transac = info.Fecha_Transac = DateTime.Now
             };
             Context.ro_prestamo.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public bool modificarDB(ro_prestamo_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdPrestamo == info.IdPrestamo);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.descuento_mensual  = info.descuento_mensual;
                    Entity.descuento_men_quin = info.descuento_men_quin;
                    Entity.descuento_quincena = info.descuento_quincena;
                    Entity.IdEmpleado         = info.IdEmpleado;
                    Entity.IdRubro            = info.IdRubro;
                    Entity.IdEmpleado_Aprueba = info.IdEmpleado_Aprueba;
                    Entity.Fecha           = info.Fecha.Date;
                    Entity.MontoSol        = info.MontoSol;
                    Entity.TasaInteres     = info.TasaInteres;
                    Entity.TotalPrestamo   = info.TotalPrestamo;
                    Entity.NumCuotas       = info.NumCuotas;
                    Entity.Fecha_PriPago   = info.Fecha_PriPago.Date;
                    Entity.Observacion     = info.Observacion;
                    Entity.Tipo_Calculo    = info.Tipo_Calculo;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #10
0
        public bool anularDB(ro_PrestamoMasivo_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_PrestamoMasivo Entity    = Context.ro_PrestamoMasivo.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal && q.IdCarga == info.IdCarga).FirstOrDefault();
                    var prestamo_masivo_detalle = Context.ro_PrestamoMasivo_Det.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdCarga == info.IdCarga).ToList();

                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.Estado          = info.Estado = false;
                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    Entity.MotiAnula       = info.MotiAnula;

                    if (prestamo_masivo_detalle != null || prestamo_masivo_detalle.Count() > 0)
                    {
                        foreach (var item in prestamo_masivo_detalle)
                        {
                            ro_prestamo Entity_Prestamo = Context.ro_prestamo.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdPrestamo == item.IdPrestamo).FirstOrDefault();
                            Entity_Prestamo.Estado = false;
                        }
                    }

                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #11
0
        public bool anularDB(ro_prestamo_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdPrestamo == info.IdPrestamo);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.Estado          = info.Estado = false;
                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #12
0
        public bool modificarDB(ro_prestamo_Info info)
        {
            try
            {
                var ro_parametro = odata.get_info(info.IdEmpresa);
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdPrestamo == info.IdPrestamo);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.descuento_mensual  = info.descuento_mensual;
                    Entity.descuento_men_quin = info.descuento_men_quin;
                    Entity.descuento_quincena = info.descuento_quincena;
                    Entity.IdEmpleado         = info.IdEmpleado;
                    Entity.IdRubro            = info.IdRubro;
                    Entity.Fecha           = info.Fecha.Date;
                    Entity.MontoSol        = info.MontoSol;
                    Entity.NumCuotas       = info.NumCuotas;
                    Entity.Fecha_PriPago   = info.Fecha_PriPago.Date;
                    Entity.Observacion     = info.Observacion;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Entity.EstadoAprob     = ro_parametro.EstadoCreacionPrestamos;
                    Entity.GeneraOP        = info.GeneraOP;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #13
0
        public bool aprobar_prestamo(int IdEmpresa, string[] Lista, string IdUsuarioAprueba)
        {
            Entities_rrhh Context = new Entities_rrhh();
            Entities_cuentas_por_pagar Context_cxp = new Entities_cuentas_por_pagar();
            Entities_contabilidad      Context_ct  = new Entities_contabilidad();

            try
            {
                ro_Parametros Entity_ro_parametros          = Context.ro_Parametros.Where(q => q.IdEmpresa == IdEmpresa).FirstOrDefault();
                cp_orden_pago_tipo_x_empresa Entity_op_tipo = Context_cxp.cp_orden_pago_tipo_x_empresa.Where(q => q.IdEmpresa == IdEmpresa && q.IdTipo_op == Entity_ro_parametros.IdTipo_op_prestamos).FirstOrDefault();


                decimal IdOrdenPago   = 1;
                decimal IdCbteCble_OP = 1;

                foreach (var item in Lista)
                {
                    var         IdPrestamo      = Convert.ToDecimal(item);
                    ro_prestamo Entity_Prestamo = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdPrestamo == IdPrestamo);
                    if (Entity_Prestamo != null)
                    {
                        Entity_Prestamo.IdUsuarioAprueba = IdUsuarioAprueba;
                        Entity_Prestamo.EstadoAprob      = "APROB";
                    }

                    if (Entity_Prestamo.GeneraOP)
                    {
                        IdOrdenPago   = data_op.get_id(Entity_Prestamo.IdEmpresa);
                        IdCbteCble_OP = data_ct.get_id(Entity_Prestamo.IdEmpresa, Convert.ToInt32(Entity_op_tipo.IdTipoCbte_OP));
                        ro_empleado Entity_Empleado = Context.ro_empleado.Where(q => q.IdEmpresa == Entity_Prestamo.IdEmpresa && q.IdEmpleado == Entity_Prestamo.IdEmpleado).FirstOrDefault();
                        var         cuenta_x_rubro  = Context.ro_rubro_tipo.Where(q => q.IdEmpresa == Entity_Prestamo.IdEmpresa && q.IdRubro == Entity_Prestamo.IdRubro).FirstOrDefault();

                        if (
                            Entity_Empleado.IdCtaCble_x_pagar_empleado != null &&
                            Entity_Empleado.IdCtaCble_Emplea != null
                            )
                        {
                            cp_orden_pago op = new cp_orden_pago
                            {
                                IdEmpresa          = IdEmpresa,
                                IdSucursal         = Entity_Empleado.IdSucursal,
                                IdOrdenPago        = IdOrdenPago,
                                Observacion        = "Prestamo #" + Entity_Prestamo.IdPrestamo,
                                IdTipo_op          = Entity_ro_parametros.IdTipo_op_prestamos,
                                IdTipo_Persona     = cl_enumeradores.eTipoPersona.EMPLEA.ToString(),
                                IdPersona          = Entity_Empleado.IdPersona,
                                IdEntidad          = Entity_Prestamo.IdEmpleado,
                                Fecha              = DateTime.Now.Date,
                                IdEstadoAprobacion = Entity_op_tipo.IdEstadoAprobacion,
                                IdFormaPago        = cl_enumeradores.eFormaPagoOrdenPago.CHEQUE.ToString(),
                                Estado             = "A"
                            };

                            Entity_Prestamo.IdEmpresa_op = op.IdEmpresa;
                            Entity_Prestamo.IdOrdenPago  = op.IdOrdenPago;

                            Context_cxp.cp_orden_pago.Add(op);

                            ct_cbtecble diario = new ct_cbtecble
                            {
                                IdEmpresa       = IdEmpresa,
                                IdTipoCbte      = Convert.ToInt32(Entity_op_tipo.IdTipoCbte_OP),
                                IdCbteCble      = IdCbteCble_OP,
                                cb_Fecha        = DateTime.Now.Date,
                                cb_Observacion  = op.Observacion,
                                IdPeriodo       = Convert.ToInt32(DateTime.Now.Date.ToString("yyyyMM")),
                                IdSucursal      = Entity_Empleado.IdSucursal,
                                cb_FechaTransac = DateTime.Now,
                                cb_Estado       = "A"
                            };

                            Entity_Prestamo.IdEmpresa_dc = diario.IdEmpresa;
                            Entity_Prestamo.IdTipoCbte   = diario.IdTipoCbte;
                            Entity_Prestamo.IdCbteCble   = diario.IdCbteCble;

                            Context_ct.ct_cbtecble.Add(diario);

                            ct_cbtecble_det diario_det = new ct_cbtecble_det
                            {
                                IdEmpresa  = diario.IdEmpresa,
                                IdTipoCbte = diario.IdTipoCbte,
                                IdCbteCble = diario.IdCbteCble,
                                secuencia  = 1,
                                IdCtaCble  = Entity_Empleado.IdCtaCble_Emplea,
                                dc_Valor   = Math.Round(Convert.ToDouble(Entity_Prestamo.MontoSol), 2, MidpointRounding.AwayFromZero),
                            };

                            Context_ct.ct_cbtecble_det.Add(diario_det);

                            ct_cbtecble_det diario_det_ = new ct_cbtecble_det
                            {
                                IdEmpresa  = diario.IdEmpresa,
                                IdTipoCbte = diario.IdTipoCbte,
                                IdCbteCble = diario.IdCbteCble,
                                secuencia  = 2,
                                IdCtaCble  = Entity_Empleado.IdCtaCble_x_pagar_empleado,
                                dc_Valor   = Math.Round(Convert.ToDouble(Entity_Prestamo.MontoSol), 2, MidpointRounding.AwayFromZero) * -1
                            };

                            Context_ct.ct_cbtecble_det.Add(diario_det_);

                            cp_orden_pago_det op_det = new cp_orden_pago_det
                            {
                                IdEmpresa   = op.IdEmpresa,
                                IdOrdenPago = op.IdOrdenPago,
                                Secuencia   = 1,

                                IdEmpresa_cxp  = diario.IdEmpresa,
                                IdTipoCbte_cxp = diario.IdTipoCbte,
                                IdCbteCble_cxp = diario.IdCbteCble,

                                Valor_a_pagar      = Convert.ToDouble(Entity_Prestamo.MontoSol),
                                IdEstadoAprobacion = Entity_op_tipo.IdEstadoAprobacion,
                                IdFormaPago        = cl_enumeradores.eFormaPagoOrdenPago.CHEQUE.ToString(),
                                Fecha_Pago         = op.Fecha
                            };

                            Context_cxp.cp_orden_pago_det.Add(op_det);
                        }
                    }
                    Context_ct.SaveChanges();
                    Context_cxp.SaveChanges();
                    Context.SaveChanges();
                }

                Context_ct.Dispose();
                Context_cxp.Dispose();
                Context.Dispose();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #14
0
        public bool guardarDB(ro_PrestamoMasivo_Info info)
        {
            try
            {
                var     ro_parametro = odata.get_info(info.IdEmpresa);
                var     Secuencia    = 1;
                decimal IdPrestamo   = odata_prestamo.get_id(info.IdEmpresa);
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_PrestamoMasivo Entity = new ro_PrestamoMasivo
                    {
                        IdEmpresa          = info.IdEmpresa,
                        IdSucursal         = info.IdSucursal,
                        IdCarga            = info.IdCarga = get_id(info.IdEmpresa),
                        Fecha_PriPago      = info.Fecha_PriPago,
                        NumCuotas          = info.NumCuotas,
                        descuento_mensual  = info.descuento_mensual,
                        descuento_men_quin = info.descuento_men_quin,
                        descuento_quincena = info.descuento_quincena,
                        Observacion        = info.Observacion,
                        Estado             = info.Estado = true,
                        IdUsuario          = info.IdUsuario,
                        Fecha_Transac      = info.Fecha_Transac = DateTime.Now
                    };
                    Context.ro_PrestamoMasivo.Add(Entity);

                    foreach (var item in info.lst_detalle)
                    {
                        ro_PrestamoMasivo_Det Entity_Det = new ro_PrestamoMasivo_Det
                        {
                            IdEmpresa  = info.IdEmpresa,
                            IdSucursal = info.IdSucursal,
                            IdCarga    = info.IdCarga,
                            Secuencia  = Secuencia++,
                            IdEmpleado = item.IdEmpleado,
                            IdRubro    = item.IdRubro,
                            Monto      = item.Monto,
                            NumCuotas  = item.NumCuotas
                        };

                        var info_prestamo = new ro_prestamo_Info
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdPrestamo         = IdPrestamo++,
                            IdEmpleado         = item.IdEmpleado,
                            IdRubro            = item.IdRubro,
                            descuento_mensual  = info.descuento_mensual,
                            descuento_men_quin = info.descuento_men_quin,
                            descuento_quincena = info.descuento_quincena,
                            Fecha         = info.Fecha_PriPago.Date,
                            MontoSol      = item.Monto,
                            NumCuotas     = item.NumCuotas,
                            Fecha_PriPago = info.Fecha_PriPago.Date,
                            Observacion   = info.Observacion,
                            GeneraOP      = true,
                            Estado        = true,
                            EstadoAprob   = ro_parametro.EstadoCreacionPrestamos,
                            IdUsuario     = info.IdUsuario,
                            Fecha_Transac = info.Fecha_Transac = DateTime.Now
                        };

                        if (info.descuento_men_quin == true)
                        {
                            info_prestamo = get_calculoquincenal_y_men(info_prestamo);
                        }

                        if (info.descuento_quincena == true)
                        {
                            info_prestamo = get_calculoquincenal(info_prestamo);
                        }

                        if (info.descuento_mensual == true)
                        {
                            info_prestamo = get_calculomensual(info_prestamo);
                        }

                        if (info_prestamo == null)
                        {
                            return(false);
                        }
                        else
                        {
                            ro_prestamo Entity_Cab_Prestamo = new ro_prestamo
                            {
                                IdEmpresa          = info_prestamo.IdEmpresa,
                                IdPrestamo         = info_prestamo.IdPrestamo,
                                IdEmpleado         = info_prestamo.IdEmpleado,
                                IdRubro            = info_prestamo.IdRubro,
                                descuento_mensual  = info_prestamo.descuento_mensual,
                                descuento_men_quin = info_prestamo.descuento_men_quin,
                                descuento_quincena = info_prestamo.descuento_quincena,
                                Fecha         = info_prestamo.Fecha_PriPago.Date,
                                MontoSol      = info_prestamo.MontoSol,
                                NumCuotas     = info_prestamo.NumCuotas,
                                Fecha_PriPago = info_prestamo.Fecha_PriPago.Date,
                                Observacion   = info_prestamo.Observacion,
                                GeneraOP      = info_prestamo.GeneraOP,
                                Estado        = info_prestamo.Estado,
                                EstadoAprob   = info_prestamo.EstadoAprob,
                                IdUsuario     = info_prestamo.IdUsuario,
                                Fecha_Transac = info_prestamo.Fecha_Transac
                            };

                            Entity_Det.IdPrestamo = Entity_Cab_Prestamo.IdPrestamo;
                            Context.ro_prestamo.Add(Entity_Cab_Prestamo);
                            Context.ro_PrestamoMasivo_Det.Add(Entity_Det);

                            foreach (var item_prest in info_prestamo.lst_detalle)
                            {
                                ro_prestamo_detalle Entity_Det_Prestamo = new ro_prestamo_detalle
                                {
                                    IdEmpresa         = info_prestamo.IdEmpresa,
                                    IdPrestamo        = info_prestamo.IdPrestamo,
                                    NumCuota          = item_prest.NumCuota,
                                    SaldoInicial      = item_prest.SaldoInicial,
                                    TotalCuota        = item_prest.TotalCuota,
                                    Saldo             = item_prest.Saldo,
                                    FechaPago         = item_prest.FechaPago,
                                    EstadoPago        = item_prest.EstadoPago,
                                    Estado            = true,
                                    Observacion_det   = item_prest.Observacion_det,
                                    IdNominaTipoLiqui = item_prest.IdNominaTipoLiqui
                                };
                                Context.ro_prestamo_detalle.Add(Entity_Det_Prestamo);
                            }
                        }
                    }

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                tb_LogError_Data LogData = new tb_LogError_Data();
                LogData.GuardarDB(new tb_LogError_Info {
                    Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_prestamo_Data", Metodo = "guardarDB", IdUsuario = info.IdUsuario
                });
                return(false);
            }
        }