Best way to print Invoice ?

Re: Best way to print Invoice ?

Postby anserkk » Tue May 19, 2009 8:26 am

Thank you Mr.Frank for the information.

Printing/reporting a very simple thing which we used to do it in clipper & DOS has turned out to be a very complicated thing in Windows environment. :o and hence many third party tools. I prefer not to depend on a third party tool and do it from FWH itself. I understand that I have to learn the trick to do it from FWH and it is not that simple.

Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby anserkk » Tue May 19, 2009 9:09 am

Dear Mr.Otto,

No installation/setup is necessary – if your Fivewin application executes on the client machine also the report is working!


Do you mean that we don't have to install EasyReport on each client machine ? Instead, all the contents of the Folder Distribution (ErStart.Exe, many DLL's etc) and the .vrd file (Report File) should be distributed along with our FWH application and from FWH we can call EasyReport using the following command
ShellExecute( 0, "Open", "ERStart.exe", "-File=.\test.vrd -PREVIEW", NIL, 1 )

Any idea where should be the Distribution folder copied while we distribute the FWH application ?
Can we use EasyReport to create reports using the data from MySQL tables ?

I have got 1 developer/designer License (Free) which is bundled along with the FWH Purchase. (That's what I understand). I am planning to try this and distribute the ErStart.Exe and .vrd file on my Client's PC. Would you mind giving me some useful hints so that I get a push in the right direction.

In my DOS clipper Invoice.Prg, I have the Company name, Address, VAT Reg No etc kept in one DBF and the Line Items ie Item Code, Item Name, Qty, Price etc. in another Temporary DBF which is created at Run Time and deleted after the printing of the invoice

The Grand Total, VAT Total, discount Totals etc (Printed at the bottom) are calculated values while processing the Temporary DBF in a Do While loop.

How and where do I start with the above said Scenario ?

Thanks & Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby Otto » Tue May 19, 2009 10:15 am

Mr. Anser,

I am happy. You are on the right way!

Do you mean that we don't have to install EasyReport on each client machine ? Instead, all the contents of the Folder Distribution (ErStart.Exe, many DLL's etc) and the .vrd file (Report File) should be distributed along with our FWH application


Yes. I have a directory inside my program where the EasyReport files are located and one or more where I have the reports.

You define the report – you can also locate the reports on a net drive. Then all the WS have the same.


EASYREPORT oVRD NAME ".\xVRD\Paketaufkleber.vrd" ;
PREVIEW lPreview TO cPrinter OF oWnd PRINTDIALOG IIF( lPreview, .F., .F. )


and from FWH we can call EasyReport using the following command
ShellExecute( 0, "Open", "ERStart.exe", "-File=.\test.vrd -PREVIEW", NIL, 1 )

no this is all handled automatically.

#include "VRD.CH"

1. define the report
2. define you PRINTAREA’s which is in practice an ARRAY with an ID and the value you want to be print to this ID which you have given in your design.

PRINTAREA 1 OF oVRD ;
ITEMIDS { 101,102,103,104,204,205,206,207,208 } ;
ITEMVALUES { cCompany,cAddr1,cAddr2,cAddr3,cAnrede,cName,cStrasse,cOrt,cLandFeld }

Any idea where should be the Distribution folder copied while we distribute the FWH application ?


In the same folder as your program.

Can we use EasyReport to create reports using the data from MySQL tables ?


Yes.

Here a very easy – but much used report. This prints a client address on a white paper:

Code: Select all  Expand view
function f_paket
    local oVRD
    local lPreview :=.t.
    local cPrinter := GetPvProfString( "DRUCKER","Standard","Standard", ".\INI\WINHOTEL.INI" )
    local cCompany  := ""
    local cAddr1    := ""
    local cAddr2    := ""
    local cAddr3    := ""

    local cAnrede   := ""
    local cName     := ""
    local cStrasse  := ""
    local cOrt      := ""
    local cLandFeld := ""
 
    cCompany  := ALLTRIM(setup->company)
    cAddr1    := ALLTRIM(setup->addr1)
    cAddr2    := ALLTRIM(setup->addr2)
    cAddr3    := ALLTRIM(setup->addr3)

    cAnrede   := kunden->anrede
    cName     := ALLTRIM(kunden->name)+" "+ALLTRIM(kunden->vorname)+" "+Trim(kunden->titel)
    cStrasse  := kunden->strasse
    cOrt      := ALLTRIM(kunden->plz)+" "+kunden->ort
    cLandFeld := f_landfeld(kunden->lkz)

//----------------------------------------------------------------------------//
    EASYREPORT oVRD NAME ".\xVRD\Paketaufkleber.vrd" ;
        PREVIEW lPreview TO cPrinter OF oWnd  PRINTDIALOG IIF( lPreview, .F., .F. )

      PRINTAREA 1 OF oVRD ;
        ITEMIDS    { 101,102,103,104,204,205,206,207,208 } ;
        ITEMVALUES { cCompany,cAddr1,cAddr2,cAddr3,cAnrede,cName,cStrasse,cOrt,cLandFeld }

    oVRD:End()
RETURN NIL
//----------------------------------------------------------------------------//
 


Image


Then you define the header for your bodytext.
Code: Select all  Expand view
//Print position header
   PRINTAREA 2 OF oVRD
 



Then you define a PRINTAREA for the data that changes.
You request for example the data in a do while and you print every line like this:

In my case the PRINTAREA3 is defined with a high of 5 mm.
(Order positions)

Image



Code: Select all  Expand view
do while .not. eof()
PRINTAREA 3 OF oVRD ;
         ITEMIDS    { 101,102,105,106,107 } ;
         ITEMVALUES { cMenge, ;
         cBezeichnung, ;
         cPreis, ;
         cWert, ;
         cRabatt }
enddo
 


Here democode for the footer:

Code: Select all  Expand view
  //Print order footer
               cText1 := "Fortsetzung Seite: " + ALLTRIM(str(nSeite))
               cText2 := "Zwischensumme " +  ALLTRIM(transform( rgsumm ,"999,999.99")) //text Fortsetzungsblatt
               PRINTAREA 9 OF oVRD ;
                  ITEMIDS    { 101, 102 } ;
                  ITEMVALUES { cText1, cText2 }
 


Important: you have to take care for the pagebreak - but the code is easy:
IF oVRD:nNextRow > oVRD:nPageBreak
nSeite := nSeite + 1
//Print order footer
cText1 := "Fortsetzung Seite: " + ALLTRIM(str(nSeite))
cText2 := "Zwischensumme " + ALLTRIM(transform( rgsumm ,"999,999.99")) //text Fortsetzungsblatt
PRINTAREA 9 OF oVRD ;
ITEMIDS { 101, 102 } ;
ITEMVALUES { cText1, cText2 }

PAGEBREAK oVRD

//Print position header
cText1 := "Seite: " + ALLTRIM(str(nSeite))
cText2 := "Rechnung-NR: " + cOrderNr
PRINTAREA 6 OF oVRD ;
ITEMIDS { 101, 102,105 ,106} ;
ITEMVALUES { cText1, cText2,"Übertrag:",ALLTRIM(transform( rgsumm ,"999,999.99")) }
PRINTAREA 2 OF oVRD





Image


Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6088
Joined: Fri Oct 07, 2005 7:07 pm

Re: Best way to print Invoice ?

Postby James Bott » Tue May 19, 2009 11:28 am

You can create some rather complex invoices using the standard FW Report class. I have made invoices that are more complex than your example using TReport. I do not have a complete simple example since my reports are part of more complex classes, like a Sales Order and Invoice classes.

Here is a partial example:

Code: Select all  Expand view
     REPORT oReport;
         HEADER ;
           "Invoice: "+trim(::invno), "Page: "+;
           ltrim(str(oReport:nPage,3)) RIGHT;
         TITLE ::oSysdata:company, ;
           ::oSysdata:address,;
           trim(::oSysdata:city)+", "+trim(::oSysdata:state)+" "+::oSysdata:zip,;
           " "," ",;
           "Ship to:", ;
           " ",;
           ::oCustomer:Contact,;
           ::oCustomer:company,;
           trim(::oCustomer:address1)+if(!empty(::oCustomer:address2),", "+::oCustomer:address2,""),;
           trim(::oCustomer:city)+", "+trim(::oCustomer:state)+" "+::oCustomer:zip,;
           ::oCustomer:phone," "," ",;
           "PO No: "+::oInvmast:PONum+"  Invoice date: "+dtoc(::oInvmast:invdte)+;
           "  Terms: "+::oInvmast:pterms LEFT;//+"  Salesperson: "," " LEFT;
           FOOTER cFooter1,cFooter2 CENTER;
         FONT oFont;
         TO DEVICE oDevice


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Best way to print Invoice ?

Postby anserkk » Wed May 20, 2009 4:31 am

Dear Mr.Otto

Thank you for providing the samples. Now I understand the trick behind the Report Designer and Passing the values to it. I have not used any report designers till now. EasyReport is really Easy :D

IF oVRD:nNextRow > oVRD:nPageBreak

I understand that we should write the code to do the necessary things as per our requirement when a PageBreak is reached.
But how is this oVRD:nPageBreak identified ? Do we have to set the PageBreak (When should a PageBreak should occur) or Will EasyReport automatically finds the PageBreak based on the Page Length of the opted PaperSize (A4) of the Report

Dear Mr.James,
There are very few samples on the usage of TReport. Would have been better if we had a small sample showing the power of TReport to print a sample invoice with a regular simple invoice model containing

The Company Name
Company Address

Invoice Details like Invoice No, Invoice Date etc.
Customer Details like Customer Name, Customer Address etc

Column Heading with Lines/Boxes seperating the Columns
Line Items with Lines/Boxes seperating the Columns

Sub Total
Grand Total
Statuatory Declarations etc.

With both of your samples and explanations, now the concepts are getting more clear.

Regards

Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby Otto » Wed May 20, 2009 6:48 am

Hello Mr. Anser,

I am sorry I posted yesterday screenshots from EasyReport where the language was set to German.
You can setup the language of EasyReport-designer.

There are general report settings you can make.


These settings are stored in the file with the extension … . vrd
and the printareas then as … . v01 to … . vn

This is the setting vrd of the screenshot RECHNUNG I posted. You see I use 17 ! PRINTAREAS.
Header, Subheader, Folio, Items, invoice endtext and so on.

Image

You don’t have to care about the vrd-files. Only if you want you can manipulate the file directly with an editor.
Sometimes this is much faster.

Code: Select all  Expand view

[General]
EditProperties=1
EditAreaProperties=1
EditLanguage=1
DeveloperMode=1
InsertMode=1
Title=Rechnung
Measure=1
GridWidth=1
GridHeight=1
ShowGrid=0
TopMargin=26
LeftMargin=11
Expressions=1
GeneralExpressions=EasyReport General.dbf
UserExpressions=EasyReport User.dbf
DataExpressions=EasyReport Database.dbf
PageBreak=240
Orientation=1
ShowInfoMsg=1
PrintIDs=1
Group=Order
AreaFilesDir=.\xVRD\
PaperSize=9
PaperWidth=0
PaperHeight=0

[Fonts]
// maximal 20
// Parameters: name| nWidth| nHeight| bold| italic| underline| strikeout| escapement
1=Arial| 0| -12| 0| 0| 0| 0| 0
2=Arial| 0| -20| 1| 0| 0| 0| 0
3=Arial| 0| -9| 0| 0| 0| 0| 0
4=Arial| 5| -12| 0| 1| 1| 0| 0
5=Arial| 0| -18| 1| 1| 1| 0| 200
6=Arial| 0| -7| 0| 0| 0| 0| 0
7=Arial| 0| -12| 0| 0| 0| 0| 0
8=Arial| 0| -12| 0| 0| 0| 0| 2700
9=Arial| 0| -12| 0| 0| 0| 0| 900
10=Arial| 0| -14| 1| 0| 0| 0| 0
11=Arial| 0| -8| 0| 0| 0| 0| 0

[Colors]
// Parameters: RGB - A numeric (RGB) value corresponding to the red| green
//                   and blue values specified.
1=0
2=16777215
3=0
4=4227072
5=8421376
6=65535
7=13500148
8=16250871
9=8355711
11=0


[Infos]
Author=Mag. Otto Atzwanger
Company=Atzwanger Tourismussoftware
Comment=Rechnung
Revision=1996
SaveDate=20.05.2009
SaveTime=08:30:47
[Areas]
1=rechnung.v01
2=rechnung.v02
3=rechnung.v03
4=rechnung.v04
5=rechnung.v05
6=rechnung.v06
7=rechnung.v07
8=rechnung.v08
9=rechnung.v09
10=rechnung.v10
11=rechnung.v11
12=rechnung.v12
13=rechnung.v13
14=rechnung.v14
15=rechnung.v15
16=rechnung.v16
17=rechnung.v17

 


Best regards,
Otto





Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6088
Joined: Fri Oct 07, 2005 7:07 pm

Re: Best way to print Invoice ?

Postby anserkk » Wed May 20, 2009 2:49 pm

Dear Mr.Otto,

Thank you. I shall try and test.

Regards

Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby max » Thu May 21, 2009 6:54 am

Anserkk,
I am very much new to printing using FWH. I think more than you!
I think (like you) that in the beginning, the simplest way is not to use 3rd party applications.
There are many other problems in my mind that make confusion.
And how printing better from my FWH applications in this moment is not the most important problem in this moment!
I have to solve first HOW PRINTING. Only after, i will spend my time for doing it better.
So, for me the better thing is to consider 3rd party applications for printing in a second time.
As first step, for printing i'm using the syntax:
PRINT oPRN NAME "Title"
PAGE
oprn:say() && for printing text
oprn:line() && for printing line
ENDPAGE
ENDPRINT
and it works fine.
Now after reading your post, i'm trying the free library TCLIPPRT from Manuel Mercado, and i think is good because it give me the possibility not change my mind and my way of developing.

To Manuel:
your library is simple so is great ! One question: how can i use different fonts in the same print? Is it possible or not?
I haven't find this issue in the example..

Thanks

Max
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Best way to print Invoice ?

Postby anserkk » Thu May 21, 2009 7:36 am

Hi Mr.Max,

Both of us are on the same route :D

From where can I get the Class TCLIPPRT so that I can also test printing using the class

oprn:line() && for printing line

What about printing a vertical line ? Boxes

PRINT oPRN NAME "Title"
PAGE
oprn:say() && for printing text
oprn:line() && for printing line
ENDPAGE
ENDPRINT


I am looking for more samples on printing like the way quoted above. At least a simple sample showing how to print a simple Invoice as I have already said above in this thread

Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby anserkk » Thu May 21, 2009 8:28 am

Hi Mr.Max,

I got the Class TCLIPPRT after searching the forum. I shall test.

Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby max » Thu May 21, 2009 8:31 am

Anser,
anserkk wrote:From where can I get the Class TCLIPPRT so that I can also test printing using the class


Look in the bottom of the first page of your post: Manuel Mercado directly suggest you tu use TCLIPPRT class and wrote you the link . Only thanks to this post now i know that TCLIPPRT exist, so I'm trying this free class for the first time.
However, oprn:line() and oprn:say() is included by default to standard class TPRINTER.
Class TCLIPPRT is another way for simple printing like your invoice example.

What about printing a vertical line ? Boxes


With oprn:line() you can draw vertical lines and boxes too.
Look at TESTPRN2.PRG in your \FWH\SAMPLES and to help file FWCLASS in \FWH\MANUAL .

Max
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Best way to print Invoice ?

Postby Otto » Thu May 21, 2009 8:53 am

Hello mr. Anser,

I feel you are not convinced.
Here you have your example with the help of EasyReport.
Design of the invoice you can change with the designer like in WORD.

Best regards,
Otto
Code: Select all  Expand view

#include "FiveWin.ch"
#INCLUDE "VRD.CH"

static oWnd

//----------------------------------------------------------------------------//

function Main()

   local oBar
   local oPopup

   DEFINE WINDOW oWnd FROM 1, 10 TO 20, 60 ;
      TITLE "Printing an invoice"
   @ 3,10 BUTTON "invoice" size 100,50  OF oWnd ACTION PrintInvoice()

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//

function PrintInvoice()
   local oVRD
   local company  :=    "ABC Company"
   local add1     :=    "Address 12/123445"
   local add2     :=    "That Street"
   local Pincode  :=    "Pincode : 999999"
   local InvoiceNo :=   "23"
   local InvoiceDt :=   "15-05-2009"
   local I := 0
   local nTotal := 0
   local aArr  := {;
      {"1" ,  "Item 1", "3",  "10.00" , " 4%" ,   "0.40",   "10.40" },;    
      {"2" ,  "Item 2", "5",  "15.00" , " 4%" ,   "0.40",   "15.40" },;    
      {"3" ,  "Item 3", "2",  "20.00" , " 4%" ,   "0.40",   "20.40"  } }  


   EASYREPORT oVRD NAME ".\xVRD\invoice.vrd"

   PRINTAREA 1 OF oVRD;
         ITEMIDS    { 101,102,103,104,105,106 } ;
         ITEMVALUES { company,add1,add2,Pincode,InvoiceNo,InvoiceDt }
   
   PRINTAREA 2 OF oVRD
   FOR I = 1 to len(aArr)
        IF oVRD:nNextRow > oVRD:nPageBreak
            PAGEBREAK oVRD
        endif
      nTotal := nTotal + VAL(aArr[I,7])
      PRINTAREA 3 OF oVRD ;    
         ITEMIDS    { 101,102,103,104,105,106,107 } ;
         ITEMVALUES { aArr[I,1],aArr[I,2],aArr[I,3],aArr[I,4],aArr[I,5],aArr[I,6],aArr[I,7] }
   next
   PRINTAREA 4 OF oVRD ;    
      ITEMIDS    { 107 } ;
      ITEMVALUES { str(nTotal) }

   oVRD:End()

return nil
 


Image


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6088
Joined: Fri Oct 07, 2005 7:07 pm

Re: Best way to print Invoice ?

Postby Otto » Thu May 21, 2009 9:02 am

Mr. Anser,

and if your client wants another design:


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6088
Joined: Fri Oct 07, 2005 7:07 pm

Re: Best way to print Invoice ?

Postby anserkk » Thu May 21, 2009 10:09 am

Dear Mr.Otto,

Thank you very much for the Sample.

I feel you are not convinced.

I am convinced with EasyReport. I understand that it is very easy to create report using any Visual Report Designer and EasyReport is a very simple and elegant tool and as it is developed using FiveWin, the developers of EasyReport definitely knows the xBase way.

In windows environment it is difficult to design a report without a visual report designer. It is difficult to calculate the printing coordinates especially when using different fonts.

The latest sample which you have provided is very useful to me. The ID nos 107,108 etc are they generated automatically while you design the report ?. Do you modify these id numbers ? When I tried I was getting values -1, etc

The only thing bothering me is the external dependencies. I understand that while distributing the application there will be few EasyReport DLL files + For each report there will be a .vrd file and for each PrintArea in that particular report there will be .V01 .V02 ... files. One of the threats faced by me here is that I get calls from my clients saying that files are missing, due to accidental deletion of files. The same problem exists when using DBF files too. But for my new applications I am using MySQL and thus eliminated missing DBF files. One advantage of using the FWH's builtin classes is that I reduce the chances of this problem, because everything is bundled inside the FWH application exe. Of course the strain and time taken to write the report is too much and I am also exploring other possibilities to simplify the report generation.

Regards

Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Best way to print Invoice ?

Postby anserkk » Thu May 21, 2009 10:13 am

Dear MR.Max,

Look in the bottom of the first page of your post: Manuel Mercado directly suggest you tu use TCLIPPRT class and wrote you the link .

I think I was blind. I don't know how I missed Mr.Manuel's post in this thread.
When I tried the sample which cam along with class, I am getting a Linking error about a missing AlphaBlend Brushes function in FiveHc.Lib

Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests