Thursday, 29 October 2009 14:07
Wrong Issue Dates on your Invoices
When you create an invoice in vTiger CRM, you can store the issue date, and the due date. So depending on your payment terms, your due date will be 10 days, 15 days, or 30 days after your issue date, for example.
So these dates are safely stored in the CRM database invoice record. However, when you come to print your invoice, by Exporting to PDF, the issue date will be shown as today's date, not the actual issue date you stored.
This is not a problem if you print your invoice on the same day you create it.
However there are some scenarios, where this behaviour will cause annoyance.
- You want to re-print an invoice to file in your own records
- Your customer asks you to re-send the invoice for what ever reason, back-dated or post-dated
- You delayed sending the customer invoice, but now want to reflect the true job completion date
No matter what you store on the invoice, the issue date will be replaced with todays print date. So, at best, your printed records don't match your real CRM data. However, at worst case, it may persuade your customer to pay 30 days after the printed issue date (not by the due date), or even reject the invoice on a technicality because the dates don't match! Which means you would have to re-issue the invoice and wait for another payment cycle.
Fix to Print Correct Invoice Issue Date
Unfortunately this behaviour cannot be changed from the Administrator Settings. It requires a code fix. More CRM plumbing I'm afraid !
Here it is. First we need to find this file on your server:
my_vtiger_install_directory
modules
Invoice
CreatePDF.php
In the CreatePDF.php script file we need to find the code which looks like this:
// **************** BEGIN POPULATE DATA ******************** // populate data if($focus->column_fields["salesorder_id"] != '') $so_name = getSoName($focus->column_fields["salesorder_id"]); else $so_name = ''; $po_name = $focus->column_fields["vtiger_purchaseorder"]; $valid_till = $focus->column_fields["duedate"]; $valid_till = getDisplayDate($valid_till); $bill_street = $focus->column_fields["bill_street"]; $bill_city = $focus->column_fields["bill_city"]; $bill_state = $focus->column_fields["bill_state"]; $bill_code = $focus->column_fields["bill_code"]; $bill_country = $focus->column_fields["bill_country"];
After this code:
$valid_till = $focus->column_fields["duedate"]; $valid_till = getDisplayDate($valid_till);
We need to insert these two lines:
$invoice_date = $focus->column_fields["invoicedate"]; // added to use actual invoice date, not todays date $invoice_date = getDisplayDate($invoice_date); // added to use actual invoice date, not todays date
Next, we need to find this file:
my_vtiger_install_directory
modules
Invoice
pdf_templates
header.php
And replace this code in the header.php script:
// issue date block
$issueBlock=array("80","37");
$pdf->addRecBlock(getDisplayDate(date("Y-m-d")), $app_strings["Issue Date"],$issueBlock);
... with this code, which makes use of the $invoice_date variable we created earlier:
// issue date block
$issueBlock=array("80","37");
// This commented out bit used to insert todays date on invoice. I need actual invoice issue date.
// $pdf->addRecBlock(getDisplayDate(date("Y-m-d")), $app_strings["Issue Date"],$issueBlock);
$pdf->addRecBlock($invoice_date, $app_strings["Issue Date"],$issueBlock); // prints actual invoice issue date.
With these two code changes, your invoices will now print out the correct issue date. I hope this fix proved useful, and if you need to change your vTiger invoices, Business2dot0 can help with your CRM plumbing.
| Next > |
|---|



