Skip to content

fix(FI0-11277): NMD departure vs arrival fishery weight validation#188

Open
salfedev wants to merge 2 commits into
developfrom
bug/FI0-11277-nmd-departure-arrival-weight-validation
Open

fix(FI0-11277): NMD departure vs arrival fishery weight validation#188
salfedev wants to merge 2 commits into
developfrom
bug/FI0-11277-nmd-departure-arrival-weight-validation

Conversation

@salfedev
Copy link
Copy Markdown
Contributor


Description

Summary

Fixes FI0-11277 (Defect 593 UAT) — NMD departure and arrival weights validation was missing the check that fishery product departure weight ≤ fishery product arrival weight. This allowed users to submit an NMD with a fishery departure weight greater than its fishery arrival weight.

There was also no re-validation of departure vs arrival weight relationships at submission time, meaning a user who edited arrival weights after confirming departure weights could submit an NMD with stale/invalid weight data.

Changes

src/services/handlers/storage-notes.ts

  • Added new exported function checkNetWeightFisheryProductDepartureExceedsArrival (Scenario 5): blocks submission of the departure-product-summary page when fishery product departure weight exceeds fishery product arrival weight.
  • Called the new check on the /create-non-manipulation-document/:documentNumber/departure-product-summary handler alongside the existing checks.

src/services/progress.service.ts

  • Imported and called checkNetWeightFisheryProductDepartureExceedsArrival in catchesHaveValidDepartureWeights so the departure section shows as INCOMPLETE if the fishery arrival invariant is violated.

src/services/orchestration.service.ts

  • Imported the three weight-comparison functions from the storage-notes handler.
  • Updated checkValidationStorageNotes (submission endpoint) to re-run all departure vs arrival weight checks at submit time — sdNetWeightProductDepartureExceedsArrival, sdNetWeightFisheryProductDepartureExceedsArrival, and sdNetWeightFisheryProductDepartureExceedsProductDeparture — pushing failures into validationErrors to block document submission.

Tests

  • 2 new unit tests in storage-notes.jest.spec.ts covering Scenario 5 (error case and no-error case).
  • 3 new unit tests in orchestration.service.jest.spec.ts covering submission-time weight validation (departure > arrival, fishery departure > fishery arrival, valid case).

Fixes - Jira Link #

Ticket

FI0-11277

Type of change

Please tick the relevant option for your PR request. Follow Semantic Version: vMAJOR.MINOR.PATCH

  • Bug fix - PATCH (non-breaking change which fixes an issue)
  • New feature - MINOR (non-breaking change which adds functionality)
  • Breaking change - MAJOR (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, or other non-code files.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

salfedev added 2 commits May 13, 2026 12:27
…r NMD

- Add checkNetWeightFisheryProductDepartureExceedsArrival (Scenario 5)
  to storage-notes handler; called on /departure-product-summary
- Call the new check in progress.service catchesHaveValidDepartureWeights
  so the departure section is marked incomplete when invalid
- Re-run all departure vs arrival weight checks in
  checkValidationStorageNotes at submission time to block NMD submit
  when arrival weights were edited after departure weights were confirmed
…rs to shared module

Move the three departure vs arrival weight comparison functions out of
storage-notes.ts into a new src/validators/storageWeightValidator.ts.

storage-notes.ts already imports utility helpers from orchestration.service;
importing storage-notes in orchestration.service created a cycle. The new
shared module has no dependencies on either file.

- storage-notes.ts: import + re-export from storageWeightValidator
- orchestration.service.ts: import from storageWeightValidator (not storage-notes)
- progress.service.ts: import three comparison fns from storageWeightValidator

Also adds isolated progress service test for Scenario 5 (fishery departure
exceeds fishery arrival but product departure is valid).
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant