[TUTORIAL]Change Invoice Created Date equal to Invoice Paid Date WHMCS

Category : cPanel/WHM

Here is the quick fix to make the WHMCS invoices generated date equal to the payment date without use of any hooks or complex coding.
Kindly note that you need to use Performa invoice option from setting so that taxable invoice is only generated when a user makes a payment.

Steps to make WHMCS paid invoice date equal to the payment date :

      1. We need to edit invoicepdf.tpl file to achieve the same. The file is responsible for all the invoices PDF file generated.
      2. The file can be found at whmcsfolder/templates/{your active template}/invoicepdf.tpl
      3. Find the below code (around line number 64)

$pdf->Cell(0, 6, Lang::trans(‘invoicesdatecreated’) . ‘: ‘ . $datecreated, 0, 1, ‘L’, ‘1’);
$pdf->Cell(0, 6, Lang::trans(‘invoicesdatedue’) . ‘: ‘ . $duedate, 0, 1, ‘L’, ‘1’);

4. We need to replace the above code by the following 6 lines of code :

$pdf->Cell(0, 6, Lang::trans('invoicesdatecreated') . ': ' . $datepaid, 0, 1, 'L', '1');
$pdf->Cell(0, 6, Lang::trans('invoicesdatecreated') . ': ' . $datecreated, 0, 1, 'L', '1');
$pdf->Cell(0, 6, Lang::trans('invoicesdatedue') . ': ' . $duedate, 0, 1, 'L', '1');

5. Save the file and it’s done!

Understanding of the simple code : We have put a condition in the template that if the status of the invoice is paid (kindly note that the invoice pdf is generated after the status of invoice get’s changed to paid upon successful payment) then it will be printing the $datepaid i.e payment date.

But to keep the performa invoice working as it is, we kept the old same code in the else condition.