Hi Everyone.

A customer of ours uses InvoicePlane as their self hosted invoicing system, and although the default template was great, they required it to be customised in PHP to fit the Australian Invoicing Standards.

If you are new to customising templates in InvoicePlane, here is a link that explains the process and where they can be found. You will need to have access to the the file directory of your hosting system.

https://wiki.invoiceplane.com/en/1.0/templates/using-templates

 
We created a template for our customer which we thought we would share with you all

Firstly you will also need to create some custom fields for the extra information you want to display on the invoice.

custom_fields

 

The code is below. You can either replace the default file (InvoicePlane.php) or create a new PHP file and select it as your default template, using the instructions in the link above.

The below code shows the GST as one big sum at the end. Make sure to name the Tax Rate as “GST”, as the code checks if an invoice item with that exact name exists, and if it does, show a message at the end, stating whether or not there is GST included, you can also change this part for your own countries Tax Type.

<html lang="<?php echo lang('cldr'); ?>">
<head>
    <meta charset="utf-8">
    <title><?php echo lang('invoice'); ?></title>
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/templates.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/default/css/custom-pdf.css">
</head>
<body>
<header class="clearfix">
    <div id="logo">
        <?php echo invoice_logo_pdf(); ?>
    </div>
    <div id="client">
        <div>
            <b><?php echo $invoice->client_name; ?></b>
        </div>
        <?php 
		
		if ($invoice->client_custom_contact_name) {
            echo '<div>Name: ' . $invoice->client_custom_contact_name . '</div>';		
		}		
		
		if ($invoice->client_email) {
            echo '<div>Email: ' . $invoice->client_email . '</div>';		
		}
		if ($invoice->client_custom_abn) {
            echo '<div>ABN: ' . $invoice->client_custom_abn . '</div>';		
		}
		echo "<br>";
		
		if ($invoice->client_vat_id) {
            echo '<div>' . lang('vat_id_short') . ': ' . $invoice->client_vat_id . '</div>';
        }
        if ($invoice->client_tax_code) {
            echo '<div>' . lang('tax_code_short') . ': ' . $invoice->client_tax_code . '</div>';
        }
        if ($invoice->client_address_1) {
            echo '<div>' . $invoice->client_address_1 . '</div>';
        }
        if ($invoice->client_address_2) {
            echo '<div>' . $invoice->client_address_2 . '</div>';
        }
		 if ($invoice->client_city) {
            echo '<div>' . $invoice->client_city . '</div>';
        }
        if ($invoice->client_state && $invoice->client_zip) {
            echo '<div>' . $invoice->client_state . ' ' . $invoice->client_zip . '</div>';
        } else {
            if ($invoice->client_state) {
                echo '<div>' . $invoice->client_state . '</div>';
            }
            if ($invoice->client_zip) {
                echo '<div>' . $invoice->client_zip . '</div>';
            }
        }
       
        if ($invoice->client_country) {
            echo '<div>' . get_country_name(lang('cldr'), $invoice->client_country) . '</div>';
        }
        echo '<br/>';
        if ($invoice->client_phone) {
            echo '<div>' . lang('phone_abbr') . ': ' . $invoice->client_phone . '</div>';
        } ?>
    </div>
    <div id="company">
        <div><b><?php echo $invoice->user_company; ?></b></div>
        <?php 
		
		if ($invoice->user_vat_id) {
            echo '<div>' . lang('vat_id_short') . ': ' . $invoice->user_vat_id . '</div>';
        }
        if ($invoice->user_tax_code) {
            echo '<div>' . lang('tax_code_short') . ': ' . $invoice->user_tax_code . '</div>';
        }
        if ($invoice->user_address_1) {
            echo '<div>' . $invoice->user_address_1 . '</div>';
        }
        if ($invoice->user_address_2) {
            echo '<div>' . $invoice->user_address_2 . '</div>';
        }
		if ($invoice->user_city) {
            echo '<div>' . $invoice->user_city . '</div>';
        }
        if ($invoice->user_state && $invoice->user_zip) {
            echo '<div>' . $invoice->user_state . ' ' . $invoice->user_zip . '</div>';
        } else {
            if ($invoice->user_state) {
                echo '<div>' . $invoice->user_city . '</div>';
            }
            if ($invoice->user_zip) {
                echo '<div>' . $invoice->user_zip . '</div>';
            }
        }
        
        if ($invoice->user_country) {
            echo '<div>' . get_country_name(lang('cldr'), $invoice->user_country) . '</div>';
        }
        if ($invoice->user_custom_abn) {
            echo '<div>ABN: ' . $invoice->user_custom_abn . '</div>';
        }
        echo '<br/>';
        if ($invoice->user_phone) {
            echo '<div>' . lang('phone_abbr') . ': ' . $invoice->user_phone . '</div>';
        }
        if ($invoice->user_fax) {
            echo '<div>' . lang('fax_abbr') . ': ' . $invoice->user_fax . '</div>';
        }
        ?>
    </div>
</header>
<main>
    <div class="invoice-details clearfix">
        <table>
            <tr>
                <td><?php echo lang('invoice_date') . ':'; ?></td>
                <td><?php echo date_from_mysql($invoice->invoice_date_created, true); ?></td>
            </tr>
            <tr>
                <td><?php echo lang('due_date') . ': '; ?></td>
                <td><?php echo date_from_mysql($invoice->invoice_date_due, true); ?></td>
            </tr>
            <tr>
                <td><?php echo lang('amount_due') . ': '; ?></td>
                <td><?php echo format_currency($invoice->invoice_balance); ?></td>
            </tr>
            <?php if ($payment_method): ?>
                <tr>
                    <td><?php echo lang('payment_method') . ': '; ?></td>
                    <td><?php echo $payment_method->payment_method_name; ?></td>
                </tr>
            <?php endif; ?>
        </table>
    </div>
    <h1 class="invoice-title"><?php echo 'Tax Invoice' . ' ' . $invoice->invoice_number; ?></h1>
	<td><?php echo '<b>Order Details:</b> ' . $invoice->invoice_custom_order_details; ?></td>
	<td><?php  echo '<br/>';  ?></td>
    <table class="item-table">
        <thead>
        <tr>
            <th class="item-name"><?php echo lang('item'); ?></th>
            <th class="item-desc"><?php echo lang('description'); ?></th>
            <th class="item-amount text-right"><?php echo lang('qty'); ?></th>
            <th class="text-right"><?php echo 'Unit Price'; ?></th>
            <?php if ($show_discounts) : ?>
                <th class="item-discount text-right"><?php echo lang('discount'); ?></th>
            <?php endif; ?>
            <th class="item-total text-right"><?php echo lang('total'); ?></th>
        </tr>
        </thead>
        <tbody>
        <?php
        foreach ($items as $item) { ?>
            <tr>
                <td><?php echo $item->item_name; ?></td>
                <td><?php echo nl2br($item->item_description); ?></td>
                <td class="text-right">
                    <?php echo floor(format_amount($item->item_quantity)); ?>
                </td>
                <td class="text-right">
                    <?php echo format_currency($item->item_price); ?>
                </td>
 
                <?php if ($show_discounts) : ?>
                    <td class="text-right">
                        <?php echo format_currency($item->item_discount); ?>
                    </td>
                <?php endif; ?>
                <td class="text-right">
                    <?php echo format_currency($item->item_total); ?>
                </td>
            </tr>
        <?php } ?>
        </tbody>
        <tbody class="invoice-sums">
  
<?php $display_GST = 0; ?>
<?php foreach ($invoice_tax_rates as $invoice_tax_rate) : ?>
           
<?php  if ($invoice_tax_rate->invoice_tax_rate_name == 'GST') { ?>
        <?php $display_GST = 1; ?>
<?php }  ?>
<tr>
                  <td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
                    <?php echo 'Tax'.': '.$invoice_tax_rate->invoice_tax_rate_name . ' (' . $invoice_tax_rate->invoice_tax_rate_percent . '%)'; ?>
                </td>
                <td class="text-right">
                    <?php echo format_currency($invoice_tax_rate->invoice_tax_rate_amount); ?>
                </td>
            </tr>
        <?php endforeach ?>
		
<?php 
// YEU Display percentage and amount of the discount
if ($invoice->invoice_discount_percent != floatval(0)) { ?>
    <tr>
         <td <?php echo($show_discounts ? 'colspan="3"' : 'colspan="2"'); ?> class="text-right">
        <?php $display_discount_percent = ($invoice->invoice_discount_percent); ?>
        <td colspan="2" class="text-right"><?php echo lang('discount') . ' ' . $display_discount_percent; ?>%</td>
        <?php $get_subtotal = ($invoice->invoice_item_subtotal); ?>
        <?php $display_discount_amount = round(($display_discount_percent / 100) * $get_subtotal, 2); ?>
        <td class="text-right"><?php echo format_currency(-$display_discount_amount); ?></td>
    </tr>
<?php } elseif ($invoice->invoice_discount_amount != 0 ) { ?>
    <tr>
       <td <?php echo($show_discounts ? 'colspan="3"' : 'colspan="2"'); ?> class="text-right">
        <?php $display_discount_amount = ($invoice->invoice_discount_amount); ?>
        <?php $get_subtotal = ($invoice->invoice_item_subtotal); ?>
        <?php $display_discount_percent = round(($display_discount_amount / $get_subtotal) * 100,2); ?>
        <td colspan="2" class="text-right"><?php echo lang('discount') . ' ' . $display_discount_percent; ?>%</td>
        <td class="text-right"><?php echo format_currency(-$display_discount_amount); ?> </td>
    </tr>
<?php } ?>
        <tr>
                  <td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
                <b><?php echo lang('total'); ?></b>
            </td>
            <td class="text-right">
                <b><?php echo format_currency($invoice->invoice_total); ?></b>
            </td>
        </tr>
        <tr>
                  <td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
                <?php echo lang('paid'); ?>
            </td>
            <td class="text-right">
                <?php echo format_currency($invoice->invoice_paid); ?>
            </td>
        </tr>
        <tr>
                  <td <?php echo($show_discounts ? 'colspan="5"' : 'colspan="4"'); ?> class="text-right">
                <b><?php echo lang('balance'); ?></b>
            </td>
            <td class="text-right">
                <b><?php echo format_currency($invoice->invoice_balance); ?></b>
            </td>
        </tr>
        </tbody>
    </table>
<?php  if ($display_GST == 1) { ?>    
<?php echo '<div style="text-align:right"> '.'<b>'.('The total price includes GST').'<b>'.'</div>'  ?></b>
<?php } else { ?>
<?php echo '<div style="text-align:right"> '.'<b>'.('The total price does not include GST').'<b>'.'</div>'  ?></b>
<?php } ?>
<?php echo "<br>" ?>
</main>
<footer>
    <?php if ($invoice->invoice_terms) : ?>
        <div class="notes">
  <b><?php echo('Payment Terms') ?></b><br/>          
            <?php echo nl2br($invoice->invoice_terms); ?>
        </div>
    <?php endif; ?>
</footer>
</body>
</html>
Share This Via: