Author Topic: Bug with tax mode: based on shipping address when no shipping address is given  (Read 12547 times)

ozswisssurf

  • Beginner
  • *
  • Posts: 14
Dear virtuemart team,

We have 2 simple business requirements which we’re not able to configure with virtuemart 1.1.4. I saw many threads with similar needs and therefore I’m hoping you can help all of us:

Current tax configuration:
  • Virtual tax: enabled
    Tax mode: based on shipping address – we ship international (excl.tax) and national (incl tax)
    Enable multiple tax rates: disabled
    Shopper group: - default- //  Show Prices including tax?: enabled
    Product weight added
    We are based in Switzerland and have no states, ship national (incl. tax) and international (excl. tax)

1 Business requirement:
Product prices should be shown as gross prices (incl. local tax) with the additional text “(including XX% tax)” for not logged in users. e.g. for Switzerland/ CHE (store.country):

CHF 209.00 (including 7.6 % tax)

Problem: The gross price “(including XX% tax)” is only shown when a user has been logged in and the bill_to_address.country is equal store.country.

Solution: Define default session country = store.country for not logged users for tax rate calculation and gross/ net price display in price.tpl.php, ps_cart.php and ps_checkout.php
Default (not logged in) should always be gross prices (including xx% tax) because local tax applies and is a legal requirement.

2 Business requirement/ (BUG):
The “Tax Total” amount in ps_cart.php and ps_checkout.php should be calculated based on bill_to_address.country if no ship_to_address is defined

Problem: If you have tax mode = based on shipping address and on checkout page you select shipping information option “- Default (Same as Billing)” the Tax Total Amount remains 0.00 because no shipping address.country is defined. (this is reproducible bug)

Solution: If shipping information option “- Default (Same as Billing)” use the bill_to.address.country properly for tax and price calculation

This took me 4 hours to isolate, so please help me to fix this bug. I found many threads but not one solving the real issue.

Thanks for your support which is really appreciated.
Mark


[attachment cleanup by admin]

stinga

  • Contributing Developer
  • Full Member
  • *
  • Posts: 872
    • Squangle ltd
The simple solution to 1 is to always show both prices. Problem 2 does not exhibit in 1.1.2 (which we have) so it is either a new bug or a configuration issue.
I can't help with 1.1.4, we are not using it yet...
Stinga.
614869 products in 747 categories with 15749 products in 1 category.
                                             Document Complete   Fully Loaded
                Load Time First Byte Start Render   Time      Requests      Time      Requests
First View     2.470s     0.635s     1.276s          2.470s       31            2.470s      31
Repeat View  1.064s     0.561s     1.100s          1.064s       4             1.221s       4

ozswisssurf

  • Beginner
  • *
  • Posts: 14
Stinga,

Thanks for your response.

On 1: Sounds simple, but tell me how can I configure Virtuemart to show both prices. I googled it and there is no proper config solution beside an old hack (2007/2008)

On 2: Where do I log a bug at virtuemart website, I only found this forum.

Can you do me favour and send/post me your ps_checkout.php of version 1.1.2?

Thanks
Mark

ozswisssurf

  • Beginner
  • *
  • Posts: 14
Dear Virtemart Developers and Moderators,

Please help me to fix this problem - in 10 days we will go online and this "bug" is still around and I haven't a proper solution.

The problem lies when during checkout not ship_to_address is given and the user selects the checkbox - same as billing address.

The "Tax Total" is wrong on the check out process please see the attachement.

Thanks
Mark

ozswisssurf

  • Beginner
  • *
  • Posts: 14
with attachement

[attachment cleanup by admin]

ozswisssurf

  • Beginner
  • *
  • Posts: 14
Dear support team,

I really do not understand why nobody is helping me.

In 4 days we go online and your product doesn't work proberly when you ship out of Switzerland national/ international and you just need to check the ps_checkout.php and point out where you have the database query and change it to bill_to address.

Please help.

Best regards,
Mark

mauri

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297
I tested and it works?
See attach.

[attachment cleanup by admin]
VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11

mauri

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297
Have you set VAT Id:(same as taxrate CHE) in all products?
   
VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11

ozswisssurf

  • Beginner
  • *
  • Posts: 14
Mauri,

Thanks for your help! it works! ;D

My fault, sorry.

Take care
Ozswisssurf

mauri

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297
If you want to show products taxes, before customer have logged in:
/administrator/components/com_virtuemart/classes/ps_product.php
Find rows 1471-1474:

