Skip to content

Issue/woomob 370 handle displaying refunded shipments #14190

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

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Jun 12, 2025

Part of WOOMOB-373

Description

This PR makes following changes:

  • Before, we had two models, PurchasedLabelModel and ShippingLabelModel. They were similar, but I initially created them as two models because one used a String type for the id, and the other used an Int. I noticed that this string/int difference is not based on the endpoint, it's based on the shipment. In other words, even in same response, a shipment may have "id: 0" and the next shipment may have "id": "small_box_id". This inconsistency is likely due to mobile platforms calling the purchase endpoint with the wrong ID type (I will fix this later and it's already discussed in p1749620015063859-slack-C05VBLKHHV1). In this PR, I've removed PurchasedLabelModel and used string id in ShippingLabelModel. This way, we can support both string and number formats without any issue.
  • Before, we were using purchased labels data to determine whether a shipment had been purchased. Now, we additionally check if the label has been refunded. If it has, we no longer consider the shipment as purchased. This behavior is consistent with the web.
  • Before, The "Create shipping label" button was hidden if all shipments were fulfilled. I’ve updated the logic to match the behavior on the web and iOS, where the button remains visible.

Warning

Known issue: After refunding a label and navigating back to the main creation screen, the label is still being displayed as purchased. I’ll address this in a subsequent PR.

Steps to reproduce

  1. On the web prepare an order with multiple shipments. Do not purchase from the app, because currently purchase flow send some incorrect data and may break orders.
  2. Purchase two orders.
  3. Refund one of them.
  4. Open the order from the app and compare it with the web.
  5. Purchase all shipments.
  6. Navigate back and ensure "Create shipping label" button is visible for fulfilled shipments.

The tests that have been performed

Steps above

Images/gif

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@irfano irfano added feature: shipping labels Related to creating, ordering, or printing shipping labels. Task (new) labels Jun 12, 2025
@irfano irfano requested a review from hichamboushaba June 12, 2025 21:25
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 12, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit88c3d65
Direct Downloadwoocommerce-wear-prototype-build-pr14190-88c3d65.apk

@irfano irfano force-pushed the issue/WOOMOB-370-handle-displaying-refunded-shipments branch 2 times, most recently from 49b7833 to 046388d Compare June 12, 2025 21:49
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 12, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit88c3d65
Direct Downloadwoocommerce-prototype-build-pr14190-88c3d65.apk

@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2025

Codecov Report

Attention: Patch coverage is 41.66667% with 14 lines in your changes missing coverage. Please review.

Project coverage is 37.83%. Comparing base (98f5ebd) to head (88c3d65).

Files with missing lines Patch % Lines
...ndroid/ui/orders/wooshippinglabels/GetShipments.kt 0.00% 6 Missing and 3 partials ⚠️
...oid/ui/orders/wooshippinglabels/networking/DTOs.kt 60.00% 2 Missing ⚠️
...ers/wooshippinglabels/models/PurchasedLabelData.kt 0.00% 1 Missing ⚠️
...ers/wooshippinglabels/models/ShippingLabelModel.kt 85.71% 1 Missing ⚠️
...nglabels/networking/WooShippingNetworkingMapper.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14190      +/-   ##
============================================
+ Coverage     37.78%   37.83%   +0.04%     
+ Complexity     8933     8931       -2     
============================================
  Files          1956     1955       -1     
  Lines        109724   109676      -48     
  Branches      14390    14380      -10     
============================================
+ Hits          41461    41491      +30     
+ Misses        64472    64396      -76     
+ Partials       3791     3789       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@irfano irfano requested a review from JorgeMucientes June 13, 2025 17:20
Base automatically changed from issue/WOOMOB-370-shipping-label-refund-network to trunk June 13, 2025 18:01
@irfano irfano added this to the 22.7 milestone Jun 13, 2025
irfano added 4 commits June 13, 2025 21:11
Previously, there were two separate models due to the "id" field being either a Long or a String. I’ve now combined them into one model by defining the id as a String. This allows us to parse the value as a string regardless of whether it’s originally a number or a string.
The button was previously hidden if all shipments were fulfilled.

This change ensures that the "Create shipping label" button is always visible for orders that are eligible for shipping label creation, regardless of the fulfillment status of individual shipments.
@irfano irfano force-pushed the issue/WOOMOB-370-handle-displaying-refunded-shipments branch from ec078ef to 88c3d65 Compare June 13, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels. Task (new)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants