PDF invoices can be created by KonaKart for a variety of different purposes including:
To send to customers as email attachments in order confirmation emails.
For internal record-keeping - some store owners may wish to save all their invoices in PDF format.
For display and download from both the store front (under the customer's "My Account" page) and the Admin Application. In order to activate the download links, you must set the "Enable" configuration variable in the Configuration >> PDF Configuration section of the Admin App.
By default, no PDF invoices are created by KonaKart. They can be created in a number of different ways:
The application code can be modified to create the PDF invoices typically at the point when an order is confirmed or when payment is received. The methods that need to be modified are getEmailOptions() in CheckoutConfirmationSubmitAction.java (for when an order is confirmed) and sendOrderConfirmationMail() in BaseGatewayAction.java (for when payment is received).
A batch job is provided that can be executed from Quartz (using standard KonaKart job scheduling) that will create invoices for orders that haven't yet had invoices created. This batch job can be modified to suit your particular requirements - for example you may only want invoices to be created when an order reaches a certain order status. Full source code is provided for the batch jobs to enable you to make any modifications required. By default the batch job is not scheduled to execute. To schedule it to run you need to uncomment the cron-expression tag for the CreateInvoicesTrigger in your konakart_jobs.xml Quartz job definition file.
Invoices can be created by calling a "createInvoice()" method from the OrderIntegrationMgr and/or the AdminOrderIntegrationMgr. This call is commented out in the supplied versions of these two order integration managers making it easy to modify to create the invoices at this stage. As in the batch job, it would also be easy to code logic here that only created invoices when the order reached a certain specified order status if that was required.
Invoices can be created "on-the-fly" by calling the GetPDF servlet. This is useful when you don't ever want to create a permanent record of the PDF file on the file system (possibly for Data Protection restrictions). The GetPDF servlet will return the PDF invoice if it already exists or, if it doesn't exist, create the PDF invoice dynamically and then return the contents of this.
By default, KonaKart stores the created invoices in a hierarchical structure on the file system. The directory structure is deep to distribute the files evenly across multiple directories to avoid the possibility of creating too many files in a single directory. The root location is defined in the "PDF_BASE_DIRECTORY" configuration variable. This can be set to any location accessible to the KonaKart code that creates the invoices.
An example PDF invoice filename, on Linux, is: "/home/greg/konakart/pdf/store1/2/2010/3/199-547b759d-735c-48bb-a23d-4cf526be9c3a.pdf"
In turn, the directories used are:
"store1" - the storeId
"2" - 2 is the code for an Invoice (other document types are packing slips (3) and order details (1))
"2010" - the year at the time the invoice was created (YYYY)
"3" - the month at the time the invoice was created (M)
"199-547b759d-735c-48bb-a23d-4cf526be9c3a.pdf" - the filename has the format: orderId + "-" + UUID + ".pdf"