Skip to content

Extract shared WooPosOrderCreatedData to remove duplicated types#15604

Merged
malinajirka merged 6 commits intotrunkfrom
issue/refactor-order-created-shared-data-classes
Apr 6, 2026
Merged

Extract shared WooPosOrderCreatedData to remove duplicated types#15604
malinajirka merged 6 commits intotrunkfrom
issue/refactor-order-created-shared-data-classes

Conversation

@kidinov
Copy link
Copy Markdown
Contributor

@kidinov kidinov commented Apr 2, 2026

Description

[Internal] Extract ProductInfo and CouponInfo data classes from the duplicated OrderCreated event definitions into a shared WooPosOrderCreatedData class.

Both ChildToParentEvent.OrderCreated and ParentToChildrenEvent.OrderCreated had identical ProductInfo (Simple + Variation) and CouponInfo hierarchies defined independently. This forced a 37-line boilerplate mapping function (handleOrderCreated) in WooPosHomeViewModel that copied every field one-by-one between the two identical types.

Now both events wrap a single WooPosOrderCreatedData, eliminating the duplication and the mapping code entirely.

Test Steps

  1. Open the POS
  2. Add products (simple + variable) and a coupon to the cart
  3. Check out
  4. Verify the cart updates correctly after order creation (prices, names, coupon discounts reflect server response)
  5. Verify "Changes in the cart" toast appears if the server returned different data
  6. Start a new transaction and confirm everything resets properly

Images/gif

N/A — no UI changes.

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

kidinov added 3 commits April 2, 2026 15:02
Extract ProductInfo and CouponInfo data classes into a standalone
shared file so both ChildToParent and ParentToChildren event
hierarchies can reference the same types.
Both ChildToParentEvent.OrderCreated and ParentToChildrenEvent.OrderCreated
had identical ProductInfo and CouponInfo hierarchies, forcing a boilerplate
mapping function in HomeViewModel. Now both events wrap the single shared
WooPosOrderCreatedData, removing ~100 lines of duplication and mapping code.
@kidinov kidinov added type: technical debt Represents or solves tech debt of the project. feature: point of sale POS project labels Apr 2, 2026
@kidinov kidinov requested a review from malinajirka April 2, 2026 13:06
@kidinov kidinov added this to the 24.6 milestone Apr 2, 2026
@kidinov kidinov marked this pull request as ready for review April 2, 2026 13:08
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 2, 2026

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 Number739
Version24.5-rc-1
Application IDcom.woocommerce.android.prealpha
Commit26239af
Installation URL6kpbvebvj0rj8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.64%. Comparing base (b3ed27d) to head (26239af).
⚠️ Report is 7 commits behind head on trunk.

Files with missing lines Patch % Lines
...roid/ui/woopos/home/cart/WooPosCartItemsUpdater.kt 33.33% 0 Missing and 4 partials ⚠️
...android/ui/woopos/home/cart/WooPosCartViewModel.kt 0.00% 2 Missing ⚠️
...erce/android/ui/woopos/home/WooPosHomeViewModel.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #15604      +/-   ##
============================================
- Coverage     39.64%   39.64%   -0.01%     
- Complexity    11357    11358       +1     
============================================
  Files          2259     2260       +1     
  Lines        130543   130492      -51     
  Branches      18284    18283       -1     
============================================
- Hits          51756    51728      -28     
+ Misses        73502    73479      -23     
  Partials       5285     5285              

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

Copy link
Copy Markdown
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.

LGTM, nice cleanup!

@malinajirka malinajirka enabled auto-merge April 2, 2026 15:18
@malinajirka malinajirka merged commit 8146506 into trunk Apr 6, 2026
16 checks passed
@malinajirka malinajirka deleted the issue/refactor-order-created-shared-data-classes branch April 6, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: point of sale POS project type: technical debt Represents or solves tech debt of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants