AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby CARLOS ATUNCAR » Sun Mar 14, 2021 3:18 am

Saludos,
Necesito leer los datos de un xml de factura electronica e intentado con los ejemplos q he encontrado pero no he logrado en su totalidad
este es el archivo xml
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent><ds:Signature Id="SignatureSP"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>xh/m/3wVPDnhU5JOYAoSnWTOMe0=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>MPY7AcpWsLeQzz59sYwEODkqJA+NQmPAnUMpdi5O1FZMq2wFDF0cv+2bdHqwJtqv1Rb7KiyOocoM7RpKQqH2JdMN1zNfxYx/z4vkw2Ta5Hj78EV5F9eVJhgCFhho2z4w0GmjO1opnUk6W6Uj30yh5OXfKdHsqiojk1F66dCQHXS/iWjnzsTcPx615ltoTItzPnQ7AaENuumc6il+SHro9ju2Izdf780DVXf1QwKOAtaVJwdmpBd1P1WjMBKdgHEdl6pI0pO6p7D+jujz+DC03UlkznGL8z/UC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NoYTIvY2FjbGFzczEuY3JsMDWgM6Axhi9odHRwOi8vY3JsMi5yZW5pZWMuZ29iLnBlL2NybC9zaGEyL2NhY2xhc3MxLmNybDAOBgNVHQ8BAf8EBAMCBsAwEwYDVR0lBAwwCgYIKwYBBQUHAwQwDQYJKoZIhvcNAQELBQADggIBAI8B9mw6tp7VQNxlwD2W/Qa2ct2dWXgxknbq/534qk7yjYL+/4bMrfQImFDT6R1Exb6b4Qsd3/1/1GxIIdwkhRu17gkgKkABkxyP9aPJkfEsaXyDzjf1cgTLGtlyyA9t8cww1f28enMWvSkARavpZijRMh6VQ/7SRd4U3ISiRXyAe/tjOJC5vaqUUGh9sZVcfIBIHB7a89I+OMxkKEO7XDD9JruxRj17onulgV/jG+eHFLM/2OcT97IntNzDSoZsvYajX0/Dbo7dBeGm8vFoo10hfXjTca7HHefW5b2LZnBME+8PcMkWq3/vcpwUObiI2zvu7kN8UrL7eVlw68r1sQjBGgRiqL60eCVvN5qE/I5QnE7HY9ORUZvIStJCUY/czpgWmMUkLp/FlkXNFh67o+bJgrzmCFV7nnn1seHwNG7E4wJb+QWQLMMi0hF1/4EDq5GPG622i9Sodg9IhzY8GPyxvq6bzQWpXHnEGKiP2s55NZ9t0fxgAH5pUiswCjv3gtf5hRCj7IYNDBkS+RqZ+qSEf3w2ZsG3dlWZtJ0FsHaZKrHPsp+wLTuflsT3Rn7pY/BlxtI0VIwhGwnrbclULXugAiGGGYRf3Cg2U8n/YA4HJ97JpT7TgI9+mtw27Oftyryp/v5GKSRZQn+TNM9BJjq/QnpccxOLgOiwFMhRNQDK</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature></ext:ExtensionContent>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>2.0</cbc:CustomizationID>
<cbc:ID>F001-30</cbc:ID>
<cbc:IssueDate>2021-02-18</cbc:IssueDate>
<cbc:IssueTime>00:00:00</cbc:IssueTime>
<cbc:DueDate>2021-02-18</cbc:DueDate>
<cbc:InvoiceTypeCode listID="0101">01</cbc:InvoiceTypeCode>
<cbc:Note languageLocaleID="1000"><![CDATA[TRESCIENTOS OCHENTA CON 20/100 SOLES]]></cbc:Note>
<cbc:DocumentCurrencyCode>PEN</cbc:DocumentCurrencyCode>
<cac:Signature>
<cbc:ID>20606177896</cbc:ID>
<cbc:Note><![CDATA[LAFARYAT II E.I.R.L.]]></cbc:Note>
<cac:SignatoryParty>
<cac:PartyIdentification>
<cbc:ID>20606177896</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name><![CDATA[LAFARYAT II E.I.R.L.]]></cbc:Name>
</cac:PartyName>
</cac:SignatoryParty>
<cac:DigitalSignatureAttachment>
<cac:ExternalReference>
<cbc:URI>#SIGN-EMPRESA</cbc:URI>
</cac:ExternalReference>
</cac:DigitalSignatureAttachment>
</cac:Signature>
<cac:AccountingSupplierParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="6">20606177896</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name><![CDATA[LAFARYAT II E.I.R.L.]]></cbc:Name>
</cac:PartyName>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[LAFARYAT II E.I.R.L.]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cbc:ID>110201</cbc:ID>
<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
<cbc:CitySubdivisionName>NONE</cbc:CitySubdivisionName>
<cbc:CityName>CHINCHA</cbc:CityName>
<cbc:CountrySubentity>ICA</cbc:CountrySubentity>
<cbc:District>CHINCHA ALTA</cbc:District>
<cac:AddressLine>
<cbc:Line><![CDATA[AV. ALVA MAURTUA NRO. 598 OTR. AVENIDA ICA - CHINCHA - CHINCHA ALTA]]></cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>PE</cbc:IdentificationCode>
</cac:Country>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="6">20451640047</cbc:ID>
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[MEDICOS & FISIOTERAPEUTAS FISIOAPAIN E.I.R.L]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cac:AddressLine>
<cbc:Line><![CDATA[CAL.DANIEL OLAECHEA NRO. 260 DPTO. 504 URB. HUASCAR (CRUCE CON AV. INCA RIPAC)]]></cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>PE</cbc:IdentificationCode>
</cac:Country>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">58</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">322.2</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">58</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal></cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="PEN">322.2</cbc:LineExtensionAmount>
<cbc:TaxInclusiveAmount currencyID="PEN">380.2</cbc:TaxInclusiveAmount>
<cbc:PayableAmount currencyID="PEN">380.2</cbc:PayableAmount>
</cac:LegalMonetaryTotal><cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU">5.00</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="PEN">80.51</cbc:LineExtensionAmount>
<cac:PricingReference>
<cac:AlternativeConditionPrice>
<cbc:PriceAmount currencyID="PEN">19.00000</cbc:PriceAmount>
<cbc:PriceTypeCode>01</cbc:PriceTypeCode>
</cac:AlternativeConditionPrice>
</cac:PricingReference>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">14.49</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">80.51</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">14.49</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:Percent>18.00</cbc:Percent>
<cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Description><![CDATA[FLORA BALANCE 2000 MILLONES/5ML SUSP. ORAL CJA X 10 FCOS]]></cbc:Description>
<cac:SellersItemIdentification>
<cbc:ID>00076</cbc:ID>
</cac:SellersItemIdentification>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="PEN">16.10000</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine><cac:InvoiceLine>
<cbc:ID>2</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU">2.00</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="PEN">21.36</cbc:LineExtensionAmount>
<cac:PricingReference>
<cac:AlternativeConditionPrice>
<cbc:PriceAmount currencyID="PEN">12.60000</cbc:PriceAmount>
<cbc:PriceTypeCode>01</cbc:PriceTypeCode>
</cac:AlternativeConditionPrice>
</cac:PricingReference>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">3.84</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">21.36</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">3.84</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:Percent>18.00</cbc:Percent>
<cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Description><![CDATA[LEVOGLOB 500MG CAJAX10 TABLETA RECUBIERTA]]></cbc:Description>
<cac:SellersItemIdentification>
<cbc:ID>00128</cbc:ID>
</cac:SellersItemIdentification>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="PEN">10.68000</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine><cac:InvoiceLine>
<cbc:ID>3</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU">10.00</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="PEN">118.64</cbc:LineExtensionAmount>
<cac:PricingReference>
<cac:AlternativeConditionPrice>
<cbc:PriceAmount currencyID="PEN">14.00000</cbc:PriceAmount>
<cbc:PriceTypeCode>01</cbc:PriceTypeCode>
</cac:AlternativeConditionPrice>
</cac:PricingReference>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">21.36</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">118.64</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">21.36</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:Percent>18.00</cbc:Percent>
<cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Description><![CDATA[AZBACT 500MG CAJAX10 TABLETAS RECUBIERTAS]]></cbc:Description>
<cac:SellersItemIdentification>
<cbc:ID>00129</cbc:ID>
</cac:SellersItemIdentification>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="PEN">11.86000</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine><cac:InvoiceLine>
<cbc:ID>4</cbc:ID>
<cbc:InvoicedQuantity unitCode="NIU">2.00</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="PEN">101.69</cbc:LineExtensionAmount>
<cac:PricingReference>
<cac:AlternativeConditionPrice>
<cbc:PriceAmount currencyID="PEN">60.00000</cbc:PriceAmount>
<cbc:PriceTypeCode>01</cbc:PriceTypeCode>
</cac:AlternativeConditionPrice>
</cac:PricingReference>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="PEN">18.31</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="PEN">101.69</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="PEN">18.31</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:Percent>18.00</cbc:Percent>
<cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:Item>
<cbc:Description><![CDATA[LEVOFLOXACINO 500MG CAJA X 100 TAB RECUBIERTAS]]></cbc:Description>
<cac:SellersItemIdentification>
<cbc:ID>00288</cbc:ID>
</cac:SellersItemIdentification>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="PEN">50.85000</cbc:PriceAmount>
</cac:Price>
</cac:InvoiceLine></Invoice>



Cuando necesito leer el dato del RUC del cliente de esta parte no encuentro como diferenciar ya que <cac:PartyIdentification> se encuenta en 3 partes


<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="6">20451640047</cbc:ID>
</cac:PartyIdentification>
<cac:PartyLegalEntity>
<cbc:RegistrationName><![CDATA[MEDICOS & FISIOTERAPEUTAS FISIOAPAIN E.I.R.L]]></cbc:RegistrationName>
<cac:RegistrationAddress>
<cac:AddressLine>
<cbc:Line><![CDATA[CAL.DANIEL OLAECHEA NRO. 260 DPTO. 504 URB. HUASCAR (CRUCE CON AV. INCA RIPAC)]]></cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>PE</cbc:IdentificationCode>
</cac:Country>
</cac:RegistrationAddress>
</cac:PartyLegalEntity>
</cac:Party>
</cac:AccountingCustomerParty>
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
CARLOS ATUNCAR
 
Posts: 176
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru

Re: AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby jbrita » Wed Mar 17, 2021 3:36 pm

Hola... Prueba asi:

static function revisarnodo()
Local oXMLDoc := TOLEAUTO():New("Microsoft.XMLDOM")
Local lSuccess,oteste,xDestEmit,cXMLDestEmit
oXMLDoc:async := .f.

lSuccess := oXMLDoc:load( "D:\SYSTEMA\BUS\PRG\JOSE.xml" )

xDestEmit := oXMLDoc:getElementsByTagName( "cac:PartyIdentification" )
cXMLDestEmit := xDestEmit:Item(0):xml
msginfo(cXMLDestEmit )

return .t.

saludos
jbrita
 
Posts: 502
Joined: Mon Jan 16, 2006 3:42 pm

Re: AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby hmpaquito » Wed Mar 17, 2021 3:51 pm

Aunque no la he probado, porque uso una de Rafa Carmona, esta clase tiene muy buena pinta y siendo de Cristóbal, el certificado de funcionamiento va implícito

http://fivetechsupport.com/forums/viewt ... 17&t=37597
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby lubin » Fri Mar 19, 2021 2:27 am

Hola Carlos

Por casualidad podrías comentarnos como solucionaste el problema de la lectura del XML, quizas un ejemplo

Me parece que eres de Perú, quizás podemos ver algunos temas por aquí de Sunat

gracias

Lubin
User avatar
lubin
 
Posts: 449
Joined: Fri Dec 09, 2005 12:41 am
Location: Lima, Peru

Re: AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby jacgsoft » Sat Mar 27, 2021 3:08 am

#include 'FiveWin.Ch'

Function Main()
Local _Xml_,Pos_1,_Txt_

_Xml_:='<cac:PartyIdentification>'+ ;
'<cbc:ID>20606177896</cbc:ID>'+ ;
'</cac:PartyIdentification>'

Pos_1:=HB_At('PartyIdentification',_Xml_)
_Txt_:=Subs(_Xml_,Pos_1,60)

Pos_1:=HB_At('ID>',_Txt_)

? 'Ruc -> '+Subs(_Txt_,Pos_1+3,11)



Return(Nil)
User avatar
jacgsoft
 
Posts: 105
Joined: Fri Nov 24, 2006 9:03 pm
Location: Lima - Peru

Re: AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby CARLOS ATUNCAR » Thu Apr 01, 2021 3:34 am

Asi lo solucione para cargar registro de ventas desde lo xlm

Extraigo la informacion con la funcion Extrae()

cFileXml := op:temp+"xml\"+aDir[a][1]
cXml:=MEMOREAD( cFileXml ) && lee xml

tmp->( DbAppend())
tmp->voucher := a
tmp->orden := "1"
tmp->fecha := Extrae("cbc:IssueDate",,.F.,cXml)
tmp->vence := Extrae("cbc:IssueDate",,.F.,cXml)


Static Function Extrae(cProc,cNodo,lNodo,cXml )
Local InicioNodo := "<"+cProc+">"
Local FinalNodo := "</"+cProc+">"
Local nPosIni := At(InicioNodo,cXml)
Local nPosFim := At(FinalNodo,cXml)
Local cRet := '0'
local oXmlDoc,oNode,cText
local xmlNode,cPath

If nPosIni==0 .or. nPosFim==0
Return cRet // aqui que ela aborta... retorna '0'
Endif

If cNodo != NIL
cText := Substr(cXml,nPosIni+Len(InicioNodo),nPosFim-nPosIni-Len(FinalNodo)+1)

nXml := '<?xml version="1.0" encoding="UTF-8"?>'+CRLF
nXml += cText
Else
nXml := cXml
cNodo:= cProc
EndIf

oXmlDoc := TXmlDocument():new( nXml )

IF oXmlDoc:nStatus != HBXML_STATUS_OK
RETURN cRet
ENDIF

oNode := oXmlDoc:findfirst(cNodo)

If oNode != Nil
If lNodo
xmlNode := oXmlDoc:oRoot:oChild

WHILE xmlNode != NIL
cPath := xmlNode:Path()
If xmlNode:nType=5
cRet :=xmlNode:cData
Exit
EndIf
xmlNode := xmlNode:NextInTree()
ENDDO
Else
cRet := oNode:cData
EndIf
Endif

Return(cRet)
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
CARLOS ATUNCAR
 
Posts: 176
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru

Re: AYUDA PARA LEER XML DE FACTURA ELECTRONICA ( SOLUCIONADO )

Postby CARLOS ATUNCAR » Thu Apr 01, 2021 3:37 am

lubin wrote:Hola Carlos

Por casualidad podrías comentarnos como solucionaste el problema de la lectura del XML, quizas un ejemplo

Me parece que eres de Perú, quizás podemos ver algunos temas por aquí de Sunat

gracias

Lubin


claro me puedes contactar por whastapp 956993597
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
CARLOS ATUNCAR
 
Posts: 176
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests