Пример #1
0
        private void formMain_Load(object sender, EventArgs e)
        {
            var cert = Wsd.GetCertificate();

            if (cert == null)
            {
                MessageBox.Show("Debe configurar un certificado digital para utilizar la aplicación.");
            }

            string cn = cert.Subject.Replace("CN=", "");

            string[] tokens = cn.Split('-');

            string nifCandidate = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim();

            if (tokens.Length > 1 && nifCandidate.Length == 9)
            {
                txTitularPartyName.Text = tokens[0].Trim();
                txTitularTaxIdentificationNumber.Text = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim();
            }

            Inizialize();

            grdIva.Rows.Add(4, null, null);
            grdIva.Rows.Add(10, 100, 10);
            grdIva.Rows.Add(21, 100, 21);
        }
Пример #2
0
        /// <summary>
        /// Ejemplo de envío de un lote de facturas emitidas
        /// </summary>
        public void EnviarLoteFacturasEmitidas()
        {
            // Creamos un lote de factura recibidas
            ARInvoicesBatch LoteDeFacturasEmitidas =
                CreaLoteDeFacturasEmitidas();

            // Creo el sobre SOAP con el objeto XML a enviar a la AEAT
            Envelope envelope = LoteDeFacturasEmitidas.GetEnvelope();

            // Edito directamente el objeto XML
            FacturaExpedida facturaExpedida = envelope.Body.SuministroLRFacturasEmitidas.RegistroLRFacturasEmitidas[0].FacturaExpedida;

            facturaExpedida.Contraparte.IDOtro = new IDOtro
            {
                IDType     = "06",
                CodigoPais = "US",
                ID         = "NIF_EXTRANJERO"
            };


            // Realizamos el envío del SOBRE a la AEAT
            Wsd.Send(envelope);



            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            LoteDeFacturasEmitidas.GetReceivedFileName());
        }
Пример #3
0
        private void formMain_Load(object sender, EventArgs e)
        {
            _TextBoxes = new List<Control>();
            GetTextBoxes(this, _TextBoxes);

            var cert = Wsd.GetCertificate();

            if (cert == null)
            {
                MessageBox.Show("Debe configurar un certificado digital para utilizar la aplicación.");
            }

            string cn = cert.Subject.Replace("CN=", "");

            string[] tokens = cn.Split('-');

            string nifCandidate = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim();

            if (tokens.Length > 1 && nifCandidate.Length==9)
            { 
                txEmisorPartyName.Text = tokens[0].Trim();
                txEmisorTaxIdentificationNumber.Text = tokens[1].Replace("CIF","").Replace("NIF","").Trim();
            }

            Inizialize();

        }
Пример #4
0
        private void EnviaLoteEnCurso()
        {
            // Realizamos el envío del lote a la AEAT
            Wsd.SendOperIntracom(_LoteOperIntracom);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser

            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _LoteOperIntracom.GetReceivedFileName()
            };

            frmXmlViewer.ShowDialog();

            // Obtengo la respuesta de facturas recibidas del archivo de
            // respuesta de la AEAT.
            RespuestaLRF respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaLRDetOperacionesIntracomunitarias;

            if (respuesta == null)
            {
                DialogResult resultMsg;
                string       _msgError = "Se ha recibido una respuesta inesperada. Pulse 'Aceptar', si quiere revisarla";
                resultMsg = MessageBox.Show(_msgError, "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);

                if (resultMsg == DialogResult.OK)
                {
                    frmXmlViewer.ShowDialog();
                }

                return;
            }

            foreach (DataGridViewRow row in grdInvoices.Rows) // Recorro las facturas enviadas
            {
                string numFra = row.Cells[0].Value.ToString();

                // Busco en las líneas de la respuesta el número de factura
                var linqQryFra = from respuestaFra in respuesta.RespuestaLinea
                                 where respuestaFra.IDFactura.NumSerieFacturaEmisor == numFra
                                 select respuestaFra;

                // Si el estado del registro es correcto lo marco como ok
                foreach (RespuestaLinea respuestaFra in linqQryFra)
                {
                    if (respuestaFra.EstadoRegistro == "Correcto")
                    {
                        row.Cells[7].Value = MSeniorSII.Properties.Resources.circle_green;
                    }
                    else
                    {
                        row.Cells[7].Value = MSeniorSII.Properties.Resources.circle_red;
                    }
                }
            }


            MessageBox.Show($"Estado del envío realizado a la AEAT: {respuesta.EstadoEnvio}.\nCódigo CVS: {respuesta.CSV}");
        }
Пример #5
0
        private void EnviaLoteEnCurso()
        {
            // Realizamos el envío del lote a la AEAT
            Wsd.SendCobrosFacturasEmitidas(_LoteDeCobrosEmitidas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser

            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _LoteDeCobrosEmitidas.GetReceivedFileName()
            };

            //frmXmlViewer.ShowDialog();

            // Obtengo la respuesta de facturas recibidas del archivo de
            // respuesta de la AEAT.
            RespuestaLRF respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaLRCobrosEmitidas;

            if (respuesta == null)
            {
                SoapFault msgError = new Envelope(frmXmlViewer.Path).Body.RespuestaError;
                if (msgError != null)
                {
                    MessageBox.Show(msgError.FaultDescription, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            foreach (DataGridViewRow row in grdInvoices.Rows) // Recorro las facturas enviadas
            {
                string numFra = row.Cells[0].Value.ToString();

                // Busco en las líneas de la respuesta el número de factura
                var linqQryFra = from respuestaFra in respuesta.RespuestaLinea
                                 where respuestaFra.IDFactura.NumSerieFacturaEmisor == numFra
                                 select respuestaFra;

                // Si el estado del registro es correcto lo marco como ok
                foreach (RespuestaLinea respuestaFra in linqQryFra)
                {
                    if (respuestaFra.EstadoRegistro == "Correcto")
                    {
                        row.Cells[5].Value = MSeniorSII.Properties.Resources.circle_green;
                    }
                    else
                    {
                        row.Cells[5].Value = MSeniorSII.Properties.Resources.circle_red;
                        row.Cells[6].Value = respuestaFra.DescripcionErrorRegistro;
                    }
                }
            }

            if (respuesta.EstadoEnvio == "Correcto")
            {
                string _msg = ($"Estado del envío realizado a la AEAT: {respuesta.EstadoEnvio}.\nCódigo CSV: {respuesta.CSV}");
                MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #6
0
        private void btBuscaFacts_Click(object sender, EventArgs e)
        {
            BindModelTitular();
            BindModelBusqueda();

            // Realizamos la consulta de las facturas en la AEAT
            Wsd.GetFacturasEmitidasCobros(_PetCobroFactEmitEnviadas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _PetCobroFactEmitEnviadas.GetReceivedFileName()
            };

            //frmXmlViewer.ShowDialog();

            try
            {
                // Obtengo la respuesta de la consulta de facturas recibidas del archivo de respuesta de la AEAT.
                RespuestaConsultaCobros respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaConsultaCobros;

                if (respuesta == null)
                {
                    DialogResult resultMsg;
                    string       _msg = "Se ha recibido una respuesta inesperada. Pulse 'Aceptar', si quiere revisarla";
                    resultMsg = MessageBox.Show(_msg, "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);

                    if (resultMsg == DialogResult.OK)
                    {
                        frmXmlViewer.ShowDialog();
                    }

                    return;
                }

                // Tenemos que recorrernos la respuesta y rellenar el datagrid con los datos de cada factura.
                grdInvoices.Rows.Clear();

                if (respuesta.ResultadoConsulta == "ConDatos")
                {
                    foreach (var invoice in respuesta.RegistroRespuestaConsultaCobros)
                    {
                        System.Drawing.Icon _marcaFact = MSeniorSII.Properties.Resources.Tag_Ok;

                        decimal TotalTmp = Convert.ToDecimal(invoice.Cobro.Importe, DefaultNumberFormatInfo);

                        grdInvoices.Rows.Add(invoice.Cobro.Fecha, TotalTmp.ToString("#,##0.00"), invoice.Cobro.Medio, invoice.Cobro.Cuenta_O_Medio,
                                             invoice, _marcaFact, invoice.DatosPresentacion.TimestampPresentacion);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            txFechaBusqueda.Focus();
        }
Пример #7
0
        private void LanzarConsulta()
        {
            // Realizamos la consulta de las facturas en la AEAT
            Wsd.GetOperIntracom(_PetOperIntraEnviadas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _PetOperIntraEnviadas.GetReceivedFileName()
            };

            //frmXmlViewer.ShowDialog();

            try
            {
                // Obtengo la respuesta de la consulta de facturas recibidas del archivo de respuesta de la AEAT.
                RespuestaConsultaLRDetOperIntracomunitarias respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaConsultaLRDetOperIntracomunitarias;

                if (respuesta == null)
                {
                    SoapFault msgError = new Envelope(frmXmlViewer.Path).Body.RespuestaError;
                    if (msgError != null)
                    {
                        MessageBox.Show(msgError.FaultDescription, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                // Tenemos que recorrernos la respuesta y rellenar el datagrid con los datos de cada factura.
                grdInvoices.Rows.Clear();

                if (respuesta.ResultadoConsulta == "ConDatos")
                {
                    foreach (var invoice in respuesta.RegistroRCLRDetOperIntracom)
                    {
                        System.Drawing.Icon _marcaFact = MSeniorSII.Properties.Resources.Tag_Ok;

                        if (invoice.EstadoFactura.EstadoRegistro == "Anulada")
                        {
                            _marcaFact = MSeniorSII.Properties.Resources.Tag_Delete;
                        }

                        grdInvoices.Rows.Add(invoice.IDFactura.NumSerieFacturaEmisor, invoice.IDFactura.FechaExpedicionFacturaEmisor,
                                             invoice.OperacionIntracomunitaria.OperacionIntracom.TipoOperacion, invoice.OperacionIntracomunitaria.OperacionIntracom.ClaveDeclarado,
                                             invoice.OperacionIntracomunitaria.OperacionIntracom.DescripcionBienes, invoice, _marcaFact, invoice.DatosPresentacion.TimestampPresentacion,
                                             invoice.EstadoFactura.TimestampUltimaModificacion);
                    }
                }
            }
            catch (Exception ex)
            {
                string _msgError = "Error: " + ex.Message;
                MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            txFechaBusqueda.Focus();
        }
Пример #8
0
        private void LanzarConsulta()
        {
            // Realizamos la consulta de las facturas en la AEAT
            Wsd.GetFacturasRecibidas(_PetFactRecEnviadas);

            string responsePath = Settings.Current.InboxPath + _PetFactRecEnviadas.GetReceivedFileName();

            Envelope envelopeRespuesta = new Envelope(responsePath);

            try
            {
                // Obtengo la respuesta de la consulta de facturas recibidas del archivo de respuesta de la AEAT.
                RespuestaConsultaLRFacturasRecibidas respuesta = envelopeRespuesta.Body.RespuestaConsultaLRFacturasRecibidas;

                if (respuesta == null && envelopeRespuesta.Body.RespuestaError != null)
                {
                    MessageBox.Show(envelopeRespuesta.Body.RespuestaError.FaultDescription, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Tenemos que recorrernos la respuesta y rellenar el datagrid con los datos de cada factura.
                grdInvoices.Rows.Clear();

                if (respuesta.ResultadoConsulta == "SinDatos")
                {
                    MessageBox.Show("No se han encontrado registros", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (respuesta.ResultadoConsulta == "ConDatos")
                {
                    foreach (var invoice in respuesta.RegistroRCLRFacturasRecibidas)
                    {
                        System.Drawing.Icon _marcaFact = MSeniorSII.Properties.Resources.Tag_Ok;

                        if (invoice.EstadoFactura.EstadoRegistro == "Anulada")
                        {
                            _marcaFact = MSeniorSII.Properties.Resources.Tag_Delete;
                        }

                        decimal TotalTmp = Convert.ToDecimal(invoice.FacturaRecibida.ImporteTotal, DefaultNumberFormatInfo);

                        grdInvoices.Rows.Add(invoice.IDFactura.NumSerieFacturaEmisor, invoice.IDFactura.FechaExpedicionFacturaEmisor,
                                             invoice.FacturaRecibida.Contraparte.NIF, invoice.FacturaRecibida.Contraparte.NombreRazon,
                                             TotalTmp.ToString("#,##0.00"), invoice, _marcaFact, invoice.DatosPresentacion.TimestampPresentacion, invoice.EstadoFactura.TimestampUltimaModificacion);
                    }
                }
            }
            catch (Exception ex)
            {
                string _msgError = "Error: " + ex.Message;
                MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            txFechaBusqueda.Focus();
        }
Пример #9
0
        /// <summary>
        /// Ejemplo de envío de un lote de bienes inversión
        /// </summary>
        public void EnviarLoteBienesInversion()
        {
            // Creamos un lote de bienes inversión
            AssetsBatch LoteBienesInversion = CrearLoteBienesInversion();

            // Realizamos el envío del lote a la AEAT
            Wsd.SendBienesInversion(LoteBienesInversion);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            LoteBienesInversion.GetReceivedFileName());
        }
Пример #10
0
        private void LanzarConsulta()
        {
            // Realizamos la consulta de las facturas en la AEAT
            Wsd.GetFacturasEmitidasCobros(_PetCobroFactEmitEnviadas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _PetCobroFactEmitEnviadas.GetReceivedFileName()
            };

            //frmXmlViewer.ShowDialog();

            try
            {
                // Obtengo la respuesta de la consulta de facturas recibidas del archivo de respuesta de la AEAT.
                RespuestaConsultaCobros respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaConsultaCobros;

                if (respuesta == null)
                {
                    SoapFault msgError = new Envelope(frmXmlViewer.Path).Body.RespuestaError;
                    if (msgError != null)
                    {
                        MessageBox.Show(msgError.FaultDescription, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                // Tenemos que recorrernos la respuesta y rellenar el datagrid con los datos de cada factura.
                grdInvoices.Rows.Clear();

                if (respuesta.ResultadoConsulta == "ConDatos")
                {
                    foreach (var invoice in respuesta.RegistroRespuestaConsultaCobros)
                    {
                        System.Drawing.Icon _marcaFact = MSeniorSII.Properties.Resources.Tag_Ok;

                        decimal TotalTmp = Convert.ToDecimal(invoice.Cobro.Importe, DefaultNumberFormatInfo);

                        grdInvoices.Rows.Add(invoice.Cobro.Fecha, TotalTmp.ToString("#,##0.00"), invoice.Cobro.Medio, invoice.Cobro.Cuenta_O_Medio,
                                             invoice, _marcaFact, invoice.DatosPresentacion.TimestampPresentacion);
                    }
                }
            }
            catch (Exception ex)
            {
                string _msgError = "Error: " + ex.Message;
                MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            txFechaBusqueda.Focus();
        }
Пример #11
0
        // Ejemplo de eliminar una factura emitida comunicada anteriormente al SII
        public void EliminarFacturaRecibida()
        {
            // Crea un lote de facturas recibidas envíadas al SII con anterioridad a eliminar
            APInvoicesDeleteBatch loteFacturasRecibidasEliminar = CrearLoteFacturaRecibidasEliminar();

            // Envíamos lote con las peticiones de borrado
            Wsd.DeleteFacturasRecibidas(loteFacturasRecibidasEliminar);


            // Mostramos el xml de respuesta de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            loteFacturasRecibidasEliminar.GetReceivedFileName());
        }
Пример #12
0
        // Consulta cobros facturas emitidas comunicados al SII
        public void ConsultarCobrosFacturasEmitidas()
        {
            // Creo un objeto consulta de cobros de factura emitidas
            ARPaymentsQuery consultaCobrosFacturasEmitidas = CrearConsultaCobrosFacturasEmitidas();

            // Obtengo la respuesta de la AEAT a la consulta.
            Wsd.GetFacturasEmitidasCobros(consultaCobrosFacturasEmitidas);


            // Muestro el archivo xml de respuesta en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            consultaCobrosFacturasEmitidas.GetReceivedFileName());
        }
Пример #13
0
        /// <summary>
        /// Ejemplo de envío de un lote de facturas emitidas
        /// </summary>
        public void EnviarConsultaFactEmit()
        {
            // Creamos un lote de factura recibidas
            ARInvoicesQuery LoteDeFacturasEmitidas =
                CreaLoteDeEmitidasEnviadas();

            // Realizamos el envío del lote a la AEAT
            Wsd.GetFacturasEmitidas(LoteDeFacturasEmitidas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            LoteDeFacturasEmitidas.GetReceivedFileName());
        }
Пример #14
0
        /// <summary>
        /// Ejemplo de envío de un lote de facturas recibidas
        /// </summary>
        public void EnviarLoteOperIntracom()
        {
            // Creamos un lote de factura recibidas
            ITInvoicesBatch LoteOperIntracom =
                CrearLoteOperIntracom();

            // Realizamos el envío del lote a la AEAT
            Wsd.SendOperIntracom(LoteOperIntracom);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            LoteOperIntracom.GetReceivedFileName());
        }
Пример #15
0
        /// <summary>
        /// Ejemplo de envío de un asiento resumen de facturas simplificadas
        /// </summary>
        public void EnviarAsientoResumenFacturasSimplificadas()
        {
            // Creamos un lote de factura recibidas
            ARInvoicesBatch asientoResumentFacturasSimplificadas =
                CreaAsientoResumenFacturasSimplificadas();

            // Realizamos el envío del lote a la AEAT
            Wsd.SendFacturasEmitidas(asientoResumentFacturasSimplificadas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            asientoResumentFacturasSimplificadas.GetReceivedFileName());
        }
Пример #16
0
        public void ConsultarFacturasRecibidas()
        {
            // Creo un objeto consulta de facturas recibidas
            APInvoicesQuery consultaFacturasRecibidas = CrearConsultaFacturasRecibidas();

            // Envío la consulta
            Wsd.GetFacturasRecibidas(consultaFacturasRecibidas);


            // Muestro el archivo xml de respuesta
            webBrw.Navigate(Settings.Current.InboxPath +
                            consultaFacturasRecibidas.GetReceivedFileName());
        }
Пример #17
0
        /// <summary>
        /// Consultar facturas emitidas.
        /// </summary>
        public void ConsultarFacturasEmitidas()
        {
            // Creo la consulta de facturas emitidas
            ARInvoicesQuery consultaFacturasEmitidas = CrearConsultaFacturasEmitidas();

            // Petición de factura emitidas envíada a la AEAT mediante el SII.
            Wsd.GetFacturasEmitidas(consultaFacturasEmitidas);


            // Mostramos el xml de respuesta de la AEAT en el web browser.
            webBrw.Navigate(Settings.Current.InboxPath +
                            consultaFacturasEmitidas.GetReceivedFileName());
        }
Пример #18
0
        /// <summary>
        /// Devuelve las facturas emitidas registradas
        /// por los clientes del titular
        /// del lote en el periodo indicado.
        /// </summary>
        /// <param name="period">Periodo en formato yyyy.MM.</param>
        /// <param name="titular">Titular de las facturas a recuperar.</param>
        /// <param name="cliente">Cliente del que recuperar las facturas.</param>
        /// <returns>Lista de facturas emitidas en el periodo.</returns>
        private static RespuestaConsultaLRFactInformadasCliente GetByPeriodFE(string period, Party titular, Party cliente)
        {
            ARInvoicesQuery batchInvoiceQuery = new ARInvoicesQuery()
            {
                Titular = titular
            };

            ARInvoice templateInvoiceQuery = new ARInvoice();

            templateInvoiceQuery.BuyerParty = cliente;

            string syear  = period.Substring(0, 4);
            string smonth = period.Substring(5, 2);

            int year  = Convert.ToInt32(syear);
            int month = Convert.ToInt32(smonth);

            DateTime date = new DateTime(year, month, 1);

            // Necesitamos indicar una fecha de factura, para que se pueda calcular el ejercicio y periodo
            // que son necesarios y obligatorios para realizar esta peticiones.
            templateInvoiceQuery.IssueDate = date;
            batchInvoiceQuery.ARInvoice    = templateInvoiceQuery;

            string response = Wsd.GetFacturasEmitidasCliente(batchInvoiceQuery);

            try
            {
                // Obtengo la respuesta de la consulta de facturas recibidas del archivo de respuesta de la AEAT.
                Envelope envelope = Envelope.FromXml(response);

                if (envelope.Body.RespuestaConsultaLRFactInformadasCliente != null)
                {
                    return(envelope.Body.RespuestaConsultaLRFactInformadasCliente);
                }

                SoapFault msgError = envelope.Body.RespuestaError;

                if (msgError != null)
                {
                    throw new Exception($"{msgError.FaultDescription}");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(null);
        }
Пример #19
0
        /// <summary>
        /// Rutina de ejemplo de envío de lote de cobros al SII de la AEAT.
        /// </summary>
        public void EnviarLoteCobrosFacturasEmitidas()
        {
            // Creamos un lote de cobros de facturas emitidas en regimen especial de caja
            ARInvoicesPaymentsBatch LoteCobrosFacturasEmitidas =
                CrearLoteCobrosFacturasEmitidas();

            // Realizamos el envío del lote a la AEAT
            Wsd.SendCobrosFacturasEmitidas(LoteCobrosFacturasEmitidas);


            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            LoteCobrosFacturasEmitidas.GetReceivedFileName());
        }
Пример #20
0
        /// <summary>
        /// Ejemplo de envío de un lote de facturas recibidas
        /// </summary>
        public void EnviarLoteFacturasRecibidas()
        {
            // Creamos un lote de factura recibidas
            APInvoicesBatch LoteFacturasRecibidas =
                CrearLoteFacturasRecibidas();



            /*****************************************/

            //Envelope envelope = LoteFacturasRecibidas.GetEnvelope();

            //SuministroLRFacturasRecibidas slrFrasRecibidas =  envelope.Body.SuministroLRFacturasRecibidas;

            //FacturaRecibida fraRecibida = slrFrasRecibidas.RegistroLRFacturasRecibidas[0].FacturaRecibida;

            //fraRecibida.TipoRectificativa = "I";

            //fraRecibida.FacturasRectificadas = new List<IDFactura>();
            //fraRecibida.FacturasRectificadas.Add(new IDFactura());
            //fraRecibida.FacturasRectificadas[0].NumSerieFacturaEmisor = "000000000055";
            //fraRecibida.FacturasRectificadas[0].FechaExpedicionFacturaEmisor =
            //    "01-01-2015" ;
            //// En este caso pongo a null IDEmisorFactura para que no serialice una etiqueta vacía.
            //fraRecibida.FacturasRectificadas[0].IDEmisorFactura = null;

            ////fraRecibida.FacturasRectificadas = new EasySII.Xml.Sii.FacturasRectificadas();
            ////fraRecibida.FacturasRectificadas.IDFacturaRectificada = new IDFactura();
            ////fraRecibida.FacturasRectificadas.IDFacturaRectificada.NumSerieFacturaEmisor = "00000000022";
            ////fraRecibida.FacturasRectificadas.IDFacturaRectificada.FechaExpedicionFacturaEmisor = "01-01-2015";

            //string response = Wsd.Send(envelope);
            //string file = Settings.Current.InboxPath +
            // LoteFacturasRecibidas.GetReceivedFileName();

            //File.WriteAllText(file, response);

            //webBrw.Navigate(file);

            //return;

            /*****************************************/

            // Realizamos el envío del lote a la AEAT
            Wsd.SendFacturasRecibidas(LoteFacturasRecibidas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            webBrw.Navigate(Settings.Current.InboxPath +
                            LoteFacturasRecibidas.GetReceivedFileName());
        }
Пример #21
0
        // Envía una lote de cobros de facturas recibidas aL SII de la AEAT.
        public void EnviarLotePagosFacturasRecibidas()
        {
            // Creamos el lote de de pago de facturas recibidas en regimen especial
            // de caja al SII de la AEAT.
            APInvoicesPaymentsBatch LotePagosFacturasRecibidas = CrearLotePagosFacturasRecibidas();

            // Envía el lote de pagos de factura recibidas a la AEAT.
            Wsd.SendPagosFacturasRecibidas(LotePagosFacturasRecibidas);


            //Muestra el archivo xml recibido de la AEAT con la respuesta en el
            // web browser.
            webBrw.Navigate(Settings.Current.InboxPath +
                            LotePagosFacturasRecibidas.GetReceivedFileName());
        }
Пример #22
0
        private void EnviaLoteEnCurso()
        {
            // Realizamos el envío del lote a la AEAT
            Wsd.SendFacturasRecibidas(_LoteDeFacturasRecibidas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser

            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _LoteDeFacturasRecibidas.GetReceivedFileName()
            };

            frmXmlViewer.ShowDialog();
        }
Пример #23
0
        public void ObtCertificadoDigital(ref string NIFEmpresa, ref string NomEmpresa)
        {
            var cert = Wsd.GetCertificate();

            if (cert == null)
            {
                string _msg = "Debe configurar un certificado digital para utilizar la aplicación.";
                MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (cert.Subject.StartsWith("CN="))
            {
                string cn = cert.Subject.Replace("CN=", "");

                string[] tokens = cn.Split('-');

                string nifCandidate = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim();

                if (tokens.Length > 1 && nifCandidate.Length == 9)
                {
                    NomEmpresa = tokens[0].Trim();
                    NIFEmpresa = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim();
                }
            }
            else
            {
                string[] tokens       = cert.Subject.Split(',');
                string   nifCandidate = tokens[2].Replace("OID.2.5.4.97=VATES-", "").Trim();

                if (tokens.Length > 1 && nifCandidate.Length == 9)
                {
                    NomEmpresa = tokens[1].Replace("O=", "").Trim();
                    NIFEmpresa = nifCandidate;
                }
            }
        }
Пример #24
0
        private void btBuscaFacts_Click(object sender, EventArgs e)
        {
            BindModelTitular();
            BindModelBusqueda();

            // Realizamos la consulta de las facturas en la AEAT
            Wsd.GetOperIntracom(_PetOperIntraEnviadas);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser
            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath +
                       _PetOperIntraEnviadas.GetReceivedFileName()
            };

            //frmXmlViewer.ShowDialog();

            try
            {
                // Obtengo la respuesta de la consulta de facturas recibidas del archivo de respuesta de la AEAT.
                RespuestaConsultaLRDetOperIntracomunitarias respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaConsultaLRDetOperIntracomunitarias;

                if (respuesta == null)
                {
                    DialogResult resultMsg;
                    string       _msg = "Se ha recibido una respuesta inesperada. Pulse 'Aceptar', si quiere revisarla";
                    resultMsg = MessageBox.Show(_msg, "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);

                    if (resultMsg == DialogResult.OK)
                    {
                        frmXmlViewer.ShowDialog();
                    }

                    return;
                }

                // Tenemos que recorrernos la respuesta y rellenar el datagrid con los datos de cada factura.
                grdInvoices.Rows.Clear();

                if (respuesta.ResultadoConsulta == "ConDatos")
                {
                    foreach (var invoice in respuesta.RegistroRCLRDetOperIntracom)
                    {
                        System.Drawing.Icon _marcaFact = MSeniorSII.Properties.Resources.Tag_Ok;

                        if (invoice.EstadoFactura.EstadoRegistro == "Anulada")
                        {
                            _marcaFact = MSeniorSII.Properties.Resources.Tag_Delete;
                        }

                        grdInvoices.Rows.Add(invoice.IDFactura.NumSerieFacturaEmisor, invoice.IDFactura.FechaExpedicionFacturaEmisor,
                                             invoice.OperacionIntracomunitaria.OperacionIntracom.TipoOperacion, invoice.OperacionIntracomunitaria.OperacionIntracom.ClaveDeclarado,
                                             invoice.OperacionIntracomunitaria.OperacionIntracom.DescripcionBienes, invoice, _marcaFact, invoice.DatosPresentacion.TimestampPresentacion,
                                             invoice.EstadoFactura.TimestampUltimaModificacion);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            txFechaBusqueda.Focus();
        }
Пример #25
0
        private void EnviaLoteEnCurso()
        {
            // Realizamos el envío del lote de facturas a borrar a la AEAT
            Wsd.DeleteOperIntracom(_LoteBajaOperIntracom);

            // Muestro el xml de respuesta recibido de la AEAT en el web browser

            FormXmlViewer frmXmlViewer = new FormXmlViewer
            {
                Path = Settings.Current.InboxPath + _LoteBajaOperIntracom.GetReceivedFileName()
            };

            //frmXmlViewer.ShowDialog();

            // Obtengo la respuesta de la baja de facturas emitidas del archivo de respuesta de la AEAT.
            RespuestaLRF respuesta = new Envelope(frmXmlViewer.Path).Body.RespuestaLRBajaDetOperacionesIntracomunitarias;

            if (respuesta == null)
            {
                SoapFault msgError = new Envelope(frmXmlViewer.Path).Body.RespuestaError;
                if (msgError != null)
                {
                    MessageBox.Show(msgError.FaultDescription, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            foreach (DataGridViewRow row in grdInvoices.Rows) // Recorro las facturas enviadas
            {
                string numFra = row.Cells[0].Value.ToString();

                // Busco en las líneas de la respuesta el número de factura
                var linqQryFra = from respuestaFra in respuesta.RespuestaLinea
                                 where respuestaFra.IDFactura.NumSerieFacturaEmisor == numFra
                                 select respuestaFra;

                // Si el estado del registro es correcto lo marco como factura eliminada
                foreach (RespuestaLinea respuestaFra in linqQryFra)
                {
                    if (respuestaFra.EstadoRegistro == "Correcto")
                    {
                        row.Cells[6].Value = MSeniorSII.Properties.Resources.Tag_Delete;
                    }
                    else
                    {
                        row.Cells[6].Value = MSeniorSII.Properties.Resources.Tag_Ok;
                    }
                }
            }

            string _msg = "";

            if (respuesta.EstadoEnvio == "Incorrecto")
            {
                _msg = "Envío Rechazado. Para saber el motivo revise el fichero: " + frmXmlViewer.Path;
            }
            else
            {
                _msg = ($"Estado del envío realizado a la AEAT: {respuesta.EstadoEnvio}.\nCódigo CVS: {respuesta.CSV}");
            }
            MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }