Ro-factura 2024 - discutii

::e-Factura, conectare SPV
Forum rules
:: limbajul folosit in acest forum va fi unul civilizat, in limita subiectelor din topicurile deschise.
:: orice manifestare necivilizata (agresiune verbala, comportament neadecvat, reclama abuziva fara legatura cu forumul) va duce la stergerea contului de user.
:: pt. inscriere USER NOU la acest FORUM, folositi linkul https://profox.ro/forum-register/
mrapi
Posts: 344
Joined: 20 May 2022, 16:53

Re: Ro-factura 2024 - discutii

Post by mrapi »

ai linkul catre comentariul fb https://www.facebook.com/groups/3239944 ... tid=zDhOQc
radubalanpro wrote: 10 Apr 2024, 00:23 Din pacate nu gasesc detalierea pe FB, ma poti ajuta te rog ? Am o multime de tokene in cloud de la transped. Ms.
gabi123
Posts: 147
Joined: 28 Jun 2022, 20:56

Re: Ro-factura 2024 - discutii

Post by gabi123 »

La Efacturile primite incep sa apara o sumedenie de prefixuri: cac, cbc, n0..., ns0.... ,
sau taguri de genul:
<ns1:ID xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">VAT</ns1:ID>
sau
<ID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">VAT</ID>
Aveti vre-o idee de stergere rapida a acestor prefixuri in afara de a folosi strtran() pentru fiecare caz in parte ?
User avatar
admin
Posts: 99
Joined: 16 Jun 2022, 17:03

Re: Ro-factura 2024 - discutii

Post by admin »

nope.. nu exista.. fiecare programator a facut cum l-a taiat capul... si asta doar din vina ANAF care nu a impus anumite reguli foarte clare pt e-factura...

Personal am implementat o functie de curatare a xml-ului primit care merge pt toate pana acum :) :
*****************
PARAMETERS curattext
IF ATC('<![CDATA[',curattext)>0
**curata taguri inutile
curattext=STRTRAN(curattext,'<![CDATA[','')
curattext=STRTRAN(curattext,']]>','')
ENDIF
**alte texte inutile sau din alt sistem
cScama=' xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"'
curattext=STRTRAN(curattext,cScama,'')
**
cScama=' xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"'
curattext=STRTRAN(curattext,cScama,'')
**
cScama=' xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
curattext=STRTRAN(curattext,cScama,'')
**
cScama=' xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
curattext=STRTRAN(curattext,cScama,'')
**
curattext=STRTRAN(curattext,'<ns2:','<cbc:')
curattext=STRTRAN(curattext,'</ns2:','</cbc:')
**
curattext=STRTRAN(curattext,'<ns3:','<cac:')
curattext=STRTRAN(curattext,'</ns3:','</cac:')
**
curattext=STRTRAN(curattext,'../../','')
***
RETURN curattext

*******************************
In plus , pt. ca multi baga in linia tagului si alte scheme , la interpretare iau linia respectiva si apoi din linie iau doar datele necesare sarind peste eventualele definitii aberate ale unor programatori (bagate la fiecare linie !!!).

Exemplu de preluare data emitere sarind peste definitiile aberante inserate:
**initial iau linia cu tot cu definitiile aberante de tipul urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
xliniex=STREXTRACT(xcontinut,'<cbc:IssueDate','</cbc:IssueDate',1,4)

**apoi iau doar datele dintre tagurile > si <
xdata=STREXTRACT(xliniex,'>','</cbc:IssueDate',1)
xdata=ALLTRIM(STRTRAN(xdata,'-',''))
xdata=CTOD(RIGHT(xdata,2)+'/'+RIGHT(LEFT(xdata,6),2)+'/'+LEFT(xdata,4))

Sper sa te ajute :)
gabi123 wrote: 09 Aug 2024, 10:22 La Efacturile primite incep sa apara o sumedenie de prefixuri: cac, cbc, n0..., ns0.... ,
sau taguri de genul:
<ns1:ID xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">VAT</ns1:ID>
sau
<ID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">VAT</ID>
Aveti vre-o idee de stergere rapida a acestor prefixuri in afara de a folosi strtran() pentru fiecare caz in parte ?
mrapi
Posts: 344
Joined: 20 May 2022, 16:53

Re: Ro-factura 2024 - discutii

Post by mrapi »

la capitolul asta,locul fruntas il detine o factura de la IKEA,daca in mod normal sunt 2 astia le si indexeaza,am 110 pe o factura cu 6 linii:

Code: Select all

<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
	<wstxns1:UBLVersionID xmlns:wstxns1="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2.1</wstxns1:UBLVersionID>
	<wstxns2:CustomizationID xmlns:wstxns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1</wstxns2:CustomizationID>
	<wstxns3:ID xmlns:wstxns3="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">IKEA2400000....</wstxns3:ID>
	<wstxns4:IssueDate xmlns:wstxns4="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2024-07-06</wstxns4:IssueDate>
	<wstxns5:InvoiceTypeCode xmlns:wstxns5="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">380</wstxns5:InvoiceTypeCode>
	<wstxns6:DocumentCurrencyCode xmlns:wstxns6="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">RON</wstxns6:DocumentCurrencyCode>
	<wstxns7:AccountingSupplierParty xmlns:wstxns7="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
		<wstxns7:Party>
			<wstxns7:PartyName>
				<wstxns8:Name xmlns:wstxns8="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">IKEA...</wstxns8:Name>
			</wstxns7:PartyName>
			<wstxns7:PostalAddress>
				<wstxns9:StreetName xmlns:wstxns9="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">Soseaua Bucure....</wstxns9:StreetName>
				<wstxns10:CityName xmlns:wstxns10="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">SECTOR1</wstxns10:CityName>
				<wstxns11:PostalZone xmlns:wstxns11="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">0136..</wstxns11:PostalZone>
				<wstxns12:CountrySubentity xmlns:wstxns12="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">RO-B</wstxns12:CountrySubentity>
				<wstxns7:Country>
					<wstxns13:IdentificationCode xmlns:wstxns13="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">RO</wstxns13:IdentificationCode>
				</wstxns7:Country>
			</wstxns7:PostalAddress>
			<wstxns7:PartyTaxScheme>
				<wstxns14:CompanyID xmlns:wstxns14="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">RO17....</wstxns14:CompanyID>
				<wstxns7:TaxScheme>
					<wstxns15:ID xmlns:wstxns15="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">VAT</wstxns15:ID>
				</wstxns7:TaxScheme>
			</wstxns7:PartyTaxScheme>
			<wstxns7:PartyLegalEntity>
				<wstxns16:RegistrationName xmlns:wstxns16="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">IKEA .....</wstxns16:RegistrationName>
				<wstxns17:CompanyID xmlns:wstxns17="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">RO1754...</wstxns17:CompanyID>
			</wstxns7:PartyLegalEntity>
		</wstxns7:Party>
	</wstxns7:AccountingSupplierParty>
	<wstxns18:AccountingCustomerParty xmlns:wstxns18="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
		<wstxns18:Party>
			<wstxns18:PartyName>
				<wstxns19:Name xmlns:wstxns19="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">..... S.R.L.</wstxns19:Name>
			</wstxns18:PartyName>
			<wstxns18:PostalAddress>
.........................................

			<wstxns100:InvoiceLine xmlns:wstxns100="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
		<wstxns101:ID xmlns:wstxns101="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">6</wstxns101:ID>
		<wstxns102:InvoicedQuantity xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" unitCode="EA">1</wstxns102:InvoicedQuantity>
		<wstxns103:LineExtensionAmount xmlns:wstxns103="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" currencyID="RON">...</wstxns103:LineExtensionAmount>
		<wstxns100:Item>
			<wstxns104:Name xmlns:wstxns104="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">...</wstxns104:Name>
			<wstxns100:SellersItemIdentification>
				<wstxns105:ID xmlns:wstxns105="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2051...</wstxns105:ID>
			</wstxns100:SellersItemIdentification>
			<wstxns100:ClassifiedTaxCategory>
				<wstxns106:ID xmlns:wstxns106="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">S</wstxns106:ID>
				<wstxns107:Percent xmlns:wstxns107="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">19.00</wstxns107:Percent>
				<wstxns100:TaxScheme>
					<wstxns108:ID xmlns:wstxns108="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">VAT</wstxns108:ID>
				</wstxns100:TaxScheme>
			</wstxns100:ClassifiedTaxCategory>
		</wstxns100:Item>
		<wstxns100:Price>
			<wstxns109:PriceAmount xmlns:wstxns109="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" currencyID="RON">...</wstxns109:PriceAmount>
			<wstxns110:BaseQuantity xmlns:wstxns110="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" unitCode="EA">1</wstxns110:BaseQuantity>
		</wstxns100:Price>
	</wstxns100:InvoiceLine>
</Invoice>

Last edited by mrapi on 11 Aug 2024, 19:25, edited 1 time in total.
mgabi
Posts: 394
Joined: 23 May 2022, 21:15

Re: Ro-factura 2024 - discutii

Post by mgabi »

Pe asta n-o vazusem pana acum!
Am muncit degeaba!!! Trebuie sa refact toata procedura de interpretare XML !!!
:shock:
mrapi
Posts: 344
Joined: 20 May 2022, 16:53

Re: Ro-factura 2024 - discutii

Post by mrapi »

poate nu ai muncit geaba,cred ca toti ne am facut o lista cu ce eliminam,in cazul de mai sus,incepi de la sfarsitul fisierului si cauti primul tag care se deschide,acela contine indexul maxim,de la 1 la max,adaugi in lista neagra ...
mgabi
Posts: 394
Joined: 23 May 2022, 21:15

Re: Ro-factura 2024 - discutii

Post by mgabi »

Eu am incercat sa fac o procedura general valabila, fara liste negre ... o iau de la capat!
User avatar
admin
Posts: 99
Joined: 16 Jun 2022, 17:03

Re: Ro-factura 2024 - discutii

Post by admin »

mgabi wrote: 11 Aug 2024, 23:12 Eu am incercat sa fac o procedura general valabila, fara liste negre ... o iau de la capat!
incearca aceasta functie... este generala si a acoperit pana acum cam tot.. este mai complexa decat cea postata anterior de mine :)
am testat-o inclusiv cu facturile de la ikea... :)
poate o mai ajustezi tu cu alte cazuri si revii cu o functie mai complexa


Parameters curattext
**sterg aberatii
If Atc('<![CDATA[',curattext)>0
**curata taguri inutile
curattext=Strtran(curattext,'<![CDATA[','')
curattext=Strtran(curattext,']]>','')
Endif
**
curattext=Strtran(curattext,'../../','')

If Atc('<cac:',curattext)=0 Or Atc('<cbc:',curattext)=0
***CURAT TAGURI HAOTICE
tagcbc=''
tagcac=''
**identific tag cbc haotice
If Atc(':IssueDate ',curattext)>0
**am scheme redefinite la fiecare linie
poztag=Atc(':IssueDate ',curattext)
sirtag=Substr(curattext,poztag-15,15)
If !Empty(sirtag)
For ttt=0 To 14
If Substr(sirtag,15-ttt,1)='<'
sirtag2=Right(sirtag,ttt+1)
tagcbc=Alltrim(Strtran(sirtag2,'<',''))
Endif
Endfor
Endif
Else
**nu am scheme adaugate pe linie
If Atc(':IssueDate>',curattext)>0
poztag=Atc(':IssueDate>',curattext)
sirtag=Substr(curattext,poztag-15,15)
If !Empty(sirtag)
For ttt=0 To 14
If Substr(sirtag,15-ttt,1)='<'
sirtag2=Right(sirtag,ttt+1)
tagcbc=Alltrim(Strtran(sirtag2,'<',''))
Endif
Endfor
Endif
Endif
Endif

**identific tag cac haotice
If Atc(':AccountingSupplierParty ',curattext)>0
**am scheme redefinite la fiecare linie
poztag=Atc(':AccountingSupplierParty ',curattext)
sirtag=Substr(curattext,poztag-15,15)
If !Empty(sirtag)
For ttt=0 To 14
If Substr(sirtag,15-ttt,1)='<'
sirtag2=Right(sirtag,ttt+1)
tagcac=Alltrim(Strtran(sirtag2,'<',''))
Endif
Endfor
Endif
Else
**nu am scheme adaugate pe linie
If Atc(':AccountingSupplierParty ',curattext)>0
poztag=Atc(':AccountingSupplierParty>',curattext)
sirtag=Substr(curattext,poztag-15,15)
If !Empty(sirtag)
For ttt=0 To 14
If Substr(sirtag,15-ttt,1)='<'
sirtag2=Right(sirtag,ttt+1)
tagcac=Alltrim(Strtran(sirtag2,'<',''))
Endif
Endfor
Endif
Endif
Endif
***elimina cifre din taguri haotice
tagcac=Alltrim(extragex(Strtran(tagcac,' ','')))
tagcbc=Alltrim(extragex(Strtran(tagcbc,' ','')))

**inlocuiesc n taguri cbc si cac
If !Empty(tagcac) And !Empty(tagcbc)
**AND (ALLTRIM(tagcac)<>'cac' or ALLTRIM(tagcbc)<>'cbc'
If tagcac<>tagcbc
**schimb tag cac
For ttt=1000 To 0 Step -1
cecurat='<'+Alltrim(tagcac)+Alltrim(Str(ttt))
cecurat2='xmlns:'+Alltrim(tagcac)+Alltrim(Str(ttt))
curattext=Strtran(curattext,cecurat2,'')
curattext=Strtran(curattext,cecurat,'<cac')
cecurat='</'+Alltrim(tagcac)+Alltrim(Str(ttt))
curattext=Strtran(curattext,cecurat,'</cac')

Endfor
cecurat='</'+Alltrim(tagcac)
curattext=Strtran(curattext,cecurat,'</cac')
***gata cac

**schimb tag cbc
For ttt=1000 To 0 Step -1
cecurat='<'+Alltrim(tagcbc)+Alltrim(Str(ttt))
cecurat2='xmlns:'+Alltrim(tagcbc)+Alltrim(Str(ttt))
curattext=Strtran(curattext,cecurat2,'')
curattext=Strtran(curattext,cecurat,'<cbc')
cecurat='</'+Alltrim(tagcbc)+Alltrim(Str(ttt))
curattext=Strtran(curattext,cecurat,'</cbc')
Endfor
cecurat='</'+Alltrim(tagcbc)
curattext=Strtran(curattext,cecurat,'</cbc')
***gata cbc
Else
**schimb tag cac
For ttt=1000 To 0 Step -1
cecurat='<'+Alltrim(tagcac)+Alltrim(Str(ttt))
cecurat2='xmlns:'+Alltrim(tagcac)+Alltrim(Str(ttt))
curattext=Strtran(curattext,cecurat2,'')
curattext=Strtran(curattext,cecurat,'<cac')
cecurat='</'+Alltrim(tagcac)+Alltrim(Str(ttt))
curattext=Strtran(curattext,cecurat,'</cac')
Endfor
cecurat='</'+Alltrim(tagcac)
curattext=Strtran(curattext,cecurat,'</cac')
***gata cac
Endif
Endif
***

***sterg scheme haotice
**alte texte inutile sau din alt sistem
cScama='="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"'
curattext=Strtran(curattext,cScama,'')
cScama='="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
curattext=Strtran(curattext,cScama,'')
***

Else
**CAZ NORMAL CAC SI CBC
**alte texte inutile sau din alt sistem
cScama=' xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"'
curattext=Strtran(curattext,cScama,'')
**
cScama=' xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"'
curattext=Strtran(curattext,cScama,'')
**
cScama=' xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
curattext=Strtran(curattext,cScama,'')
**
cScama=' xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
curattext=Strtran(curattext,cScama,'')
Endif

**daca se doreste eliminarea totala a markerilor de tag cac si cbc se lanseaza si liniile urmatoare
curattext=Strtran(curattext,'cac:','')
curattext=Strtran(curattext,'cbc:','')

Return curattext
********

functia extragex elimina toate cifrele din text si este de forma:
*********************************************************************************
procedure extragex
PARAMETERS CEEXTRAG
CEEXTRAG=ALLTRIM(CEEXTRAG)
QQ=LEN(CEEXTRAG)
AMEXTRAS=''
FOR WW=1 TO QQ
CELIT=SUBSTR(CEEXTRAG,WW,1)
IF ATC(CELIT,'0123456789')=0
AMEXTRAS=AMEXTRAS+CELIT
ENDIF
ENDFOR
RETURN AMEXTRAS
******************

vezi daca se rezolva pt cazurile tale de facturi
nicu
Posts: 256
Joined: 23 May 2022, 13:18

Re: Ro-factura 2024 - discutii

Post by nicu »

@mrapi
- daca poti , posteaza factura in intregime ( modifica datele sensibile: cumparator, nr factura, data si cam atat... )
mrapi
Posts: 344
Joined: 20 May 2022, 16:53

Re: Ro-factura 2024 - discutii

Post by mrapi »

https://zippyshare.day/jb2MjE0bGSW5vom/file
nicu wrote: 12 Aug 2024, 22:22 @mrapi
- daca poti , posteaza factura in intregime ( modifica datele sensibile: cumparator, nr factura, data si cam atat... )
Post Reply