Page 22 of 25

Re: Ro-factura 2024 - discutii

Posted: 13 Aug 2024, 17:44
by gabi123
Revin cu o rezolvare ptr utilizatorii de chilkat , scuze daac e banala dar eu sunt mai nou pe chilkat
Adica am cautat un removeprefix si se pare ca nu exista , si pana la urma vad ca merge cu banala * , in toate situatiile
...GetChildContent("*:AccountingSupplierParty|*:Party|*:PartyLegalEntity|*:CompanyID")

Re: Ro-factura 2024 - discutii

Posted: 15 Aug 2024, 02:47
by mgabi
@sasort

Cva de genul acesta am si eu, doar ca nu ma leg de acele "urn:oasis:name..... pentru ca nu ma incurca deocamdata.
Trebuie insa sa modific procedura acum si sa o completez si cu acele cifre (incrementate).

Munca inutila si timp pierdut aiurea pentru ca un standard nu este standard!
Cand "produci" un standard general valabil, care sa fie folosit pentru interconectarea multor sisteme diferite trebuie sa ai reguli clare.

Re: Ro-factura 2024 - discutii

Posted: 15 Aug 2024, 12:22
by mrapi
cel mai bine merge cand xml ul este curatat de toate acele prefixuri,apoi citirea o fac cu aceasta metoda: viewtopic.php?p=1637#p1637

Re: Ro-factura 2024 - discutii

Posted: 16 Aug 2024, 09:20
by nicu
-eliminare prefix din xml; poate va ajuta:

**********************************************************************************************
Function CleanXMLPrefix( tcXmlString )

Create Cursor All_prefix_from_xml ( Prefix c(20), TextSupl c(254), Sirtag M )
lcXmlString = tcXmlString
cContorPrefixTag = Occurs( '<', lcXmlString )

For a = 1 to cContorPrefixTag

cSirTag = StrExtract( lcXmlString, '<', '>', a)
*<wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">125022</wstxns102:ItemClassificationCode>
* wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"

If Left(Allt(cSirTag), 1) <> "/" &&& </wstxns102:ItemClassificationCode> elimin tagul de inchidere, preiau doar tagul de inceput fiind complet
cPrefix = StrExtract( cSirTag, '', ":") &&& wstxns102
cTextSupl = ""

* wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
For Parte = 1 To Occurs( '"', cSirTag)
*
afluSir = StrExtract( cSirTag, '"', '"', parte )
*
If Occurs( ':', afluSir)>=2 &&& "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
nPozitieInceput = Atc( afluSir, cSirTag ) - 1
cSirPinaLaTextSupl = SubStr( cSirTag, 1, nPozitieInceput ) &&& wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102=
nSpatii = Occurs( ' ', cSirPinaLaTextSupl ) &&& spatii in sir
cTextSupl = StrExtract( cSirTag, ' ', '"', nSpatii) + '"'+afluSir+'"' &&& xmlns:wstxns102=
Exit
EndIf
*
EndFor
*
If Len(AllTrim(cPrefix))>0 AND Occurs( ' ', AllTrim(cPrefix) )=0
Select * From All_prefix_from_xml Where Prefix=cPrefix And TextSupl=cTextSupl Into Cursor Exista_prefix
If Reccount('Exista_prefix')=0
Insert Into All_prefix_from_xml ( Prefix , TextSupl , Sirtag );
Values ( cPrefix, cTextSupl, cSirTag )
EndIf
EndIf
EndIf
EndFor

Select All_prefix_from_xml
Scan
lcXmlString = StrTran( lcXmlString, AllTrim(All_prefix_from_xml.prefix)+":" , '')
If Len(AllTrim(All_prefix_from_xml.TextSupl))>0
lcXmlString = StrTran( lcXmlString, " "+AllTrim(All_prefix_from_xml.TextSupl), '')
EndIf
EndScan
*
Return lcXmlString
EndProc

Re: Ro-factura 2024 - discutii

Posted: 16 Aug 2024, 14:43
by nicu
- procedure de sus elimina tot ( si cele indexate - "wstxns102:" si cele gen "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" )

Re: Ro-factura 2024 - discutii

Posted: 20 Aug 2024, 08:47
by vicos
Alta varianta:

Function RemoveNamespaces
LParameters lcXML
Local loXml, loNewXML, loRoot, loNode, loNodes, lcResult, lcRootName

loXml = CreateObject("MSXML2.DOMDocument.6.0")
loXml.LoadXML(lcXML)
loXml.setProperty("SelectionLanguage", "XPath")

loNewXML = CreateObject("MSXML2.DOMDocument.6.0")
loNewXML.preserveWhiteSpace = .F.
loNewXML.AppendChild(loNewXML.createProcessingInstruction("xml", 'version="1.0"'))

* Get the root element name without namespace
lcRootName = IIf(At(":", loXml.documentElement.NodeName) > 0, SubStr(loXml.documentElement.NodeName, At(":", loXml.documentElement.NodeName) + 1), loXml.documentElement.NodeName)

* Create a new root element with the same name
loRoot = loNewXML.CreateElement(lcRootName)
loNewXML.AppendChild(loRoot)

* Copy nodes without namespaces
loNodes = loXml.documentElement.ChildNodes
For Each loNode In loNodes
AddNodeWithoutNamespace(loRoot, loNode)
EndFor

*loNewXML.formatting = 1 && Enable pretty print
*lcResult = loNewXML.XML

If Not File("prettyprint.xslt")
Text To lcSQL NoShow TextMerge
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="4"/>
<!--Important! Remove existing whitespace in DOM elements.-->
<xsl:strip-space elements="*"/>
<!--Identity transformation (see http://www.w3.org/TR/xslt#copying).-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
EndText
EndIf
* Apply XSLT for pretty print
loXSLT = CREATEOBJECT("MSXML2.FreeThreadedDOMDocument.6.0")
loXSLT.async = .F.
loXSLT.load("prettyprint.xslt")

loTransformedXML = CREATEOBJECT("MSXML2.DOMDocument.6.0")
loNewXML.transformNodeToObject(loXSLT, loTransformedXML)

lcResult = loTransformedXML.XML
Return lcResult
EndFunc
* __________________________________________________________________________________________________________
Procedure AddNodeWithoutNamespace
LParameters loParent, loNode
Local loNewNode, loChildNode, lcNodeName

If loNode.NodeType = 1 && Element node
* Remove prefix from node name
lcNodeName = IIf(At(":", loNode.NodeName) > 0, SubStr(loNode.NodeName, At(":", loNode.NodeName) + 1), loNode.NodeName)
loNewNode = loParent.ownerDocument.CreateNode(1, lcNodeName, "")
loParent.AppendChild(loNewNode)

For Each loChildNode In loNode.ChildNodes
AddNodeWithoutNamespace(loNewNode, loChildNode)
EndFor
Else
If loNode.NodeType = 3 && Text node
loNewNode = loParent.ownerDocument.createTextNode(loNode.nodeValue)
loParent.AppendChild(loNewNode)
EndIf
EndIf
EndProc
* __________________________________________________________________________________________________________

Re: Ro-factura 2024 - discutii

Posted: 20 Aug 2024, 14:33
by Liviut
Salutare ,
Validatorul de pe ANAF merge si pentru CreditNote ? Mie mi-a dat erori

Re: Ro-factura 2024 - discutii

Posted: 20 Aug 2024, 16:51
by mrapi
salut
posibil sa se fi scos,nu mai exista nici la BT-3 in aplicatia anaf https://www.anaf.ro/CompletareFactura/f ... rale.xhtml

Re: Ro-factura 2024 - discutii

Posted: 20 Aug 2024, 18:28
by blumache
Liviut wrote: 20 Aug 2024, 14:33 Salutare ,
Validatorul de pe ANAF merge si pentru CreditNote ? Mie mi-a dat erori
Se selecteaza FCN, identic ca la validarea din API

Re: Ro-factura 2024 - discutii

Posted: 04 Sep 2024, 18:56
by mgabi
Am reusit sa-mi fac timp pentru o functie generala care elimina ORICE prefix (cbc: , ns1: , xxx156: etc).
Mai bine mai tarziu decat niciodata ...

Code: Select all

FUNCTION delprefixtag
PARAMETERS lctextxmlfct
***mg:   sterge TOATE prefixurile din XML ...  de ex. cbc: , ns1: , wstxns100:  caut prefixurile de genul  </wstxns14:CompanyID>
xtextfct=ALLTRIM(lctextxmlfct)
xnrelem=OCCURS('</',xtextfct)                     && toate "inchiderile" de tag  </...>  , de aici iau prefixul, este mai sigur asa.
FOR ii=1 TO xnrelem
	xtag=STREXTRACT(xtextfct,'</','>',ii,1)
	xtag=GETWORDNUM(xtag,1,' ')                 && iau primul cuvant ... asta n-ar trebui, este doar de siguranta
	IF ':'$xtag                                               && daca am cbc: sau xxx715:  sau ubl: .... etc
		xprefix=STREXTRACT(xtag,'',':',1) + ':'             && prefixul pe care urmeaza sa-l sterg  ... de ex   cbc:   sau xx256:
		xtextfct=STRTRAN(xtextfct,'<'+xprefix,'<')
		xtextfct=STRTRAN(xtextfct,'</'+xprefix,'</')
	ENDIF
ENDFOR 
RETURN xtextfct
Procedura este simpla, strict pentru interpretare fact, cu urmatoare observatii:
- Elementele goale <element/> nu m-au interesat, pt. ca nu am ce valori sa iau din ele
- urn:oasis: .... nu m-au interesat