|
QR code
May 24, 2019 15:56:46 GMT -5
Post by tenochtitlanuk on May 24, 2019 15:56:46 GMT -5
Try this- it adds a jump to the start of your data region. Also slightly altered the number-formatting for neater print out. And increased number of data pairs to up to 20 rather than 10.
' <cbc:PriceAmount currencyID="EUR">16.98</cbc:PriceAmount> to get the price. ' I have to replace the "."for a "," otherwise I get an error in the financial software ' data_text, data_QR, price_text, price_QR.
'I don't have it working yet. I don't get all the invoice lines.
'I need all the <cbc:Name> and <cbc:PriceAmount currencyID="EUR"> data between ' the <cac:InvoiceLine> and </cac:InvoiceLine>
'In this example are 13 items off <cbc:Name>. 'But the tricky is in the begin off the file is <cbc:Name> also used ' for the name off the person for who the invoice is send. 'But that is not needed. Needed are the invoice lines.
start0$ ="<cac:InvoiceLine>": len2S =len( start0$) ' only between these.. finish0$ ="</cac:InvoiceLine>": len2F =len( finish0$)
start1$ ="<cbc:Name>": len1S =len( start1$) ' data type- name finish1$ ="</cbc:Name>": len1F =len( finish1$)
start2$ ="EUR" +chr$( 34) +">": len2S =len( start2$) ' data type- price finish2$ ="</cbc:PriceAmount>": len2F =len( finish2$)
open "jack.xml" for input as #fIn file$ =input$( #fIn, lof( #fIn)) close #fIn
pointer =1 i =0 ' array starts at term 0, so add one when printing later
dim data1$( 100), data2$( 100)
start =instr( file$, start0$) pointer =start finish =instr( file$, finish0$)
while not( pointer >=len( file$)) and i <20 ' <<<<<<<<<<<<<<<<<<< was 10 startOfItem1 =instr( file$, start1$, pointer) +len1S
if ( pointer =0) then exit while endOfItem1 =instr( file$, finish1$, pointer) data1$( i) =mid$( file$, startOfItem1, endOfItem1 -startOfItem1)
startOfItem2 =instr( file$, start2$, endOfItem1) +len2S endOfItem2 =instr( file$, finish2$, startOfItem2) data2$( i) =mid$( file$, startOfItem2, endOfItem2 -startOfItem2)
print "Item "; i +1 , data1$( i); tab( 70); decToComma$( data2$( i)) i =i +1 pointer =instr( file$, start2$, endOfItem2)
scan wend
end
function decToComma$( a$) for j =1 to len( a$) c$ =mid$( a$, j, 1) if c$ ="." then decToComma$ =decToComma$ +"," else decToComma$ =decToComma$ +c$ end if next j if instr( "0123456789", left$( decToComma$, 1)) then decToComma$ ="+" +decToComma$ decToComma$ =right$( " " +decToComma$, 8) end function
which produced ( but forum messes up the formatting!)
|
|
konijn
Junior Member
Posts: 96
|
QR code
May 26, 2019 10:57:46 GMT -5
Post by konijn on May 26, 2019 10:57:46 GMT -5
Thanks John,
I have the lines now. I have to set it up to 30. I had a invoice with 25 lines. But thats no problem? if you have 3 lines or 25 lines?
Now I am a bit struggling with how to send the data to google qr maker and make a list as you had in the begin. If the size of the QR code is 80x 80 its no problem for the scanner. I don't know if the invoice is longer then ... lines LB will print 2 pages?
This code I was trying:
start0$ ="<cac:InvoiceLine>": len2S =len( start0$) ' only between these.. finish0$ ="</cac:InvoiceLine>": len2F =len( finish0$)
start1$ ="<cbc:Name>": len1S =len( start1$) ' data type- name finish1$ ="</cbc:Name>": len1F =len( finish1$)
start2$ ="EUR" +chr$( 34) +">": len2S =len( start2$) ' data type- price finish2$ ="</cbc:PriceAmount>": len2F =len( finish2$)
open "jack.xml" for input as #fIn 'open "c:\snelstart\ubl\82994.xml" for input as #fIn file$ =input$( #fIn, lof( #fIn)) close #fIn
pointer =1 i =0 ' array starts at term 0, so add one when printing later
dim data1$( 100), data2$( 100)
start =instr( file$, start0$) pointer =start finish =instr( file$, finish0$)
while not( pointer >=len( file$)) and i <30 ' <<<<<<<<<<<<<<<<<<< was 10 startOfItem1 =instr( file$, start1$, pointer) +len1S
if ( pointer =0) then exit while endOfItem1 =instr( file$, finish1$, pointer) data1$( i) =mid$( file$, startOfItem1, endOfItem1 -startOfItem1)
startOfItem2 =instr( file$, start2$, endOfItem1) +len2S endOfItem2 =instr( file$, finish2$, startOfItem2) data2$( i) =mid$( file$, startOfItem2, endOfItem2 -startOfItem2)
print "Item "; i +1 , data1$( i); tab( 70); decToComma$( data2$( i)) i =i +1 pointer =instr( file$, start2$, endOfItem2)
scan wend
[print] for j = 0 to i -1 print data1$( j) print data2$( j) http$ ="http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl=" +data1$( j) http$ ="http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl=" +decToComma$( data2$( i)) result = DownloadToFile( http$, "QR" +str$( j) +".png") result = DownloadToFile( http$, "QR1" +str$( j) +".png") timer 2000, [o1] ' wait 2 seconds for code to be sent back wait [o1] timer 0
' call IM to convert png to 24 bit bmp ' load chosen image; remove transparency; resize; save temporarily as bmp. ' Note if your directory or file names include spaces you have to add the quote here.. ' ie put chr$( 34) either side of the file/pathname. ' trucolor to force 24 bit. Resize if you want- here not needed.
IM$ ="convert +matte -resize 150x150 -type truecolor " +chr$( 34) +"QR" +str$( j) +".png" +chr$( 34) +" temp.bmp " print IM$ ' use when debugging!!
run "cmd.exe /c "; chr$( 34); IM$; chr$( 34), HIDE ' Give it 2 seconds to execute ( may not be enough for large images) timer 2000, [o2] wait [o2] timer 0
loadbmp "imx", "temp.bmp" kill "temp.bmp" kill "QR" +str$( j) +".png"
#1 "up ; goto 20 "; j *150 +50 #1 "down" #1 "\"; data$( j) #1 "drawbmp imx 300 "; j *150 next j
#1 "flush ; print 800"
close #1 end
sub quit h$ close #h$ end end sub
Function DownloadToFile( urlfile$, localfile$) open "URLmon" for dll as #url calldll #url, "URLDownloadToFileA",_ 0 as long,_ ' null urlfile$ as ptr,_ ' url to download localfile$ as ptr,_ ' save file name 0 as long,_ ' reserved, must be 0 0 as long,_ ' callback address, can be 0 DownloadToFile as ulong ' 0 =success close #url end function
function decToComma$( a$) for j =1 to len( a$) c$ =mid$( a$, j, 1) if c$ ="." then decToComma$ =decToComma$ +"," else decToComma$ =decToComma$ +c$ end if next j if instr( "0123456789", left$( decToComma$, 1)) then decToComma$ ="" +decToComma$ decToComma$ =right$( " " +decToComma$, 8) end function
|
|
|
QR code
May 28, 2019 17:26:10 GMT -5
Post by tenochtitlanuk on May 28, 2019 17:26:10 GMT -5
Currently rather distracted by gathering family for a wedding in Scotland... The following code shows how to print successive sets of data to a page, and print it/ start a new one when you hit bottom. It prints to your default printer. I have this set to 'print to pdf' normally so don't waste lots of paper printing things like this! As provided it invents random strings for the data1 and 2 strings, and uses the same QR code each time. You'd be indexing through real ones. I'll try to add the ability to load the png files in LB4 since LB5 is not yet ready for full use. It's straightforward to load png directly in LB4 without needing to call ImageMagick. Unlikely to have time available for about ten days tho'. nomainwin
WindowWidth =800 ' page sides in ratio root 2 to 1 WindowHeight =800 *1.42 '
open "Report printing window" for graphics_nsb as #wg
#wg "trapclose quit" #wg "font 10"
dim data1$( 50), data2$( 50)
for i =0 to 19 data1$( i) =right$( "___" +str$( i), 3) +" Data 1 " +Chars$( 20, "U") data2$( i) ="Data 2 " +Chars$( 30, "L") next i
entriesPerPage =6
for i =0 to 19 y =60 +( i mod entriesPerPage) *160 call textDisplay data1$( i), 10, y call textDisplay data2$( i), 110, y +40 call imageDisplay "QR1.bmp", 610, y -50 ' print page after every 8 rows of data if ( i mod entriesPerPage) =entriesPerPage -1 then call printPage calldll #kernel32, "Sleep", 1000 as ulong, sleep as void next i
if ( i mod entriesPerPage) <entriesPerPage then call printPage
notice "Completed"
close #wg
wait
sub printPage #wg "flush" #wg "print 800" #wg "cls" calldll #kernel32, "Sleep", 1000 as ulong, sleep as void end sub
sub textDisplay t$, xpos, ypos #wg "up ; goto "; xpos; " "; ypos #wg "down" #wg "\"; t$ end sub
sub imageDisplay im$, xpos, ypos #wg "up ; goto "; xpos; " "; y loadbmp "scr", "QR1.bmp" #wg "down ; drawbmp scr "; xpos; " "; ypos end sub
sub quit h$ close #wg end end sub
function Chars$( n, case$) for k =1 to n if case$ ="U" then Chars$ =Chars$ +chr$( 65 +int( 26 *rnd( 1))) else Chars$ =Chars$ +chr$( 97 +int( 26 *rnd( 1))) end if next k end function
EDIT Forgot to print a final partially-filled page. Corrected.
|
|
konijn
Junior Member
Posts: 96
|
QR code
Jun 8, 2019 11:36:02 GMT -5
Post by konijn on Jun 8, 2019 11:36:02 GMT -5
Hello tenochtitlanuk Thanks!! Sorry for the late reaction, familly, hospital.... That look good. Special now it prints on paper the right way. I have to build it in the code below what I has changed. I print now two qr codes next to each other. Invoiceline and price. I have to make some more. Print the name of the company on top off the paper and make the qr code like this. companyname/invoiceline For example: tenochtitlanuk/softwareservice But companyname should not to be to long. Like this: teno/softwareservice I hope I can figure it out Jack
WindowWidth =800 WindowHeight =800 UpperLeftX = 10 UpperLeftY = 10
input "naam:"; voor$
open "Create and print QR and text" for graphics_nsb as #1
#1 "trapclose quit"
start0$ ="<cac:InvoiceLine>": len2S =len( start0$) ' only between these.. finish0$ ="</cac:InvoiceLine>": len2F =len( finish0$)
start1$ ="<cbc:Name>": len1S =len( start1$) ' data type- name finish1$ ="</cbc:Name>": len1F =len( finish1$)
start2$ ="EUR" +chr$( 34) +">": len2S =len( start2$) ' data type- price finish2$ ="</cbc:PriceAmount>": len2F =len( finish2$)
open "c:\over.xml" for input as #fIn file$ =input$( #fIn, lof( #fIn)) close #fIn
pointer =1 i =0 ' array starts at term 0, so add one when printing later
dim data1$( 100), data2$( 100)
start =instr( file$, start0$) pointer =start finish =instr( file$, finish0$)
while not( pointer >=len( file$)) and i <30 ' <<<<<<<<<<<<<<<<<<< was 10 startOfItem1 =instr( file$, start1$, pointer) +len1S
if ( pointer =0) then exit while endOfItem1 =instr( file$, finish1$, pointer) data1$( i) =mid$( file$, startOfItem1, endOfItem1 -startOfItem1)
startOfItem2 =instr( file$, start2$, endOfItem1) +len2S endOfItem2 =instr( file$, finish2$, startOfItem2) data2$( i) =mid$( file$, startOfItem2, endOfItem2 -startOfItem2)
print "Item "; i +1 , data1$( i); tab( 70); decToComma$( data2$( i)) i =i +1 pointer =instr( file$, start2$, endOfItem2)
scan wend
[print] for j = 0 to i -1 print data1$( j)
http$ ="http://chart.apis.google.com/chart?cht=qr&chs=80x80&chl=" +voor$+"/"+data1$( j) result = DownloadToFile( http$, "QR" +str$( j) +".png") timer 2000, [o1] ' wait 2 seconds for code to be sent back wait [o1] timer 0 print decToComma$( data2$( j)) http$ ="http://chart.apis.google.com/chart?cht=qr&chs=80x80&chl=" +decToComma$( data2$( j)) result = DownloadToFile( http$, "QR1" +str$( j) +".png") timer 2000, [o3] ' wait 2 seconds for code to be sent back wait [o3] timer 0
' call IM to convert png to 24 bit bmp ' load chosen image; remove transparency; resize; save temporarily as bmp. ' Note if your directory or file names include spaces you have to add the quote here.. ' ie put chr$( 34) either side of the file/pathname. ' trucolor to force 24 bit. Resize if you want- here not needed.
' [print1] ' for j = 0 to i -1 ' print data2$( j) ' http$ ="http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl=" +decToComma$( data2$( i)) ' result = DownloadToFile( http$, "QR1" +str$( j) +".png") ' timer 2000, [o3] ' wait 2 seconds for code to be sent back ' wait ' [o3] ' timer 0
IM$ ="convert +matte -resize 80x80 -type truecolor " +chr$( 34) +"QR" +str$( j) +".png" +chr$( 34) +" temp.bmp " IMI$ ="convert +matte -resize 80x80 -type truecolor " +chr$( 34) +"QR1" +str$( j) +".png" +chr$( 34) +" temp1.bmp " print IM$ ' use when debugging!! print IMI$ ' use when debugging!!
run "cmd.exe /c "; chr$( 34); IM$; chr$( 34), HIDE run "cmd.exe /c "; chr$( 34); IMI$; chr$( 34), HIDE ' Give it 2 seconds to execute ( may not be enough for large images) timer 2000, [o2] wait [o2] timer 0
loadbmp "imx", "temp.bmp" loadbmp "imxi", "temp1.bmp" kill "temp.bmp" kill "temp1.bmp" kill "QR" +str$( j) +".png" kill "QR1" +str$( j) +".png"
#1 "up ; goto 20 "; j *70 +50 #1 "down" #1 "\"; voor$+"/"+data1$( j) #1 "\"; data2$( j) #1 "drawbmp imx 350 " ; j *70 #1 "drawbmp imxi 500 " ; j *70 next j
#1 "flush ; print 800"
close #1 end
sub quit h$ close #h$ end end sub
Function DownloadToFile( urlfile$, localfile$) open "URLmon" for dll as #url calldll #url, "URLDownloadToFileA",_ 0 as long,_ ' null urlfile$ as ptr,_ ' url to download localfile$ as ptr,_ ' save file name 0 as long,_ ' reserved, must be 0 0 as long,_ ' callback address, can be 0 DownloadToFile as ulong ' 0 =success close #url end function
function decToComma$( a$) for j =1 to len( a$) c$ =mid$( a$, j, 1) if c$ ="." then decToComma$ =decToComma$ +"," else decToComma$ =decToComma$ +c$ end if next j if instr( "0123456789", left$( decToComma$, 1)) then decToComma$ ="" +decToComma$ decToComma$ =right$( " " +decToComma$, 8) end function
|
|
konijn
Junior Member
Posts: 96
|
QR code
Jun 10, 2019 13:32:44 GMT -5
Post by konijn on Jun 10, 2019 13:32:44 GMT -5
Hi tenochtitlanuk,
I was testing today and found out that I need the amount between <cbc:TaxableAmount currencyID="EUR"> and </cbc:TaxableAmount> instead of <cbc:PriceAmount currencyID="EUR"> and </cbc:PriceAmount> So I thougt I replace that, but than its not working and dont get the list anymore. How can that happen?
Jack
|
|
|
QR code
Jun 10, 2019 15:35:13 GMT -5
Post by tenochtitlanuk on Jun 10, 2019 15:35:13 GMT -5
Did you allow for the '"' symbols correctly? You can't use 'quotes mrks' within a section of quoted string, but have to includr them as chr$( 34) Try
start2$ ="<cbc:TaxableAmount currencyID=" +chr$( 34) +"EUR" +chr$( 34) +">": len2S =len( start2$) ' data type- price finish2$ ="</cbc:TaxableAmount>": len2F =len( finish2$)
Away from any Windows computer to test the printout- but seems to work for me.
|
|
|
QR code
Jun 13, 2019 14:58:33 GMT -5
Post by tenochtitlanuk on Jun 13, 2019 14:58:33 GMT -5
Slight problem that we are picking up as well as the wanted lines the two Betalingskorting 1 % ( payment discount of 1%) BTW BEDRAG KORTING HOOG ( VAT AMOUNT DISCOUNT) Easily omitted.
I've an improved version that adds page numbers and does the image type conversion by GDI without ImageMagick. Will try to post it tomorrow- I only have the one file to test it on.
Hope hospital was not a major problem.. JohnF
|
|
|
QR code
Jun 14, 2019 9:48:46 GMT -5
Post by tenochtitlanuk on Jun 14, 2019 9:48:46 GMT -5
|
|
konijn
Junior Member
Posts: 96
|
QR code
Aug 11, 2019 11:21:40 GMT -5
Post by konijn on Aug 11, 2019 11:21:40 GMT -5
Slight problem that we are picking up as well as the wanted lines the two Betalingskorting 1 % ( payment discount of 1%) BTW BEDRAG KORTING HOOG ( VAT AMOUNT DISCOUNT) Easily omitted. I've an improved version that adds page numbers and does the image type conversion by GDI without ImageMagick. Will try to post it tomorrow- I only have the one file to test it on. Hope hospital was not a major problem.. JohnF Hi John,
Sory for the delay.
I lost my father in law last month. I was not able to concentrate me on the computer. It was a painful and emotional experience. But we have to go on. i saw you made a lot off work off it. Thanks for that. I will try to pick it up and test!
Best regards
Jack
|
|
|
QR code
Sept 28, 2019 11:53:56 GMT -5
via mobile
Post by kaylab on Sept 28, 2019 11:53:56 GMT -5
|
|
|
QR code
Sept 28, 2019 13:05:18 GMT -5
Post by tenochtitlanuk on Sept 28, 2019 13:05:18 GMT -5
For anyone else picking up on this thread, current version uses GDI rather than ImageMagick to load and print the Google-supplied QR codes. Fast and easy if you have an internet connection...
WindowWidth = 800 WindowHeight =1200 UpperLeftX = 10 UpperLeftY = 10
filedialog "Select xml file", "*.xml", fName$
voor$ =fName$ ' or eg "John F"
open "Create and print QR and text" for graphics_nsb as #1
#1 "trapclose quit"
#1 "up ; goto 10 10 ; down ; box 780 1150"
InvoiceHeader$ ="<cac:InvoiceLine>" lengthInvoiceHeader =len( InvoiceHeader$) ' use data only after this start .. InvoiceFooter$ ="</cac:InvoiceLine>" lengthInvoiceFooter =len( InvoiceFooter$)
NameHeader$ ="<cbc:Name>" lengthNameHeader =len( NameHeader$) ' data - name NameFooter$ ="</cbc:Name>" lengthNameFooter =len( NameFooter$)
TaxableAmountHeader$ ="<cbc:TaxableAmount currencyID=" +chr$( 34) +"EUR" +chr$( 34) +">" lengthTaxableAmountHeader =len( TaxableAmountHeader$) ' data - price TaxableAmountFooter$ ="</cbc:TaxableAmount>" lengthTaxableAmountFooter =len( TaxableAmountFooter$)
open fName$ for input as #fIn L =lof( #fIn) file$ =input$( #fIn, L) close #fIn
i =0 ' array starts at term 0, so add one when printing later
dim taxableAmount$( 100), name$( 100)
start =instr( file$, InvoiceHeader$)
pointer =start +1 ' Do not look before the finish of unwanted part..
print "Showing results as they are found." print ""
while 1 startOfTaxableAmount =instr( file$, TaxableAmountHeader$, pointer) +len( TaxableAmountHeader$) endOfTaxableAmount =instr( file$, TaxableAmountFooter$, pointer) dataLength =endOfTaxableAmount -startOfTaxableAmount
taxableAmount$( i) =mid$( file$, startOfTaxableAmount, dataLength)
startName =instr( file$, NameHeader$, endOfTaxableAmount) +len( NameHeader$) endName =instr( file$, NameFooter$, startName) dataLength =endName -startName
name$( i) =mid$( file$, startName +lengthNameHeadert, dataLength) ' name
print "Item "; i +1; " "; name$( i), ; tab( 70); decToComma$( taxableAmount$( i))
i =i +1
pointer =instr( file$, TaxableAmountHeader$, endOfTaxableAmount) if ( pointer =0) then exit while
scan
wend
[print]
'print "": print "Saved results from this file.."
for j = 0 to i -1
'print name$( j), http$ ="http://chart.apis.google.com/chart?cht=qr&chs=80x80&chl=" +decToComma$( name$( j)) result = DownloadToFile( http$, "QR1" +str$( j) +".png") timer 2000, [o3] ' wait 2 seconds for code to be sent back wait [o3] timer 0
'print decToComma$( taxableAmount$( j))
http$ ="http://chart.apis.google.com/chart?cht=qr&chs=80x80&chl=" +voor$+"/"+taxableAmount$( j) imgfile$ ="QR" +str$( j) +".png" result = DownloadToFile( http$, imgfile$) 'wait timer 2000, [o1] ' wait 2 seconds for code to be sent back wait [o1] timer 0
hBitmap =GDIPlusLoadImage( imgfile$) loadbmp "image", hBitmap
#1 "up ; goto 20 "; j *70 +50 #1 "down" #1 "\" +name$( j) #1 "\"; taxableAmount$( j) #1 "drawbmp image 650 " ; j *70 +20 next j
alteredFilePathName$ ="<<<"
for m =1 to len( fName$) ch$ =mid$( fName$, m, 1)
if ch$ ="\" or ch$ ="/" then alteredFilePathName$ = alteredFilePathName$ +"|" else alteredFilePathName$ =alteredFilePathName$ +ch$ end if next m
a$ =alteredFilePathName$ +">>>"
#1 "up ; goto 260 "; 1100 #1 "down" #1 "\"; a$ print "": print tab( 10); a$
#1 "flush ; print 800"
timer 5000, [f] wait [f] timer 0
close #1
end
sub quit h$ close #h$ end end sub
Function DownloadToFile( urlfile$, localfile$) open "URLmon" for dll as #url calldll #url, "URLDownloadToFileA",_ 0 as long,_ ' null urlfile$ as ptr,_ ' url to download localfile$ as ptr,_ ' save file name 0 as long,_ ' reserved, must be 0 0 as long,_ ' callback address, can be 0 DownloadToFile as ulong ' 0 =success close #url end function
function decToComma$( a$) a$ =left$( a$,10) ' <<<<<<<<<<<<<<<<<< for j =1 to len( a$) c$ =mid$( a$, j, 1) if c$ ="." then decToComma$ =decToComma$ +"," else decToComma$ =decToComma$ +c$ end if next j if instr( "0123456789", left$( decToComma$, 1)) then decToComma$ ="" +decToComma$ decToComma$ =right$( " " +decToComma$, 8) end function
'********************************* 'You do not need to understand the two functions that follow. 'Paste them at the bottom of your code, and call the image-loading function like this: ' hBitmap=GDIPlusLoadImage(imgfile$) 'You may then use Liberty BASIC's LOADBMP function to load the image. ' loadbmp "image",hBitmap 'Draw it in a graphicbox or graphics window with LB's DRAWBMP statement. '*********************************
function GDIPlusLoadImage( file$) open "gdiplus.dll" for dll as #gdiplus 'this struct will be filled by API functions
STRUCT GDITOKEN, token as ulong 'we MUST fill this struct with GdiPlusVersion number
STRUCT GdiplusStartupInput,_ GdiplusVersion as ulong,_ DebugEventCallback as ulong,_ SuppressBackgroundThread as long,_ SuppressExternalCodecs as long
GdiplusStartupInput.GdiplusVersion.struct =1 'must be = 1
calldll #gdiplus,"GdiplusStartup",_ GDITOKEN as struct,_ GdiplusStartupInput as struct,_ status as ulong 'returns zero if successful
token =GDITOKEN.token.struct
if status <>0 then GDIPlusLoadImage =0 else wFile$ =MultiByteToWideChar$( file$)
calldll #gdiplus, "GdipCreateBitmapFromFile", _ wFile$ as ptr,_ 'filename string in unicode (wide) character format GDITOKEN as struct,_ status as ulong 'returns zero if successful
hBmpGdip =GDITOKEN.token.struct 'GDI+ bitmap returned in struct
if status <>0 then GDIPlusLoadImage =0 else 'create GDI bitmap handle from GDI+ bitmap calldll #gdiplus, "GdipCreateHBITMAPFromBitmap", _ hBmpGdip as ulong,_ 'GDIPlus bitmap GDITOKEN as struct,_ 'bitmap handle will be returned in this struct 0 as ulong,_ status as ulong 'returns zero if successful
if status <>0 then GDIPlusLoadImage=0 else 'get a bitmap handle we can use with Liberty BASIC's LOADBMP GDIPlusLoadImage =GDITOKEN.token.struct end if
calldll #gdiplus, "GdipDisposeImage",_ 'remove GDI+ bitmap hImage as ulong,_ 'GDI+ bitmap handle result as ulong end if
calldll #gdiplus,"GdiplusShutdown",_ 'you must call this when finished token as ulong,_ 'Token returned by a previous call to GdiplusStartup. result as void 'no return from this function
close #gdiplus end if end function
function MultiByteToWideChar$( String$) 'converts any string into unicode CodePage = 0 dwFlags = 0 cchMultiByte = -1 lpMultiByteStr$ = String$ cchWideChar = len( String$) *3 lpWideCharStr$ = space$( cchWideChar)
calldll #kernel32, "MultiByteToWideChar", _ CodePage as ulong, _ 'CP_ACP=0, ansi code page dwFlags as ulong, _ 'use 0, flags for character translation lpMultiByteStr$ as ptr,_ 'the ascii string to convert cchMultiByte as long, _ 'len of string, -1 for null-terminated string lpWideCharStr$ as ptr, _ 'buffer for returned ansi string cchWideChar as long, _ 'size in wide characters of string buffer result as long 'returns number of wide characters written to buffer
if result = 0 then MultiByteToWideChar$ = "" else MultiByteToWideChar$ = left$( lpWideCharStr$, result *2) end if
end function
|
|
konijn
Junior Member
Posts: 96
|
QR code
Aug 27, 2020 14:42:29 GMT -5
Post by konijn on Aug 27, 2020 14:42:29 GMT -5
Hello, You all helped me a lot. With the QR codes I was able to manage to get the invoice data in the computer. Now our software is almost ready to import the ubl files. Only problem the want UBL2.1 and I have UBL2.0. That gives problem with the import. Now there is also another way. The software has also there own xml standard. The question is can we convert an ubl to the other xml file? It must be if like we do with the QR codes.
What is the best way to handle this and how to start with it?
This is the code of the xml is has te be:
<?xml version="1.0" encoding="UTF-8"?> <AdedTransaction xmlns="http://www.ec-design.nl/ATC/TEST/1.0/structures"> <A402617CodeMuntsoort>EUR</A402617CodeMuntsoort> <A201029SoortOverzicht>380</A201029SoortOverzicht> <A201136Faktuurnummer>20190001</A201136Faktuurnummer> <A201134Faktuurdatum>2019-11-04</A201134Faktuurdatum> <A800004UniekBerichtNummer>/20190001</A800004UniekBerichtNummer> <A800006AssociationAssignedCode>EVF2.2</A800006AssociationAssignedCode> <A204654Toelichting> / 20190001</A204654Toelichting> <AdedLeverancier> <A700129Naam>UBL Test Bedrijf</A700129Naam> <A700766PostadresStraat>Testlaan 100</A700766PostadresStraat> <A700767PostadresHuisnummer /> <A700768PostadresPlaats>Teststad</A700768PostadresPlaats> <A204587PostadresPostcode>3568TS</A204587PostadresPostcode> <A700770PostadresLand>NL</A700770PostadresLand> <A204581Iban>NL17RABO0683931423</A204581Iban> <A204582Bic>RABONL2U</A204582Bic> <A204651VatNumberInternational>NL187447810B01</A204651VatNumberInternational> </AdedLeverancier> <AdedAfnemer> <A700129Naam>UBL Ketentest Klant</A700129Naam> <A700766PostadresStraat>De Testlaan 200</A700766PostadresStraat> <A700767PostadresHuisnummer /> <A700768PostadresPlaats>Testdorp</A700768PostadresPlaats> <A204587PostadresPostcode>8457NN</A204587PostadresPostcode> <A700770PostadresLand>NL</A700770PostadresLand> <A203813Relatienummer>0</A203813Relatienummer> <A203838CodeBetaling>1</A203838CodeBetaling> <AdedFinanKorting> <A702000SoortKorting /> <A702007KortingsbedragExcl>-100.00</A702007KortingsbedragExcl> <A203841Kortingspercentage>10000</A203841Kortingspercentage> </AdedFinanKorting> <AdedFinanKorting> <A702000SoortKorting /> <A702007KortingsbedragExcl>25.00</A702007KortingsbedragExcl> <A203841Kortingspercentage>2500</A203841Kortingspercentage> </AdedFinanKorting> </AdedAfnemer> <AdedLevering> <A702078Regelnummer>1</A702078Regelnummer> <A702164DatumLevering>2019-11-04</A702164DatumLevering> <A300225BonnummerLeveringsbon>1</A300225BonnummerLeveringsbon> <A702165Leveringsbonregelnummer>1</A702165Leveringsbonregelnummer> <A702827OrderNummerLeverancier>10001</A702827OrderNummerLeverancier> <A203811BedragBrutoExBtw>100.00</A203811BedragBrutoExBtw> <A203862BedragNettoExBtw>100.00</A203862BedragNettoExBtw> <A203822HoeveelheidProdukt>1.00</A203822HoeveelheidProdukt> <A204652Eenheid>ST</A204652Eenheid> <AdedProdukt> <A203819Artikelcode>Artikel - Een - Hoog</A203819Artikelcode> <A401013PrijsBruto>100.00</A401013PrijsBruto> <A203820OmschrijvingProdukt>Artikel - Een - Hoog</A203820OmschrijvingProdukt> <AdedBtw> <A202637Btw>21.00</A202637Btw> <A702004BedragBtw>21.00</A702004BedragBtw> </AdedBtw> </AdedProdukt> </AdedLevering> <AdedLevering> <A702078Regelnummer>2</A702078Regelnummer> <A702164DatumLevering>2019-11-04</A702164DatumLevering> <A300225BonnummerLeveringsbon>2</A300225BonnummerLeveringsbon> <A702165Leveringsbonregelnummer>2</A702165Leveringsbonregelnummer> <A702827OrderNummerLeverancier>10001</A702827OrderNummerLeverancier> <A203811BedragBrutoExBtw>200.00</A203811BedragBrutoExBtw> <A203862BedragNettoExBtw>200.00</A203862BedragNettoExBtw> <A203822HoeveelheidProdukt>1.00</A203822HoeveelheidProdukt> <A204652Eenheid>ST</A204652Eenheid> <AdedProdukt> <A203819Artikelcode>Artikel - Twee - Hoog</A203819Artikelcode> <A401013PrijsBruto>200.00</A401013PrijsBruto> <A203820OmschrijvingProdukt>Artikel - Twee - Hoog</A203820OmschrijvingProdukt> <AdedBtw> <A202637Btw>21.00</A202637Btw> <A702004BedragBtw>42.00</A702004BedragBtw> </AdedBtw> </AdedProdukt> </AdedLevering> <AdedLevering> <A702078Regelnummer>3</A702078Regelnummer> <A702164DatumLevering>2019-11-04</A702164DatumLevering> <A300225BonnummerLeveringsbon>3</A300225BonnummerLeveringsbon> <A702165Leveringsbonregelnummer>3</A702165Leveringsbonregelnummer> <A702827OrderNummerLeverancier>10001</A702827OrderNummerLeverancier> <A203811BedragBrutoExBtw>300.00</A203811BedragBrutoExBtw> <A203862BedragNettoExBtw>300.00</A203862BedragNettoExBtw> <A203822HoeveelheidProdukt>1.00</A203822HoeveelheidProdukt> <A204652Eenheid>ST</A204652Eenheid> <AdedProdukt> <A203819Artikelcode>Artikel - Drie - Hoog</A203819Artikelcode> <A401013PrijsBruto>300.00</A401013PrijsBruto> <A203820OmschrijvingProdukt>Artikel - Drie - Hoog</A203820OmschrijvingProdukt> <AdedBtw> <A202637Btw>21.00</A202637Btw> <A702004BedragBtw>63.00</A702004BedragBtw> </AdedBtw> </AdedProdukt> </AdedLevering> <AdedLevering> <A702078Regelnummer>4</A702078Regelnummer> <A702164DatumLevering>2019-11-04</A702164DatumLevering> <A300225BonnummerLeveringsbon>4</A300225BonnummerLeveringsbon> <A702165Leveringsbonregelnummer>4</A702165Leveringsbonregelnummer> <A702827OrderNummerLeverancier>10001</A702827OrderNummerLeverancier> <A203811BedragBrutoExBtw>400.00</A203811BedragBrutoExBtw> <A203862BedragNettoExBtw>400.00</A203862BedragNettoExBtw> <A203822HoeveelheidProdukt>1.00</A203822HoeveelheidProdukt> <A204652Eenheid>ST</A204652Eenheid> <AdedProdukt> <A203819Artikelcode>Artikel - Vier - Hoog</A203819Artikelcode> <A401013PrijsBruto>400.00</A401013PrijsBruto> <A203820OmschrijvingProdukt>Artikel - Vier - Hoog</A203820OmschrijvingProdukt> <AdedBtw> <A202637Btw>21.00</A202637Btw> <A702004BedragBtw>84.00</A702004BedragBtw> </AdedBtw> </AdedProdukt> </AdedLevering> <AdedBtw1> <A202637Btw>21.00</A202637Btw> <A203836BtwGrondslag>900.00</A203836BtwGrondslag> <A702004BedragBtw>189.00</A702004BedragBtw> </AdedBtw1> <AdedBtw1> <A202637Btw>0.00</A202637Btw> <A203836BtwGrondslag>25.00</A203836BtwGrondslag> <A702004BedragBtw>0.00</A702004BedragBtw> </AdedBtw1> <AdedTotalen> <A700154Bedrag>1114.00</A700154Bedrag> <A204655Bedragqualifier>86</A204655Bedragqualifier> </AdedTotalen> </AdedTransaction>
And this is the source file:
<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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd"> <cbc:UBLVersionID>2.1</cbc:UBLVersionID> <cbc:CustomizationID>urn:www.cenbii.eu:transaction:biitrns010:ver2.0:extended:urn:www.peppol.eu:bis:peppol4a:ver2.0:extended:urn:www.simplerinvoicing.org:si:si-ubl:ver1.1.x</cbc:CustomizationID> <cbc:ProfileID>urn:www.cenbii.eu:profile:bii04:ver2.0</cbc:ProfileID> <cbc:ID>20190001</cbc:ID> <cbc:IssueDate>2019-11-04</cbc:IssueDate> <cbc:InvoiceTypeCode listAgencyID="6" listID="UNCL1001">380</cbc:InvoiceTypeCode> <cbc:DocumentCurrencyCode listAgencyID="6" listID="ISO 4217 Alpha">EUR</cbc:DocumentCurrencyCode> <cac:AdditionalDocumentReference> <cbc:ID>20190001</cbc:ID> <cac:Attachment> <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" /> </cac:Attachment> </cac:AdditionalDocumentReference> <cac:AccountingSupplierParty> <cac:Party> <cac:PartyName> <cbc:Name>UBL Test Bedrijf</cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:StreetName>Testlaan 100</cbc:StreetName> <cbc:CityName>Teststad</cbc:CityName> <cbc:PostalZone>3568TS</cbc:PostalZone> <cac:Country> <cbc:IdentificationCode listAgencyID="6" listID="ISO3166-1:Alpha2">NL</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyTaxScheme> <cbc:CompanyID schemeAgencyID="ZZZ" schemeID="NL:VAT">NL187447810B01</cbc:CompanyID> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:PartyTaxScheme> <cac:PartyLegalEntity> <cbc:CompanyID schemeAgencyID="ZZZ" schemeID="NL:KVK">15548754</cbc:CompanyID> </cac:PartyLegalEntity> <cac:Contact> <cbc:Name>Jan Janssen</cbc:Name> <cbc:Telephone>0455157845</cbc:Telephone> <cbc:ElectronicMail>ovanpiggelen@snelstart.nl</cbc:ElectronicMail> </cac:Contact> </cac:Party> </cac:AccountingSupplierParty> <cac:AccountingCustomerParty> <cac:Party> <cac:PartyName> <cbc:Name>UBL Ketentest Klant</cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:StreetName>De Testlaan 200</cbc:StreetName> <cbc:CityName>Testdorp</cbc:CityName> <cbc:PostalZone>8457NN</cbc:PostalZone> <cac:Country> <cbc:IdentificationCode listAgencyID="6" listID="ISO3166-1:Alpha2">NL</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyTaxScheme> <cbc:CompanyID schemeAgencyID="ZZZ" schemeID="NL:VAT">NL158778510B01</cbc:CompanyID> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:PartyTaxScheme> <cac:PartyLegalEntity> <cbc:CompanyID schemeAgencyID="ZZZ" schemeID="NL:KVK">01654897</cbc:CompanyID> </cac:PartyLegalEntity> <cac:Contact> <cbc:Name>D.E. Klant</cbc:Name> <cbc:Telephone>048548754</cbc:Telephone> <cbc:ElectronicMail>ovanpiggelen@snelstart.nl</cbc:ElectronicMail> </cac:Contact> </cac:Party> </cac:AccountingCustomerParty> <cac:Delivery> <cac:DeliveryLocation> <cac:Address> <cbc:StreetName>De Testlaan 200</cbc:StreetName> <cbc:CityName>Testdorp</cbc:CityName> <cbc:PostalZone>8457NN</cbc:PostalZone> <cac:Country> <cbc:IdentificationCode listAgencyID="6" listID="ISO3166-1:Alpha2">NL</cbc:IdentificationCode> </cac:Country> </cac:Address> </cac:DeliveryLocation> </cac:Delivery> <cac:PaymentMeans> <cbc:PaymentMeansCode listID="UNCL4461">1</cbc:PaymentMeansCode> <cbc:PaymentDueDate>2019-12-04</cbc:PaymentDueDate> <cac:PayeeFinancialAccount> <cbc:ID schemeID="IBAN">NL17RABO0683931423</cbc:ID> <cac:FinancialInstitutionBranch> <cac:FinancialInstitution> <cbc:ID schemeID="BIC">RABONL2U</cbc:ID> </cac:FinancialInstitution> </cac:FinancialInstitutionBranch> </cac:PayeeFinancialAccount> </cac:PaymentMeans> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>Factuurkorting</cbc:AllowanceChargeReason> <cbc:Amount currencyID="EUR">100.00</cbc:Amount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305">S</cbc:ID> <cbc:Percent>21.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">21.00</cbc:TaxAmount> </cac:TaxTotal> </cac:AllowanceCharge> <cac:AllowanceCharge> <cbc:ChargeIndicator>true</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>Administratiekosten - Hoog</cbc:AllowanceChargeReason> <cbc:Amount currencyID="EUR">25.00</cbc:Amount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305">Z</cbc:ID> <cbc:Percent>0.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">0.00</cbc:TaxAmount> </cac:TaxTotal> </cac:AllowanceCharge> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">189.00</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">900.00</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">189.00</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>21.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">25.00</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">0.00</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305" schemeAgencyID="6">Z</cbc:ID> <cbc:Percent>0.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:LegalMonetaryTotal> <cbc:LineExtensionAmount currencyID="EUR">1000.00</cbc:LineExtensionAmount> <cbc:TaxExclusiveAmount currencyID="EUR">925.00</cbc:TaxExclusiveAmount> <cbc:TaxInclusiveAmount currencyID="EUR">1114.00</cbc:TaxInclusiveAmount> <cbc:AllowanceTotalAmount currencyID="EUR">100.00</cbc:AllowanceTotalAmount> <cbc:ChargeTotalAmount currencyID="EUR">25.00</cbc:ChargeTotalAmount> <cbc:PayableAmount currencyID="EUR">1114.00</cbc:PayableAmount> </cac:LegalMonetaryTotal> <cac:InvoiceLine> <cbc:ID>1</cbc:ID> <cbc:InvoicedQuantity unitCode="ZZ">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="EUR">100.00</cbc:LineExtensionAmount> <cac:OrderLineReference> <cbc:LineID>1</cbc:LineID> <cac:OrderReference> <cbc:ID>10001</cbc:ID> </cac:OrderReference> </cac:OrderLineReference> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">21.00</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">100.00</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">21.00</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>21.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:Item> <cbc:Name>Artikel - Een - Hoog</cbc:Name> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="EUR">100.00</cbc:PriceAmount> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>2</cbc:ID> <cbc:InvoicedQuantity unitCode="ZZ">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="EUR">200.00</cbc:LineExtensionAmount> <cac:OrderLineReference> <cbc:LineID>2</cbc:LineID> <cac:OrderReference> <cbc:ID>10001</cbc:ID> </cac:OrderReference> </cac:OrderLineReference> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">42.00</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">200.00</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">42.00</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>21.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:Item> <cbc:Name>Artikel - Twee - Hoog</cbc:Name> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="EUR">200.00</cbc:PriceAmount> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>3</cbc:ID> <cbc:InvoicedQuantity unitCode="ZZ">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="EUR">300.00</cbc:LineExtensionAmount> <cac:OrderLineReference> <cbc:LineID>3</cbc:LineID> <cac:OrderReference> <cbc:ID>10001</cbc:ID> </cac:OrderReference> </cac:OrderLineReference> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">63.00</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">300.00</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">63.00</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>21.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:Item> <cbc:Name>Artikel - Drie - Hoog</cbc:Name> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="EUR">300.00</cbc:PriceAmount> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>4</cbc:ID> <cbc:InvoicedQuantity unitCode="ZZ">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="EUR">400.00</cbc:LineExtensionAmount> <cac:OrderLineReference> <cbc:LineID>4</cbc:LineID> <cac:OrderReference> <cbc:ID>10001</cbc:ID> </cac:OrderReference> </cac:OrderLineReference> <cac:TaxTotal> <cbc:TaxAmount currencyID="EUR">84.00</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="EUR">400.00</cbc:TaxableAmount> <cbc:TaxAmount currencyID="EUR">84.00</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UNCL5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>21.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeAgencyID="6" schemeID="UN/ECE 5153">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:Item> <cbc:Name>Artikel - Vier - Hoog</cbc:Name> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="EUR">400.00</cbc:PriceAmount> </cac:Price> </cac:InvoiceLine> </Invoice>
Is this to do? Or is it to diffucult to start with? Some UBL files has this value: LineCountNumeric Then you can see how many invoicelines there are. But not all files has that, so you can not use it I am afraid.
I think to switch the adresses and but what to do if a invoice has 1 line and the next one has 7 lines?
Thanks
Jack
(must I start a new topic for this?)
|
|
konijn
Junior Member
Posts: 96
|
QR code
Aug 28, 2020 7:39:35 GMT -5
Post by konijn on Aug 28, 2020 7:39:35 GMT -5
With this code '`use AFTERLAST$() and AFTER$() might be helpful? ??
start$ ="<cac:InvoiceLine>" lenS =len(start$) finish$ ="</cac:InvoiceLine>" lenF =len( finish$)
open "c:\factuur\SEPA\SEPAbestanden\ubl.xml" for input as #fIn file$ =input$( #fIn, lof( #fIn)) close #fIn
current = 1
[look] pointer =instr( file$, start$, current) if pointer <>0 then endItem =instr( file$, finish$, pointer +2) data$ =mid$( file$, pointer +lenS , endItem -pointer +1 -lenF) current =endItem print data$
else end end if
scan goto [look]
What you write for me tenochtitlanuk I get the info between the <invoicelines>. But how do I get the specific data out off there. Like price, amount, tax etc?
|
|
konijn
Junior Member
Posts: 96
|
QR code
Aug 29, 2020 11:50:04 GMT -5
Post by konijn on Aug 29, 2020 11:50:04 GMT -5
I tried to figure something. I hope I do it the right way. I have problems with the InvoicedQuantity. I miss a record. With the other data it will work.
He will mot get the value of the second InvoicedQuantity line.
What goes wrong?
With this line: "<cbc:InvoicedQuantity unitCode=" +chr$( 34) +"ZZ" +chr$( 34) +">" The ZZ is not always the same. Somethimes its EA. How to fix? Use a joker some way?
Right mouse button, choice for save as...
' WindowWidth = 800 ' WindowHeight =1200 ' UpperLeftX = 10 ' UpperLeftY = 10
' filedialog "Select xml file", "*.xml", fName$
' voor$ =fName$ ' or eg "John F"
InvoiceHeader$ ="<cac:InvoiceLine>" lengthInvoiceHeader =len( InvoiceHeader$) ' use data only after this start .. InvoiceFooter$ ="</cac:InvoiceLine>" lengthInvoiceFooter =len( InvoiceFooter$)
NameHeader$ ="<cbc:Name>" lengthNameHeader =len( NameHeader$) ' data - name NameFooter$ ="</cbc:Name>" lengthNameFooter =len( NameFooter$)
TaxableAmountHeader$ ="<cbc:TaxableAmount currencyID=" +chr$( 34) +"EUR" +chr$( 34) +">" lengthTaxableAmountHeader =len( TaxableAmountHeader$) TaxableAmountFooter$ ="</cbc:TaxableAmount>" lengthTaxableAmountFooter =len( TaxableAmountFooter$)
TaxAmountHeader$ ="<cbc:TaxAmount currencyID=" +chr$( 34) +"EUR" +chr$( 34) +">" lengthTaxAmountHeader =len( TaxAmountHeader$) ' TaxAmountFooter$ ="</cbc:TaxAmount>" lengthTaxAmountFooter =len( TaxAmountFooter$)
InvoicedQuantityHeader$ ="<cbc:InvoicedQuantity unitCode=" +chr$( 34) +"ZZ" +chr$( 34) +">" lengthInvoicedQuantityHeader =len( InvoicedQuantityHeader$) ' InvoicedQuantityFooter$ ="</cbc:InvoicedQuantity>" lengthInvoicedQuantityFooter =len( InvoicedQuantityFooter$)
PercentHeader$ ="<cbc:Percent>" lengthPercentHeader =len( Percent$) PercentFooter$ ="</cbc:Percent>" lengthPercentFooter =len( PercentFooter$) ' PriceAmountHeader$ ="<cbc:PriceAmount currencyID=" +chr$( 34) +"EUR" +chr$( 34) +">" lengthPriceAmountHeader =len( PriceAmount$) PriceAmountFooter$ ="</cbc:PriceAmount" lengthPriceAmountFooter =len( PriceAmountFooter$)
' open fName$ for input as #fIn
open "c:\factuur\sepa\sepabestanden\ubl.xml" for input as #fIn
L =lof( #fIn) file$ =input$( #fIn, L) close #fIn
i = 0 ' array starts at term 0, so add one when printing later
dim taxableAmount$( 100), name$( 100), TaxAmount$( 100), InvoicedQuantity$( 100), Percent$( 100), PriceAmount$( 100)
start =instr( file$, InvoiceHeader$)
pointer =start +1 ' Do not look before the finish of unwanted part..
print "Showing results as they are found." print ""
while 1 startOfTaxableAmount =instr( file$, TaxableAmountHeader$, pointer) +len( TaxableAmountHeader$) endOfTaxableAmount =instr( file$, TaxableAmountFooter$, pointer) dataLength =endOfTaxableAmount -startOfTaxableAmount
taxableAmount$( i) =mid$( file$, startOfTaxableAmount, dataLength)
startName =instr( file$, NameHeader$, endOfTaxableAmount) +len( NameHeader$) endName =instr( file$, NameFooter$, startName) dataLength =endName -startName
name$( i) =mid$( file$, startName +lengthNameHeadert, dataLength) ' name
startOfTaxAmount =instr( file$, TaxAmountHeader$, pointer) +len( TaxAmountHeader$) endOfTaxAmount =instr( file$, TaxAmountFooter$, pointer) dataLength =endOfTaxAmount -startOfTaxAmount
TaxAmount$( i) =mid$( file$, startOfTaxAmount, dataLength)
startOfInvoicedQuantity =instr( file$, InvoicedQuantityHeader$, pointer) +len( InvoicedQuantityHeader$) endOfInvoicedQuantity =instr( file$, InvoicedQuantityFooter$, pointer) dataLength =endOfInvoicedQuantity -startOfInvoicedQuantity
InvoicedQuantity$( i) =mid$( file$, startOfInvoicedQuantity, dataLength)
startOfPercent =instr( file$, PercentHeader$, pointer) +len( PercentHeader$) endOfPercent =instr( file$, PercentFooter$, pointer) dataLength =endOfPercent -startOfPercent
Percent$( i) =mid$( file$, startOfPercent, dataLength)
startOfPriceAmount =instr( file$, PriceAmountHeader$, pointer) +len( PriceAmountHeader$) endOfPriceAmount =instr( file$, PriceAmountFooter$, pointer) dataLength =endOfPriceAmount -startOfPriceAmount
PriceAmount$( i) =mid$( file$, startOfPriceAmount, dataLength)
print name$( i), ; tab( 70); taxableAmount$( i), TaxAmount$( i), InvoicedQuantity$( i), Percent$( i), PriceAmount$( i)
i =i +1
pointer =instr( file$, TaxableAmountHeader$, endOfTaxableAmount) if ( pointer =0) then exit while
scan
wend
|
|
|
QR code
Aug 29, 2020 15:12:04 GMT -5
Post by tenochtitlanuk on Aug 29, 2020 15:12:04 GMT -5
EDIT hadn't seen your latest post when I put this up- I'm rather busy at present- but glad to see you getting ahead with this project!!
Not sure where the UBL files come in But to get the bits out of the invoice 'blobs' you already have extracted, something like this works to extract the data you want.. basically defined a new function. Only trick isd realising to get double-quotes in a string you need to put it in as a chr$( 34)- see the Help files. start$ ="<cac:InvoiceLine>" lenS =len(start$) finish$ ="</cac:InvoiceLine>" lenF =len( finish$)
comma$ =chr$( 34)
open "source.ublinv" for input as #fIn file$ =input$( #fIn, lof( #fIn)) close #fIn
current = 1
[look] pointer =instr( file$, start$, current) if pointer <>0 then endItem =instr( file$, finish$, pointer +2) data$ =mid$( file$, pointer +lenS , endItem -pointer -lenF) current =endItem
print "Tax "; dataBetween$( "<cbc:TaxAmount currencyID=" +comma$ +"EUR" +comma$ +">", "</cbc:TaxAmount>", data$); " euros" print "Price "; dataBetween$( "<cbc:PriceAmount currencyID=" +comma$ +"EUR" +comma$ +">", "</cbc:PriceAmount>", data$); " euros" print "" else e=nd end if
scan goto [look]
wait ' ___________________________________________________
function dataBetween$( start$, finish$, source$) S =instr( source$, start$) +len( start$) rightHand$ =mid$( source$, S) d$ =upto$( rightHand$, finish$) dataBetween$ =d$ end function
..which produced the following off you example file ( note path and name changed for my debugging) Tax 21.00 euros Price 100.00 euros
Tax 42.00 euros Price 200.00 euros
Tax 63.00 euros Price 300.00 euros
Tax 84.00 euros Price 400.00 euros
|
|