Skip to content

Conversation

@usavkov-epam
Copy link
Contributor

@usavkov-epam usavkov-epam commented Jan 20, 2026

Purpose

https://folio-org.atlassian.net/browse/UIOR-1466
https://folio-org.atlassian.net/browse/UIOR-1468

Use the ACQ holdings-analyzer service to determine whether a holding should be considered "abandoned" in order workflows. This centralizes and standardizes the abandonment check (replacing ad-hoc/duplicate heuristics in the UI), improving accuracy when validating/operating on holdings during order creation, editing and related interactions.

Why:

  • Ensure a single source of truth for holdings-abandonment logic used by ui-orders.
  • Prevent incorrect operations on holdings that the acquisitions domain considers abandoned.
  • Reduce duplicated logic and edge-case inconsistencies across order screens.

Summary of changes:

  • Integrated holdings-analyzer calls where holdings abandonment must be checked.
  • Added a small service/utility layer to call and cache analyzer responses.
  • Updated UI components and validation flows to use the analyzer result.
  • Tests and mocks updated to cover new behavior.
  • CHANGELOG entry added.

Approach

  • Delegate abandonment detection to the ACQ holdings-analyzer service via a new client wrapper in ui-orders.
  • Replace previous local heuristic checks with the analyzer result where applicable (order item/holding validation, form save/pre-submit checks).
  • Add unit tests for the new service and for components that now rely on analyzer responses, including failure/fallback scenarios.
  • Keep network failures safe: failures fall back to the prior behavior (non-blocking) and log errors so the UI remains usable if the analyzer is temporarily unavailable.

Learning

Pre-Merge Checklist

  • I've added appropriate record to the CHANGELOG.md
  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • If any API-related changes - okapi interfaces and permissions are reviewed/changed correspondingly
    • There are no breaking changes in this PR.

@usavkov-epam usavkov-epam self-assigned this Jan 20, 2026
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Jest Unit Test Results

    1 files  ± 0    294 suites   - 2   6m 58s ⏱️ -18s
1 001 tests +28  1 001 ✅ +28  0 💤 ±0  0 ❌ ±0 
1 009 runs  +28  1 009 ✅ +28  0 💤 ±0  0 ❌ ±0 

Results for commit a45c832. ± Comparison against base commit c639f5b.

This pull request removes 11 and adds 39 tests. Note that renamed tests count towards both.
PO Lines list contains at least one line with 'Independent order and receipt quantity' receiving workflow checkIndependentPOLinesAbandonedHoldings should return 'willAbandoned' value as 'false' if there are no abandoned holdings ‑ PO Lines list contains at least one line with 'Independent order and receipt quantity' receiving workflow checkIndependentPOLinesAbandonedHoldings should return 'willAbandoned' value as 'false' if there are no abandoned holdings
PO Lines list contains at least one line with 'Independent order and receipt quantity' receiving workflow checkIndependentPOLinesAbandonedHoldings should return 'willAbandoned' value as 'true' if there are some abandoned holdings ‑ PO Lines list contains at least one line with 'Independent order and receipt quantity' receiving workflow checkIndependentPOLinesAbandonedHoldings should return 'willAbandoned' value as 'true' if there are some abandoned holdings
PO Lines list contains at least one line with 'Synchronized order and receipt quantity' receiving workflow checkSynchronizedPOLinesAbandonedHoldings should return 'willAbandoned' value as 'false' if there are no abandoned holdings ‑ PO Lines list contains at least one line with 'Synchronized order and receipt quantity' receiving workflow checkSynchronizedPOLinesAbandonedHoldings should return 'willAbandoned' value as 'false' if there are no abandoned holdings
PO Lines list contains at least one line with 'Synchronized order and receipt quantity' receiving workflow checkSynchronizedPOLinesAbandonedHoldings should return 'willAbandoned' value as 'true' if there are some abandoned holdings ‑ PO Lines list contains at least one line with 'Synchronized order and receipt quantity' receiving workflow checkSynchronizedPOLinesAbandonedHoldings should return 'willAbandoned' value as 'true' if there are some abandoned holdings
checkRelatedHoldings should check if holding(s) related to piece(s), which not related to current POLine ‑ checkRelatedHoldings should check if holding(s) related to piece(s), which not related to current POLine
getConsortiumPiecesAndItemsCountByHoldingIds should call initPublicationRequest with correct URL, method, tenants, and signal ‑ getConsortiumPiecesAndItemsCountByHoldingIds should call initPublicationRequest with correct URL, method, tenants, and signal
getConsortiumPiecesAndItemsCountByHoldingIds should handle errors in responses ‑ getConsortiumPiecesAndItemsCountByHoldingIds should handle errors in responses
getConsortiumPiecesAndItemsCountByHoldingIds should handle mixed successful and error responses ‑ getConsortiumPiecesAndItemsCountByHoldingIds should handle mixed successful and error responses
getConsortiumPiecesAndItemsCountByHoldingIds should handle successful responses ‑ getConsortiumPiecesAndItemsCountByHoldingIds should handle successful responses
getPiecesAndItemsCountByHoldingIds should return pieces and items fetched by holding IDs ‑ getPiecesAndItemsCountByHoldingIds should return pieces and items fetched by holding IDs
…
checkRelatedHoldings analyzer.analyze call should call analyzer.analyze with correct parameters ‑ checkRelatedHoldings analyzer.analyze call should call analyzer.analyze with correct parameters
checkRelatedHoldings mixed scenarios should handle mixed abandoned and related holdings ‑ checkRelatedHoldings mixed scenarios should handle mixed abandoned and related holdings
checkRelatedHoldings mixed scenarios should return willAbandoned: false when multiple lines share same holding but not abandoned ‑ checkRelatedHoldings mixed scenarios should return willAbandoned: false when multiple lines share same holding but not abandoned
checkRelatedHoldings with abandoned holdings should calculate holdingsItemsCount from related items ‑ checkRelatedHoldings with abandoned holdings should calculate holdingsItemsCount from related items
checkRelatedHoldings with abandoned holdings should return willAbandoned: true when holding will be abandoned ‑ checkRelatedHoldings with abandoned holdings should return willAbandoned: true when holding will be abandoned
checkRelatedHoldings with empty holdings should handle missing explain structure gracefully ‑ checkRelatedHoldings with empty holdings should handle missing explain structure gracefully
checkRelatedHoldings with empty holdings should return false flags when no holdingIds provided ‑ checkRelatedHoldings with empty holdings should return false flags when no holdingIds provided
checkRelatedHoldings with related holdings should aggregate items count from multiple holdings ‑ checkRelatedHoldings with related holdings should aggregate items count from multiple holdings
checkRelatedHoldings with related holdings should return relatedToAnother: true when holding is related to another PO Line ‑ checkRelatedHoldings with related holdings should return relatedToAnother: true when holding is related to another PO Line
getHoldingIdsFromPOLines empty cases should handle PO line without locations property ‑ getHoldingIdsFromPOLines empty cases should handle PO line without locations property
…

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link

@usavkov-epam usavkov-epam merged commit e31b952 into master Jan 26, 2026
15 checks passed
@usavkov-epam usavkov-epam deleted the UIOR-1466 branch January 26, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants