Skip to content

Instantly share code, notes, and snippets.

@GaneshKandu
Created February 4, 2018 16:07
Show Gist options
  • Save GaneshKandu/0955f522d1389359007d54aa1440d496 to your computer and use it in GitHub Desktop.
Save GaneshKandu/0955f522d1389359007d54aa1440d496 to your computer and use it in GitHub Desktop.
GST Calculator Class
include 'gst.php';
//adding gst
$return = gst::add(500,5);
print_r($return);
//removing gst
$return = gst::remove(500,5);
print_r($return);
<?php
/*
GST is an Indirect Tax which has replaced many Indirect Taxes in India. The Goods and Service Tax Act was passed in the Parliament on 29th March 2017. The Act came into effect on 1st July 2017.
*/
class gst{
/**
*
* Cal. add gst
*
* @param int $cost
* @param int $per
* @return array
*
*/
public static function add($cost,$per){
$output = array();
$output['GST_PRICE'] = (($cost*$per)/100);
$output['NET_PRICE'] = $cost + $output['GST_PRICE'];
return $output;
}
/**
*
* Cal. remove gst
*
* @param int $cost
* @param int $per
* @return array
*
*/
public static function remove($cost,$per){
$output = array();
$output['GST_PRICE'] = $cost - ($cost * ( 100 / ( 100 + $per )));
$output['NET_PRICE'] = $cost - $output['GST_PRICE'];
return $output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment