Sometimes, when you delete a voucher from an order in back office, you will get an exception and the order gets messed up.
How to reproduce:
Cause:
Total discounts with tax is rounded to 290; without tax to 240,
Cart rule is NOT ROUNDED - with tax 290 and without tax 239,65.
When you delete the voucher, Prestashop does this:
// Update amounts of order
$order->total_discounts -= $order_cart_rule->value;
$order->total_discounts_tax_incl -= $order_cart_rule->value;
$order->total_discounts_tax_excl -= $order_cart_rule->value_tax_excl;
The resulting total discounts W/O TAX is 0,35, which is bigger than WITH TAX, which is invalid. Sometimes total_discounts is negative, which is also invalid.
Possible resolution:
Instead of subtracting the voucher value from total discounts...
Versions:
Happens in all 1.6 and 1.7 versions, the code is still the same.
PHP 5.6, 7.1 and currently 7.2
Screenshots:


Hi @Hlavtox,
I did not manage to reproduce the issue with the last version 1.7.4.3.
I attached a video record.
https://drive.google.com/file/d/1mXcGwzr_2z5ft9RroLKm_9zvTUO_be3P/view
Thanks to check & feedback.
Hi @khouloudbelguith :)
I just managed to reproduce it on 1.7.3.2.
Can you check your database values for the order and the voucher?
Order:
Voucher:
Exception:
Hi @Hlavtox,
Thanks for this clarification ( The product should have a tax rule)
Steps to reproduce the issue:
1- Create a product
1.1 Price (tax incl.) = 435.95 €
1.2 Tax rule = 50% => Price (tax excl.) = 290.633333 €

Thanks!
Any updates on this? It's pretty important I think, if you can't manage the order.
Hi @Hlavtox,
Sorry not yet.
Thanks for your understanding and your patience.
@khouloudbelguith Can you lift this issue somewhere higher? I think the whole "Order editing" stuff should be really, really thinked through, especially when converting the page to Symphony.
There is more stuff that is wrong. When adding or deleting a product from order, the code also subtracts or adds the product's price from total_paid, but this creates a room for rounding errors.
The order's total and taxes should be recalculated whenewer anything is changed - a product, shipping, voucher. Then these exceptions like I submitted in this issue wouldn't happen.
@khouloudbelguith
I can't reproduce the issue with the following scenario on 1.7.6.x, the discount is well deleted without any error
1- Create a product
1.1 Price (tax incl.) = 435.95 €
1.2 Tax rule = 50% => Price (tax excl.) = 290.633333 €
Can you try to reproduce it ?
Hi @marionf,
No, I did not manage to reproduce the issue with PS1.7.6.0beta1
https://drive.google.com/file/d/1iBJp_sigAD68RbE2xYsooK8PRh5uOo9R/view
It seems to be fixed.
I close the issue.
THanks!
@khouloudbelguith
I don't know if somebody is trying to make jokes of people or WTF is happening here. I am opening this issue for second time and always somebody quiets it down or says it's fixed when it's not.
Now there is another issue and it throws 500 even when creating the voucher.
https://youtu.be/MHbHYnx5UAo
Hi @Hlavtox
the scenario described in this one isn't reproducible with 1.7.6.0
You have another issue, so I created a new issue for you: https://github.com/PrestaShop/PrestaShop/issues/13809
1.6.x
/controllers/admin/AdminOrdersController.php
~ 1317 row:
// Update amounts of order
$order->total_discounts -= $order_cart_rule->value;
$order->total_discounts_tax_incl -= $order_cart_rule->value;
after that put this code:
$round = round($order_cart_rule->value_tax_excl);
$order_cart_rule->value_tax_excl = $round;
That's all.
Most helpful comment
@khouloudbelguith
I don't know if somebody is trying to make jokes of people or WTF is happening here. I am opening this issue for second time and always somebody quiets it down or says it's fixed when it's not.
Now there is another issue and it throws 500 even when creating the voucher.
https://youtu.be/MHbHYnx5UAo