By default, the KashFlow PDF Theme generator displays a Line Item “Total” net of the VAT Amount– this is the equivalent of the Line Item Quantity * Rate. However, adding some JavaScript to the bottom of the DOCUMENT.HTML template will allow you to achieve the display of a true Gross Total inclusive of the VAT Amount.
Pre-Face
This solution assumes the following:
- You are customising a PDF Theme based on the “Clean” or “Classic” templates
- You have not included a tbody element before that within of #document-lines
- You only intend on having the Gross Total of Line Items displayed on Quotes, Invoices, and Reminder Letters
The Code
At the very bottom of the DOCUMENT.HTML template of your PDF Theme, outside of the html tag insert:
<script type="text/javascript">
if (document.getElementsByTagName('html')[0].classList.contains('quote')
|| document.getElementsByTagName('html')[0].classList.contains('invoice')
|| document.getElementsByTagName('html')[0].classList.contains('reminderLetter')
) {
var rows = document.getElementById('document-lines').getElementsByTagName('tbody')[0].rows;
for (i = 0, lngth = rows.length; i < lngth; i++) {
try {
rows[i].getElementsByClassName('column-d')[0].innerHTML = (
parseFloat(rows[i].getElementsByClassName('column-d')[0].innerHTML.replace(/,/g , "")) +
parseFloat(rows[i].getElementsByClassName('column-e')[0].innerHTML.replace(/,/g , ""))
).toFixed(2);
} catch(e) {};
};
};
</script>
Disclaimer
This article assumes the reader has knowledge of at least the basic principles of HTML, and provides a single solution though there are many others. This does not advise on general HTML, CSS or JavaScript practises.
The default PDF Themes of your KashFlow account ('Clean', and 'Classic') have protected code thus cannot be edited. You will need to create a new PDF Theme for any changes you wish to make through the HTML/ CSS templates. The basics of setting up a custom PDF Theme may be found here.
Support
If you require assistance with the topic of this article, please feel free to contact KashFlow Support and we will assist you where possible. Most matters of PDF Themes will require us to access your account, so please include the following in your email to us:
- The Username for your KashFlow Bookkeeping account
- Confirmation you have chosen to "Enable Support Access" from the "Help" tab therein
- The name of the PDF Theme you would like changed to include Gross Totals on Line Items