VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Checkout / Order Management VM 1.1 => Topic started by: ozswisssurf on May 15, 2010, 21:34:35 pm

Title: Bug with tax mode: based on shipping address when no shipping address is given
Post by: ozswisssurf on May 15, 2010, 21:34:35 pm
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:

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]
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: stinga on May 17, 2010, 19:57:44 pm
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...
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: ozswisssurf on May 19, 2010, 20:07:31 pm
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
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: ozswisssurf on May 31, 2010, 23:16:13 pm
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
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: ozswisssurf on May 31, 2010, 23:18:29 pm
with attachement

[attachment cleanup by admin]
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: ozswisssurf on June 08, 2010, 16:05:40 pm
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
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: mauri on June 09, 2010, 17:24:31 pm
I tested and it works?
See attach.

[attachment cleanup by admin]
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: mauri on June 09, 2010, 17:54:03 pm
Have you set VAT Id:(same as taxrate CHE) in all products?
   
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: ozswisssurf on June 09, 2010, 23:25:01 pm
Mauri,

Thanks for your help! it works! ;D

My fault, sorry.

Take care
Ozswisssurf
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: mauri on June 10, 2010, 18:22:59 pm
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]
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: anfield on February 26, 2011, 12:45:35 pm
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
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: mauri on March 03, 2011, 20:44:53 pm

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];


Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: Rune Rasmussen on March 07, 2011, 23:06:19 pm
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?
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: anfield on March 18, 2011, 14:41:03 pm

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

Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: kleinbaas on April 15, 2011, 15:26:43 pm
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!
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: nicole2292 on May 31, 2011, 05:56:52 am
Hi kleinbaas,

Did you manage to solve this? I have the exact same problem as you.

Thanks,

Nicole
Title: Re: Bug with tax mode: based on shipping address when no shipping address is given
Post by: nicole2292 on May 31, 2011, 07:14:00 am
Apologies. For me it is broken regardless of whether I use the default address or otherwise.
Therefore I have started a new thread for my issue at http://forum.virtuemart.net/index.php?topic=87161.0