Write a Program to Calculate GST Tax in Amount
GST = Goods and Services Tax (In India)
Central Goods & Services Tax (CGST)
State Goods & Services Tax (SGST)
Integrated Goods & Services Tax (IGST)
Formula
GST Included in Amount
GST Amount = Original Cost – (Original Cost * (100 / (100 + GST% ) ) )
Net Price = Original Cost – GST Amount
GST Exculded in Amount
GST Amount = ( Original Cost * GST% ) / 100
Net Price = Original Cost + GST Amount
Program :
<?php function getGstincluded($amount,$percent,$cgst,$sgst){ $gst_amount = $amount-($amount*(100/(100+$percent))); $percentcgst = number_format($gst_amount/2, 2); $percentsgst = number_format($gst_amount/2, 2); $display="<p>"; if($cgst&&$sgst){ $gst = $percentcgst + $percentsgst; $display .= " CGST = ".$percentcgst." SGST = " . $percentsgst; }elseif($cgst){ $gst = $percentcgst; $display .= " CGST = ".$percentcgst; }else{ $gst = $percentsgst; $display .= " SGST = ".$percentsgst; } $withoutgst = number_format($amount - $gst_amount,2); $withgst = number_format($withoutgst + $gst_amount,2); $display .="</p>"; $display .="<p>".$withoutgst . " + " . $gst . " = " . $withgst."</p>"; return $display; } function getGstexcluded($amount,$percent,$cgst,$sgst){ $gst_amount = ($amount*$percent)/100; $amountwithgst = $amount + $gst_amount; $percentcgst = number_format($gst_amount/2, 2); $percentsgst = number_format($gst_amount/2, 2); $display="<p>"; if($cgst&&$cgst){ $gst = $percentcgst + $percentsgst; $display .= " CGST = ".$percentcgst." SGST = " . $percentsgst; }elseif($cgst){ $gst = $percentcgst; $display .= " CGST = ".$percentcgst; }else{ $gst = $percentsgst; $display .= " SGST = ".$percentsgst; } $display .="</p>"; $display .="<p>".$amount . " + " . $gst . " = " . $amountwithgst."</p>"; return $display; } function simplegstincluded($amount,$percent){ $gst_amount = $amount-($amount*(100/(100+$percent))); $percentcgst = number_format($gst_amount/2, 3); $percentsgst = number_format($gst_amount/2, 3); $withoutgst = number_format($amount - $gst_amount,2); $total = number_format($withoutgst+$gst_amount, 2); $display="<p>".$withoutgst." + ".number_format($gst_amount,2)." ( CGST = ".$percentcgst." SGST = " . $percentsgst." ) = " . $total."</p>"; return $display; } function simplegstexcluded($amount,$percent){ $gst_amount = ($amount*$percent)/100; $total = number_format($amount+$gst_amount, 2); $percentcgst = number_format($gst_amount/2, 3); $percentsgst = number_format($gst_amount/2, 3); $display="<p>".$amount." + ".number_format($gst_amount,2)." ( CGST = ".$percentcgst." SGST = " . $percentsgst." ) = " . $total."</p>"; return $display; } echo simplegstincluded(100, 12); echo simplegstexcluded(100, 12); echo "GST Included Already "; echo getGstincluded(100,12,true,true); echo "GST Included After "; echo getGstexcluded(100,12,true,true); ?>
Output:
GST Result 89.28+10.72=100
GST Result 100+12=112
GST Included Already
CGST = 5.36 SGST = 5.36
89.29 + 10.72 = 100.00
GST Included After
CGST = 6.00 SGST = 6.00
100 + 12 = 112
GST Result 100+12=112
GST Included Already
CGST = 5.36 SGST = 5.36
89.29 + 10.72 = 100.00
GST Included After
CGST = 6.00 SGST = 6.00
100 + 12 = 112
Online Calculator :
GST Own Numbers
Demo
(Visited 17,539 times, 4 visits today)
Written by:
this program is not working