コード例 #1
0
        public List <vwAf_Valores_Depre_Contabilizar_Info> Get_List_ValoresDepreciacion_xCtaCble
            (int IdEmpresa, decimal IdDepreciacion, int IdTipoDepreciacion, int IdPeriodo, Cl_Enumeradores.eForma_Contabilizar FormaContabilizar)
        {
            try
            {
                List <vwAf_Valores_Depre_Contabilizar_Info> lstInfo = new List <vwAf_Valores_Depre_Contabilizar_Info>();

                using (EntitiesActivoFijo listado = new EntitiesActivoFijo())
                {
                    var selectValores = from q in listado.vwAf_Valores_Depre_Contabilizar
                                        where q.IdEmpresa == IdEmpresa && q.IdDepreciacion == IdDepreciacion &&
                                        q.IdTipoDepreciacion == IdTipoDepreciacion && q.IdPeriodo == IdPeriodo
                                        select q;


                    var select = from gro in selectValores
                                 group gro by new
                    {
                        gro.IdEmpresa,
                        gro.IdDepreciacion,
                        gro.IdTipoDepreciacion,
                        gro.IdPeriodo,
                        gro.Cod_Depreciacion,
                        gro.cod_tipo_depreciacion,
                        gro.Fecha_Depreciacion,
                    } into grouping
                        select new { grouping.Key, Valor_Depre = grouping.Sum(p => p.Valor_Depreciacion) };

                    foreach (var item in select)
                    {
                        vwAf_Valores_Depre_Contabilizar_Info info = new vwAf_Valores_Depre_Contabilizar_Info();
                        info.IdEmpresa          = item.Key.IdEmpresa;
                        info.IdDepreciacion     = item.Key.IdDepreciacion;
                        info.IdTipoDepreciacion = item.Key.IdTipoDepreciacion;
                        info.Cod_Depreciacion   = item.Key.Cod_Depreciacion;
                        info.IdPeriodo          = item.Key.IdPeriodo;
                        info.Fecha_Depreciacion = item.Key.Fecha_Depreciacion;
                        info.Valor_Depreciacion = Convert.ToDouble(item.Valor_Depre);
                        //info.IdCtaCbleDepre = item.Key.IdCtaCble_Dep_Acum ;
                        //info.IdCtaCbleGastos = item.Key.IdCtaCble_Gastos_Depre ;
                        info.cod_tipo_depreciacion = item.Key.cod_tipo_depreciacion;
                        info.ObservacionCbteCble   = "Contabilizacion " + FormaContabilizar + " de " + item.Key.cod_tipo_depreciacion + " Periodo " + Convert.ToString(item.Key.IdPeriodo);

                        lstInfo.Add(info);
                    }
                }
                return(lstInfo);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
コード例 #2
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)
                      };
            }
        }