Rounding Errors

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 11 months ago #135428

-- HikaShop version -- : 2.2.2
-- Joomla version -- : 3.2
-- PHP version -- : 5.3.3
-- Browser(s) name and version -- : N/A
-- Error-message(debug-mod must be tuned on) -- : N/A

There appears to be a rounding mismatch with the paypal payment rounding and hikashops rounding. In hikashop the tax ($2.9375) is rounded down to $2.93. When I have "Send details of the order" on in the paypal payment option the figure that is sent to paypal is rounded up to $2.94. The problem with this is because the payments don't match hikashop automatically cancels the order.

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 11 months ago #135429

If you want to try to reproduce this the setup I have is as follows:

2 products $24.95 each
Shipping $8.75
+ 5% tax on everything

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 11 months ago #135508

Hi,

The issue is with PayPal which doesn't round properly the calculations. You have two potential solutions:
1. Turn back off the "send order details" option of the payment method as it is the case by default so that PayPal directly uses the total amount.
2. Toggle the "calculations rounding" option of the configuration so that HikaShop calculations are done the way PayPal does them.

The following user(s) said Thank You: MumsHealth

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 11 months ago #135520

I turned the "calculations rounding" option on and it seems to have fixed the prices to match paypal.

The only problems I am having now are with the reports. When I try to do a sales report none of the prices are rounded. It just adds them all together and the final figure is quite far off from the actual amount of money collected. Is there any way to get the reports to round each transaction down (like it originally did when they were charged) or do I have to go into each individual order and change the amounts manually?

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 11 months ago #135795

Also if you try to display a table with tax data (image attached) the following error is returned.

0 SQL=SELECT SUM(prod.order_product_tax*prod.order_product_quantity) as Total, a.order_currency_id FROM jos_hikashop_order AS a LEFT JOIN jos_hikashop_order_product AS prod ON a.order_id=prod.order_id AND prod.order_product_tax > 0 LEFT JOIN jos_hikashop_order_product AS prod ON a.order_id=prod.order_id WHERE a.order_type='sale' AND a.order_created > 1384020571 AND a.order_created < 1386612571 GROUP BY a.order_currency_id

Attachments:
Last edit: 10 years 11 months ago by MumsHealth.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 11 months ago #136126

Hi,

Please use the "mysqli" driver for your Joomla 3, this database driver have some patch which give you a precise error message for the SQL query (the patch for the "mysql" driver will be in another Joomla 3 release).
Like that I don't see any particular problem in the query so the database error message will give us some precious information.

Regards,


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

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 11 months ago #136283

Changed it and the error is now.

1066 Not unique table/alias: 'prod' SQL=SELECT SUM(prod.order_product_tax*prod.order_product_quantity) as Total, a.order_currency_id FROM jos_hikashop_order AS a LEFT JOIN jos_hikashop_order_product AS prod ON a.order_id=prod.order_id AND prod.order_product_tax > 0 LEFT JOIN jos_hikashop_order_product AS prod ON a.order_id=prod.order_id WHERE a.order_type='sale' AND a.order_created > 1384282128 AND a.order_created < 1386874128 GROUP BY a.order_currency_id

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 11 months ago #136386

Hi,

Thanks to try to edit the file "administrator/components/com_hikashop/classes/widget.php" function "data()"

And add the code:

if(!isset($leftjoin['order_product']))
Before each:
$leftjoin['order_product'] = ' LEFT JOIN '.hikashop_table('order_product').' AS prod ON prod.order_id = o.order_id ';

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 11 months ago #136441

Added if(!isset($leftjoin)) in front of lines 620 and 634 but it didn't seem to change anything.
I probably just did it wrong as I know nothing about php.

Here is lines 616-623

if($setFilters){
			if(isset($widget->widget_params->filters['cat.category_id'])){
				if(($widget->widget_params->content=='customers' || $widget->widget_params->content=='partners')){
					$leftjoin['order'] = ' LEFT JOIN '.hikashop_table('order').' AS o ON o.order_id = a.user_id ';
					if(!isset($leftjoin['order_product']))$leftjoin['order_product'] = ' LEFT JOIN '.hikashop_table('order_product').' AS prod ON prod.order_id = o.order_id ';
				}else{
					if(!isset($leftjoin['order_product']))$leftjoin['order_product'] = ' LEFT JOIN '.hikashop_table('order_product').' AS prod ON prod.order_id = a.order_id ';
				}

And here are lines 631-639
if(isset($widget->widget_params->filters['prod.product_id'])){
				if(($widget->widget_params->content=='customers' || $widget->widget_params->content=='partners')){
					$leftjoin['order'] = ' LEFT JOIN '.hikashop_table('order').' AS o ON o.order_user_id = a.user_id ';
					if(!isset($leftjoin['order_product']))$leftjoin['order_product'] = ' LEFT JOIN '.hikashop_table('order_product').' AS prod ON prod.order_id = o.order_id ';
				}else{
					if(!isset($leftjoin['order_product']))$leftjoin['order_product'] = ' LEFT JOIN '.hikashop_table('order_product').' AS prod ON prod.order_id = a.order_id ';
				}
			}
		}

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 8 months ago #147224

Hi,

Sorry for this very late reply.
Do you have solved the issue or found a way of doing what you want ?

If it is, sharing the solution could help the other users :)

Last edit: 10 years 8 months ago by Xavier.

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 8
  • Hikashop Business
10 years 8 months ago #147585

I havent found a way to do this retroactivly but turning on "Round prices during calculations" under system>configuration>main>taxes seems to fix future orders

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum