-
Notifications
You must be signed in to change notification settings - Fork 131
[Shipping labels] Request label refund network #14171
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
Conversation
This commit adds a new data class `RefundLabelResponseDTO` to handle the response when refunding a shipping label.
This commit introduces the functionality to request a refund for a shipping label directly from the `WooShippingLabelRefundViewModel`.
d0163c0
to
bb8177b
Compare
📲 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.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #14171 +/- ##
============================================
+ Coverage 37.74% 37.75% +0.01%
- Complexity 8952 8956 +4
============================================
Files 1955 1955
Lines 109520 109542 +22
Branches 14364 14365 +1
============================================
+ Hits 41334 41363 +29
+ Misses 64427 64416 -11
- Partials 3759 3763 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…OOMOB-370-shipping-label-refund-network
…OOMOB-370-shipping-label-refund-network
…OOMOB-370-shipping-label-refund-network
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.
Thanks @irfano, this works well, I left some comments, and I'll explain the currency issue with more details below:
I see that we currently use the order.currency
for formatting of the shipping label rates and refund, which is problematic, as the order could be created using a different currency (either when using a multi-currency plugin, or just by changing Woo settings), and this issue results in the following:
![]() |
![]() |
I think we should use the currency from the StoreOptionsModel
and for refund another option is to use the currency that we get from the endpoint /wcshipping/v1/label/purchase/<order-id>
(that's what was done in the old flow), anyway, I think each approach is fine.
Given this issue is present in other places of the flow, I'm pre-approving the PR, as I think it should be addressed in a separate PR.
@@ -56,6 +60,19 @@ class WooShippingLabelRefundViewModel @Inject constructor( | |||
if (networkStatus.isConnected()) { | |||
_viewState.update { ViewState.Loading } | |||
launch { | |||
selectedSite.getOrNull()?.let { |
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.
np, I'm not sure using getOrNull()
in this cases is needed, IMO it just complicates the code with nullability handling. When the user reaches this step, we are sure there is a selected site, so it should be fine to use get()
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.
Makes sense! Done: ec27f71
repository.refundLabel( | ||
it, | ||
arguments.orderId, | ||
arguments.shipment.labelId ?: return@launch |
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.
np, WDYT about passing just what's needed and not the whole ShipmentUIModel
? this will have the advantage of avoiding nullable items as we can check for null items before triggering the navigation.
This is also related to a potential issue with the currency
usage that we have in this screen and other places, I'll explain this further in the review itself.
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.
In my first attempt, I used separate parameters, but then I noticed I'm already using items
, purchaseDate
, refundableAmount
and labelId
from ShipmentUIModel
. So, I thought it would be cleaner to use only ShipmentUIModel
.
This is also related to a potential issue with the currency usage that we have in this screen and other places
If we fix that issue, we might stop using items
, but it’s likely that we’ll use the shipping rates’ currency instead, which can also be part of ShipmentUIModel
.
So, I thought it would be cleaner to use a single model, ShipmentUIModel
. Let me know if you still think passing separate arguments would be a better approach.
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.
As I pointed, this is just a np comment, but personally I think it's still better to pass separate items, or even better just pass the labelId
of the label, and retrieve the data from the DataStores (like what we did in the old flow).
When we pass a large model to a screen, it gets saved into the SavedStateHandle
, and thus increasing the chances of TransactionTooLargeException
crashes, I don't think the model is that large in this case, but to me it's just a good practice that I try to follow, given these crashes were hard to fix in the past for us.
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.
Merging this as is and revisiting this when working on the currency fix is an option too 🙂
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.
Okay, that makes sense. It would be better to pass fewer arguments. I’ll do it in another PR.
Version |
Thanks for the review, @hichamboushaba!
|
Part of WOOMOB-370
Description
This implements network integration for the Refund Request screen.
Warning
Known issues:
Steps to reproduce
Successful case
Testing information
The tests that have been performed
Steps above.
Images/gif
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.