Skip to content

OBPIH-7143 return quantity allocated in cycle count pages#5276

Merged
awalkowiak merged 2 commits intodevelopfrom
ft/OBPIH-7143-cc-detect-pending-outbound
Jun 2, 2025
Merged

OBPIH-7143 return quantity allocated in cycle count pages#5276
awalkowiak merged 2 commits intodevelopfrom
ft/OBPIH-7143-cc-detect-pending-outbound

Conversation

@ewaterman
Copy link
Member

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7143

Description:

  1. On the backend, return quantityAllocated to the client for all rows in all cycle count tables (via PendingCycleCountRequest and CycleCountCandidate views) so that the client can grey out rows with quantityAllocated > 0
  2. On the backend, prevent a count from being requested on a product with quantityAllocated > 0

@ewaterman ewaterman self-assigned this May 23, 2025
@github-actions github-actions bot added type: feature A new piece of functionality for the app domain: backend Changes or discussions relating to the backend server flag: schema change Hilights a pull request that contains a change to the database schema domain: l10n Changes or discussions relating to localization & Internationalization labels May 23, 2025
CycleCountCandidate candidate = CycleCountCandidate.findByFacilityAndProduct(obj.facility, product)
if (candidate != null && candidate.quantityAllocated > 0) {
return ['hasQuantityAllocated', product.productCode]
}
Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator

@awalkowiak awalkowiak May 30, 2025

Choose a reason for hiding this comment

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

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I don't know why I was determined to use CycleCountCandidate for this

@codecov
Copy link

codecov bot commented May 23, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.35%. Comparing base (91765a6) to head (141198c).
⚠️ Report is 123 commits behind head on develop.

Files with missing lines Patch % Lines
...arehouse/inventory/CycleCountRequestCommand.groovy 0.00% 5 Missing ⚠️
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.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Integer quantityOnHand

Integer quantityAvailable
Integer quantityAllocated
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 don't think this was being used anywhere on the frontend (yet)

@awalkowiak awalkowiak merged commit 8acac6c into develop Jun 2, 2025
8 checks passed
@awalkowiak awalkowiak deleted the ft/OBPIH-7143-cc-detect-pending-outbound branch June 2, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server domain: l10n Changes or discussions relating to localization & Internationalization flag: schema change Hilights a pull request that contains a change to the database schema type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants