-
Notifications
You must be signed in to change notification settings - Fork 137
[Woo POS][Refunds] Create full refund #15135
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
base: trunk
Are you sure you want to change the base?
Conversation
…t state changes during processing
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
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.
Pull request overview
This PR implements full refund functionality in the Woo POS by adding refund processing capabilities, new UI states for handling loading/success/error scenarios, and calculation logic for refund amounts including taxes. The implementation follows a happy path refund flow where all items in an order can be refunded at once.
Key changes include:
- Addition of refund calculation utilities (subtotal, tax, and item grouping)
- Integration with WCRefundStore API to create refunds
- New state machine transitions for processing, success, and error states
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
RefundRequestItem.kt |
Made refundTotal and refundTax fields nullable with default null values to support optional refund data |
WooPosRefundViewModel.kt |
Added refund processing logic, state management for Processing/Success/Error states, and changed data source method from getOrderById to refreshOrderById |
WooPosRefundState.kt |
Added Processing, RefundSuccess, and RefundError states to handle refund operation lifecycle |
WooPosIssueRefundDialog.kt |
Added UI handling for Processing state with loading indicator and RefundSuccess/RefundError states with appropriate content |
WooPosGroupRefundItems.kt |
New utility class to group refundable items by order item ID and calculate refund totals and taxes |
WooPosCalculateRefundTax.kt |
New utility class to calculate proportional tax amounts for refunded items |
WooPosCalculateRefundSubtotal.kt |
New utility class to calculate refund subtotals by summing unit prices |
WooPosRefundableItem.kt |
Removed lineTotal and lineTax computed properties (calculation moved to dedicated utilities) |
WooPosRefundViewModelTest.kt |
Updated all test mocks to use refreshOrderById instead of getOrderById and added new dependencies to test setup |
WooPosGroupRefundItemsTest.kt |
Comprehensive test coverage for item grouping logic including edge cases |
WooPosCalculateRefundTaxTest.kt |
Test coverage for tax calculation including partial and full refunds |
WooPosCalculateRefundSubtotalTest.kt |
Test coverage for subtotal calculation with various item combinations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/model/refunds/RefundRequestItem.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModel.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModel.kt
Show resolved
Hide resolved
...ommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosCalculateRefundTax.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModel.kt
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModel.kt
Show resolved
Hide resolved
...ce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosCalculateRefundSubtotal.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosGroupRefundItems.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModel.kt
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosRefundViewModel.kt
Show resolved
Hide resolved
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
…or empty item lists
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #15135 +/- ##
============================================
+ Coverage 38.63% 38.66% +0.02%
- Complexity 10448 10469 +21
============================================
Files 2178 2181 +3
Lines 123901 124051 +150
Branches 17093 17115 +22
============================================
+ Hits 47875 47960 +85
- Misses 71206 71262 +56
- Partials 4820 4829 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
WOOMOB-1855
Description
This PR allows creating a full refund in Woo POS for a happy path refund scenario.
💡 UI of the loading states, error, and success states is not in scope of this PR-it will be updated in the next iteration.
Test Steps
a) order containing single item
b) order containing multiple items
c) order containing multiple quantities of the same item
Images/gif
demo-19-dec.mp4
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.