** NORMAS DEL FORO **
Inicio del foro Inicio del foro > Access y VBA > Access y VBA
  Mensajes nuevos Mensajes nuevos RSS - Leer FacturaE XML
  Preguntas frecuentes Preguntas frecuentes  Buscar en el foro   Eventos   Registro Registro  Iniciar sesion Iniciar sesion

Leer FacturaE XML

 Responder Responder
Autor
Mensaje
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Tema: Leer FacturaE XML
    Enviado: 04/Septiembre/2023 a las 15:24
Buenos dias
estoy tratando de extraer todos los campos de un fichero xml de FacruraE
Uso este procedimiento
Solo expongo la parte que no logro acotar, el resto ya funciona correctamente
Es el primer nodo "TaxesOutputs" que aparece en el documento

Option Compare Database
Option Explicit
Dim xDoc As MSXML2.DOMDocument60

Private Sub BtnFtraE_Click()
Dim xNodes As MSXML2.IXMLDOMNodeList, xNodes1 As MSXML2.IXMLDOMNodeList
Dim xNode As IXMLDOMNode, xNode1 As IXMLDOMNode, textline As String

    Set xDoc = New MSXML2.DOMDocument60
    xDoc.async = False
    xDoc.validateOnParse = True
    xDoc.Load (Me.FileXML) 

Debug.Print "---------------------IMPORTES POR TIPO DE IVA---------------------------"
        Set xNodes = xDoc.selectNodes("//TaxesOutputs")
  For Each xNode In xNodes
     textline = DameValor1(xNode, "Tax/TaxTypeCode"): Debug.Print textline
     textline = DameValor1(xNode, "Tax/TaxRate"): Debug.Print Trim(CurrencyFromXml(textline))
     textline = DameValor1(xNode, "Tax/TaxableBase/TotalAmount"): Debug.Print Trim(CurrencyFromXml(textline))
     textline = DameValor1(xNode, "Tax/TaxAmount/TotalAmount"): Debug.Print Trim(CurrencyFromXml(textline))
 Next
End Sub
Esto me devuelve lo sigiente:
01
10
194,47
19,06
01
10
194,47
19,06
01
21
5,83
1,2
01
5
204,41
10,02
Y no aacabo de entender porqué me duplica el primero de ellos:
01
10
194,47
19,06


El fichero es este

<?xml version="1.0" encoding="UTF-8"?>
<fe:Facturae xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fe="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae">
<FileHeader>
<SchemaVersion>3.2.1</SchemaVersion>
<Modality>I</Modality>
<InvoiceIssuerType>EM</InvoiceIssuerType>
<Batch>
<BatchIdentifier>Z00034</BatchIdentifier>
<InvoicesCount>1</InvoicesCount>
<TotalInvoicesAmount>
<TotalAmount>426.89</TotalAmount>
</TotalInvoicesAmount>
<TotalOutstandingAmount>
<TotalAmount>426.89</TotalAmount>
</TotalOutstandingAmount>
<TotalExecutableAmount>
<TotalAmount>426.89</TotalAmount>
</TotalExecutableAmount>
<InvoiceCurrencyCode>EUR</InvoiceCurrencyCode>
</Batch>
</FileHeader>
<Parties>
<SellerParty>
<TaxIdentification>
<PersonTypeCode>J</PersonTypeCode>
<ResidenceTypeCode>R</ResidenceTypeCode>
<TaxIdentificationNumber>B77777787</TaxIdentificationNumber>
</TaxIdentification>
<PartyIdentification>1</PartyIdentification>
<LegalEntity>
<CorporateName>SUMINISTROS DE HOSTELERIA S.L.</CorporateName>
<TradeName>SUMINISTROS DE HOSTELERIA S.L.</TradeName>
<RegistrationData>
<Book/>
<RegisterOfCompaniesLocation/>
<Sheet/>
<Folio/>
<Section/>
<Volume/>
</RegistrationData>
<AddressInSpain>
<Address>MARCELINO SUAREZ, 75, 2 C</Address>
<PostCode>33012</PostCode>
<Town>OVIEDO</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
<ContactDetails>
<Telephone>985231200</Telephone>
<TeleFax/>
<WebAddress>www.inseGgur.com</WebAddress>
<ElectronicMail/>
<ContactPersons/>
</ContactDetails>
</LegalEntity>
</SellerParty>
<BuyerParty>
<TaxIdentification>
<PersonTypeCode>J</PersonTypeCode>
<ResidenceTypeCode>R</ResidenceTypeCode>
<TaxIdentificationNumber>A77777841</TaxIdentificationNumber>
</TaxIdentification>
<PartyIdentification>1</PartyIdentification>
<AdministrativeCentres>
<AdministrativeCentre>
<CentreCode>A01004456</CentreCode>
<RoleTypeCode>01</RoleTypeCode>
<Name>INTERVENCION GENERAL DE LA JUNTA DE ANDA</Name>
<AddressInSpain>
<Address>CL C/ RIO NALON N 10</Address>
<PostCode>33012</PostCode>
<Town>GIJON</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
</AdministrativeCentre>
<AdministrativeCentre>
<CentreCode>A01004389</CentreCode>
<RoleTypeCode>02</RoleTypeCode>
<Name>DELEGACION TERRITORIAL DE IGUALDAD, SALU</Name>
<AddressInSpain>
<Address>CL C/ RIO NALON N 10</Address>
<PostCode>33012</PostCode>
<Town>GIJON</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
</AdministrativeCentre>
<AdministrativeCentre>
<CentreCode>A01015197</CentreCode>
<RoleTypeCode>03</RoleTypeCode>
<Name>CENTRO RESIDENCIAL PARA PERSONAS MAYORES</Name>
<AddressInSpain>
<Address>CL C/ RIO NALON N 10</Address>
<PostCode>33012</PostCode>
<Town>GIJON</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
</AdministrativeCentre>
</AdministrativeCentres>
<LegalEntity>
<CorporateName/>
<TradeName>** SIDRERIA MATADOR **</TradeName>
<RegistrationData>
<Book/>
<RegisterOfCompaniesLocation/>
<Sheet/>
<Folio/>
<Section/>
<Volume/>
</RegistrationData>
<AddressInSpain>
<Address>CL C/ RIO NALON N 10</Address>
<PostCode>33012</PostCode>
<Town>GIJON</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
<ContactDetails>
<Telephone/>
<TeleFax/>
<WebAddress/>
<ElectronicMail/>
<ContactPersons/>
</ContactDetails>
</LegalEntity>
</BuyerParty>
</Parties>
<Invoices>
<Invoice>
<InvoiceHeader>
<InvoiceNumber>Z00034</InvoiceNumber>
<InvoiceDocumentType>FC</InvoiceDocumentType>
<InvoiceClass>OO</InvoiceClass>
</InvoiceHeader>
<InvoiceIssueData>
<IssueDate>2023-03-02</IssueDate>
<PlaceOfIssue>
<PostCode>33012</PostCode>
<PlaceOfIssueDescription>OVIEDO</PlaceOfIssueDescription>
</PlaceOfIssue>
<InvoiceCurrencyCode>EUR</InvoiceCurrencyCode>
<TaxCurrencyCode>EUR</TaxCurrencyCode>
<LanguageName>es</LanguageName>
</InvoiceIssueData>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>10</TaxRate>
<TaxableBase>
<TotalAmount>194.47</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>19.06</TotalAmount>
</TaxAmount>
</Tax>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21</TaxRate>
<TaxableBase>
<TotalAmount>5.83</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>1.2</TotalAmount>
</TaxAmount>
</Tax>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>5</TaxRate>
<TaxableBase>
<TotalAmount>204.41</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>10.02</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<InvoiceTotals>
<TotalGrossAmount>396.61</TotalGrossAmount>
<TotalGeneralDiscounts>8.1</TotalGeneralDiscounts>
<TotalGrossAmountBeforeTaxes>396.61</TotalGrossAmountBeforeTaxes>
<TotalTaxOutputs>30.28</TotalTaxOutputs>
<TotalTaxesWithheld>0</TotalTaxesWithheld>
<InvoiceTotal>426.89</InvoiceTotal>
<TotalOutstandingAmount>426.89</TotalOutstandingAmount>
<TotalExecutableAmount>426.89</TotalExecutableAmount>
</InvoiceTotals>
<Items>
<InvoiceLine>
<DeliveryNotesReferences>
<DeliveryNote>
<DeliveryNoteNumber>S00002</DeliveryNoteNumber>
<DeliveryNoteDate>2023-01-25</DeliveryNoteDate>
</DeliveryNote>
</DeliveryNotesReferences>
<ItemDescription>PLATO BOTELLA CAVA TRANSPARENTE</ItemDescription>
<Quantity>9</Quantity>
<UnitPriceWithoutTax>21.6081</UnitPriceWithoutTax>
<TotalCost>194.47</TotalCost>
<GrossAmount>194.47</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>10</TaxRate>
<TaxableBase>
<TotalAmount>194.47</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>19.06</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>000010</ArticleCode>
</InvoiceLine>
<InvoiceLine>
<DeliveryNotesReferences>
<DeliveryNote>
<DeliveryNoteNumber>S00001</DeliveryNoteNumber>
<DeliveryNoteDate>2023-01-20</DeliveryNoteDate>
</DeliveryNote>
</DeliveryNotesReferences>
<ItemDescription>SERRIN AHUMADOR ALADIN CHIPS</ItemDescription>
<Quantity>1</Quantity>
<UnitPriceWithoutTax>5.8293</UnitPriceWithoutTax>
<TotalCost>5.83</TotalCost>
<GrossAmount>5.83</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21</TaxRate>
<TaxableBase>
<TotalAmount>5.83</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>1.2</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>000003</ArticleCode>
</InvoiceLine>
<InvoiceLine>
<ItemDescription>AHUMADOR ALADIN SUPER</ItemDescription>
<Quantity>1</Quantity>
<UnitPriceWithoutTax>204.4085</UnitPriceWithoutTax>
<TotalCost>204.41</TotalCost>
<GrossAmount>204.41</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>5</TaxRate>
<TaxableBase>
<TotalAmount>204.41</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>10.02</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>000002</ArticleCode>
</InvoiceLine>
</Items>
<PaymentDetails>
<Installment>
<InstallmentDueDate>2023-03-02</InstallmentDueDate>
<InstallmentAmount>426.89</InstallmentAmount>
<PaymentMeans>03</PaymentMeans>
<PaymentReconciliationReference>Z00034-01</PaymentReconciliationReference>
<DebitReconciliationReference>Z00034-01</DebitReconciliationReference>
</Installment>
</PaymentDetails>
</Invoice>
</Invoices>
</fe:Facturae>

Agradeceria alguna colaboración que me lo aclare

SALUDOS



Editado por main - 05/Septiembre/2023 a las 09:35
Arriba
pitxiku Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 27/Septiembre/2017
Localización: En mi casa
Estado: Sin conexión
Puntos: 1487
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita pitxiku Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 04/Septiembre/2023 a las 22:46
Si en vez de coger la información por partes de cada nodo, lo imprimes directamente, verás que el primer nodo no es igual a los otros 3: es como si el primer nodo fuese la unión de los 3 hijos. Si con esta parte siempre te pasa lo mismo en todas las facturas, una posibilidad es usar la propiedad length para saber cuántos hijos hay, y saltarte el primero:

Dim xDoc As MSXML2.DOMDocument60

Public Sub BtnFtraE_Click()
Dim xNodes As MSXML2.IXMLDOMNodeList, xNodes1 As MSXML2.IXMLDOMNodeList
Dim xNode As IXMLDOMNode, xNode1 As IXMLDOMNode, textline As String

    Set xDoc = New MSXML2.DOMDocument60
    xDoc.async = False
    xDoc.validateOnParse = True
    'xDoc.Load (Me.FileXML)
    Call xDoc.Load(CurrentProject.Path & "\factura.xml")

Debug.Print "---------------------IMPORTES POR TIPO DE IVA---------------------------"
        Set xNodes = xDoc.selectNodes("//TaxesOutputs")
  For Each xNode In xNodes
    Debug.Print xNode.Text
     'textline = DameValor1(xNode, "Tax/TaxTypeCode"): Debug.Print textline
     'textline = DameValor1(xNode, "Tax/TaxRate"): Debug.Print Trim(CurrencyFromXml(textline))
     'textline = DameValor1(xNode, "Tax/TaxableBase/TotalAmount"): Debug.Print Trim(CurrencyFromXml(textline))
     'textline = DameValor1(xNode, "Tax/TaxAmount/TotalAmount"): Debug.Print Trim(CurrencyFromXml(textline))
 Next

    Dim l As Long
    
    Set xNodes = xDoc.selectNodes("//TaxesOutputs")
    
    For l = 1 To xNodes.Length - 1
        Debug.Print "-- Nodo " & l & ":",
        Debug.Print xNodes(l).selectSingleNode("Tax/TaxTypeCode").Text,
        Debug.Print xNodes(l).selectSingleNode("Tax/TaxRate").Text,
        Debug.Print xNodes(l).selectSingleNode("Tax/TaxableBase/TotalAmount").Text,
        Debug.Print xNodes(l).selectSingleNode("Tax/TaxAmount/TotalAmount").Text
    Next
End Sub

Otra cosa: toda esa información que hay en el Xml, ¿no será real, verdad? Todos esos CIFs/NIFs, nombres, direcciones, ¿son inventados, cierto? Porque puedes tener algún problemilla con la Agencia de Protección de datos
Arriba
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 05/Septiembre/2023 a las 00:31
Hola Pitxiku
Gracias por la respuesta y hasta ahora me  pasa siempre lo mismo, aunque solo haya uno.
Pero con tu solución creo que está arreglado.
Esa parte quedaría así:
Debug.Print "---------------------IMPORTES POR TIPO DE IVA---------------------------"
        
        Dim I As Long
        Set xNodes = xDoc.SelectNodes("//TaxesOutputs")
         Debug.Print "NODOS " & xNodes.Length '- 1
     For I = 1 To xNodes.Length - 1
        Debug.Print "-- Nodo " & I & ":",
        Debug.Print xNodes(I).selectSingleNode("Tax/TaxTypeCode").Text,
        Debug.Print xNodes(I).selectSingleNode("Tax/TaxRate").Text,
        Debug.Print xNodes(I).selectSingleNode("Tax/TaxableBase/TotalAmount").Text,
        Debug.Print xNodes(I).selectSingleNode("Tax/TaxAmount/TotalAmount").Text
    Next
No lo acabo de entender, el porqué, pero funciona correctamente.
Y en cuanto a los datos, CIF NIF, y nombres, son inventados a excepción de los CentreCode que supongo son públicos.
Muchas gracias de nuevo
Se puede cerrar el tema.


Arriba
pitxiku Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 27/Septiembre/2017
Localización: En mi casa
Estado: Sin conexión
Puntos: 1487
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita pitxiku Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 05/Septiembre/2023 a las 07:40
Una cosa que no me había dado cuenta: revisando el xml, si que lo estabas haciendo bien. En el raíz del xml hay 4 grupos de impuestos. En el primero están los 3 impuestos que imprimes, y luego hay otros 3 grupos, donde en cada uno hay uno de esos 3 impuestos. Al ser datos iguales, da la sensación de que se repiten, pero en realidad te está mostrando nodos distintos.
Arriba
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 06/Septiembre/2023 a las 10:39
Hola:
Si es así, como delimito para extraer solo los del primer grupo.
He puesto:
Set xNodes = xDoc.SelectNodes("//TaxesOutputs")
Debug.Print "Grupo 1: " & xNodes.item(0).Text
Me devuelve
01 10 194.47 19.06 01 21 5.83 1.2 01 5 204.41 10.02
Que son respectivamente el conjunto de datos que deseo extraer (Primer grupo de impuestos)
Ahora la pregunta es como los extraigo con el método primitivo.(For Each)
Como bien interpretabas el primer grupo es el resumen de todos los que le siguen, agrupados por el tipo de IVA (TaxRate) y las sumas de bases y cuotas.

SALUDOS



Arriba
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 06/Septiembre/2023 a las 11:13
Me respondo en parte, por verificar si mi solución es ortodoxa
For I = 1 To 1
        Debug.Print "-- Nodo " & I & ":",
        Debug.Print xNodes(I).selectSingleNode("Tax/TaxTypeCode").Text,
        Debug.Print CurrencyFromXml(xNodes(I - 1).selectSingleNode("Tax/TaxRate").Text),
        Debug.Print CurrencyFromXml(xNodes(I - 1).selectSingleNode("Tax/TaxableBase/TotalAmount").Text),
        Debug.Print CurrencyFromXml(xNodes(I - 1).selectSingleNode("Tax/TaxAmount/TotalAmount").Text)
    Next
Eso si usando selectSingleNode y no  el DameValor1()
Ya me direis
saludos

Arriba
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 06/Septiembre/2023 a las 16:52
Buenas tardes de nuevo:
Expongo un nuevo archivo XML porque el anterior que me facilitaron no reflejaba correctamente el primer grupo de Impuestos.

<?xml version="1.0" encoding="UTF-8"?>
<fe:Facturae xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fe="http://www.facturae.es/Facturae/2014/v3.2.1/Facturae">
<FileHeader>
<SchemaVersion>3.2.1</SchemaVersion>
<Modality>I</Modality>
<InvoiceIssuerType>EM</InvoiceIssuerType>
<Batch>
<BatchIdentifier>A00001</BatchIdentifier>
<InvoicesCount>1</InvoicesCount>
<TotalInvoicesAmount>
<TotalAmount>77.18</TotalAmount>
</TotalInvoicesAmount>
<TotalOutstandingAmount>
<TotalAmount>77.18</TotalAmount>
</TotalOutstandingAmount>
<TotalExecutableAmount>
<TotalAmount>77.18</TotalAmount>
</TotalExecutableAmount>
<InvoiceCurrencyCode>EUR</InvoiceCurrencyCode>
</Batch>
</FileHeader>
<Parties>
<SellerParty>
<TaxIdentification>
<PersonTypeCode>J</PersonTypeCode>
<ResidenceTypeCode>R</ResidenceTypeCode>
<TaxIdentificationNumber>A33060000</TaxIdentificationNumber>
</TaxIdentification>
<PartyIdentification>1</PartyIdentification>
<LegalEntity>
<CorporateName>CASA LUCES</CorporateName>
<TradeName>CASA LUCES</TradeName>
<RegistrationData>
<Book/>
<RegisterOfCompaniesLocation/>
<Sheet/>
<Folio/>
<Section/>
<Volume/>
</RegistrationData>
<AddressInSpain>
<Address>Vazquez</Address>
<PostCode>33000</PostCode>
<Town>OVIEDO</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
<ContactDetails>
<Telephone/>
<TeleFax/>
<WebAddress/>
<ElectronicMail/>
<ContactPersons/>
</ContactDetails>
</LegalEntity>
</SellerParty>
<BuyerParty>
<TaxIdentification>
<PersonTypeCode>J</PersonTypeCode>
<ResidenceTypeCode>R</ResidenceTypeCode>
<TaxIdentificationNumber>Q21600000</TaxIdentificationNumber>
</TaxIdentification>
<PartyIdentification>10</PartyIdentification>
<AdministrativeCentres>
<AdministrativeCentre>
<CentreCode>A13013761</CentreCode>
<RoleTypeCode>01</RoleTypeCode>
<Name>HOSPITAL CENTRAL DE LA CRUZ ROJA</Name>
<AddressInSpain>
<Address>CL. MARTINEZ VIGIL, 36</Address>
<PostCode>33001</PostCode>
<Town>OVIEDO</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
</AdministrativeCentre>
<AdministrativeCentre>
<CentreCode>A13003096</CentreCode>
<RoleTypeCode>02</RoleTypeCode>
<Name>SERVICIO MADRILENO DE SALUD (SERMAS)</Name>
<AddressInSpain>
<Address>CL. MARTINEZ VIGIL, 36</Address>
<PostCode>33001</PostCode>
<Town>OVIEDO</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
</AdministrativeCentre>
<AdministrativeCentre>
<CentreCode>A13013761</CentreCode>
<RoleTypeCode>03</RoleTypeCode>
<Name>HOSPITAL CENTRAL DE LA CRUZ ROJA</Name>
<AddressInSpain>
<Address>CL. MARTINEZ VIGIL, 36</Address>
<PostCode>33001</PostCode>
<Town>OVIEDO</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
</AdministrativeCentre>
</AdministrativeCentres>
<LegalEntity>
<CorporateName>LA ROJA ESPANOLA</CorporateName>
<TradeName>LA ROJA ESPANOLA</TradeName>
<RegistrationData>
<Book/>
<RegisterOfCompaniesLocation/>
<Sheet/>
<Folio/>
<Section/>
<Volume/>
</RegistrationData>
<AddressInSpain>
<Address>CL. MARTINEZ CASERO, 16</Address>
<PostCode>33001</PostCode>
<Town>OVIEDO</Town>
<Province>ASTURIAS</Province>
<CountryCode>ESP</CountryCode>
</AddressInSpain>
<ContactDetails>
<Telephone/>
<TeleFax/>
<WebAddress/>
<ElectronicMail/>
<ContactPersons/>
</ContactDetails>
</LegalEntity>
</BuyerParty>
</Parties>
<Invoices>
<Invoice>
<InvoiceHeader>
<InvoiceNumber>A00001</InvoiceNumber>
<InvoiceDocumentType>FC</InvoiceDocumentType>
<InvoiceClass>OO</InvoiceClass>
</InvoiceHeader>
<InvoiceIssueData>
<IssueDate>2023-09-06</IssueDate>
<PlaceOfIssue>
<PostCode>33002</PostCode>
<PlaceOfIssueDescription>OVIEDO</PlaceOfIssueDescription>
</PlaceOfIssue>
<InvoiceCurrencyCode>EUR</InvoiceCurrencyCode>
<TaxCurrencyCode>EUR</TaxCurrencyCode>
<LanguageName>es</LanguageName>
</InvoiceIssueData>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>4</TaxRate>
<TaxableBase>
<TotalAmount>24.5</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>0.98</TotalAmount>
</TaxAmount>
</Tax>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>10</TaxRate>
<TaxableBase>
<TotalAmount>37.1</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>3.71</TotalAmount>
</TaxAmount>
</Tax>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21</TaxRate>
<TaxableBase>
<TotalAmount>9</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>1.89</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<InvoiceTotals>
<TotalGrossAmount>70.6</TotalGrossAmount>
<TotalGeneralDiscounts>0</TotalGeneralDiscounts>
<TotalGrossAmountBeforeTaxes>70.6</TotalGrossAmountBeforeTaxes>
<TotalTaxOutputs>6.58</TotalTaxOutputs>
<TotalTaxesWithheld>0</TotalTaxesWithheld>
<InvoiceTotal>77.18</InvoiceTotal>
<TotalOutstandingAmount>77.18</TotalOutstandingAmount>
<TotalExecutableAmount>77.18</TotalExecutableAmount>
</InvoiceTotals>
<Items>
<InvoiceLine>
<DeliveryNotesReferences>
<DeliveryNote>
<DeliveryNoteNumber>A00002</DeliveryNoteNumber>
<DeliveryNoteDate>2023-01-24</DeliveryNoteDate>
</DeliveryNote>
</DeliveryNotesReferences>
<ItemDescription>PAN BARRAS DE 600</ItemDescription>
<Quantity>10</Quantity>
<UnitPriceWithoutTax>1.63</UnitPriceWithoutTax>
<TotalCost>16.3</TotalCost>
<GrossAmount>16.3</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>4</TaxRate>
<TaxableBase>
<TotalAmount>16.3</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>0.65</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>1001</ArticleCode>
</InvoiceLine>
<InvoiceLine>
<ItemDescription>PAN BARRA DE 1/2</ItemDescription>
<Quantity>20</Quantity>
<UnitPriceWithoutTax>1.06</UnitPriceWithoutTax>
<TotalCost>21.2</TotalCost>
<GrossAmount>21.2</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>10</TaxRate>
<TaxableBase>
<TotalAmount>21.2</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>2.12</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>1002</ArticleCode>
</InvoiceLine>
<InvoiceLine>
<ItemDescription>PAN BARRA DE 1/4 INTEGRAL</ItemDescription>
<Quantity>10</Quantity>
<UnitPriceWithoutTax>0.82</UnitPriceWithoutTax>
<TotalCost>8.2</TotalCost>
<GrossAmount>8.2</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>4</TaxRate>
<TaxableBase>
<TotalAmount>8.2</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>0.33</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>10032</ArticleCode>
</InvoiceLine>
<InvoiceLine>
<ItemDescription>PAN BARRA DE 1/2</ItemDescription>
<Quantity>15</Quantity>
<UnitPriceWithoutTax>1.06</UnitPriceWithoutTax>
<TotalCost>15.9</TotalCost>
<GrossAmount>15.9</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>10</TaxRate>
<TaxableBase>
<TotalAmount>15.9</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>1.59</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
<ArticleCode>1002</ArticleCode>
</InvoiceLine>
<InvoiceLine>
<ItemDescription>OTROS</ItemDescription>
<Quantity>1</Quantity>
<UnitPriceWithoutTax>5</UnitPriceWithoutTax>
<TotalCost>5</TotalCost>
<GrossAmount>5</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21</TaxRate>
<TaxableBase>
<TotalAmount>5</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>1.05</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
</InvoiceLine>
<InvoiceLine>
<ItemDescription>OTROS</ItemDescription>
<Quantity>1</Quantity>
<UnitPriceWithoutTax>4</UnitPriceWithoutTax>
<TotalCost>4</TotalCost>
<GrossAmount>4</GrossAmount>
<TaxesOutputs>
<Tax>
<TaxTypeCode>01</TaxTypeCode>
<TaxRate>21</TaxRate>
<TaxableBase>
<TotalAmount>4</TotalAmount>
</TaxableBase>
<TaxAmount>
<TotalAmount>0.84</TotalAmount>
</TaxAmount>
</Tax>
</TaxesOutputs>
<AdditionalLineItemInformation/>
</InvoiceLine>
</Items>
</Invoice>
</Invoices>
</fe:Facturae>
 
Ahora espero se entienda mejor

Arriba
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 06/Septiembre/2023 a las 17:20
Y EL PROCEDIMIENTO:
Private Sub BtnFtraE_Click()
Dim xNodes As MSXML2.IXMLDOMNodeList, xNodes1 As MSXML2.IXMLDOMNodeList
Dim xNode As IXMLDOMNode, xNode1 As IXMLDOMNode, textline As String

    Set xDoc = New MSXML2.DOMDocument60
    xDoc.async = False
    xDoc.validateOnParse = True
    xDoc.Load (Me.FileXML) 

   Dim I As Long
        Set xNodes = xDoc.SelectNodes("//TaxesOutputs")
         Debug.Print "NODOS TOTALES " & xNodes.Length ' - 1
         Debug.Print "HIJOS " & xNodes.item(0).Text
         Debug.Print "HIJOS PRIMER GRUPO " & xNodes.item(0).ChildNodes.Length
     For I = 1 To xNodes.item(0).ChildNodes.Length
                 Debug.Print "VALORES " & xNodes.item(0).ChildNodes.item(I - 1).nodeTypedValue
      Next

Debug.Print "------ LINEAS FACTURA-------"
    For I = 2 To xNodes.Length
        Debug.Print "-- Linea " & I - 1 & ":",
        Debug.Print xNodes(I - 1).selectSingleNode("Tax/TaxTypeCode").Text,
        Debug.Print CurrencyFromXml(xNodes(I - 1).selectSingleNode("Tax/TaxRate").Text),
        Debug.Print CurrencyFromXml(xNodes(I - 1).selectSingleNode("Tax/TaxableBase/TotalAmount").Text),
        Debug.Print CurrencyFromXml(xNodes(I - 1).selectSingleNode("Tax/TaxAmount/TotalAmount").Text)
    Next

