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

Comments

dinazaur created an issue. See original summary.

dinazaur’s picture

Issue summary: View changes
tonytheferg’s picture

Status: Needs work » Needs review

Good catch. Thanks!

tonytheferg’s picture

StatusFileSize
new1.2 KB

Test only patch

tonytheferg’s picture

StatusFileSize
new1.7 KB

patch with test

The last submitted patch, 4: 3323174-4-test-only.patch, failed testing. View results

  • tonytheferg committed 39504896 on 2.0.x
    Issue #3323174 by tonytheferg, dinazaur: Price after vado discount is...
tonytheferg’s picture

Status: Needs review » Fixed
tonytheferg’s picture

Status: Fixed » Closed (fixed)
dinazaur’s picture

Hello, @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.

dinazaur’s picture

StatusFileSize
new613 bytes

We 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.

tonytheferg’s picture

Shouldn't 39.3757 rounded be 39.38?