Jump to content

Calculating VAT


x1nick

Recommended Posts

Feel so stupid asking this because its so simple.

 

But having nothing but trouble with it!

 

Basically I can't calculate VAT properly 100% of the time. Every now and again the price will be out by 1p

May not be much, but its incorrect.

 

The code im using

<?php
$price = 68.69;
$vat = 15;

echo round($price * (($vat / 100) + 1), 2);
?>

 

If the price is set at 68.69 or 68.70 you will see the outcome is either 78.99 or 79.01

Making it impossible to get 79.00

 

Is there any way round this?

Link to comment
Share on other sites

I remember when the VAT was lowered from 17.5% to 15%, I was working as a salesman at the time. Customers assumed that every product would then be x amount cheaper, but it just didn't work like that. As we were a electronic goods retailer, prices were calculted using trade + desired markup + vat then normally rounded to the nearest £50. Due to it being rounded the price didn't actually change in many cases, (which obviously customer saw as us robbing them) despite the fact we were not making desired markup in many cases because the nearest £50 was rounding down. Since most prices are displayed inclusive of vat, its quite difficult to change when the VAT value changes. For neatness prices generally are to the closest £1, yet people still expected you to divide the old price by 1.175 then multiply by 1.15.

 

Long story short, for that reason our epos system actually calculated it backwards, you put in how much your charging and it calculated how much of it was VAT. Not entirely relevant I guess but it's a simpler way of handling VAT. In your current method I suspect most people would use ceil so that every part penny rounds up to a penny.

Link to comment
Share on other sites

  • 2 weeks later...

Still can't get this to work!

function calc_vat($value,$vat) {
	$prec = 0.01;
	if (is_numeric($value) && is_numeric($vat)) {
		$value = $value * (($vat / 100) + 1);
		$retval = ceil($value/$prec) * $prec;
	} else{
		$retval = false;
	}
	return $retval;
}

 

Results:

42.6 = 48.99

 

42.61 = 49.01

 

42.62 = 49.02

 

Anyone got any suggestions?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.