-
Notifications
You must be signed in to change notification settings - Fork 27
PSP-11387 remove the notice of claim if the noc comment/date are not specified. #5286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,7 @@ import { | |||||
| stringToNumberOrNull, | ||||||
| toTypeCodeNullable, | ||||||
| } from '@/utils/formUtils'; | ||||||
| import { exists, isValidId, isValidIsoDateTime } from '@/utils/utils'; | ||||||
| import { exists, isValidId, isValidIsoDateTime, isValidString } from '@/utils/utils'; | ||||||
|
|
||||||
| import { PropertyForm } from '../../shared/models'; | ||||||
| import { ChecklistItemFormModel } from '../../shared/tabs/checklist/update/models'; | ||||||
|
|
@@ -81,6 +81,19 @@ export class AcquisitionForm implements WithAcquisitionTeam, WithAcquisitionOwne | |||||
| toApi(): ApiGen_Concepts_AcquisitionFile { | ||||||
| const fileProperties = this.properties.map(x => this.toPropertyApi(x)); | ||||||
| const sortedProperties = applyDisplayOrder(fileProperties); | ||||||
| const noticeOfClaim: ApiGen_Concepts_NoticeOfClaim | null = this.noticeOfClaim | ||||||
| ? { | ||||||
| ...this.noticeOfClaim, | ||||||
| receivedDate: isValidString(this.noticeOfClaim?.receivedDate) | ||||||
| ? this.noticeOfClaim.receivedDate | ||||||
| : null, | ||||||
| comment: isValidString(this.noticeOfClaim?.comment?.trim()) | ||||||
| ? this.noticeOfClaim.comment.trim() | ||||||
| : null, | ||||||
| } | ||||||
| : null; | ||||||
| const hasNoticeOfClaim = | ||||||
| isValidString(noticeOfClaim?.receivedDate) || isValidString(noticeOfClaim?.comment); | ||||||
|
|
||||||
| return { | ||||||
| id: this.id ?? 0, | ||||||
|
|
@@ -136,7 +149,7 @@ export class AcquisitionForm implements WithAcquisitionTeam, WithAcquisitionOwne | |||||
| legacyStakeholders: null, | ||||||
| product: null, | ||||||
| project: null, | ||||||
| noticeOfClaim: exists(this.noticeOfClaim) ? [this.noticeOfClaim] : [], | ||||||
| noticeOfClaim: hasNoticeOfClaim && noticeOfClaim ? [noticeOfClaim] : [], | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
| ...getEmptyBaseAudit(this.rowVersion), | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,10 @@ export const UpdateAcquisitionFileYupSchema = yup | |
| .nullable() | ||
| .max(2000, 'Physical file details must be at most ${max} characters'), | ||
| noticeOfClaim: yup.object().shape({ | ||
| comment: yup.string().max(4000, 'Notice of claim comment must be at most ${max} characters'), | ||
| comment: yup | ||
| .string() | ||
| .nullable() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this nullable validation should be added to AddAcquisitionFileYupSchema.ts as well - right? |
||
| .max(4000, 'Notice of claim comment must be at most ${max} characters'), | ||
| }), | ||
| }) | ||
| .concat(UpdateAcquisitionTeamYupSchema) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { UpdateAcquisitionSummaryFormModel } from './models'; | ||
|
|
||
| describe('UpdateAcquisitionSummaryFormModel', () => { | ||
| describe('toApi noticeOfClaim handling', () => { | ||
| it('omits noticeOfClaim when date and comment are empty', () => { | ||
| const model = new UpdateAcquisitionSummaryFormModel(); | ||
| model.noticeOfClaim = { | ||
| id: null, | ||
| acquisitionFileId: null, | ||
| managementFileId: null, | ||
| comment: '', | ||
| receivedDate: '', | ||
| rowVersion: null, | ||
| }; | ||
|
|
||
| const apiModel = model.toApi(); | ||
|
|
||
| expect(apiModel.noticeOfClaim).toEqual([]); | ||
| }); | ||
|
|
||
| it('normalizes empty date to null and trims comment', () => { | ||
| const model = new UpdateAcquisitionSummaryFormModel(); | ||
| model.noticeOfClaim = { | ||
| id: null, | ||
| acquisitionFileId: null, | ||
| managementFileId: null, | ||
| comment: ' file update comment ', | ||
| receivedDate: '', | ||
| rowVersion: null, | ||
| }; | ||
|
|
||
| const apiModel = model.toApi(); | ||
|
|
||
| expect(apiModel.noticeOfClaim).toHaveLength(1); | ||
| expect(apiModel.noticeOfClaim?.[0]).toEqual( | ||
| expect.objectContaining({ | ||
| comment: 'file update comment', | ||
| receivedDate: null, | ||
| }), | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import { ApiGen_Concepts_InterestHolder } from '@/models/api/generated/ApiGen_Co | |
| import { ApiGen_Concepts_NoticeOfClaim } from '@/models/api/generated/ApiGen_Concepts_NoticeOfClaim'; | ||
| import { getEmptyBaseAudit } from '@/models/defaultInitializers'; | ||
| import { fromTypeCode, fromTypeCodeNullable, toTypeCodeNullable } from '@/utils/formUtils'; | ||
| import { exists, isValidId, isValidIsoDateTime } from '@/utils/utils'; | ||
| import { exists, isValidId, isValidIsoDateTime, isValidString } from '@/utils/utils'; | ||
|
|
||
| import { | ||
| AcquisitionOwnerFormModel, | ||
|
|
@@ -79,6 +79,20 @@ export class UpdateAcquisitionSummaryFormModel | |
| noticeOfClaim: ApiGen_Concepts_NoticeOfClaim; | ||
|
|
||
| toApi(): ApiGen_Concepts_AcquisitionFile { | ||
| const noticeOfClaim: ApiGen_Concepts_NoticeOfClaim | null = this.noticeOfClaim | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same comments regarding |
||
| ? { | ||
| ...this.noticeOfClaim, | ||
| receivedDate: isValidString(this.noticeOfClaim?.receivedDate) | ||
| ? this.noticeOfClaim.receivedDate | ||
| : null, | ||
| comment: isValidString(this.noticeOfClaim?.comment?.trim()) | ||
| ? this.noticeOfClaim.comment.trim() | ||
| : null, | ||
| } | ||
| : null; | ||
| const hasNoticeOfClaim = | ||
| isValidString(noticeOfClaim?.receivedDate) || isValidString(noticeOfClaim?.comment); | ||
|
|
||
| return { | ||
| id: this.id || 0, | ||
| parentAcquisitionFileId: isValidId(this.parentAcquisitionFileId) | ||
|
|
@@ -143,7 +157,7 @@ export class UpdateAcquisitionSummaryFormModel | |
| product: null, | ||
| project: null, | ||
| totalAllowableCompensation: null, | ||
| noticeOfClaim: exists(this.noticeOfClaim) ? [this.noticeOfClaim] : [], | ||
| noticeOfClaim: hasNoticeOfClaim && noticeOfClaim ? [noticeOfClaim] : [], | ||
| ...getEmptyBaseAudit(this.rowVersion), | ||
| }; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { ManagementFormModel } from './ManagementFormModel'; | ||
|
|
||
| describe('ManagementFormModel', () => { | ||
| describe('toApi noticeOfClaim handling', () => { | ||
| it('omits noticeOfClaim when date and comment are empty', () => { | ||
| const model = new ManagementFormModel(); | ||
| model.noticeOfClaim = { | ||
| id: null, | ||
| acquisitionFileId: null, | ||
| managementFileId: null, | ||
| comment: '', | ||
| receivedDate: '', | ||
| rowVersion: null, | ||
| }; | ||
|
|
||
| const apiModel = model.toApi(); | ||
|
|
||
| expect(apiModel.noticeOfClaim).toEqual([]); | ||
| }); | ||
|
|
||
| it('normalizes empty date to null and trims comment', () => { | ||
| const model = new ManagementFormModel(); | ||
| model.noticeOfClaim = { | ||
| id: null, | ||
| acquisitionFileId: null, | ||
| managementFileId: null, | ||
| comment: ' comment from formik ', | ||
| receivedDate: '', | ||
| rowVersion: null, | ||
| }; | ||
|
|
||
| const apiModel = model.toApi(); | ||
|
|
||
| expect(apiModel.noticeOfClaim).toHaveLength(1); | ||
| expect(apiModel.noticeOfClaim?.[0]).toEqual( | ||
| expect.objectContaining({ | ||
| comment: 'comment from formik', | ||
| receivedDate: null, | ||
| }), | ||
| ); | ||
| }); | ||
|
|
||
| it('keeps receivedDate when provided and normalizes empty comment', () => { | ||
| const model = new ManagementFormModel(); | ||
| model.noticeOfClaim = { | ||
| id: null, | ||
| acquisitionFileId: null, | ||
| managementFileId: null, | ||
| comment: ' ', | ||
| receivedDate: '2026-04-17', | ||
| rowVersion: null, | ||
| }; | ||
|
|
||
| const apiModel = model.toApi(); | ||
|
|
||
| expect(apiModel.noticeOfClaim).toHaveLength(1); | ||
| expect(apiModel.noticeOfClaim?.[0]).toEqual( | ||
| expect.objectContaining({ | ||
| comment: null, | ||
| receivedDate: '2026-04-17', | ||
| }), | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import { ApiGen_Concepts_NoticeOfClaim } from '@/models/api/generated/ApiGen_Con | |
| import { getEmptyBaseAudit } from '@/models/defaultInitializers'; | ||
| import { applyDisplayOrder } from '@/utils'; | ||
| import { fromTypeCode, toNullableId, toTypeCodeNullable } from '@/utils/formUtils'; | ||
| import { exists, isValidId } from '@/utils/utils'; | ||
| import { exists, isValidId, isValidString } from '@/utils/utils'; | ||
|
|
||
| import { PropertyForm } from '../../shared/models'; | ||
| import { ManagementTeamSubFormModel, WithManagementTeam } from './ManagementTeamSubFormModel'; | ||
|
|
@@ -50,6 +50,19 @@ export class ManagementFormModel implements WithManagementTeam { | |
| const sortedProperties = applyDisplayOrder(fileProperties); | ||
| const personId = this.responsiblePayer?.personId ?? null; | ||
| const organizationId = !personId ? this.responsiblePayer?.organizationId ?? null : null; | ||
| const noticeOfClaim: ApiGen_Concepts_NoticeOfClaim | null = this.noticeOfClaim | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments re: exists()
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also AddManagementFormYupSchema needs to be updated with nullable comment field |
||
| ? { | ||
| ...this.noticeOfClaim, | ||
| receivedDate: isValidString(this.noticeOfClaim?.receivedDate) | ||
| ? this.noticeOfClaim.receivedDate | ||
| : null, | ||
| comment: isValidString(this.noticeOfClaim?.comment?.trim()) | ||
| ? this.noticeOfClaim.comment.trim() | ||
| : null, | ||
| } | ||
| : null; | ||
| const hasNoticeOfClaim = | ||
| isValidString(noticeOfClaim?.receivedDate) || isValidString(noticeOfClaim?.comment); | ||
|
|
||
| return { | ||
| id: this.id ?? 0, | ||
|
|
@@ -81,7 +94,8 @@ export class ManagementFormModel implements WithManagementTeam { | |
| .filter(exists), | ||
| fileProperties: sortedProperties ?? [], | ||
| ...getEmptyBaseAudit(this.rowVersion), | ||
| noticeOfClaim: exists(this.noticeOfClaim) ? [this.noticeOfClaim] : [], | ||
| noticeOfClaim: hasNoticeOfClaim && noticeOfClaim ? [noticeOfClaim] : [], | ||
| ...getEmptyBaseAudit(this.rowVersion), | ||
| }; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use
exists()