Completing the Installation

Completing the Installation

Back   Posted on 1 september 2018 / Updated on 20 january 2020
Reading time 4 minutes

Automatic Importer

Before reading this article make sure you completed the preliminary steps described here.

When you install Billing Extension, it respects your existing configuration for WHMCS and EU VAT Addon (if in use). Moreover the module creates the first Company Profile based on your current details (Company Name, Pay To Text, Country). That being said, we recommend to double-check all settings to make sure that everything has been properly configured.

Customizations

Now that you have successfully installed Billing Extension, take your time to deepen your understanding of its features and options. All settings can be found in Addons > Billing Extension > Settings divided in multiple tabs:
  • Company Profile
  • Tax Rules
  • Late Fees
  • Settings
The content of the first 3 tabs is self-explanatory. In the last one, Settings, you find a huge amount of options that allows you to customize the module to match your specific needs. All options are complete with descriptions and when needed fully documented. If there's something unclear about a particular option, just click on the information icon. You'll be redirected on the relative article of our documentation.

Incorrect Invoice Detection

WHMCS doesn't distinguish between proforma and invoices and doesn't even support credit notes. On the contrary Billing Extension marks every document as Proforma, Invoice or Credit Note. This difference might raise a problem. In fact there's no intelligibile way to detect document type when you install the module for the first time.

Of course on your system can easily say the difference between a proforma and an invoice by simply looking at invoice numbers. Probably you're using a prefix like "F", "I" or "INV" to mark invoices but the module cannot know what prefix or suffix every company is using therefore it will try to guess this information based on various criteria.

That being said, Billing Extension could incorrectly mistake an invoice for a proforma. It happens especially with Unpaid documents. For this reason when you complete the installation we enable a feature that allows you to manually fix such mistakes. To correct an invoice open Client Details tab from Invoice View. Here you'll find the orange button Snapshot as Invoice that will automatically fix the document type.



This feature can also be used massively from Addons > Billing Extension > Invoices (preview). If you think there are no documents to correct, you can disable it from Addons > Billing Extension > Settings > Utilities > Incorrect Invoice Detection.

Integration Code

Most parts of the integration with WHMCS are handled by Billing Extension automatically. However there few small changes that need to be made manually by adding some snippets of code in templates/{YOUR_TEMPLATE}/invoicepdf.tpl. Open this file with a text editor and place the following code right after the php opening tag:
# Billing Extension - Integration Code
if(file_exists(ROOTDIR . '/modules/addons/BillingExtension/core/autoload.php'))
{
    require_once(ROOTDIR . '/modules/addons/BillingExtension/core/autoload.php');
    $hook = new BillingExtension\BillingExtension_Admin\Hook;
    $hook = $hook->Integration($tplvars, 'pdf');
    foreach($hook as $k=>$v) $$k = $v;
}
Now look for the following section:
$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
Replace it with this code:
if ($companylogo) {
    $pdf->Image($companylogo, 15, 25, 75); # Billing Extension - Company Logo
}
else {
    $pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
}
Lastly copy this snippet right before # Notes section:
# Billing Extension - Footer Text
if ($footertext) {
    $pdf->Ln(5);
    $pdf->SetFont($pdfFont, '', 6);
    $pdf->MultiCell(140, 5, $footertext, 0, 'C', '', 1, 35, '', true);
}
Once finished save changes and upload it into your WHMCS. Don't forget to deactivate EU VAT Addon if in use.

Header and Footer Integration

In version 7.0 and above of WHMCS it is possible to have header and/or footer automatically repeat on every page of a multi-page PDF invoice (for more details refer to this article). If this feature is in use, the integration is slightly different. First off begin complete the basic integration then place the code provided below in invoicepdfheader.tpl and/or invoicepdffooter.tpl files right after php opening tags.
# Billing Extension - Integration Code
if(file_exists(ROOTDIR . '/modules/addons/BillingExtension/core/autoload.php'))
{
require_once(ROOTDIR . '/modules/addons/BillingExtension/core/autoload.php');
$hook = new BillingExtension\BillingExtension_Admin\Hook;
$hook = $hook->Integration($tplvars, 'pdf');
foreach($hook as $k=>$v) $$k = $v;
}

If invoicepdffooter.pdf is in use and you want to show footer text on every page, begin by moving the snippet in question from invoicepdf.tpl to invoicepdffooter.pdf. Once done, change Ln(5) to Ln(-5) to avoid footer text being too close to bottom margin like we did in the snippet below.

# Billing Extension - Footer Text
if ($footertext) {
$pdf->Ln(-5);
$pdf->SetFont($pdfFont, '', 6);
$pdf->MultiCell(140, 5, $footertext, 0, 'C', '', 1, 35, '', true);
}

The same principle applies to invoicepdfheader.tpl and all other sections of PDF invoice. For example if you want the logo to appear in the header, move it from invoicepdf.tpl to invoicepdfheader.tpl.

Payment Details

You may want to display additional information on Invoice PDF based on the selected Paymenth Method. For example here is how you can display bank details on PDF. Place the following code right after # Clients Details section.

// Billing Extension - Payment Method Details
if (in_array($status, array('Unpaid', 'Draft', 'Payment Pending')) AND $paymentmethod == 'banktransfer')
{
	$ref_height = $pdf->GetY() - $addressypos;
	$this_text = "Bank: Test Ltd.\nIBAN: IT005500\nPay to: Mark White\nReference: " . $invoicenum;
	$this_width = 80;
	$this_height = $pdf->getStringHeight($this_width, $this_text, false, true, '', 0);
	if ($this_height < $ref_height): $this_height = $ref_height; endif;
	$pdf->SetFillColor(255);
	$pdf->MultiCell($this_width, $this_height, $this_text, 0, 'R', true, 1, 116, $addressypos, true, 0, false, true, 0, 'T', true);
	$pdf->lastPage();
	$pdf->Ln(5);
}

You can preview how it looks here. Please keep in mind that the code we've just provided is just an example that has been tested on the default invoicepdf.tpl file of WHMCS. You may need to change it depending on your template.

Comments (0)

Speak Your Mind Cancel Reply