-
Notifications
You must be signed in to change notification settings - Fork 132
[Refunds] Fix taxes handling #14064
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
[Refunds] Fix taxes handling #14064
Conversation
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
0de75f6
to
fe84ddb
Compare
a215e0b
to
73219b5
Compare
) : Parcelable { | ||
val availableRefundQuantity | ||
get() = maxQuantity.toInt() | ||
sealed class RefundItem : Parcelable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring is not really needed for this PR, but it will be useful for a future refactoring of the IssueRefundViewModel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done @hichamboushaba the changes look good and work as described.
The `taxes` array returned by the API includes raw taxes, not rounded, while the `total_tax` property is using rounded values, and this leads to some inconsistencies for calculating the amount when using them, so for now, we calculate the total amount using `total_tax` in the ViewModel.
43f4448
to
9ba4f9d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #14064 +/- ##
============================================
+ Coverage 37.68% 37.71% +0.03%
- Complexity 8885 8896 +11
============================================
Files 1951 1951
Lines 108870 108899 +29
Branches 14232 14239 +7
============================================
+ Hits 41031 41076 +45
+ Misses 64094 64072 -22
- Partials 3745 3751 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes: WOOMOB-395
Description
This PR builds on top of the previous PR to fix the issue of tax refunding, as for now, we weren't handling it correctly.
This PR updates the logic of the refunding to handle splitting the taxes refund according to each item taxes.
Important: There is a discrepancy between the
taxes
array that each order line returns, and thetotal_tax
, thetotal_tax
is rounded, while the values in the array are raw. Initially, I wanted to avoid making any calculations on client side, and drop theamount
argument from the API call, but I noticed an issue where the refunds could have less amount that the total order amount, so for now, we'll still send theamount
, and its value will still use thetotal_tax
for calculation (this matches iOS behavior too).This issue will become problematic when we try to add support for partial refunds, I asked about it here p1747301522966739-slack-C07JJG089M0, and depending on the response, I'll document the next steps.
Steps to reproduce
Testing information
The tests that have been performed
^
Images/gif
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: