OBPIH-7143 return quantity allocated in cycle count pages#5276
OBPIH-7143 return quantity allocated in cycle count pages#5276awalkowiak merged 2 commits intodevelopfrom
Conversation
| CycleCountCandidate candidate = CycleCountCandidate.findByFacilityAndProduct(obj.facility, product) | ||
| if (candidate != null && candidate.quantityAllocated > 0) { | ||
| return ['hasQuantityAllocated', product.productCode] | ||
| } |
There was a problem hiding this comment.
This is slow. We have a task to materialize the CycleCountCandidate views so that would speed this up, but I'm wondering if we even need to validate this on the backend.
We have https://pihemr.atlassian.net/browse/OBPIH-7046 which will have the frontend greying out rows where quantityAllocated > 0 so that would already be covering this case. The only reason to also have this logic on the backend would be if we want to protect against people calling the API directly (and so bypassing the frontend validation). But do we care about that? The backend logic still works if you do a count where quantityAllocated > 0 so there's nothing malicious that can be done.
There was a problem hiding this comment.
If this is problematic from the performance point of view, would it not be better to just do: (ProductAvailability.findAllByLocationAndProduct(obj.facility, product)?.sum { it.quantityAllocated ?: 0 } ?: 0) > 0
(fyi, I just typed this in here, did not test if it works, but I think it should)
There was a problem hiding this comment.
Good idea. I don't know why I was determined to use CycleCountCandidate for this
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5276 +/- ##
============================================
+ Coverage 8.33% 8.35% +0.01%
- Complexity 977 1000 +23
============================================
Files 645 649 +4
Lines 43368 43616 +248
Branches 10531 10571 +40
============================================
+ Hits 3613 3642 +29
- Misses 39204 39413 +209
- Partials 551 561 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| Integer quantityOnHand | ||
|
|
||
| Integer quantityAvailable | ||
| Integer quantityAllocated |
There was a problem hiding this comment.
I don't think this was being used anywhere on the frontend (yet)
✨ Description of Change
Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7143
Description: