Skip to content

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Dec 23, 2025

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

  1. Create order in POS and try creating full refund through POS Orders screen:
    a) order containing single item
    b) order containing multiple items
    c) order containing multiple quantities of the same item
  2. Verify that the network request and server response look as expected.
  3. Verify order is properly refunded in wp-admin.

Images/gif

demo-19-dec.mp4
  • 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.

@samiuelson samiuelson added the type: task An internally driven task. label Dec 23, 2025
@samiuelson samiuelson added this to the 23.9 milestone Dec 23, 2025
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 23, 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 NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitb767f93
Direct Downloadwoocommerce-wear-prototype-build-pr15135-b767f93.apk

Copy link
Contributor

Copilot AI left a 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.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 23, 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 NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitb767f93
Direct Downloadwoocommerce-prototype-build-pr15135-b767f93.apk

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 52.91005% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.66%. Comparing base (98fa016) to head (bd8e0ac).

Files with missing lines Patch % Lines
...ndroid/ui/woopos/orders/WooPosIssueRefundDialog.kt 0.00% 72 Missing ⚠️
.../android/ui/woopos/orders/WooPosRefundViewModel.kt 76.27% 5 Missing and 9 partials ⚠️
...android/ui/woopos/orders/WooPosGroupRefundItems.kt 88.00% 1 Missing and 2 partials ⚠️
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.
📢 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.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 23, 2025

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants