VAT logic illogical

There is something that does not seems right with the way the VAT is handled in CS cart:



I’ve checked it on the DEMO site so its not a miss configuration of my site

There is something wrong with the way the VAT is handled in CS cart: I’ve checked it on the DEMO site so its not a miss configuration of my site



IF you have 10% VAT in the default Location (Local Sale) (US in the demo)

and 0% VAT in the other location (export sale)



For a 10$ item that has include VAT ticked



For an LOCAL customer:

Subtotal: $10

VAT (10% included): $1

Total cost: 10$



For a VAT free zone customer

Subtotal: $10

Total cost: 10$



it should display

Total 10$

VAT (10% exempted): - $1 (minus 1€)

Total cost: 9$

Zeke pointed out in the bug traker that it was a feature not a bug, I beg to differ:





Thank you Zeke for explaining how CS cart Work, but unfortunately this is Broken Unfonctional at least for European User. let explain in details.



Unlike in the USA In Europe it is mandatory to display price including VAT (if you sale item to non buisness customer) , it is also mandatory to express the VAT in the Total.

In other word if I display a book for 10€ or 10£ it means including VAT and on the global invoice I have to state including x % vat



as long as you do business with European end user CS cart way of processing VAT is fine, but the VAT logic of CA Cart is broken if you start to do business with registered company within Europe not from your country or if you have Customer From outside Europe.





bare with me that YOU have to have “price includes tax” ON , and the way CS cart work

TVA exemption on the customer option or 0% taxe wont give you the proper number





I did not have a look at the chekout code but I guess it should no be to complicated to have CS cart compute Total cost the right way ?



I also would like to point out that this issue has been pointed out before me



Kind regards

I have been looking for a wait to fix this but my knowledge of the language and teh system is too limited.





The main problem is that from what I read in the code CS cart is aware of one of the VAT% the relative one , and we have to be able to access the “default one”.



I dont know if you guys follow me … but from what I saw in the template CS cart call the VAT% if the % is 0 great he has a 0 and on the other hand the displayed price 10€ , CS cart can tell if the 10€ is with ot without VAT but cant do anything about it as he doesn’t know what was the default VAT%



If we can call for default VAT the fix is easy if we can not



I thought of a Quick and dirty Work around:

Define a Discount that you will call “taxe exemption VAT free” give this discount your local VAT.

on the check out have something like: if VAT = 0 or if User is taxe exempted apply discount “taxe exemption VAT free”

My Investigation, I think something need to be edited in fn.cart.php

```php // Get all rates for specific tax

//

function fn_get_tax_rates($tax_id, $destination_id = 0)

{

if (empty($tax_id)) {

return false;

}

return db_get_array(“SELECT * FROM ?:tax_rates WHERE tax_id = ?i AND destination_id = ?i”, $tax_id, $destination_id);

}



//

// Get selected taxes

//

function fn_get_set_taxes($taxes_set)

{

if (empty($taxes_set)) {

return false;

}



return db_get_hash_array(“SELECT tax_id, address_type, priority, price_includes_tax, regnumber FROM ?:taxes WHERE tax_id IN (?n) AND status = ‘A’ ORDER BY priority”, ‘tax_id’, explode(‘,’, $taxes_set));

}



function fn_add_exclude_products(&$cart, &$auth)

{

$subtotal = 0;

$pure_subtotal = 0;



if (isset($cart[‘products’]) && is_array($cart[‘products’])) {

foreach($cart[‘products’] as $cart_id => $product) {

if (isset($product[‘extra’][‘exclude_from_calculate’])) {

if (empty($cart[‘order_id’])) {

unset($cart[‘products’][$cart_id]);

}

} else {

$product_subtotal = fn_apply_options_modifiers($product[‘product_options’], $product[‘price’], ‘P’) * $product[‘amount’];

$pure_subtotal += $product_subtotal;

$subtotal += $product_subtotal - ((isset($product[‘discount’])) ? $product[‘discount’] : 0);

}

}

}



fn_set_hook(‘exclude_products_from_calculation’, $cart, $auth, $pure_subtotal, $subtotal);



}

// Calculate taxes

if ($cart[‘subtotal’] > 0 && $calculate_taxes == true && $auth[‘tax_exempt’] != ‘Y’) {

fn_calculate_taxes($cart, $cart_products, $shipping_rates, $auth);

} elseif ($cart[‘stored_taxes’] != ‘Y’) {

$cart[‘taxes’] = array();

}



$cart[‘subtotal’] = $cart[‘display_subtotal’] = 0;



fn_update_cart_data($cart, $cart_products);



// Calculate totals

foreach ($cart_products as $k => $v) {

$_tax = (!empty($cart_products[$k][‘tax_summary’]) ? ($cart_products[$k][‘tax_summary’][‘added’] / $v[‘amount’]) : 0);

$cart_products[$k][‘display_price’] = $cart_products[$k][‘price’] + (Registry::get(‘settings.Appearance.cart_prices_w_taxes’) == ‘Y’ ? $_tax : 0);

$cart_products[$k][‘subtotal’] = $cart_products[$k][‘price’] * $v[‘amount’];



$cart_products[$k][‘display_subtotal’] = $cart_products[$k][‘display_price’] * $v[‘amount’];



$cart[‘subtotal’] += $cart_products[$k][‘subtotal’];

$cart[‘display_subtotal’] += $cart_products[$k][‘display_subtotal’];

$cart[‘products’][$k][‘display_price’] = $cart_products[$k][‘display_price’];



$cart[‘tax_subtotal’] += (!empty($cart_products[$k][‘tax_summary’]) ? ($cart_products[$k][‘tax_summary’][‘added’]) : 0);



$cart[‘total’] += ($cart_products[$k][‘price’] - 0) * $v[‘amount’];



if (!empty($v[‘discount’])) {

$cart[‘discount’] += $v[‘discount’] * $v[‘amount’];

}

}



$cart[‘subtotal’] = fn_format_price($cart[‘subtotal’]);

$cart[‘display_subtotal’] = fn_format_price($cart[‘display_subtotal’]);



$cart[‘total’] += $cart[‘tax_subtotal’];



$cart[‘total’] = fn_format_price($cart[‘total’] + $cart[‘shipping_cost’]);



if (!empty($cart[‘subtotal_discount’])) {

$cart[‘total’] -= ($cart[‘subtotal_discount’] < $cart[‘total’]) ? $cart[‘subtotal_discount’] : $cart[‘total’];

}

}



fn_set_hook(‘calculate_cart’, $cart, $cart_products, $auth, $calculate_shipping, $calculate_taxes, $apply_cart_promotions);



$cart[‘recalculate’] = false;

return array (

$cart_products,

$shipping_rates

);

}



function fn_cart_is_empty($cart)

{

$result = true;



if (!empty($cart[‘products’])) {

foreach ($cart[‘products’] as $v) {

if (!isset($v[‘extra’][‘exclude_from_calculate’]) && empty($v[‘extra’][‘parent’])) {

$result = false;

break;

}

}

}



if ($result == true) {

fn_set_hook(‘is_cart_empty’, $cart, $result);

}



return $result;

}



/**

  • Calculate total cost of products in cart

    *
  • @param array $cart cart information
  • @param array $cart_products cart products
  • @param char $type S - cost for shipping, A - all, C - all, exception excluded from calculation
  • @return int products cost

    */

    function fn_get_products_cost($cart, $cart_products, $type = ‘S’)

    {

    $cost = 0;



    if (is_array($cart_products)) {

    foreach ($cart_products as $k => $v) {

    if ($type == ‘S’) {

    if (($v[‘is_edp’] == ‘Y’ && $v[‘edp_shipping’] != ‘Y’) || $v[‘free_shipping’] == ‘Y’ || fn_exclude_from_shipping_calculate($cart[‘products’][$k])) {

    continue;

    }

    } elseif ($type == ‘C’) {

    if (isset($v[‘exclude_from_calculate’])) {

    continue;

    }

    }

    if (isset($v[‘price’])) {

    $cost += $v[‘subtotal’];

    }

    }

    }



    return $cost;

    }

    ```

we have function that allow to get all rate for specific tax rate



what we need in the calculation process is something like this



2 modifications:





1 ) Mod to the line that process/ display " # VAT ( “GLOBAL DEFAULT tx%” included): n "



If client is taxe empted of of taxe base on shiphing location = 0

then display :

VAT (“tx%” [COLOR=“Red”]exempted[/COLOR]): nvat "

the trick is that that the processor must use GLOBAL DEFAULtx% not the taxe base on location





2) Mod to the line that process/ display " Total Cost "

If client is taxe empted of of taxe base on shiphing = 0

Processor need to do: total cost = total cost - n (n being n vat calculated above)









Some how i think it will simplifie the payment calculator processor

I have to agree: for a site where VAT is applicable for users in some locations and not in others, the system makes little sense. Short of hacking the source code, I’m unable to see any way of making it work as required.



My client has an existing site which sells items according to an established price list. For example, an item might cost $39.99, of which 15% is UK VAT. When that item is purchased by someone outside the EU, that 15% needs to be discounted from the price of the item; currently, the system merely sells it at the same price, without displaying the tax.



As it stands, the only way of doing it would be to unselect the “prices include tax” option, then calculate and add all of the prices without the VAT. But what happens when the VAT rate changes, as it’s about to in the UK? As with many businesses, my client will absorb the increase himself in order to keep his prices the same…but he would need to enter them all again!



Does anyone have any suggestions for how to tackle this problem?



Many thanks,



ian.

Also i´ved the same issue problems. I come from germany, and in germany are the laws with showing the Vat in the Shop nea by the prices very hard. Therefore i´ve made changings with the Support team on my shop. Now i put the prices with “net prices” and the shop calculate the Vat (tax) for the different countrys byself. Also in europe 19% tax and outside from europe the customers see the prices without tax. So we do not loose anything.


[quote]

But what happens when the VAT rate changes, as it’s about to in the UK?

[/quote]

then you can change it global in cs-cart admin. I think there isnt a problem.

Does anyone have any help in relation to getting this sorted out. I am racking my brains how to get this working as I also require everyone outside of Europe to see all of my items less the 17.5% TAX currently listed on all items. Meaning that for checkout I would need to take 14.89% from my sales at checkout for countries with 0% Tax such as the US, Hong Kong etc etc. Do I HAVE to re edit all of my prices to be NETT?



Anyhelp would be greatly appreciated.