Code: [Select]
}
else {
$_SESSION['taxrate'][$ps_vendor_id] = 0;
}

Edit like this:

Code: [Select]
}
else {
        //$_SESSION['taxrate'][$ps_vendor_id] = 0;


        // Let's get the store's tax rate, if user have not logged in.
        $q = "SELECT `tax_rate` FROM #__{vm}_vendor, #__{vm}_tax_rate ";
        $q .= "WHERE tax_country=vendor_country AND #__{vm}_vendor.vendor_id=1 ";
        // !! Important !! take the highest available tax rate for the store's country
        $q .= "ORDER BY `tax_rate` ASC";
        $db->query($q);
        if ($db->next_record()) {
       $_SESSION['taxrate'][$ps_vendor_id] = $db->f("tax_rate");
        }
        else {
         $_SESSION['taxrate'][$ps_vendor_id] = 0;
        }
        return $_SESSION['taxrate'][$ps_vendor_id];
}



[attachment cleanup by admin]
VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11

anfield

  • Beginner
  • *
  • Posts: 7
Hey mauri,

i know this post is old but thought i would take a chance.

i used the above hack on 1.1.6 and it worked perfectly...so thanks for that.

problem now is i updated to 1.1.7 and now it has stopped working.

can you help?

Al

many thanks

mauri

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297

Edit the row 1504
   $_SESSION['taxrate'][$ps_vendor_id] = 0;

Code: [Select]
        //$_SESSION['taxrate'][$ps_vendor_id] = 0;


        // Let's get the store's tax rate, if user have not logged in.
        $q = "SELECT `tax_rate` FROM #__{vm}_vendor, #__{vm}_tax_rate ";
        $q .= "WHERE tax_country=vendor_country AND #__{vm}_vendor.vendor_id=1 ";
        // !! Important !! take the highest available tax rate for the store's country
        $q .= "ORDER BY `tax_rate` ASC";
        $db->query($q);
        if ($db->next_record()) {
        $_SESSION['taxrate'][$ps_vendor_id] = $db->f("tax_rate");
        }
        else {
        $_SESSION['taxrate'][$ps_vendor_id] = 0;
        }
        return $_SESSION['taxrate'][$ps_vendor_id];


VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11

Rune Rasmussen

  • Jr. Member
  • **
  • Posts: 161
  • Is the stable release stable?
    • SYNTAX ERROR
  • VirtueMart Version: Latest ;)
Hm ... this feature and fix is something that should go into core by default. It's the way it's supposed to work, and the way other carts works.

Has it been added to tracker mauri?
Rune Rasmussen - http://www.syntaxerror.no
Norske nettløsninger og integrasjoner, CONSIGNOR EDI, Mamut ordreimport og produkteksport, kortbetaling og faktura m.m.

Norsk Joomla! - Norwegian Translation Team - http://www.norskjoomla.no

anfield

  • Beginner
  • *
  • Posts: 7

Edit the row 1504
   $_SESSION['taxrate'][$ps_vendor_id] = 0;

Code: [Select]
        //$_SESSION['taxrate'][$ps_vendor_id] = 0;


        // Let's get the store's tax rate, if user have not logged in.
        $q = "SELECT `tax_rate` FROM #__{vm}_vendor, #__{vm}_tax_rate ";
        $q .= "WHERE tax_country=vendor_country AND #__{vm}_vendor.vendor_id=1 ";
        // !! Important !! take the highest available tax rate for the store's country
        $q .= "ORDER BY `tax_rate` ASC";
        $db->query($q);
        if ($db->next_record()) {
        $_SESSION['taxrate'][$ps_vendor_id] = $db->f("tax_rate");
        }
        else {
        $_SESSION['taxrate'][$ps_vendor_id] = 0;
        }
        return $_SESSION['taxrate'][$ps_vendor_id];




Hey Mauri,

only just seen you reply!

many many many thanks for the help - works a treat!

Alex


kleinbaas

  • Beginner
  • *
  • Posts: 34
Hi.
I have a similar problem. Shipping tax is not added if users use the "default - same as billing" address option.

Actually the shipping tax is added to the normal tax on the 2nd (select billing address) checkout screen, but tax then does not include shipping tax in the next (select payment method) screen and is not added to the order.

All works fine if users select a new shipping address.

I have spent ages trying to fix this. I have added the code above to ro_basket etc, but no luck. Any suggestions welcome!