ESTO me devuelve:
---------------------IMPORTES POR TIPO DE IVA---------------------------
NODOS TOTALES 7
HIJOS 01 4 24.5 0.98 01 10 37.1 3.71 01 21 9 1.89
HIJOS PRIMER GRUPO 3
VALORES 01 4 24.5 0.98
VALORES 01 10 37.1 3.71
VALORES 01 21 9 1.89
------ LINEAS FACTURA-------
-- Linea 1:   01             4             16,3          0,65
-- Linea 2:   01             10            21,2          2,12
-- Linea 3:   01             4             8,2           0,33
-- Linea 4:   01             10            15,9          1,59
-- Linea 5:   01             21            5             1,05
-- Linea 6:   01             21            4             0,84
Hasta aqui no va mal aunque puede no ser lo mas eficiente
Lo que deseo es que estas lineas:
VALORES 01 4 24.5 0.98
VALORES 01 10 37.1 3.71
VALORES 01 21 9 1.89
Me las desglose para cada uno de los valores que contiene
Linea 1
01
4
24.5
0.98
Linea 2
01
10 
37.1
3.71
Linea 3
01
21
9
1.89
Y así para mi sería lo ideal
 


Arriba
pitxiku Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 27/Septiembre/2017
Localización: En mi casa
Estado: Sin conexión
Puntos: 1487
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita pitxiku Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 06/Septiembre/2023 a las 23:11
Con ese Xml, puedes recorrer hijos y puedes seleccionar los grupos de hijos deseados. Luego ya es sólo cuestión de recuperar la información que precises y jugar con ella. Por ejemplo:

Public Sub ImpuestosFacturaE()
    Dim xDoc As MSXML2.DOMDocument60
    Dim xFacturas As MSXML2.IXMLDOMNodeList
    Dim xFactura As IXMLDOMNode
    Dim xImpuestos As MSXML2.IXMLDOMNodeList
    Dim xImpuesto As IXMLDOMNode
    Dim xLineas As MSXML2.IXMLDOMNodeList
    Dim xLinea As IXMLDOMNode
    Dim lngFacturas As Long
    Dim lngLineas As Long
    
    Set xDoc = New MSXML2.DOMDocument60
    xDoc.async = False
    xDoc.validateOnParse = True
    Call xDoc.Load(CurrentProject.Path & "\XMLFile1.xml")
    
    'Impuestos totales en la factura
    Set xFacturas = xDoc.selectNodes("//Invoices/Invoice")
    Debug.Print "Hay " & xFacturas.Length & " factura(s) en el xml"
    Debug.Print "============================================"
    
    lngFacturas = 1
    For Each xFactura In xFacturas
        Debug.Print "Factura nº" & lngFacturas
        Debug.Print "-------------------------------------------"
        Debug.Print "Resumen de impuestos"
        
        Set xImpuestos = xFactura.selectNodes("TaxesOutputs/Tax")
        
        For Each xImpuesto In xImpuestos
            Debug.Print "Impuesto Tipo: " & xImpuesto.selectSingleNode("TaxTypeCode").Text,
            Debug.Print "Ratio (%): " & Porcentaje(xImpuesto.selectSingleNode("TaxRate").Text),
            Debug.Print "Base: " & Moneda(xImpuesto.selectSingleNode("TaxableBase/TotalAmount").Text),
            Debug.Print "Impuesto: " & Moneda(xImpuesto.selectSingleNode("TaxAmount/TotalAmount").Text)
        Next
        
        Debug.Print "Totales:"
        Debug.Print "Total antes de impuestos: " & Moneda(xFactura.selectSingleNode("InvoiceTotals/TotalGrossAmountBeforeTaxes").Text)
        Debug.Print "Total impuestos: " & Moneda(xFactura.selectSingleNode("InvoiceTotals/TotalTaxOutputs").Text)
        Debug.Print "Total factura con impuestos: " & Moneda(xFactura.selectSingleNode("InvoiceTotals/InvoiceTotal").Text)
        
        Debug.Print "-------------------------------------------"
        Debug.Print "Líneas de la factura"
        Debug.Print "Línea", "Elemento", , "Cantidad", "Precio/u", "Coste", "Ratio", "Porcentaje", "Coste imp."
        Debug.Print "-------------------------------------------------------------------------------------------------------------------------"
        Set xLineas = xFactura.selectNodes("Items/InvoiceLine")
        
        lngLineas = 1
        For Each xLinea In xLineas
            Debug.Print lngLineas,
            
            Debug.Print Texto(xLinea.selectSingleNode("ItemDescription").Text),
            Debug.Print Numero(xLinea.selectSingleNode("Quantity").Text),
            Debug.Print Moneda(xLinea.selectSingleNode("UnitPriceWithoutTax").Text),
            Debug.Print Moneda(xLinea.selectSingleNode("TotalCost").Text),
            Debug.Print xLinea.selectSingleNode("TaxesOutputs/Tax/TaxTypeCode").Text,
            Debug.Print Porcentaje(xLinea.selectSingleNode("TaxesOutputs/Tax/TaxRate").Text),
            Debug.Print Moneda(xLinea.selectSingleNode("TaxesOutputs/Tax/TaxAmount/TotalAmount").Text)

            lngLineas = lngLineas + 1
        Next
        
        Debug.Print "-------------------------------------------"
        lngFacturas = lngFacturas + 1
    Next
    
    Set xDoc = Nothing
End Sub

Public Function PuntoAComa(Valor) As String
    If IsNull(Valor) Then
        PuntoAComa = 0
    Else
        PuntoAComa = Replace(Valor, ".", ",")
    End If
End Function

Public Function Porcentaje(Valor) As String
    If IsNull(Valor) Then
        Porcentaje = FormatNumber(0, 2) & "%"
    Else
        Porcentaje = FormatNumber(PuntoAComa(Valor), 2) & "%"
    End If
End Function

Public Function Moneda(Valor) As String
    If IsNull(Valor) Then
        Moneda = FormatCurrency(0)
    Else
        Moneda = FormatCurrency(PuntoAComa(Valor))
    End If
End Function

Public Function Texto(Valor) As String
    Texto = Format(Valor, "!@@@@@@@@@@@@@@@@@@@@@@@@@")
End Function

Public Function Numero(Valor) As String
    If IsNull(Valor) Then
        Numero = FormatNumber(0, 2)
    Else
        Numero = FormatNumber(PuntoAComa(Valor), 2)
    End If
End Function


Editado por pitxiku - 06/Septiembre/2023 a las 23:12
Arriba
main Ver desplegable
Colaborador
Colaborador
Avatar

Unido: 31/Agosto/2009
Localización: OVIEDO
Estado: Sin conexión
Puntos: 1253
Opciones de entrada Opciones de entrada   Gracias (0) Gracias(0)   Cita main Cita  ResponderRespuesta Enlace directo a este mensaje Enviado: 07/Septiembre/2023 a las 14:40
Buen dia Pitxiku
Lo primero, muchas, muchas gracias
Brillante desarrollo
Creo que le voy cogiendo el tranquillo y yá me atrevo con los xml del SIIHug
El acotar debidamente los  MSXML2.IXMLDOMNODELIST  con su correspondiente nodo me dió la vida para comprenderlo.
En fin, ya vendran nuevas dudas
y lo dicho muchas, muchas gracias de nuevo

SALUDOS AL GRUPO.


Arriba
 Responder Responder
  Compartir tema   

Ir al foro Permisos de foro Ver desplegable