Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Forked from joshfeck/add-GST-to-invoice.php
Last active August 29, 2015 14:14
Show Gist options
  • Save Pebblo/48b2ce8b15b898a2611f to your computer and use it in GitHub Desktop.
Save Pebblo/48b2ce8b15b898a2611f to your computer and use it in GitHub Desktop.
A simple GST line itemizer for the Event Espresso 3 invoice template function file. Works in conjunction with https://gist.github.com/Pebblo/3477fb76d952684fe239
<?php
//* Please do NOT include the above opening php tag
function my_itemised_surcharge( $attendees ){
$options = get_option( 'events_organization_settings' );
$currency = $options['currency_symbol'];
$this->SetFillColor( 239,239,239 );
//var_dump($attendees);
// pull the selected ticket price breakdown from the database
global $org_options;
$total_price_per = $attendees[0][0][2];
//Set the tax percentage rate here
$tax_rate = 7
//Convert tax to decimal and calculate Net Price.
$price_before_gst = $total_price_per / ( ($tax_rate / 100) + 1 );
$gst = $total_price_per - $price_before_gst;
// print unit price w/o surcharge
$this->Cell( 95, 7, __( 'Price per unit excluding GST:','event_espresso'), 0, 0, 'L', true );
$this->Cell( 90, 7, html_entity_decode( $currency, ENT_QUOTES, 'ISO-8859-15' ) . number_format( $price_before_gst,2, '.', '' ), 0, 1, 'C', true );
// print unit surcharge
$this->Cell( 95, 7, __( 'GST per unit:','event_espresso' ), 0, 0, 'L', true );
$this->Cell( 90, 7, html_entity_decode( $currency, ENT_QUOTES, 'ISO-8859-15' ) . number_format( $gst,2, '.', '' ), 0, 1, 'C', true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment