Skip to content

Conversation

@samiuelson
Copy link
Contributor

@samiuelson samiuelson commented Sep 3, 2025

WOOMOB-1244

Description

This PR introduces POS-specific domain data model for Product Variation to replace direct usage of the ProductVariation.

Steps to reproduce

N/A

Testing information

Ensure that POS works without any visible change

  • Variations are loading
  • Variations pagination works
  • It's possible to add variation to cart and create order

The tests that have been performed

Above

Images/gif

N/A

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

@dangermattic
Copy link
Collaborator

dangermattic commented Sep 3, 2025

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@samiuelson samiuelson requested a review from Copilot September 3, 2025 21:35

This comment was marked as outdated.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 3, 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
Commit4ae74f9
Direct Downloadwoocommerce-wear-prototype-build-pr14564-4ae74f9.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 3, 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
Commit4ae74f9
Direct Downloadwoocommerce-prototype-build-pr14564-4ae74f9.apk

Base automatically changed from woomob-1232-woo-poslocal-catalog-propagate-header-with-total-number-of to trunk September 4, 2025 10:33
@samiuelson samiuelson requested a review from Copilot September 4, 2025 19:04

This comment was marked as outdated.

@samiuelson samiuelson added the feature: point of sale POS project label Sep 4, 2025
@samiuelson samiuelson modified the milestones: 23.3, 23.2 Sep 4, 2025
@samiuelson samiuelson marked this pull request as ready for review September 4, 2025 19:37
@samiuelson samiuelson requested a review from Copilot September 4, 2025 19:37
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 POS-specific domain data model WooPosVariation to replace direct usage of the general ProductVariation model within the WooCommerce POS system. The change provides better performance and cleaner separation of concerns for POS functionality.

  • Introduces WooPosVariation data class containing only POS-relevant fields
  • Replaces ProductVariation usage across POS-related classes with WooPosVariation
  • Moves and adapts the getNameForPOS extension function to work with the new model

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
WooPosVariation.kt Defines the new POS-specific variation model with conversion functions
WooPosGetVariationById.kt Updates return type to use WooPosVariation
WooPosVariationsViewModel.kt Removes extension function and updates to use new model
WooPosVariationsDataSource.kt Converts remote variations to WooPosVariation type
WooPosVariationsLRUCache.kt Updates cache type parameters to store WooPosVariation
WooPosCartViewModel.kt Updates variation handling to use new model
WooPosSearchByIdentifier*.kt Updates search functionality to work with new variation model
WooPosTotalsRepository.kt Updates import statements for moved extension function
WooPosSearchByIdentifierLocalTest.kt Updates test mocks to use actual WooPosVariation instances

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@samiuelson samiuelson marked this pull request as draft September 5, 2025 05:13
@samiuelson samiuelson marked this pull request as ready for review September 5, 2025 05:22
val remoteVariationId: Long,
val remoteProductId: Long,
val globalUniqueId: String,
val price: BigDecimal?,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 This is technically enough for now, but we'll likely need to have access to both sale and regular prices quite soon, so I'd consider including them similarly to how we do it in the product model. Having said that, feel free to leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd leave these props for now and update the model when we need them.

} else {
emptyList()
}
} catch (e: JsonSyntaxException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ I'd consider logging an error into the local log.

Copy link
Contributor

Choose a reason for hiding this comment

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

I realized this is related to the below comment - since we are doing the parsing within the model, not in a separate class, we don't have access to the logger. I'd personally vote for moving the parsing to a mapper so we can log issues and re-use a single instance of gson.

Copy link
Contributor Author

@samiuelson samiuelson Sep 5, 2025

Choose a reason for hiding this comment

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

Yes, parsing logic is now in the WooPosVariationMapper.kt file.

)
}

private val gson by lazy { Gson() }
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Having an instance of gson per instance feels a bit off. Have you considered creating a separate mapper class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the idea, done: abba849

parentId,
variationId
)?.toAppModel()
)?.toAppModel()?.toWooPosVariation()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Seems like we are mapping it to appModel and then to POS model - can we skip the first mapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in abba849

@wpmobilebot wpmobilebot modified the milestones: 23.2, 23.3 Sep 5, 2025
@wpmobilebot
Copy link
Collaborator

Version 23.2 has now entered code-freeze, so the milestone of this PR has been updated to 23.3.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 27.09677% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.29%. Comparing base (08931bc) to head (4ae74f9).
⚠️ Report is 9 commits behind head on trunk.

Files with missing lines Patch % Lines
...oid/ui/woopos/common/data/WooPosVariationMapper.kt 3.06% 95 Missing ⚠️
...home/items/variations/WooPosVariationsViewModel.kt 57.14% 5 Missing and 1 partial ⚠️
...id/ui/woopos/common/data/WooPosGetVariationById.kt 0.00% 4 Missing ⚠️
...ome/items/variations/WooPosVariationsDataSource.kt 72.72% 1 Missing and 2 partials ⚠️
...e/android/ui/woopos/common/data/WooPosVariation.kt 86.66% 2 Missing ⚠️
...id/ui/woopos/home/totals/WooPosTotalsRepository.kt 33.33% 2 Missing ⚠️
.../home/items/variations/WooPosVariationsLRUCache.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14564      +/-   ##
============================================
- Coverage     38.31%   38.29%   -0.03%     
- Complexity     9646     9651       +5     
============================================
  Files          2051     2053       +2     
  Lines        114860   114976     +116     
  Branches      15240    15247       +7     
============================================
+ Hits          44011    44029      +18     
- Misses        66817    66916      +99     
+ Partials       4032     4031       -1     

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

@malinajirka malinajirka merged commit f8e2fd7 into trunk Sep 8, 2025
18 checks passed
@malinajirka malinajirka deleted the woomob-1244-woo-poslocal-catalog-use-new-pos-specific-variation-model-in branch September 8, 2025 05:36
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.

6 participants