Skip to content

Conversation

hichamboushaba
Copy link
Member

Description

As per the previous discussion, this PR introduces a model in the DB layer that maps to the API status keys, which avoids leaking this information to the UI layer.
Please feel free to share any thoughts or suggestions for improvement here.

Testing information

Code review should be enough, but small test to confirm there is no regression would be fine.

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

override val key = "complete"
}

data class Unknown(override val key: String) : Status
Copy link
Member Author

Choose a reason for hiding this comment

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

I know I mentioned I don't like having an Unknown value, but after thinking more about this and knowing how flexible WordPress is, I decided to go for the safest approach here.
We can revisit when next-admin implements logic for displaying badges, and see if we need to modify something to align, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good 👍

val localTimezone: String
)
) {
sealed interface Status {
Copy link
Member Author

Choose a reason for hiding this comment

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

I named this Status and not PaymentStatus as this seems related more to the booking status and not just payment (for example cancelled is not really a payment status).

I wonder if we should rename the UI model too or not, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

At the time, I thought this was the order payment status, but it looks like it's not so yeah the name change makes sense.

It's still a bit confusing to me, because we can have two cancelled status tags next to each other (attendance and this one) 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's still a bit confusing to me, because we can have two cancelled status tags next to each other (attendance and this one) 🤔

As discussed yesterday in the call, the cancelled status for the attendance is just a presentation status, it happens only when the booking itself is also cancelled.

but it looks like it's not so yeah the name change makes sense.

Sounds good, I'll rename the UI model too.

@hichamboushaba
Copy link
Member Author

@AdamGrzybkowski while working on this, I noticed AttendanceStatusTag doesn't have the Booking prefix, should we add it for the sake of consistency?

@hichamboushaba hichamboushaba marked this pull request as ready for review September 30, 2025 15:59
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 30, 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
Commit41ee907
Direct Downloadwoocommerce-wear-prototype-build-pr14667-41ee907.apk

@hichamboushaba hichamboushaba added this to the 23.4 milestone Sep 30, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 30, 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
Commit41ee907
Direct Downloadwoocommerce-prototype-build-pr14667-41ee907.apk

@AdamGrzybkowski AdamGrzybkowski self-assigned this Oct 1, 2025
Copy link
Contributor

@AdamGrzybkowski AdamGrzybkowski left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! :shipit:

val localTimezone: String
)
) {
sealed interface Status {
Copy link
Contributor

Choose a reason for hiding this comment

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

At the time, I thought this was the order payment status, but it looks like it's not so yeah the name change makes sense.

It's still a bit confusing to me, because we can have two cancelled status tags next to each other (attendance and this one) 🤔

override val key = "complete"
}

data class Unknown(override val key: String) : Status
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good 👍

BookingPaymentStatus.Paid -> stringResource(R.string.booking_payment_status_paid)
BookingPaymentStatus.Cancelled -> stringResource(R.string.booking_payment_status_cancelled)
BookingPaymentStatus.Complete -> stringResource(R.string.booking_payment_status_complete)
is BookingPaymentStatus.Unknown -> key
Copy link
Contributor

@AdamGrzybkowski AdamGrzybkowski Oct 1, 2025

Choose a reason for hiding this comment

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

Not sure if there's a better alternative, but just leaving a comment that this caught my attention. Displaying the raw values to the user could be risky, but it would be very handy at spotting the issue for us. One alternative I can think of would be to hide the badge completely.

Copy link
Member Author

Choose a reason for hiding this comment

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

Displaying the raw values to the user could be risky

Not necessarly risky, for example for orders, WordPress has plugins that adds custom statuses, and for those we display the raw keys when there is no label, as this is what wp-admin does, and that's what the users are used too.

So I said, I think we need to revisit this when next-admin adds the logic for the badges.

)
}

private fun BookingEntity.Status.toUiModel(): BookingPaymentStatus = when (this) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to do this now, but we will need the same mappings in the details screen, so we could start putting those in a separate file, so they are available for reuse.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is something we need, a proper mapper class would be useful for reusability.

@AdamGrzybkowski
Copy link
Contributor

@AdamGrzybkowski while working on this, I noticed AttendanceStatusTag doesn't have the Booking prefix, should we add it for the sake of consistency?

Makes sense, I guess. Feel free to rename in this PR, or we can do it later.

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 23.4. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@hichamboushaba hichamboushaba force-pushed the ciab-bookings-payment-status-refactor branch from 62ea539 to fdd2d59 Compare October 1, 2025 08:53
@hichamboushaba hichamboushaba merged commit d666a23 into trunk Oct 1, 2025
15 checks passed
@hichamboushaba hichamboushaba deleted the ciab-bookings-payment-status-refactor branch October 1, 2025 10:02
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 14.73684% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.42%. Comparing base (0154fe1) to head (41ee907).
⚠️ Report is 31 commits behind head on trunk.

Files with missing lines Patch % Lines
...ce/android/ui/bookings/compose/BookingStatusTag.kt 0.00% 33 Missing ⚠️
.../android/fluxc/persistence/entity/BookingEntity.kt 33.33% 12 Missing ⚠️
...ings/compose/BookingAttendanceStatusBottomSheet.kt 0.00% 11 Missing ⚠️
.../ui/bookings/compose/BookingAttendanceStatusTag.kt 0.00% 9 Missing ⚠️
...erce/android/ui/bookings/compose/BookingSummary.kt 22.22% 7 Missing ⚠️
...e/android/ui/bookings/list/BookingListViewState.kt 36.36% 2 Missing and 5 partials ⚠️
...id/ui/bookings/compose/BookingAttendanceSection.kt 0.00% 1 Missing ⚠️
...xc/network/rest/wpcom/wc/bookings/BookingsStore.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14667      +/-   ##
============================================
- Coverage     38.42%   38.42%   -0.01%     
  Complexity     9818     9818              
============================================
  Files          2089     2089              
  Lines        116528   116546      +18     
  Branches      15575    15592      +17     
============================================
- Hits          44778    44777       -1     
- Misses        67597    67612      +15     
- Partials       4153     4157       +4     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants