示例#1
0
        public Boolean ModificarDB(Af_Activo_fijo_Info info, ref string msg)
        {
            try
            {
                Boolean respuesta = false;

                respuesta = data.ModificarDB(info, ref msg);

                if (respuesta)
                {
                    respuesta = activos_relacionados.EliminarDB(info.IdEmpresa, info.IdActivoFijo);

                    Af_Activo_fijo_CtasCbles_Bus BusCtas_AF = new Af_Activo_fijo_CtasCbles_Bus();
                    BusCtas_AF.EliminarDB(info.IdEmpresa, info.IdActivoFijo);

                    int c = 1;
                    foreach (var item in info.ListAf_Activo_fijo_CtasCbles)
                    {
                        item.Secuencia = c++;
                    }
                    BusCtas_AF.GuardarDB(info.ListAf_Activo_fijo_CtasCbles, ref msg);
                }
                return(respuesta);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "ModificarDB", ex.Message), ex)
                      {
                          EntityType = typeof(Af_Activo_fijo_Bus)
                      };
            }
        }
示例#2
0
        public Boolean GrabarDB(Af_Activo_fijo_Info info, ref int id, ref string CodActivo, ref string msg)
        {
            try
            {
                Boolean respuesta = false;


                respuesta = Validar_y_corregir_objeto(ref info, ref msg);

                if (respuesta == true)
                {
                    respuesta = data.GrabarDB(info, ref id, ref CodActivo, ref msg);

                    if (respuesta)
                    {
                        activos_relacionados.EliminarDB(info.IdEmpresa, info.IdActivoFijo);
                        if ((bool)info.Es_carroceria)
                        {
                            if (info.lista_Activo_relacionados != null)
                            {
                                foreach (var item in info.lista_Activo_relacionados)
                                {
                                    item.IdEmpresa         = info.IdEmpresa;
                                    item.IdActivoFijo_hijo = id;
                                }
                                activos_relacionados.EliminarDB(info.IdEmpresa, id);
                                activos_relacionados.GuardarDB(info.lista_Activo_relacionados);
                            }
                        }


                        Af_Activo_fijo_CtasCbles_Bus BusCtas_AF = new Af_Activo_fijo_CtasCbles_Bus();
                        BusCtas_AF.EliminarDB(info.IdEmpresa, info.IdActivoFijo);

                        int c = 1;
                        foreach (var item in info.ListAf_Activo_fijo_CtasCbles)
                        {
                            item.IdActivoFijo = info.IdActivoFijo;
                            item.Secuencia    = c++;
                        }

                        BusCtas_AF.GuardarDB(info.ListAf_Activo_fijo_CtasCbles, ref msg);
                    }
                }

                return(respuesta);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GrabarDB", ex.Message), ex)
                      {
                          EntityType = typeof(Af_Activo_fijo_Bus)
                      };
            }
        }
示例#3
0
        public ct_Cbtecble_Info GetCbtecble_x_Depreacion(int IdEmpresa, int IdTipoCbteDepre,
                                                         int IdPeriodo, List <vwAf_Valores_Depre_Contabilizar_Info> ListInfo_data, Cl_Enumeradores.eForma_Contabilizar sFormaContabiliza, ref string sMensajeError)
        {
            try
            {
                ct_Cbtecble_Info CbteCbleInfo = new ct_Cbtecble_Info();
                ct_Periodo_Info  InfoPeriodo  = new ct_Periodo_Info();
                ct_Periodo_Bus   BusPeriodo   = new ct_Periodo_Bus();
                DateTime         Fecha_Contab = new DateTime();

                InfoPeriodo  = BusPeriodo.Get_Info_Periodo(IdEmpresa, IdPeriodo, ref sMensajeError);
                Fecha_Contab = InfoPeriodo.pe_FechaFin;


                CbteCbleInfo.IdEmpresa      = IdEmpresa;
                CbteCbleInfo.IdTipoCbte     = IdTipoCbteDepre;
                CbteCbleInfo.CodCbteCble    = "";
                CbteCbleInfo.IdCbteCble     = 0;
                CbteCbleInfo.IdPeriodo      = (Fecha_Contab.Year * 100) + Fecha_Contab.Month;
                CbteCbleInfo.cb_Fecha       = Fecha_Contab;
                CbteCbleInfo.cb_Valor       = ListInfo_data.Where(q => q.Valor_Depreciacion > 0).Sum(q => q.Valor_Depreciacion);
                CbteCbleInfo.cb_Observacion = "Contabilizacion " + Cl_Enumeradores.eTipoDepreciacion.DEP_LIN.ToString() + " Por " + sFormaContabiliza.ToString() + " Periodo " + IdPeriodo;
                CbteCbleInfo.Secuencia      = 0;
                CbteCbleInfo.Estado         = "A";
                CbteCbleInfo.Anio           = Convert.ToDateTime(CbteCbleInfo.cb_Fecha).Year;
                CbteCbleInfo.Mes            = Convert.ToDateTime(CbteCbleInfo.cb_Fecha).Month;
                //CbteCbleInfo.IdUsuario = param.IdUsuario;
                CbteCbleInfo.cb_FechaTransac = DateTime.Now;
                CbteCbleInfo.Mayorizado      = "N";


                List <ct_Cbtecble_det_Info> lstDetalle = new List <ct_Cbtecble_det_Info>();

                List <Af_Activo_fijo_CtasCbles_Info> ListInfo_Activos_x_ctas = new List <Af_Activo_fijo_CtasCbles_Info>();
                Af_Activo_fijo_CtasCbles_Bus         BusAf_x_ctaCbles        = new Af_Activo_fijo_CtasCbles_Bus();
                ListInfo_Activos_x_ctas = BusAf_x_ctaCbles.Get_List_Activo_fijo_CtasCbles(IdEmpresa);

                Af_Parametros_Info info_param_af = new Af_Parametros_Info();
                Af_Parametros_Bus  bus_param_af  = new Af_Parametros_Bus();
                info_param_af = bus_param_af.Get_Info_Parametros(IdEmpresa);

                #region Contabilización x activo
                foreach (var item_x_data in ListInfo_data)
                {
                    List <Af_Activo_fijo_CtasCbles_Info> ListInfo_Af_x_ctas = new List <Af_Activo_fijo_CtasCbles_Info>();

                    if (info_param_af.FormaContabiliza == Cl_Enumeradores.eForma_Contabilizar.Por_Activo.ToString())
                    {
                        ListInfo_Af_x_ctas = ListInfo_Activos_x_ctas.Where(v => v.IdEmpresa == IdEmpresa && v.IdActivoFijo == item_x_data.IdActivoFijo).ToList();
                    }

                    if (info_param_af.FormaContabiliza == Cl_Enumeradores.eForma_Contabilizar.Por_CtaCble.ToString())
                    {
                    }

                    if (info_param_af.FormaContabiliza == Cl_Enumeradores.eForma_Contabilizar.Por_Tipo_CtaCble.ToString())
                    {
                        ListInfo_Af_x_ctas = ListInfo_Activos_x_ctas.Where(v => v.IdEmpresa == IdEmpresa && v.IdActijoFijoTipo == item_x_data.IdActijoFijoTipo).ToList();
                    }

                    vwAf_Valores_Depre_Contabilizar_Info Info_valores_depre_con_x_Gasto_depre = new vwAf_Valores_Depre_Contabilizar_Info();
                    Info_valores_depre_con_x_Gasto_depre = item_x_data;



                    //////////////////////////////
                    var q_Gastos_x_depre = from C in ListInfo_Af_x_ctas
                                           where C.IdTipoCuenta == "CTA_GASTOS_DEPRE"
                                           group C by new { C.IdEmpresa, C.IdTipoCuenta, C.IdCtaCble, C.porc_distribucion }
                    into grouping
                        select new { grouping.Key, Total_reg = grouping.Count() };


                    if (q_Gastos_x_depre.Count() == 1) // solo hay una cuenta x CTA_GASTOS_DEPRE
                    {
                        foreach (var item_x_cta in q_Gastos_x_depre)
                        {
                            Info_valores_depre_con_x_Gasto_depre.IdCtaCbleGastos      = item_x_cta.Key.IdCtaCble;
                            Info_valores_depre_con_x_Gasto_depre.Valor_a_contabilizar = item_x_data.Valor_Depreciacion;
                        }
                    }
                    else// mas de una cta distribuir por %
                    {
                        foreach (var item_x_cta in q_Gastos_x_depre)
                        {
                            Info_valores_depre_con_x_Gasto_depre.IdCtaCbleGastos      = item_x_cta.Key.IdCtaCble;
                            Info_valores_depre_con_x_Gasto_depre.Valor_a_contabilizar = (item_x_data.Valor_Depreciacion * item_x_cta.Key.porc_distribucion) / 100;
                        }
                    }

                    ///

                    //////////////////////////////
                    ///////// Info_valores_depre_con_x_depre_Acum
                    vwAf_Valores_Depre_Contabilizar_Info Info_valores_depre_con_x_depre_Acum = new vwAf_Valores_Depre_Contabilizar_Info();
                    Info_valores_depre_con_x_depre_Acum = item_x_data;

                    var q_depre_Acumulada = from C in ListInfo_Af_x_ctas
                                            where C.IdTipoCuenta == "CTA_DEPRE_ACUM"
                                            group C by new { C.IdEmpresa, C.IdTipoCuenta, C.IdCtaCble, C.porc_distribucion }
                    into grouping
                        select new { grouping.Key, Total_reg = grouping.Count() };


                    if (q_depre_Acumulada.Count() == 1) // solo hay una cuenta x CTA_DEPRE_ACUM
                    {
                        foreach (var item_x_cta in q_depre_Acumulada)
                        {
                            Info_valores_depre_con_x_depre_Acum.IdCtaCbleDepre       = item_x_cta.Key.IdCtaCble;
                            Info_valores_depre_con_x_depre_Acum.Valor_a_contabilizar = item_x_data.Valor_Depreciacion;
                        }
                    }
                    else// mas de una cta distribuir por %
                    {
                        foreach (var item_x_cta in q_depre_Acumulada)
                        {
                            Info_valores_depre_con_x_depre_Acum.IdCtaCbleDepre       = item_x_cta.Key.IdCtaCble;
                            Info_valores_depre_con_x_depre_Acum.Valor_a_contabilizar = (item_x_data.Valor_Depreciacion * item_x_cta.Key.porc_distribucion) / 100;
                        }
                    }



                    ct_Cbtecble_det_Info infoDetalle = new ct_Cbtecble_det_Info();

                    infoDetalle                = new ct_Cbtecble_det_Info();
                    infoDetalle.IdEmpresa      = IdEmpresa;
                    infoDetalle.IdTipoCbte     = IdTipoCbteDepre;
                    infoDetalle.IdCtaCble      = Info_valores_depre_con_x_Gasto_depre.IdCtaCbleGastos;
                    infoDetalle.dc_Valor       = Info_valores_depre_con_x_Gasto_depre.Valor_a_contabilizar;
                    infoDetalle.dc_Observacion = CbteCbleInfo.cb_Observacion;
                    infoDetalle.secuencia      = 1;
                    lstDetalle.Add(infoDetalle);

                    //datos el haber
                    infoDetalle                = new ct_Cbtecble_det_Info();
                    infoDetalle.IdEmpresa      = IdEmpresa;
                    infoDetalle.IdTipoCbte     = IdTipoCbteDepre;
                    infoDetalle.IdCtaCble      = Info_valores_depre_con_x_depre_Acum.IdCtaCbleDepre;
                    infoDetalle.dc_Valor       = Info_valores_depre_con_x_depre_Acum.Valor_a_contabilizar * -1;
                    infoDetalle.dc_Observacion = CbteCbleInfo.cb_Observacion;
                    infoDetalle.secuencia      = 2;
                    lstDetalle.Add(infoDetalle);
                }


                CbteCbleInfo._cbteCble_det_lista_info = lstDetalle;
                #endregion


                return(CbteCbleInfo);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "ContabilizarDepreciacion", ex.Message), ex)
                      {
                          EntityType = typeof(Af_Depreciacion_Bus)
                      };
            }
        }