Cartkit icon indicating copy to clipboard operation
Cartkit copied to clipboard

Wrong calculation of net price from TTC

Open texnixe opened this issue 6 years ago • 1 comments

Maybe I'm getting this all wrong, but there seems to be something wrong with the ht, tax etc. calculations:

Calculation of net price from ttc should be:

function cart_ht($ttc, $vat) {
	$ht = $ttc / (1 + $vat/100);
	return $ht;
}

Calculation of vat value to be added to a net price (this is probably what you need in your plugin if tax is set to true, but then the product prices should be net prices, because this value is added when I click the Paypal submit button; even though the text says "TVA incluse"):

function cart_vat($net, $vat) {
	$tax = $net * $vat/100;
	return $tax;
}

Calculate amount of tax included in a given TTC price:

function cart_vat_incl ($ttc, $vat) {
  $ht = $ttc / (1 + $vat/100);
  $tax_incl = $ttc - $ht;
  return $tax_incl;
}

texnixe avatar Sep 24 '17 13:09 texnixe