Commit efa62cc
committed
Fix orderTotalChanged error for 8dp vs 2dp amounts
A recent change (bdbc520) means that we now get 8dp precision on numbers in the Order when we create or update an order. That change broke the card payment process, which performs a check comparing the initial order total (when the merchant taps collect payment) and the most recent total when we take the payment.
Because this was using a string comparison, after the change we started comparing values like `“22.56”` with `“22.56000000”`. Note that the API always rounds the total to 2dp and pads it to 8dp – this is different for tax values, which were the values prompting this change.
To fix, we now convert the totals to a `NSDecimalNumber` for comparison, which matches our treatment elsewhere in the app.
We’ll discuss the merits of the 8dp change elsewhere, but even if we revert it, this is a beneficial improvement.1 parent 43a0e68 commit efa62cc
File tree
1 file changed
+10
-8
lines changed- WooCommerce/Classes/ViewRelated/Orders/Collect Payments
1 file changed
+10
-8
lines changedLines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
268 | 270 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
273 | 275 | | |
274 | 276 | | |
275 | 277 | | |
| |||
0 commit comments