Historical Currency Rates for Invoice Snapshot in WHMCS

Indietro   Pubblicato 12 ottobre 2020 / Aggiornato 24 gennaio 2021
Tempo di lettura 2 minuti

The Importance of Historical Currency Rates in WHMCS

As discussed in difference invoice and credit note, both types of documents have fiscal value meaning that it is important to fix invoice details (eg. client's name, address etc.) to that in use at the time they were issued.

Probably you know that WHMCS integrates invoice snapshots but this implementation is very limited. WHMCS in fact doesn't include various details such as company details and VIES. Most importantly, WHMCS doesn't keep track of exchange rates.

Keeping historical exchange rate data on a system that uses multiple currencies is essential. Your accountant needs to record gains from foreing exchange rates using the rate in effect on the date on which the invoice is issued.

It might not seem like much, but let us show you a practical example. For simplicity reasons we assume that we're earning 5.000 USD per month.

Year 2020 EUR / USD rate 5.000 USD / monthly
Jannuary 0.893179 4.465 €
February 0.901489 4.507 €
March 0.907082 4.535 €
April 0.914483 4.572 €
May 0.909281 4.546 €
June 0.899054 4.495 €
July 0.888097 4.440 €
August 0.849303 4.246 €
September 0.837048 4.185 €
October 0.850934 4.254 €

At the end of the year we earned 50.000 USD equivalent to 44.245 EUR. This is the effective amount we earned.

Now let's see what happens if we ignore daily currency fluctuations and use just one rate backward. Let's use the rate of October. The new amount is 42.546 €. There's a difference of 1.699 €, almost 4% less.

This example clearly shows why historical currency rates in WHMCS are important. Not only it eases the job of your accountant but also lowers the risks of billing mistakes.

Showing Currency Rates on Invoices

First off, Billing Extension keeps track of exchange rates on a daily basis. Please be aware it is not retroactive. Rates are stored starting from the moment the module is installed on your WHMCS. Let's move to the integration.

The module adds an $bx_currencies array to the following invoice files:

  • viewinvoice.tpl - printable version
  • invoicepdf.tpl - PDF

Here's a rapresentation of the array on a WHMCS that uses 3 currencies - click to enlarge.

It provides not only exchange rates but also the actual conversion for every amount of the invoice. That's how we implemented for invoice PDF by simply placing $bx_currency['rate_tosuffixed'] PHP variable in the right place.

But you can also get creative as we show in the following example.

Below we show you two examples with the printable version. The only difference is that instead of PHP variables you need to use Smarty ones. The syntax is a bit different.


Commenti (0)

Dì ciò che pensi Cancella Risposta