Skip to content

UIOR-1530 Fix payment terms accordion error state - #1878

Merged
usavkov-epam merged 1 commit into
masterfrom
UIOR-1530
Jul 27, 2026
Merged

UIOR-1530 Fix payment terms accordion error state#1878
usavkov-epam merged 1 commit into
masterfrom
UIOR-1530

Conversation

@usavkov-epam

@usavkov-epam usavkov-epam commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Purpose

Follow-up bug fixes for the Payment Terms form introduced in
UIOR-1530.

  • Make the Amount the default distribution type;
  • When activating the "Multi-year payments" checkbox, set "Total price" values based on calculated amount;
  • Keep fund distribution fields editable for non-pending order status;
  • False error indicator on the Payment Terms accordion — while async fund-distribution validation was in flight, omitFieldArraysAsyncErrors correctly stripped the pending Promise from paymentTerms.fiscalYearDistributions, but left the now-empty paymentTerms: {} object in the errors map. useErrorAccordionStatus iterates Object.keys(errors) and treats that empty object as a real error, keeping the accordion in the error state indefinitely.

Approach

Accordion false error state

Extended omitFieldArraysAsyncErrors to walk up the ancestor chain after
unsetting a nested path and remove any objects that are now empty. This ensures
{ paymentTerms: {} } is cleaned up alongside
paymentTerms.fiscalYearDistributions during the async-pending window. The
walk stops as soon as a non-empty ancestor is found, so real sibling errors
(e.g. paymentTerms.totalPrice) are preserved.

The function was also refactored into named, single-responsibility helpers
(hasPendingArrayError, hasResolvedItemErrors, isEmptyObject,
pruneEmptyAncestors) to make the logic easier to follow and test.

POLineForm was updated to use the useFormState() hook instead of
form.getState()?.errors so that the error map re-renders reactively
whenever final-form state changes.

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?
    • There are no breaking changes in this PR.

@usavkov-epam usavkov-epam self-assigned this Jul 27, 2026
@github-actions

Copy link
Copy Markdown

Jest Unit Test Results

    1 files  ± 0    307 suites  ±0   7m 4s ⏱️ -3s
1 134 tests +11  1 126 ✅ +11  8 💤 ±0  0 ❌ ±0 
1 142 runs  +11  1 134 ✅ +11  8 💤 ±0  0 ❌ ±0 

Results for commit 7113e04. ± Comparison against base commit 5fdaf1d.

@sonarqubecloud

Copy link
Copy Markdown

@usavkov-epam
usavkov-epam requested a review from a team July 27, 2026 12:07
@usavkov-epam
usavkov-epam merged commit d7feb83 into master Jul 27, 2026
16 checks passed
@usavkov-epam
usavkov-epam deleted the UIOR-1530 branch July 27, 2026 13:20
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.

2 participants