Skip to content

#538 - Fix plan version approval dates - #539

Merged
brijesh-amin merged 3 commits into
masterfrom
fix/538-plan-version-approval-date-master
Aug 10, 2026
Merged

#538 - Fix plan version approval dates#539
brijesh-amin merged 3 commits into
masterfrom
fix/538-plan-version-approval-date-master

Conversation

@brijesh-amin

Copy link
Copy Markdown
Collaborator

Summary

  • Process plan snapshots chronologically when building amendment history
  • Prevent an amendment from using an approval belonging to an earlier version
  • Preserve newest legal-version detection

Testing

  • npm test -- --run __tests__/unit/PlanSnapshot.amendmentSubmissions.spec.js
  • npm run build
  • npm run test:lint

Closes #538

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes incorrect approval-date attribution in plan version/amendment history by building amendment submissions in chronological order, ensuring approvals are only paired forward-in-time with the correct version.

Changes:

  • Process plan_snapshot rows oldest→newest when assembling amendment submission/approval pairs.
  • Update “mandatory amendment” boundary detection to use the prior snapshot in chronological iteration.
  • Preserve “current legal version” detection by searching from the newest entry while keeping chronological output.

Reviewed changes

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

File Description
src/libs/db2/model/plansnapshot.ts Switches amendment-history construction to chronological processing and adjusts current-legal-version detection accordingly.
__tests__/unit/PlanSnapshot.amendmentSubmissions.spec.js Adds a unit test covering mandatory amendment pairing with a later approval.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread __tests__/unit/PlanSnapshot.amendmentSubmissions.spec.js Outdated
Comment thread __tests__/unit/PlanSnapshot.amendmentSubmissions.spec.js
brijesh-amin and others added 2 commits August 10, 2026 11:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@brijesh-amin
brijesh-amin requested a lite review from Copilot August 10, 2026 18:45
@brijesh-amin
brijesh-amin merged commit b98c14b into master Aug 10, 2026
1 of 2 checks passed
@brijesh-amin
brijesh-amin deleted the fix/538-plan-version-approval-date-master branch August 10, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (3)

tests/unit/PlanSnapshot.amendmentSubmissions.spec.js:103

  • Same as above: assert the query orders snapshots ascending so the test will fail if the implementation reverts to descending ordering.
    const { default: PlanSnapshot } = await import('../../src/libs/db2/model/plansnapshot.ts');

    const result = await PlanSnapshot.fetchAmendmentSubmissions(db, 1444);

tests/unit/PlanSnapshot.amendmentSubmissions.spec.js:111

  • The issue description’s acceptance criteria includes “before the next amendment submission”. Consider adding a unit test that ensures an approval occurring after a newer mandatory submission is paired with the newer submission (and does not back-fill the older one).
      approvedBy: null,
    });
  });
});

tests/unit/PlanSnapshot.amendmentSubmissions.spec.js:60

  • The test currently doesn’t assert that fetchAmendmentSubmissions requests snapshots in ascending chronological order. Adding an orderBy expectation will make this regression-proof if the query ordering is accidentally changed back.

This issue also appears on line 100 of the same file.

    const { default: PlanSnapshot } = await import('../../src/libs/db2/model/plansnapshot.ts');

    const result = await PlanSnapshot.fetchAmendmentSubmissions(db, 1444);

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.

2 participants