public Boolean AnularDB(cp_retencion_Info info, ref decimal idCbteCble_anu, ref string mensaje)
        {
            Boolean res = true;

            try
            {
                cp_parametros_Bus  BusParam  = new cp_parametros_Bus();
                cp_parametros_Info InfoParam = new cp_parametros_Info();
                InfoParam = BusParam.Get_Info_parametros(info.IdEmpresa);

                cp_retencion_x_ct_cbtecble_Info info_x_cbte = Get_Info_retencion_x_ct_cbtecble(info.IdEmpresa, info.IdRetencion);
                if (info_x_cbte.ct_IdEmpresa != 0)
                {
                    info.Info_CbteCble_x_RT = CbteCble_B.Get_Info_CbteCble(info_x_cbte.ct_IdEmpresa, info_x_cbte.ct_IdTipoCbte, info_x_cbte.ct_IdCbteCble, ref mensaje);
                    if (CbteCble_B.ReversoCbteCble(info.Info_CbteCble_x_RT.IdEmpresa, info.Info_CbteCble_x_RT.IdCbteCble, info.Info_CbteCble_x_RT.IdTipoCbte
                                                   , Convert.ToInt32(InfoParam.pa_IdTipoCbte_x_Anu_Retencion),
                                                   ref idCbteCble_anu, ref mensaje, info.IdUsuarioUltAnu, info.MotivoAnulacion))
                    {
                        info.ct_IdEmpresa_Anu  = info.Info_CbteCble_x_RT.IdEmpresa;
                        info.ct_IdCbteCble_Anu = idCbteCble_anu;
                        info.ct_IdTipoCbte_Anu = InfoParam.pa_IdTipoCbte_x_Anu_Retencion;
                    }
                }
                return(data_retencion.AnularDB(info, ref mensaje));
            }
            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("", "AnularDB", ex.Message), ex)
                      {
                          EntityType = typeof(cp_retencion_Bus)
                      };
            }
            return(res);
        }
Example #2
0
        public Boolean Generacion_xml_SRI(int IdEmpresa, decimal IdRetencion, ref string MensajeError)
        {
            try
            {
                cp_parametros_Info cp_parametro     = new cp_parametros_Info();
                cp_parametros_Bus  bus_cp_parametro = new cp_parametros_Bus();
                cp_parametro = bus_cp_parametro.Get_Info_parametros(IdEmpresa);
                string sIdCbteFact = "";

                List <vwcp_Retencion_sri_Info> lista_Retencion_sri = new List <vwcp_Retencion_sri_Info>();

                lista_Retencion_sri = data_retencion.Get_list_Retencion_Sri(IdEmpresa, IdRetencion, ref MensajeError);

                if (lista_Retencion_sri.Count != 0)
                {
                    // validar objeto

                    if (!ValidarObjeto_XML_Retencion(lista_Retencion_sri, ref MensajeError))
                    {
                        return(false);
                    }

                    List <comprobanteRetencion> lista = new List <comprobanteRetencion>();
                    lista = data_retencion.GenerarXmlRetencion(IdEmpresa, IdRetencion, ref MensajeError);

                    if (lista.Count != 0)
                    {
                        foreach (var item in lista)
                        {
                            if (lista_Retencion_sri.FirstOrDefault().ContribuyenteEspecial != "NO")
                            {
                                item.infoCompRetencion.contribuyenteEspecial = lista_Retencion_sri.FirstOrDefault().ContribuyenteEspecial;
                            }
                            sIdCbteFact = item.infoTributaria.razonSocial.Substring(0, 3) + "-" + Cl_Enumeradores.eTipoCodComprobante.RET + "-" + item.infoTributaria.estab + "-" + item.infoTributaria.ptoEmi + "-" + item.infoTributaria.secuencial;
                            XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces();
                            NamespaceObject.Add("", "");
                            XmlSerializer mySerializer = new XmlSerializer(typeof(comprobanteRetencion));
                            StreamWriter  myWriter     = new StreamWriter(cp_parametro.pa_ruta_descarga_xml_fac_elct + sIdCbteFact + ".xml");
                            mySerializer.Serialize(myWriter, item, NamespaceObject);
                            myWriter.Close();
                        }
                    }
                }

                return(true);
            }
            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("", "Generacion_xml_SRI", ex.Message), ex)
                      {
                          EntityType = typeof(cp_retencion_Bus)
                      };
            }
        }
Example #3
0
        public Boolean GrabarDB(cp_nota_DebCre_Info info, ref string mensaje)
        {
            try
            {
                Boolean            res_mod_conta = false;
                decimal            IdCbteCble    = 0;
                ct_Cbtecble_Bus    BusCbteCble   = new ct_Cbtecble_Bus();
                cp_parametros_Bus  BusParam      = new cp_parametros_Bus();
                cp_parametros_Info InfoParam     = new cp_parametros_Info();
                InfoParam = BusParam.Get_Info_parametros(info.IdEmpresa);
                if (info.DebCre == "D")
                {
                    info.IdTipoCbte_Nota = Convert.ToInt32(InfoParam.pa_TipoCbte_ND);
                }
                else
                {
                    info.IdTipoCbte_Nota = Convert.ToInt32(InfoParam.pa_TipoCbte_NC);
                }

                res_mod_conta = BusCbteCble.GrabarDB(info.Info_CbteCble_X_Nota, ref IdCbteCble, ref mensaje);
                if (res_mod_conta == true)
                {
                    info.IdCbteCble_Nota = IdCbteCble;
                    info.IdTipoCbte_Nota = info.Info_CbteCble_X_Nota.IdTipoCbte;

                    res_mod_conta = data.GrabarDB(info, ref mensaje);
                }

                return(res_mod_conta);
            }
            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(cp_nota_DebCre_Bus)
                      };
            }
        }
Example #4
0
        public List <cp_nota_DebCre_Info> ProcesarDataTable_ND_x_Saldo_inicial(DataTable ds, ref string MensajeError)
        {
            cp_parametros_Bus  bus_param  = new cp_parametros_Bus();
            cp_parametros_Info info_param = new cp_parametros_Info();

            info_param = bus_param.Get_Info_parametros(param.IdEmpresa);
            cp_proveedor_Info          info_proveedor = new cp_proveedor_Info();
            cp_proveedor_Bus           bus_proveedor  = new cp_proveedor_Bus();
            List <cp_nota_DebCre_Info> lista          = new List <cp_nota_DebCre_Info>();

            int    COLUMNA_ERROR = 0;
            string FILA_ERROR    = "";

            lista.Clear();
            try
            {
                //VALIDAR QUE TENGA MAS DE 12 COLUMNAS
                //if (ds.Columns.Count == 5)
                {
                    //RECORRE EL DATATABLE REGISTRO X REGISTRO
                    if (ds.Rows.Count > 0)
                    {
                        foreach (DataRow row in ds.Rows)
                        {
                            cp_nota_DebCre_Info info = new cp_nota_DebCre_Info();
                            //RECORRE C/U DE LAS COLUMNAS
                            info.IdEmpresa           = param.IdEmpresa;
                            info.IdCbteCble_Nota     = 0;
                            info.IdTipoCbte_Nota     = Convert.ToInt32(info_param.pa_TipoCbte_ND);
                            info.DebCre              = "D";
                            info.IdTipoNota          = "T_TIP_NOTA_INT";
                            info.IdUsuario           = "SysAdmin";
                            info.PagoLocExt          = "LOC";
                            info.ConvenioTributacion = "NA";
                            info.PagoSujetoRetencion = "NA";
                            info.IdTipoFlujo         = 1;
                            info.Fecha_Transac       = param.Fecha_Transac;
                            info.cn_Por_iva          = param.iva.porcentaje;
                            info.IdCtaCble_IVA       = info_param.pa_ctacble_iva;

                            for (int col = 0; col < ds.Columns.Count + 1; col++)
                            {
                                COLUMNA_ERROR = col;
                                switch (col)
                                {
                                case 0:   //cod_prov
                                    info_proveedor   = bus_proveedor.Get_info_proveedor_x_codigo_para_saldo_inicial(param.IdEmpresa, Convert.ToString(row[col]), ref mensaje);
                                    info.IdProveedor = info_proveedor.IdProveedor;
                                    info.InfoProveedor.IdCtaCble_CXP    = info_proveedor.IdCtaCble_CXP;
                                    info.InfoProveedor.pr_codigo        = Convert.ToString(row[col]).ToString();
                                    info.InfoProveedor.pr_nombre        = info_proveedor.pr_nombre;
                                    info.InfoProveedor.IdClaseProveedor = info_proveedor.IdClaseProveedor;
                                    info.IdSucursal = param.IdSucursal;
                                    FILA_ERROR      = "Código " + Convert.ToString(row[col]);
                                    break;

                                case 1:   //# factura
                                    info.cod_nota = Convert.ToString(row[col]).Trim();
                                    FILA_ERROR    = "# factura " + Convert.ToString(row[col]);

                                    //if (info.cod_nota == "000017052")
                                    //{
                                    //    info.cn_observacion = "S.I. FAC # " + info.cod_nota;
                                    //}
                                    break;

                                case 2:   //Fecha factura
                                    info.cn_fecha = Convert.ToDateTime(row[col]).Date;
                                    FILA_ERROR    = "Fecha factura " + Convert.ToString(row[col]);
                                    break;

                                case 3:   //Fecha vcto factura
                                    info.cn_Fecha_vcto = Convert.ToDateTime(row[col]).Date;
                                    FILA_ERROR         = "Fecha vcto factura " + Convert.ToString(row[col]);
                                    break;

                                case 4:   //Saldo
                                    info.Saldo = Convert.ToDouble(row[col]);
                                    info.cn_subtotal_siniva = Convert.ToDouble(row[col]);
                                    info.cn_total           = Convert.ToDecimal(info.Saldo);
                                    info.cn_baseImponible   = info.cn_subtotal_siniva;
                                    FILA_ERROR = "Saldo " + Convert.ToString(row[col]);
                                    break;

                                case 5:   //Observacion
                                    info.cn_observacion = Convert.ToString(row[col]).Trim();
                                    FILA_ERROR          = "Observacion " + Convert.ToString(row[col]);
                                    break;

                                default:
                                    break;
                                }
                            }
                            info.Estado = "A";
                            lista.Add(info);
                        }
                    }
                    else
                    {
                        MensajeError = "Por favor verifique que el archivo contenga Datos.";
                        lista        = new List <cp_nota_DebCre_Info>();
                    }
                }

                /*else
                 * {
                 *  MensajeError = "Por favor verifique que el archivo tenga el formato correcto.\r Son 5 columnas.";
                 *  lista = new List<cp_nota_DebCre_Info>();
                 * }*/
                return(lista);
            }
            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("", "GetId", ex.Message), ex)
                      {
                          EntityType = typeof(cp_proveedor_Bus)
                      };
            }
        }
        public Boolean Validar_objeto_AprobIngEgrxOC(cp_Aprobacion_Ing_Bod_x_OC_Info Info, ref string msg)
        {
            try
            {
                if (Info.IdEmpresa == 0 || Info.IdProveedor == 0 || Info.IdProveedor == 0)
                {
                    msg = "las variables estan en cero... IdEmpresa == 0 || IdSucursal == 0 || IdProveedor == 0";
                    return(false);
                }

                Info.Observacion = Info.Observacion == null?"":Info.Observacion;

                if ((Info.Serie == null || Info.Serie == "") || (Info.Serie2 == null || Info.Serie2 == ""))
                {
                    msg = "Ingrese la Serie";
                    return(false);
                }
                if (Info.num_documento == null || Info.num_documento == "")
                {
                    msg = "Ingrese el Número de la Factura";
                    return(false);
                }

                if (Info.num_auto_Proveedor == null || Info.num_auto_Proveedor == "")
                {
                    msg = "Ingrese el Número Autorización del Proveedor";
                    return(false);
                }



                if (Info.Fecha_Factura == null)
                {
                    msg = "Ingrese la Fecha de la Factura";
                    return(false);
                }

                if (Info.IdOrden_giro_Tipo == null || Info.IdOrden_giro_Tipo == "")
                {
                    msg = "Ingrese el Tipo de Documento";
                    return(false);
                }

                if (Info.IdIden_credito == 0)
                {
                    msg = "Ingrese el Sustento Tributario";
                    return(false);
                }

                if (Info.listDetalle.Count == 0)
                {
                    msg = "El Detalle no tiene items q grabar o no ha seleccionado Items";
                    return(false);
                }



                foreach (var item in Info.listDetalle)
                {
                    if (String.IsNullOrEmpty(item.IdCtaCble_Gasto))
                    {
                        msg = "Ingrese la Cta. Contable de Gasto del siguiente registro OC#" + item.IdOrdenCompra + " Ing#" + item.IdNumMovi_Ing_Egr_Inv;
                        return(false);
                    }
                }

                if (String.IsNullOrEmpty(Info.IdCtaCble_CXP))
                {
                    cp_parametros_Data data_cpParam = new cp_parametros_Data();
                    cp_parametros_Info info_cpParam = new cp_parametros_Info();
                    info_cpParam = data_cpParam.Get_Info_parametros(Info.IdEmpresa);

                    if (!String.IsNullOrEmpty(info_cpParam.pa_ctacble_Proveedores_default))
                    {
                        Info.IdCtaCble_CXP = info_cpParam.pa_ctacble_Proveedores_default;
                    }
                    else
                    {
                        msg = "Ingrese la Cta. Contable del Proveedor";
                        return(false);
                    }
                }

                if (String.IsNullOrEmpty(Info.pa_ctacble_iva))
                {
                    cp_parametros_Info info_param_cp = new cp_parametros_Info();
                    cp_parametros_Bus  bus_param_cp  = new cp_parametros_Bus();
                    info_param_cp       = bus_param_cp.Get_Info_parametros(Info.IdEmpresa);
                    Info.pa_ctacble_iva = info_param_cp.pa_ctacble_iva;
                }

                return(true);
            }
            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("", "Validar_objeto_AprobIngEgrxOC", ex.Message), ex)
                      {
                          EntityType = typeof(cp_Aprobacion_Ing_Bod_x_OC_Bus)
                      };
            }
        }
        public Boolean Graba_CbteCble_Ret_FactProveedor(cp_retencion_Info info, ct_Cbtecble_Info cbtecble, ref string mensaje)
        {
            decimal idCbteCble               = 0;
            Boolean res_Grabar_RT            = false;
            Boolean res_Grabar_CbteCble_x_RT = false;

            try
            {
                if (cbtecble.IdTipoCbte == 0)
                {
                    cp_parametros_Bus  ParBu    = new cp_parametros_Bus();
                    cp_parametros_Info ParaInfo = new cp_parametros_Info();

                    ParaInfo            = ParBu.Get_Info_parametros(info.IdEmpresa);
                    cbtecble.IdTipoCbte = Convert.ToInt32(ParaInfo.pa_IdTipoCbte_x_Retencion);
                }



                cbtecble.IdCbteCble = idCbteCble;


                if (string.IsNullOrEmpty(cbtecble.cb_Observacion))
                {
                    cbtecble.cb_Observacion = info.observacion;
                }

                foreach (var item in cbtecble._cbteCble_det_lista_info)
                {
                    if (string.IsNullOrEmpty(item.dc_Observacion))
                    {
                        item.dc_Observacion = "RT " + info.observacion;
                    }
                }

                if (info.IdRetencion == 0)
                {//grabando cabecera y detalle de retencion
                    res_Grabar_RT = GrabarDB(info);
                }
                else
                {
                    res_Grabar_RT = true; // ya esta grabado
                }
                if (res_Grabar_RT)        //si grabo la retencion se hace el diario
                {
                    res_Grabar_CbteCble_x_RT = CbteCble_B.GrabarDB(cbtecble, ref idCbteCble, ref mensaje);



                    //puede q no guarde el diario por q sea una retencion en 0%
                    if (res_Grabar_CbteCble_x_RT && res_Grabar_RT)//si grabo cbte y retencion
                    {
                        cp_retencion_x_ct_cbtecble_Info TI = new cp_retencion_x_ct_cbtecble_Info();
                        TI.ct_IdCbteCble  = idCbteCble;
                        TI.ct_IdEmpresa   = cbtecble.IdEmpresa;
                        TI.ct_IdTipoCbte  = cbtecble.IdTipoCbte;
                        TI.Observacion    = "";
                        TI.rt_IdEmpresa   = info.IdEmpresa;
                        TI.rt_IdRetencion = info.IdRetencion;
                        GrabarDB_Ret_CbteCble(TI, ref mensaje);
                    }
                }

                return(res_Grabar_RT);
            }
            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("", "Graba_CbteCble_Ret_FactProveedor", ex.Message), ex)
                      {
                          EntityType = typeof(cp_retencion_Bus)
                      };
            }
        }