Taxes for articles with discount wrong added in database.

  • Posts: 424
  • Thank you received: 11
  • Hikaserial Subscription Hikashop Business
2 days 20 hours ago #366830

-- HikaShop version -- : 5.1.1
-- Joomla version -- : 5.2.x
-- PHP version -- : 8.2

Hi,

I almost competed a mollie plugin which also can handle recurring payements regarding the hikasubscription. But while testing i discovered a bug i think. Because a product which has a one time discount, fetches now a wrong price for recurring without discount. With some investigation i saw something in the administrator/components/com_hikashop/classes/order.php on line 695 that the tax is going to price_value i think there is something wrong.
When i look into my database i made to products, both 1 euro with tax. as you can see in the table the column order_product_price_before_discount and order_product_tax_before_discount that the product without discount is calculated correctly and the order with discount is wrong calculated because the order_product_tax_before discount now gives 1.00 and should be 0.17355
Please help
Attached some screenshots so you see what i mean.

Attachments:

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

  • Posts: 83672
  • Thank you received: 13545
  • MODERATOR
2 days 16 hours ago #366833

Hi,

I'm sorry but I'm not following you.

The createFromCart function is used when an order is created from a cart.
For recurring payments, as far as I know, that createFromCart function is not used at all. Instead, it's the createRecurringSuborder function which handles the creation of the recurring orders based on the data from the original order.

So, If you have an issue with the discount data on the products of the orders generated for recurring payments, I would think you would look at the createRecurringSuborder not the createFromCart function. Unless the problem is also with the original order ?

And in createRecurringSuborder, from what I can see it takes the product data from the original order and copies it for the new order.
So I don't see how it could change the value for the recurring order.

Now, maybe HikaSerial is involved in this ( for example with the events onBeforeCreateRecurringSuborder or onAfterCreateRecurringSuborder ) called from createRecurringSuborder ?

Note that these columns order_product_price_before_discount and order_product_tax_before_discount were added in the 4.5.1 following this thread:
www.hikashop.com/forum/discount-coupon/8...fication.html#340419
So, the sole purpose was to be able to be able to more easily retrieve the price before discount in the emails sent for orders. So the goal was not really to make these available for payment plugins, even less for recurring orders.
I don't think that any modification has been make in HikaSerial to handle this in a particular way ?
Why do you need to use these columns exactly ?

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

  • Posts: 424
  • Thank you received: 11
  • Hikaserial Subscription Hikashop Business
2 days 15 hours ago #366846

Thanks for your answer,
It is due that the order_product_tax_before discount is for products with discount is stored incorrectly, the recurring subscription wil take that price total to calculate total amount for the next time. In these columns, as you can see is for 2 orders same kind of product one with discount and 1 without, without the total will become € 1,00 but with discount in some way it will be € 1,83 as new total, and both has no recurring on them, because recurring will go wrong. we implemented to get the data from order, otherwise the recurring amount was with discount, but they get only discount for the first time(year) then the other payments must be full price.

Hope you understand a little better, sorry for my bad english. :)

I will take a look at the createRecurringSuborder, and meanwhile hoping you can help me a little further with this.
Thanks
Mark

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

  • Posts: 83672
  • Thank you received: 13545
  • MODERATOR
2 days 1 hour ago #366849

Hi,

So, if I understand correctly, your plugin has a special system to calculate the recurring amount by recalculating it so that discounts applied on the original order are not taken into account. And, to be able to do that, you want to use the column order_product_tax_before_discount, but in some cases, the data in there is not correct.

In that case, try to change the line:

$orderProduct->order_product_tax_before_discount = $orderProduct->discount->taxes_without_discount;
to:
$orderProduct->order_product_tax_before_discount = $orderProduct->discount->price_value_without_discount_with_tax - $orderProduct->discount->price_value_without_discount;
in the file administrator/components/com_hikashop/classes/order.php
It should hopefully help.
Let us know how it goes so that we can add the change on our end if it fixes the problem.

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

  • Posts: 424
  • Thank you received: 11
  • Hikaserial Subscription Hikashop Business
1 day 23 hours ago #366863

Hi Nicolas,

Made the change in the file, all is now calculated correctly. Great.
Saw the correct amounts in database and also at the payment provider for the new period.
If all testing goes well, i think we have a mighty beautifull, mollie plugin developed, which handles recuring/hikaserial subscriptions and also see when order also contains normal products. e.g. when you have 2 shirts, 1 cap and a subcription in your cart, al goes well and only the subscription will be made as a recurring payment in mollie.

I will keep you posted, might be something nice to have in you marketplace. :)

The following user(s) said Thank You: nicolas

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

  • Posts: 83672
  • Thank you received: 13545
  • MODERATOR
1 day 20 hours ago #366864

Hi,

Great! We'll be adding the change for the next version of HikaShop.
Let us know when you want us to add it to the marketplace. We'll be happy to do so!

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

Time to create page: 0.098 seconds
Powered by Kunena Forum