private void mnLoad_Click(object sender, EventArgs e) { dlgOpen.ShowDialog(); if (string.IsNullOrEmpty(dlgOpen.FileName)) { return; } string FullPath = dlgOpen.FileName; Envelope envelope = new Envelope(FullPath); if (envelope.Body.SuministroLRDetOperacionIntracomunitaria == null) { MessageBox.Show("No es un lote de Operaciones Intracomunitarias."); return; } ResetFactura(); _LoteOperIntracom = new ITInvoicesBatch(envelope.Body.SuministroLRDetOperacionIntracomunitaria); _Titular = _LoteOperIntracom.Titular; BindViewTitular(); BindViewFactura(); BindViewInvoices(); cbEsEmisor.Checked = false; }
/// <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()); }
public void MostrarLoteOperIntracom() { // Creamos un lote de factura recibidas ITInvoicesBatch LoteOperIntracom = CrearLoteOperIntracom(); string tmpath = Path.GetTempFileName(); // Genera el archivo xml y lo guarda en la ruta facilitada comno parámetro LoteOperIntracom.GetXml(tmpath); formXmlViewer frmXmlViewer = new formXmlViewer(); frmXmlViewer.Path = tmpath; frmXmlViewer.ShowDialog(); }
/// <summary> /// Inicia entorno. /// </summary> private void Inizialize() { _LoteOperIntracom = new ITInvoicesBatch { CommunicationType = CommunicationType.A0 // alta facturas: }; _Titular = new Party(); _Buyer = new Party(); _Seller = new Party(); //_Buyer = _Titular; _LoteOperIntracom.Titular = _Titular; ResetFactura(); BindModelTitular(); }
private void MnLoad_Click(object sender, EventArgs e) { try { dlgOpen.ShowDialog(); if (string.IsNullOrEmpty(dlgOpen.FileName)) { return; } string FullPath = dlgOpen.FileName; Envelope envelope = new Envelope(FullPath); if (envelope.Body.SuministroLRDetOperacionIntracomunitaria == null) { string _msg = "No es un lote de Operaciones Intracomunitarias."; MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ResetFactura(); _LoteOperIntracom = new ITInvoicesBatch(envelope.Body.SuministroLRDetOperacionIntracomunitaria); _Titular = _LoteOperIntracom.Titular; BindViewTitular(); BindViewFactura(); BindViewInvoices(); BindObtCertificado(); cbEsEmisor.Checked = false; } catch (Exception ex) { string _msgError = "Error: " + ex.Message; MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Crea lote de facturas recibidas. /// </summary> /// <returns>Lote de facturas recibidas de prueba.</returns> private static ITInvoicesBatch CrearLoteOperIntracom() { // Creamos al titular del lote. Party titular = new Party() { TaxIdentificationNumber = "B12959755", PartyName = "IRENE SOLUTIONS SL" }; // Lote de factura recibidas a enviar la AEAT al SII ITInvoicesBatch LoteOperIntracom = new ITInvoicesBatch(); LoteOperIntracom.Titular = titular; LoteOperIntracom.CommunicationType = CommunicationType.A0; // Alta de facturas: // utilizando el tipo de comunicación podemos modificar datos de facturas envíadas // anteriormente. En lugar de alta de facturas, podemos elegir modificación. Party comprador = titular; // El titular es el comprador en este caso // Ejemplo de una factura Intracomunitaria EMITIDA, en la que el titular y el 'buyer' son el mismo ITInvoice operIntracomPrimera = new ITInvoice(); operIntracomPrimera.IssueDate = new DateTime(2017, 1, 15);// Fecha de emisión factura (Ejemplo raro, sujeta con nif extranjero) operIntracomPrimera.CountryCode = "DK"; operIntracomPrimera.SellerParty = new Party() // Acreedor (Emisor factura) { TaxIdentificationNumber = "DK12345678", PartyName = "CLIENTE EXTRANJERO LTD" }; // // Según pruebas realizadas, parece ser que el 'BuyerParty' tiene que ser el mismo que el titular del libro, ya que sino indica un // error de que hay que indicar que se trata de un NIF-IVA (02). // operIntracomPrimera.BuyerParty = titular; // Comprador operIntracomPrimera.InvoiceNumber = "OI00016"; // Número de factura operIntracomPrimera.OperationType = OperationType.A; operIntracomPrimera.ClaveDeclarado = ClaveDeclarado.D; operIntracomPrimera.EstadoMiembro = "DK"; operIntracomPrimera.DescripcionBienes = "Descripción de los bienes ..."; operIntracomPrimera.DireccionOperador = "Dirección del operador ..."; LoteOperIntracom.ITInvoices.Add(operIntracomPrimera); // Añado la factura al lote // // Ejemplo de una factura Intracomunitaria RECIBIDA, en la que el titular y el 'seller' son el mismo // ITInvoice operIntracomSegunda = new ITInvoice(); operIntracomSegunda.IssueDate = new DateTime(2017, 1, 16);// Fecha de emisión factura (Ejemplo raro, sujeta con nif extranjero) operIntracomSegunda.CountryCode = "DK"; operIntracomSegunda.BuyerParty = new Party() // Acreedor (Emisor factura) { TaxIdentificationNumber = "DK12345678", PartyName = "CLIENTE EXTRANJERO LTD" }; operIntracomSegunda.SellerParty = titular; // Comprador operIntracomSegunda.InvoiceNumber = "OI00017"; // Número de factura operIntracomSegunda.OperationType = OperationType.A; operIntracomSegunda.ClaveDeclarado = ClaveDeclarado.D; operIntracomSegunda.EstadoMiembro = "ES"; operIntracomSegunda.DescripcionBienes = "Descripción de los bienes 2 ..."; operIntracomSegunda.DireccionOperador = "Dirección del operador 2 ..."; LoteOperIntracom.ITInvoices.Add(operIntracomSegunda); // Añado la factura al lote return(LoteOperIntracom); }
public void GenerarXMLIntracom(string _NombreFichero) { Intracom funcion = new Intracom(); string _NomFicheroWrk = _NombreFichero; try { ITInvoicesBatch _LoteOperIntracom = new ITInvoicesBatch(); ITInvoice _OperIntracomAct = new ITInvoice(); Party _Titular = new Party(); using (StreamReader _Lector = new StreamReader(_NomFicheroWrk)) { while (_Lector.Peek() > -1) { string _RegFichero = _Lector.ReadLine(); if (!String.IsNullOrEmpty(_RegFichero)) { // Con creamos un Array con los distintos campos que contiene el registro separados por ";" string[] _CamposReg = _RegFichero.Split(';'); string _TipoReg = _CamposReg[0]; switch (_TipoReg) { case "CABE": _Titular = funcion.TratarRegCabecera(_CamposReg); _LoteOperIntracom.Titular = _Titular; string _TipoComunicacion = _CamposReg[3]; switch (_TipoComunicacion) { case "A0": _LoteOperIntracom.CommunicationType = CommunicationType.A0; break; case "A1": _LoteOperIntracom.CommunicationType = CommunicationType.A1; break; case "A4": _LoteOperIntracom.CommunicationType = CommunicationType.A4; break; } break; case "FACT": _OperIntracomAct = new ITInvoice(); _OperIntracomAct = funcion.TratarOperIntracom(_CamposReg, _Titular); _LoteOperIntracom.ITInvoices.Add(_OperIntracomAct); break; case "FINI": // Procedemos a generar el XML final. DateTime _FechaActual = DateTime.Today; //Obtenemos la fecha actual sin la hora string nombrefichero = "SII_Intracom_" + _Titular.TaxIdentificationNumber + "_" + _FechaActual.ToString("yyyyMMdd") + ".XML"; string XmlResult = "C:/Temp/" + nombrefichero; _LoteOperIntracom.GetXml(XmlResult); string _msg = "Fichero XML generado: " + XmlResult; MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); break; default: string _msgAviso = "Tipo Registro incorrecto: " + _TipoReg; MessageBox.Show(_msgAviso, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } } } } } catch (Exception ex) { string _msgError = "Error: " + ex.Message; MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }