#538 - Fix plan version approval dates - #539
Conversation
There was a problem hiding this comment.
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_snapshotrows 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.
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>
There was a problem hiding this comment.
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
fetchAmendmentSubmissionsrequests snapshots in ascending chronological order. Adding anorderByexpectation 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);
Summary
Testing
npm test -- --run __tests__/unit/PlanSnapshot.amendmentSubmissions.spec.jsnpm run buildnpm run test:lintCloses #538