New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rounding issues with refunds/returns #6226
Comments
I believe there was also a related tax calculation rounding issue as well: I think the proper solution here would be to change scale to 4 everywhere, and ensure we properly round for display methods. |
Well, I guess the problem with changing to scale 4 everywhere, still requires that rounding to 2 is figured out for payments/totals etc, since we can't really charge to 4 decimals. I think the bigger problem, as it relates to the refund code, is mainly in the default calculator being used. It's trying to figure out refunds based on dividing line item counts, total items in order, adjustments etc. The longer term fix, IMO, would be to have every inventory_unit know its tax amounts, adjustments etc, because then refunds don't need to be "calculated" in the sense that the calculations should have been done already. This has primarily been a problem for us in applying some sort of editor/employee discount on an order that is not uniform (say one item is 40% off, one is 10% off) and the system has no way to "reverse" it. The simple solution for us right now has been to change the scale back to 2 and then added a round(2, :down) on the DefaultRefundAmount calculator so at least the "in memory" calculations align with the db:
|
It seems like in this pull request, the field precision/scale was changed for returns:
#5043
This can't be changed like that without changing the scale on ALL db amount fields (or properly figuring out how to round everywhere), as calculations now after a refund will show an order total of something like, $50.1348 with payments of $50.13 and then the order updater says that a balance is due. If spree is going to switch to a scale of 4, it needs to be coordinated across the system/db.
The text was updated successfully, but these errors were encountered: