Skip to content

Comments

[CIAB: POS] Hide collect payment button for refunded bookings#15402

Open
samiuelson wants to merge 1 commit intotrunkfrom
woomob-2285-pos-booking-detail-dont-show-collect-payment-button-for
Open

[CIAB: POS] Hide collect payment button for refunded bookings#15402
samiuelson wants to merge 1 commit intotrunkfrom
woomob-2285-pos-booking-detail-dont-show-collect-payment-button-for

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Feb 20, 2026

Description

WOOMOB-2285

When a booking is in "Cancelled" status with a "Refunded" payment status, the "Collect Payment" button was still being shown in the POS booking detail screen. This PR hides the collect payment button for refunded bookings, since collecting payment on an already-refunded booking doesn't make sense.

Adds an isBookingRefunded check alongside the existing isBookingPaid check so that collectPaymentLabel is set to null when the booking is both cancelled and refunded.

Test Steps

  1. Open a POS booking that is Cancelled with Refunded payment status
  2. Verify the "Collect Payment" button is not shown
  3. Open a POS booking that is Cancelled but not refunded
  4. Verify the "Collect Payment" button is still shown
  5. Open a paid/completed booking and verify collect payment is still hidden as before

Images/gif

Cancelled && Refunded

image

Cancelled

image
  • 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.

@wpmobilebot
Copy link
Collaborator

App Icon📲 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
Build Number727
Version24.1-rc-3
Application IDcom.woocommerce.android.prealpha
Commitc9e122f
Installation URL0r5tma1jkqgbg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.29%. Comparing base (ab7c42b) to head (c9e122f).
⚠️ Report is 21 commits behind head on trunk.

Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #15402   +/-   ##
=========================================
  Coverage     39.29%   39.29%           
- Complexity    10977    10981    +4     
=========================================
  Files          2238     2238           
  Lines        127540   127545    +5     
  Branches      17802    17803    +1     
=========================================
+ Hits          50113    50120    +7     
+ Misses        72318    72316    -2     
  Partials       5109     5109           

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

@samiuelson samiuelson marked this pull request as ready for review February 20, 2026 10:48
@samiuelson samiuelson requested a review from kidinov February 20, 2026 10:49
@kidinov kidinov self-assigned this Feb 20, 2026
else -> false
}

private fun isBookingRefunded(
Copy link
Contributor

Choose a reason for hiding this comment

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

Small naming suggestion: isBookingPaid / isBookingRefunded sound like they only check the booking status, but they actually check a combination of booking status + payment status. This is a bit misleading.

Proposal:

  // Methods
  isBookingPaid(...)    → hasPaymentBeenCollected(...)
  isBookingRefunded(...) → hasPaymentBeenRefunded(...)

  // Local variables
  val isPaid = ...      → val isPaymentCollected = ...
  val isRefunded = ...  → val isPaymentRefunded = ...

Copy link
Contributor

Choose a reason for hiding this comment

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

@samiuelson thinking further -

Suggestion: instead of two boolean methods (isBookingPaid + isBookingRefunded), we could use a single method that returns an enum. The two booleans are really three mutually exclusive states: paid, refunded, or unpaid.

private enum class PaymentState { Paid, Refunded, Unpaid }            
                                                                                                                                                                                                                                                                                                                           
private fun resolvePaymentState(                                                                                                                                                                                                                                                                                           
    bookingStatus: BookingEntity.Status,
    paymentStatus: PaymentStatus,
): PaymentState = when (bookingStatus) {
    BookingEntity.Status.Paid, BookingEntity.Status.Complete -> PaymentState.Paid
    BookingEntity.Status.Cancelled -> when (paymentStatus) {
        PaymentStatus.PAID -> PaymentState.Paid
        PaymentStatus.REFUNDED -> PaymentState.Refunded
        else -> PaymentState.Unpaid
    }
    else -> PaymentState.Unpaid
}

Then usage becomes:

// actions list
val paymentState = resolvePaymentState(booking.status, paymentStatus)
if (paymentState == PaymentState.Paid) {
    add(WooPosBookingsState.BookingAction.IssueRefund(booking.orderId))
}

// payment section
val paymentState = resolvePaymentState(booking.status, paymentStatus)
paidWithLabel = if (paymentState == PaymentState.Paid) paymentInfo?.paymentMethodTitle else null,
collectPaymentLabel = if (paymentState == PaymentState.Unpaid) totalAmount else null,

This removes the two boolean methods, makes the states explicit, and avoids the !isPaid && !isRefunded check.

Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

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

LGTM - I left a code improvement suggestion

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants