コード例 #1
0
        /// <summary>
        /// Obtiene informacion de respuesta de autorizacion para un comprobante
        /// </summary>
        /// <param name="aut">Autorizacion</param>
        /// <param name="tipoComprobante">Tipo de Comprobante</param>
        /// <param name="nroComprobante">Nro de Comprobante</param>
        /// <param name="ptoVta">Punto de Venta</param>
        /// <returns>Respuesta simil a la de solicitud de CAE</returns>
        public ClsFEXGetCMPR DatosDeComprobante( Autorizacion aut, int tipoComprobante, long nroComprobante, int ptoVta )
        {
            ClsFEXAuthRequest feAutRequest = this.wa.ConvertirFex( aut );
            ClsFEXGetCMP solicitud = new ClsFEXGetCMP();
            solicitud.Cbte_nro = nroComprobante;
            solicitud.Tipo_cbte = (short)tipoComprobante;
            solicitud.Punto_vta = (short)ptoVta;
            FEXGetCMPResponse  respuesta = this.wsfe.FEXGetCMP( feAutRequest, solicitud );
            this.managerErrores.CapturarError( respuesta.FEXErr );

            return respuesta.FEXResultGet;
        }
コード例 #2
0
 public FEXGetCMPResponse GetComprobante(ClsFEXAuthRequest fexAuthRequest, ClsFEXGetCMP fexGetCmp)
 {
     try
     {
         using (Ws.Wsfex.ServiceSoapClient client =
                    new Ws.Wsfex.ServiceSoapClient())
         {
             return(client.FEXGetCMP(fexAuthRequest, fexGetCmp));
         }
     }
     catch (Exception excepcionAlInvocarWsfe)
     {
         throw new Exception(errorWsfex + excepcionAlInvocarWsfe.Message);
     }
 }
コード例 #3
0
        public FEXGetCMPResponse GetComprobante(ClsFEXAuthRequest fexAuthRequest, ClsFEXGetCMP fexGetCmp)
        {
            AfipWrapperServiceClient client = new AfipWrapperServiceClient();

            ClientCredentialHelper.SetCredentials(client.ClientCredentials);
            try
            {
                var t = client.GetComprobante(fexAuthRequest, fexGetCmp);
                client.Close();
                return(t);
            }
            catch
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Abort();
                }

                throw;
            }
        }
コード例 #4
0
 /// <remarks/>
 public void FEXGetCMPAsync( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp, object userState )
 {
     if ( ( this.FEXGetCMPOperationCompleted == null ) )
         {
             this.FEXGetCMPOperationCompleted = new System.Threading.SendOrPostCallback( this.OnFEXGetCMPOperationCompleted );
         }
         this.InvokeAsync( "FEXGetCMP", new object[] {
                 Auth,
                 Cmp}, this.FEXGetCMPOperationCompleted, userState );
 }
コード例 #5
0
 /// <remarks/>
 public void FEXGetCMPAsync( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp )
 {
     this.FEXGetCMPAsync( Auth, Cmp, null );
 }
コード例 #6
0
 public FEXGetCMPResponse FEXGetCMP( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp )
 {
     object[] results = this.Invoke( "FEXGetCMP", new object[] {
                 Auth,
                 Cmp} );
         return ( (FEXGetCMPResponse) ( results[0] ) );
 }
コード例 #7
0
 /// <remarks/>
 public System.IAsyncResult BeginFEXGetCMP( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp, System.AsyncCallback callback, object asyncState )
 {
     return this.BeginInvoke( "FEXGetCMP", new object[] {
                 Auth,
                 Cmp}, callback, asyncState );
 }
コード例 #8
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            this.txtResultados.Text = string.Empty;
            if (cbWebService.SelectedItem != null)
            {
                string selectedValue = (cbWebService.SelectedItem as WebServiceAfipDto).Nombre.Trim();
                if (selectedValue == GetTiposMonedasNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposMonedas(this.ticket).ResultGet;
                }
                else if (selectedValue == GetTiposCbtesNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposCbte(this.ticket).ResultGet;
                }
                else if (selectedValue == GetTiposTributosNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposTributos(this.ticket).ResultGet;
                }
                else if (selectedValue == GetTiposIvaNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposIva(this.ticket).ResultGet;
                }
                else if (selectedValue == GetTiposOpcionalNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposOpcional(this.ticket).ResultGet;
                }
                else if (selectedValue == CompTotXRequestNombre)
                {
                    this.txtResultados.Text = this.client.CompTotXRequest(this.ticket).RegXReq.ToString();
                }
                else if (selectedValue == GetTiposDocNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposDoc(this.ticket).ResultGet;
                }
                else if (selectedValue == CompUltimoAutorizadoNombre)
                {
                    if (string.IsNullOrEmpty(this.txtPtoVta.Text))
                    {
                        MessageBox.Show("Debe ingresar un valor para el Punto de Venta", "Validación campos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    int ptoVtaInt = int.Parse(this.txtPtoVta.Text);
                    int cbteTipo  = int.Parse(this.cbTiposCbte.SelectedValue.ToString());
                    FERecuperaLastCbteResponse result = this.client.CompUltimoAutorizado(this.ticket, ptoVtaInt, cbteTipo);

                    var tiposDeComprobante = ComprobanteService.ObtenerTiposComprobantes();

                    string tipoComprobanteStr = result.CbteTipo.ToString();
                    var    tipoDeComprobante  = tiposDeComprobante.Where(t => t.CodigoAfip.HasValue && t.CodigoAfip.Value == result.CbteTipo).SingleOrDefault();
                    if (tipoDeComprobante != null)
                    {
                        tipoComprobanteStr = string.Format("{0}, AFIP {1} {2}", tipoDeComprobante.Codigo, tipoDeComprobante.CodigoAfip, tipoDeComprobante.Descripcion);
                    }

                    this.txtResultados.Text = string.Format(@"CbteNro: {0}{1}CbteTipo: {2}{3}PtoVta: {4}{5}",
                                                            result.CbteNro,
                                                            Environment.NewLine,
                                                            tipoComprobanteStr,
                                                            Environment.NewLine,
                                                            result.PtoVta,
                                                            Environment.NewLine);
                }
                else if (selectedValue == GetTiposConceptoNombre)
                {
                    this.gridResultados.DataSource = this.client.GetTiposConcepto(this.ticket).ResultGet;
                }
                else if (selectedValue == GetCotizacionNombre)
                {
                    string     monId      = this.cbMoneda.SelectedValue.ToString();
                    Cotizacion cotizacion = this.client.GetCotizacion(this.ticket, monId).ResultGet;
                    if (cotizacion != null)
                    {
                        this.txtResultados.Text = string.Format(@"Fecha: {0}{1}Cotizacion: ${2}{3}",
                                                                DateTime.ParseExact(cotizacion.FchCotiz, "yyyyMMdd", CultureInfo.InvariantCulture).ToString("dd/MM/yyyy"),
                                                                Environment.NewLine,
                                                                cotizacion.MonCotiz,
                                                                Environment.NewLine);
                    }
                    else
                    {
                        this.txtResultados.Text = "No hay cotizacion disponible";
                    }
                }
                else if (selectedValue == FEXGetLast_ID)
                {
                    this.gridResultados.DataSource = this.client.GetLastId(this.ticketFex).FEXResultGet;
                }
                else if (selectedValue == FEXGetPARAM_Cbte_Tipo)
                {
                    this.gridResultados.DataSource = this.client.GetTiposComprobantes(this.ticketFex).FEXResultGet;
                }
                else if (selectedValue == FEXGetPARAM_DST_CUIT)
                {
                    this.gridResultados.DataSource =
                        this.client.GetCuits(this.ticketFex).FEXResultGet.OrderBy(c => c.DST_Ds).ToList();
                }
                else if (selectedValue == FEXGetPARAM_DST_pais)
                {
                    this.gridResultados.DataSource = this.client.GetPaises(this.ticketFex).FEXResultGet.OrderBy(p => p.DST_Ds).ToList();
                }
                else if (selectedValue == FEXGetPARAM_Idiomas)
                {
                    this.gridResultados.DataSource = this.client.GetIdiomas(this.ticketFex).FEXResultGet;
                }
                else if (selectedValue == FEXGetPARAM_Incoterms)
                {
                    this.gridResultados.DataSource = this.client.GetIncoterms(this.ticketFex).FEXResultGet;
                }
                else if (selectedValue == FEXGetPARAM_MON)
                {
                    this.gridResultados.DataSource = this.client.GetMonedas(this.ticketFex).FEXResultGet.OrderBy(m => m.Mon_Ds).ToList();
                }
                else if (selectedValue == FEXGetPARAM_PtoVenta)
                {
                    this.gridResultados.DataSource = this.client.GetPuntosDeVenta(this.ticketFex).FEXResultGet;
                }
                else if (selectedValue == FEXGetPARAM_Tipo_Expo)
                {
                    this.gridResultados.DataSource = this.client.GetTiposDeExportacion(this.ticketFex).FEXResultGet;
                }
                else if (selectedValue == FEXGetPARAM_UMed)
                {
                    this.gridResultados.DataSource = this.client.GetUnidadesDeMedida(this.ticketFex).FEXResultGet.Where(u => u != null).OrderBy(u => u.Umed_Ds).ToList();
                }
                if (selectedValue == GetTiposMonedasNombre ||
                    selectedValue == GetTiposCbtesNombre ||
                    selectedValue == GetTiposTributosNombre ||
                    selectedValue == GetTiposIvaNombre ||
                    selectedValue == GetTiposOpcionalNombre ||
                    selectedValue == GetTiposDocNombre ||
                    selectedValue == GetTiposConceptoNombre)
                {
                    this.lblResultados.Text = string.Format("Resultados: {0} registros", this.gridResultados.RowCount);
                }
                else if (selectedValue == FEXGetCMP)
                {
                    if (string.IsNullOrEmpty(this.txtNroCbteFex.Text.Trim()) ||
                        string.IsNullOrEmpty(this.cbTiposCbteFex.SelectedValue.ToString()) ||
                        string.IsNullOrEmpty(this.cbPtosVtaFex.SelectedValue.ToString()))
                    {
                        MensajeValidarParametros();
                        return;
                    }
                    ClsFEXGetCMP fexGetCmp = new ClsFEXGetCMP();
                    fexGetCmp.Cbte_nro  = long.Parse(this.txtNroCbteFex.Text.Trim());
                    fexGetCmp.Cbte_tipo = short.Parse(this.cbTiposCbteFex.SelectedValue.ToString());
                    fexGetCmp.Punto_vta = short.Parse(this.cbPtosVtaFex.SelectedValue.ToString());
                    FEXGetCMPResponse result = this.client.GetComprobante(this.ticketFex, fexGetCmp);
                    // TODO: mostrar resultado
                }
                else if (selectedValue == FEXGetLast_CMP)
                {
                    if (string.IsNullOrEmpty(this.cbTiposCbteFex.SelectedValue.ToString()) ||
                        string.IsNullOrEmpty(this.cbPtosVtaFex.SelectedValue.ToString()))
                    {
                        MensajeValidarParametros();
                        return;
                    }
                    ClsFEX_LastCMP fexLastCmp = new ClsFEX_LastCMP();
                    fexLastCmp.Cbte_Tipo = short.Parse(this.cbTiposCbteFex.SelectedValue.ToString());
                    fexLastCmp.Pto_venta = short.Parse(this.cbPtosVtaFex.SelectedValue.ToString());
                    fexLastCmp.Cuit      = this.ticketFex.Cuit;
                    fexLastCmp.Sign      = this.ticketFex.Sign;
                    fexLastCmp.Token     = this.ticketFex.Token;
                    FEXResponseLast_CMP result = this.client.GetUltimoComprobanteAutorizado(fexLastCmp);
                    // TODO: mostrar resultado
                }
                else if (selectedValue == FEXGetLast_ID)
                {
                    FEXResponse_LastID result = this.client.GetLastId(this.ticketFex);
                    this.txtResultados.Text = result.FEXResultGet.Id.ToString();
                }
                else if (selectedValue == FEXGetPARAM_Ctz)
                {
                    if (string.IsNullOrEmpty(this.cbMoneda.SelectedValue.ToString()))
                    {
                        MensajeValidarParametros();
                        return;
                    }
                    string          monId      = this.cbMoneda.SelectedValue.ToString();
                    FEXResponse_Ctz cotizacion = this.client.GetFexCotizacion(this.ticketFex, monId);
                    if (cotizacion != null)
                    {
                        this.txtResultados.Text = string.Format(@"Fecha: {0}{1}Cotizacion: ${2}{3}",
                                                                DateTime.ParseExact(cotizacion.FEXResultGet.Mon_fecha, "yyyyMMdd", CultureInfo.InvariantCulture).ToString("dd/MM/yyyy"),
                                                                Environment.NewLine,
                                                                cotizacion.FEXResultGet.Mon_ctz,
                                                                Environment.NewLine);
                    }
                    else
                    {
                        this.txtResultados.Text = "No hay cotizacion disponible";
                    }
                }
            }
        }