[Skip to main content](#vessel-content)

#   Negative taxes are saving into order product table

##

- **[irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile")**
- [![irfanhanfi's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile") Topic Author
- [ Offline](/forum/user/23811-irfanhanfi)

Less More

- Posts: 64
- Thank you received: 0
-
-

11 years 6 months ago -  11 years 6 months ago [\#201315](#201315) by [irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile")  *[Negative taxes are saving into order product table](/forum/3-bug-report/876885-negative-taxes-are-saving-into-order-product-table#201315 "-- HikaShop version -- : 2.3.0 -- Joomla version -- : Joomla! 3.3.0 Stable -- PHP version -- : 5.4.13  I tried to create orders with tax. Tax and all calculations are correct during checkout and once order is created tax does not save for negative values.  If I add a product where it has two options product. a)Main product price is zero b)first options product has 70 price and tax does not apply to this c)second option product has 50 price and tax does apply to this. additionally there is a discount on main product of $50. In hikashop config Apply discounts is set to Before taxes.  On checkout page total shows 70$ for one quantity.But when order is confirmed in product order table it shows as below-  a)main product -&gt; price = - 50$ , Tax = 0(It should be -2$ which is tax) b)first option product -&gt; price = -70$ , Tax = 0(correct) b)second option product -&gt; price = 50$ , Tax = 2$(correct)  When I tried to debug the code I found something wrong in below code(after&#95;confirm)-  below should be true for -2$ but it is treated as false.  It would be great if you can help me to fix this.  I would like to add that in my localhost where BC Math extension is installed, it is working fine but on server, extension is not installed so it's using helper class custom bccomp function. Thanks,")* was created by *[irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile")*

-- HikaShop version -- : 2.3.0
-- Joomla version -- : Joomla! 3.3.0 Stable
-- PHP version -- : 5.4.13

I tried to create orders with tax. Tax and all calculations are correct during checkout and once order is created tax does not save for negative values.

If I add a product where it has two options product.
a)Main product price is zero
b)first options product has 70 price and tax does not apply to this
c)second option product has 50 price and tax does apply to this.
additionally there is a discount on main product of $50. In hikashop config **Apply discounts** is set to **Before taxes**.

On checkout page total shows 70$ for one quantity.But when order is confirmed in product order table it shows as below-

a)main product -&gt; price = - 50$ , Tax = 0(It should be -2$ which is tax)
b)first option product -&gt; price = -70$ , Tax = 0(correct)
b)second option product -&gt; price = 50$ , Tax = 2$(correct)

When I tried to debug the code I found something wrong in below code(after_confirm)-

Code:

if(!empty($product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax) &amp;&amp; bccomp($product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax,0,5)){ $tax = $product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax-$product-&gt;prices[0]-&gt;unit_price-&gt;price_value; }

below should be true for -2$ but it is treated as false.
Code:

bccomp($product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax,0,5))

It would be great if you can help me to fix this.

I would like to add that in my localhost where BC Math extension is installed, it is working fine but on server, extension is not installed so it's using helper class custom bccomp function.
Thanks,

Last edit: 11 years 6 months ago by [irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzY4ODUtbmVnYXRpdmUtdGF4ZXMtYXJlLXNhdmluZy1pbnRvLW9yZGVyLXByb2R1Y3QtdGFibGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86564
- Thank you received: 14311
-
-

11 years 6 months ago [\#201340](#201340) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Negative taxes are saving into order product table](/forum/3-bug-report/876885-negative-taxes-are-saving-into-order-product-table#201340 "-- HikaShop version -- : 2.3.0 -- Joomla version -- : Joomla! 3.3.0 Stable -- PHP version -- : 5.4.13  I tried to create orders with tax. Tax and all calculations are correct during checkout and once order is created tax does not save for negative values.  If I add a product where it has two options product. a)Main product price is zero b)first options product has 70 price and tax does not apply to this c)second option product has 50 price and tax does apply to this. additionally there is a discount on main product of $50. In hikashop config Apply discounts is set to Before taxes.  On checkout page total shows 70$ for one quantity.But when order is confirmed in product order table it shows as below-  a)main product -&gt; price = - 50$ , Tax = 0(It should be -2$ which is tax) b)first option product -&gt; price = -70$ , Tax = 0(correct) b)second option product -&gt; price = 50$ , Tax = 2$(correct)  When I tried to debug the code I found something wrong in below code(after&#95;confirm)-  below should be true for -2$ but it is treated as false.  It would be great if you can help me to fix this.  I would like to add that in my localhost where BC Math extension is installed, it is working fine but on server, extension is not installed so it's using helper class custom bccomp function. Thanks,")*

Hi,

Change the code: Code:

if(!empty($product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax) &amp;&amp; bccomp($product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax,0,5)){ $tax = $product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax-$product-&gt;prices[0]-&gt;unit_price-&gt;price_value; }

to: Code:

if(!empty($product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax)){ $tax = $product-&gt;prices[0]-&gt;unit_price-&gt;price_value_with_tax-$product-&gt;prices[0]-&gt;unit_price-&gt;price_value; }

and that should fix the problem.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzY4ODUtbmVnYXRpdmUtdGF4ZXMtYXJlLXNhdmluZy1pbnRvLW9yZGVyLXByb2R1Y3QtdGFibGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile")**
- [![irfanhanfi's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile") Topic Author
- [ Offline](/forum/user/23811-irfanhanfi)

Less More

- Posts: 64
- Thank you received: 0
-
-

11 years 6 months ago [\#201344](#201344) by [irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile")  Replied by *[irfanhanfi](/forum/user/23811-irfanhanfi "View irfanhanfi's Profile")* on topic *[Negative taxes are saving into order product table](/forum/3-bug-report/876885-negative-taxes-are-saving-into-order-product-table#201344 "-- HikaShop version -- : 2.3.0 -- Joomla version -- : Joomla! 3.3.0 Stable -- PHP version -- : 5.4.13  I tried to create orders with tax. Tax and all calculations are correct during checkout and once order is created tax does not save for negative values.  If I add a product where it has two options product. a)Main product price is zero b)first options product has 70 price and tax does not apply to this c)second option product has 50 price and tax does apply to this. additionally there is a discount on main product of $50. In hikashop config Apply discounts is set to Before taxes.  On checkout page total shows 70$ for one quantity.But when order is confirmed in product order table it shows as below-  a)main product -&gt; price = - 50$ , Tax = 0(It should be -2$ which is tax) b)first option product -&gt; price = -70$ , Tax = 0(correct) b)second option product -&gt; price = 50$ , Tax = 2$(correct)  When I tried to debug the code I found something wrong in below code(after&#95;confirm)-  below should be true for -2$ but it is treated as false.  It would be great if you can help me to fix this.  I would like to add that in my localhost where BC Math extension is installed, it is working fine but on server, extension is not installed so it's using helper class custom bccomp function. Thanks,")*

Thank you for this fix.

It looks like issue is with bccomp definition.It would be great if you can provide fix for that function.I guess this needs to fix everywhere where we have called bccomp.

Thanks,

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzY4ODUtbmVnYXRpdmUtdGF4ZXMtYXJlLXNhdmluZy1pbnRvLW9yZGVyLXByb2R1Y3QtdGFibGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4080
-
- [](http://obsi.dev)
-

11 years 6 months ago -  11 years 6 months ago [\#201473](#201473) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Negative taxes are saving into order product table](/forum/3-bug-report/876885-negative-taxes-are-saving-into-order-product-table#201473 "-- HikaShop version -- : 2.3.0 -- Joomla version -- : Joomla! 3.3.0 Stable -- PHP version -- : 5.4.13  I tried to create orders with tax. Tax and all calculations are correct during checkout and once order is created tax does not save for negative values.  If I add a product where it has two options product. a)Main product price is zero b)first options product has 70 price and tax does not apply to this c)second option product has 50 price and tax does apply to this. additionally there is a discount on main product of $50. In hikashop config Apply discounts is set to Before taxes.  On checkout page total shows 70$ for one quantity.But when order is confirmed in product order table it shows as below-  a)main product -&gt; price = - 50$ , Tax = 0(It should be -2$ which is tax) b)first option product -&gt; price = -70$ , Tax = 0(correct) b)second option product -&gt; price = 50$ , Tax = 2$(correct)  When I tried to debug the code I found something wrong in below code(after&#95;confirm)-  below should be true for -2$ but it is treated as false.  It would be great if you can help me to fix this.  I would like to add that in my localhost where BC Math extension is installed, it is working fine but on server, extension is not installed so it's using helper class custom bccomp function. Thanks,")*

Hi,

" bccomp " is like using " &gt; " ; the code was there to check that the taxes are not negative.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Last edit: 11 years 6 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzY4ODUtbmVnYXRpdmUtdGF4ZXMtYXJlLXNhdmluZy1pbnRvLW9yZGVyLXByb2R1Y3QtdGFibGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.076 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
