Skip to content

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Dec 5, 2025

WOOMOB-1826

Description

This PR introduces 2nd step in the POS refund flow. The "Review refund" step is shown after clicking "Continue" button in the item selection step. The changes include state management enhancements with a new step enum, formatted price fields for currency display, and test coverage for step navigation.

What's not included:

  • Refund reason - it's hardcoded for now, though the text style should match design specs
  • Edit reason button - it's not working yet
  • Via (payment method) - hardcoded text for now

Test Steps

  1. Go to Woo POS > Orders
  2. Tap "Issue refund" button and explore the refund flow

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.

- Introduce `RefundStep` (SelectItems, ReviewRefund) in `WooPosRefundState` to manage the refund flow.
- Add formatted price fields to `WooPosRefundState.Content` and populate them in `WooPosRefundViewModel` using `CurrencyFormatter`.
- Update `WooPosIssueRefundDialog` to render either item selection or review content based on the current step.
- Rename `RefundDialogContent` to `SelectItemsContent`.
- Add `ReviewRefundContent` composable to display refund summary, including subtotal, taxes, and total.
- Add `onContinueToReview` and `onBackToSelectItems` navigation logic to `WooPosRefundViewModel`.
- Add string resources for the refund review screen.
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 5, 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
Commit09ff917
Direct Downloadwoocommerce-wear-prototype-build-pr15064-09ff917.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 5, 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
Commit09ff917
Direct Downloadwoocommerce-prototype-build-pr15064-09ff917.apk

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 14.36170% with 161 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.63%. Comparing base (d62c547) to head (09ff917).

Files with missing lines Patch % Lines
...ndroid/ui/woopos/orders/WooPosIssueRefundDialog.kt 0.00% 161 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #15064      +/-   ##
============================================
- Coverage     38.66%   38.63%   -0.04%     
- Complexity    10362    10367       +5     
============================================
  Files          2168     2169       +1     
  Lines        123004   123170     +166     
  Branches      16977    16998      +21     
============================================
+ Hits          47561    47586      +25     
- Misses        70638    70779     +141     
  Partials       4805     4805              

☔ 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.

onContinue: () -> Unit
) {
Column(modifier = Modifier.fillMaxSize()) {
Column(modifier = Modifier.fillMaxWidth()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This makes the dialog adjust its height to the content rather than taking the whole height of the screen.

isTotal = true
)
WooPosText(
text = "Via payment card ••••1456",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be replaced with real value in the next iteration.

Copy link
Contributor

@malinajirka malinajirka Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 In general, I think it's safer to put an apparently wrong text for testing - just to ensure we don't miss it. E.g. "TEST: Via payment card ••••9999".

)
}
WooPosText(
text = "Customer bought an extra item.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well.

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 introduces a two-step refund flow in the WooCommerce POS by adding a "Review refund" step between item selection and actual refund processing. The changes include state management enhancements with a new step enum, formatted price fields for currency display, comprehensive test coverage for step navigation, and a new review screen UI with refund summary details.

  • Added RefundStep enum (SelectItems, ReviewRefund) to manage the refund workflow
  • Integrated CurrencyFormatter to populate formatted price fields in the refund state
  • Created ReviewRefundContent composable displaying subtotal, taxes, total, and placeholder sections for payment method and refund reason

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
WooPosRefundState.kt Added RefundStep sealed class and formatted price fields (formattedSubtotal, formattedTaxes, formattedTotal) to Content state
WooPosRefundUIEvent.kt Created new sealed class with events for navigation between steps (ContinueToReviewClicked, BackToSelectItemsClicked, DialogDismissed)
WooPosRefundViewModel.kt Added CurrencyFormatter dependency, price formatting logic in buildContentState, and onUIEvent handler for step transitions
WooPosRefundViewModelTest.kt Added comprehensive tests for step navigation, dialog dismissal behavior, and non-content state handling
WooPosIssueRefundDialog.kt Renamed RefundDialogContent to SelectItemsContent, added ReviewRefundContent with summary rows and action buttons, implemented step-based rendering
WooPosOrdersScreen.kt Removed onContinue parameter from WooPosIssueRefundDialog as navigation is now handled internally
strings.xml Added string resources for review screen labels, including plurals for items subtotal, refund total, reason, and edit actions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samiuelson samiuelson added type: task An internally driven task. feature: POS labels Dec 5, 2025
@samiuelson samiuelson added this to the 23.9 milestone Dec 5, 2025
@samiuelson samiuelson marked this pull request as ready for review December 5, 2025 18:32
) {
val viewModel: WooPosRefundViewModel =
hiltViewModel<WooPosRefundViewModel, WooPosRefundViewModel.Factory> { factory ->
hiltViewModel<WooPosRefundViewModel, WooPosRefundViewModel.Factory>(key = "refund_$orderId") { factory ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This recreates the VM when another order gets selected in the Orders pane.

@malinajirka malinajirka self-assigned this Dec 8, 2025
Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @samiuelson, great job! I've found a couple UI issues - they are not all related to the PR, but I thought it's better to mention them.

image
  1. I noticed the Refund dialog appears instantly without an animation - feels a bit off and inconsistent.

  2. Semi-related to the above - moving between steps is also without an animation.

  3. If I proceed to the Review refund step and I dismiss the dialog, upon reopening the flow, I'm on the review refund step instead of item selection step.

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

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants