Problem/Motivation
Price after Vado applies discount on items is not rounded.
For instance, PayPal does not support more than two decimals in the price.
All Promotions are rounding prices.
Steps to reproduce
Add discount on Parent variation.
Proposed resolution
Add rounding of price inside:
1) \Drupal\commerce_vado\VadoOrderProcessor::process
2) \Drupal\commerce_vado\EventSubscriber\VadoEventSubscriber::cartEntityAddEvent
I've tested it and seems that there is not a big difference when rounding the price so I choose VadoOrderProcessor::process.
Remaining tasks
Write tests.
User interface changes
No changes
API changes
No changes
Data model changes
No changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3323174-11.patch | 613 bytes | dinazaur |
| #5 | 3323174-5.patch | 1.7 KB | tonytheferg |
| #4 | 3323174-4-test-only.patch | 1.2 KB | tonytheferg |
Comments
Comment #2
dinazaur commentedComment #3
tonytheferg commentedGood catch. Thanks!
Comment #4
tonytheferg commentedTest only patch
Comment #5
tonytheferg commentedpatch with test
Comment #8
tonytheferg commentedComment #9
tonytheferg commentedComment #10
dinazaur commentedHello, @tonytheferg I found the problem with the approach of rounding price.
If the item price after the bundle discount application is 39.3757 we have 15 items in the cart. 39.3757 * 15 = 590.64 (590.6355). But if we will round the order item price it will be 39.38 which will lead to a total price of 38 * 15 = 590.70. Which is higher than should be.
From what I see Vado for the moment is not usable with PayPal. (And even with other payment gateways, because sending such a price 39.3757 through the API could lead to unexpected results)
The solution would be to apply adjustments to the total order item price, instead of the unit price.
Comment #11
dinazaur commentedWe agreed that it's better to sell items using a bit lowest price, so clients will not be so angry. Here is a temporal patch. But the problem should be definitely fixed in another way.
Comment #12
tonytheferg commentedShouldn't 39.3757 rounded be 39.38?
Comment #13
tonytheferg commentedhttps://git.drupalcode.org/project/commerce/-/blob/8.x-2.x/modules/price...