From b8911eac53224a8b9a593f4185c98e4b13f3c714 Mon Sep 17 00:00:00 2001 From: Jacob Gardner Date: Thu, 19 Feb 2026 10:38:40 +0000 Subject: [PATCH 1/2] PO-2946/Update minor creditor header object to match backend schema --- .../accountEnquiry/AccountEnquiryHeader.cy.ts | 15 ++--- ...-acc-minor-creditor-details.component.html | 18 +++-- ...minor-creditor-details-header.interface.ts | 35 +++++----- ...-acc-minor-creditor-details-header.mock.ts | 27 ++++---- .../fines-acc-payload.service.spec.ts | 8 +-- .../services/fines-acc-payload.service.ts | 65 ++++++++++++------- 6 files changed, 96 insertions(+), 72 deletions(-) diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts index d1954b953f..c676d4a459 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts @@ -364,7 +364,7 @@ describe('Account Enquiry - Minor Creditor Header', () => { interceptAuthenticatedUser(); }); - const minorCreditorAccountId = FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK.account_number; + const minorCreditorAccountId = FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK.creditor.account_number; const minorCreditorComponentProperties: IComponentProperties = { accountId: minorCreditorAccountId, routeRoot: 'minor-creditor', @@ -380,11 +380,10 @@ describe('Account Enquiry - Minor Creditor Header', () => { it('AC1, AC2a: renders the Minor Creditor Account Header Summary', { tags: ['PO-1924'] }, () => { const header = structuredClone(FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK); - header.has_associated_defendant = true; - header.awaiting_payout_amount = 100; - header.awarded_amount = 200; - header.paid_out_amount = 50; - header.outstanding_amount = 150; + header.financials.awaiting_payout = 100; + header.financials.awarded = 200; + header.financials.paid_out = 50; + header.financials.outstanding = 150; interceptUserState(USER_STATE_MOCK_PERMISSION_BU77); interceptMinorCreditorHeader(minorCreditorAccountId, header, '1'); @@ -416,8 +415,8 @@ describe('Account Enquiry - Minor Creditor Header', () => { it('AC2b: hides Awarded and Outstanding when no defendant is associated', () => { const header = structuredClone(FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK); - header.awaiting_payout_amount = 100; - header.paid_out_amount = 50; + header.financials.awaiting_payout = 100; + header.financials.paid_out = 50; interceptUserState(USER_STATE_MOCK_PERMISSION_BU77); interceptMinorCreditorHeader(minorCreditorAccountId, header, '1'); diff --git a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html index aee71a78ba..0cd1606285 100644 --- a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html +++ b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html @@ -11,15 +11,13 @@

Account type:

- {{ accountData.creditor_account_type.display_name }} + {{ accountData.creditor.account_type.display_name }}

Business Unit:

- {{ accountData.business_unit_summary.business_unit_name }} ({{ - accountData.business_unit_summary.business_unit_id - }}) + {{ accountData.business_unit.business_unit_name }} ({{ accountData.business_unit.business_unit_id }})

@@ -29,31 +27,31 @@

Business Unit:


- @if (accountData.has_associated_defendant) { + @if (accountData.financials.awarded > 0 || accountData.financials.outstanding > 0) {

Awarded:

- {{ accountData.awarded_amount | monetary }} + {{ accountData.financials.awarded | monetary }}

}

Paid out:

- {{ accountData.paid_out_amount | monetary }} + {{ accountData.financials.paid_out | monetary }}

Awaiting payout:

- {{ accountData.awaiting_payout_amount | monetary }} + {{ accountData.financials.awaiting_payout | monetary }}

- @if (accountData.has_associated_defendant) { + @if (accountData.financials.awarded > 0 || accountData.financials.outstanding > 0) {

Outstanding:

- {{ accountData.outstanding_amount | monetary }} + {{ accountData.financials.outstanding | monetary }}

} diff --git a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts index 3cae5a891b..2e8df3fab7 100644 --- a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts +++ b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts @@ -1,17 +1,14 @@ export interface IOpalFinesAccountMinorCreditorDetailsHeader { version: string | null; - creditor_account_id: number; - account_number: string; - creditor_account_type: { - type: string; - display_name: string; - }; - business_unit_summary: { - business_unit_id: string; - business_unit_name: string; - welsh_speaking: string; + creditor: { + account_id: number; + account_number: string; + account_type: { + type: string; + display_name: string; + }; }; - party_details: { + party: { party_id: string; organisation_flag: boolean; organisation_details?: { @@ -24,9 +21,15 @@ export interface IOpalFinesAccountMinorCreditorDetailsHeader { surname: string; }; }; - awarded_amount: number; - paid_out_amount: number; - awaiting_payout_amount: number; - outstanding_amount: number; - has_associated_defendant: boolean; + business_unit: { + business_unit_id: string; + business_unit_name: string; + welsh_speaking: string; + }; + financials: { + awarded: number; + paid_out: number; + awaiting_payout: number; + outstanding: number; + }; } diff --git a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts index 63b988ccaa..73dc031076 100644 --- a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts +++ b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts @@ -2,18 +2,20 @@ import { IOpalFinesAccountMinorCreditorDetailsHeader } from '../interfaces/fines export const FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK: IOpalFinesAccountMinorCreditorDetailsHeader = { version: null, - creditor_account_id: 99000000000800, - account_number: '87654321', - creditor_account_type: { - type: 'MN', - display_name: 'Minor Creditor', + creditor: { + account_id: 99000000000800, + account_number: '87654321', + account_type: { + type: 'MN', + display_name: 'Minor Creditor', + }, }, - business_unit_summary: { + business_unit: { business_unit_id: '77', business_unit_name: 'Camberwell Green', welsh_speaking: 'N', }, - party_details: { + party: { party_id: '99000000000900', organisation_flag: true, organisation_details: { @@ -21,9 +23,10 @@ export const FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK: IOpalFinesAccountMino organisation_aliases: null, }, }, - awarded_amount: 0, - paid_out_amount: 0, - awaiting_payout_amount: 0, - outstanding_amount: 0, - has_associated_defendant: false, + financials: { + awarded: 0, + paid_out: 0, + awaiting_payout: 0, + outstanding: 0, + }, }; diff --git a/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts b/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts index 69988df8bf..f7e71413cc 100644 --- a/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts +++ b/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts @@ -230,11 +230,11 @@ describe('FinesAccPayloadService', () => { const result: IFinesAccountState = service.transformAccountHeaderForStore(account_id, header, 'minorCreditor'); expect(result).toEqual({ - account_number: header.account_number, + account_number: header.creditor.account_number, account_id: account_id, pg_party_id: null, party_id: header.party_details.party_id, - party_type: header.creditor_account_type.display_name, + party_type: header.creditor.account_type.display_name, party_name: header.party_details.organisation_details?.organisation_name ?? null, base_version: header.version, business_unit_id: header.business_unit_summary.business_unit_id, @@ -268,11 +268,11 @@ describe('FinesAccPayloadService', () => { const result: IFinesAccountState = service.transformAccountHeaderForStore(account_id, header, 'minorCreditor'); expect(result).toEqual({ - account_number: header.account_number, + account_number: header.creditor.account_number, account_id: account_id, pg_party_id: null, party_id: header.party_details.party_id, - party_type: header.creditor_account_type.display_name, + party_type: header.creditor.account_type.display_name, party_name: header.party_details.individual_details?.title + ' ' + diff --git a/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.ts b/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.ts index 5daed96efd..bed1bf5145 100644 --- a/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.ts +++ b/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.ts @@ -86,50 +86,71 @@ export class FinesAccPayloadService { headingData: IOpalFinesAccountDefendantDetailsHeader | IOpalFinesAccountMinorCreditorDetailsHeader, partyType: 'defendant' | 'minorCreditor', ): IFinesAccountState { - // Build party_name safely - const party_name = headingData.party_details.organisation_flag - ? (headingData.party_details.organisation_details?.organisation_name ?? '') - : [ - headingData.party_details.individual_details?.title, - headingData.party_details.individual_details?.forenames, - headingData.party_details.individual_details?.surname - ? headingData.party_details.individual_details.surname.toUpperCase() - : undefined, - ] - .filter(Boolean) - .join(' '); - - const business_unit_user_id = this.payloadService.getBusinessUnitBusinessUserId( - Number(headingData.business_unit_summary.business_unit_id), - this.globalStore.userState(), - ); - + let party_name: string; let pg_party_id: string | null = null; let party_type: string; let party_id: string; + let account_number: string; + let business_unit_user_id: string | null; + let business_unit_id: string | null; + let business_unit_welsh_speaking: string | null; if (partyType === 'defendant') { const h = headingData as IOpalFinesAccountDefendantDetailsHeader; pg_party_id = h.parent_guardian_party_id; party_type = h.debtor_type; party_id = h.defendant_account_party_id; + account_number = h.account_number; + party_name = h.party_details.organisation_flag + ? (h.party_details.organisation_details?.organisation_name ?? '') + : [ + h.party_details.individual_details?.title, + h.party_details.individual_details?.forenames, + h.party_details.individual_details?.surname + ? h.party_details.individual_details.surname.toUpperCase() + : undefined, + ] + .filter(Boolean) + .join(' '); + business_unit_user_id = this.payloadService.getBusinessUnitBusinessUserId( + Number(h.business_unit_summary.business_unit_id), + this.globalStore.userState(), + ); + business_unit_id = h.business_unit_summary.business_unit_id; + business_unit_welsh_speaking = h.business_unit_summary.welsh_speaking; } else { const h = headingData as IOpalFinesAccountMinorCreditorDetailsHeader; party_type = 'Minor Creditor'; - party_id = h.party_details.party_id; + party_id = h.party.party_id; + account_number = h.creditor.account_number; + party_name = h.party.organisation_flag + ? (h.party.organisation_details?.organisation_name ?? '') + : [ + h.party.individual_details?.title, + h.party.individual_details?.forenames, + h.party.individual_details?.surname ? h.party.individual_details.surname.toUpperCase() : undefined, + ] + .filter(Boolean) + .join(' '); + business_unit_user_id = this.payloadService.getBusinessUnitBusinessUserId( + Number(h.business_unit.business_unit_id), + this.globalStore.userState(), + ); + business_unit_id = h.business_unit.business_unit_id; + business_unit_welsh_speaking = h.business_unit.welsh_speaking; } return { - account_number: headingData.account_number, + account_number, account_id: Number(account_id), pg_party_id, party_id, party_type, party_name, base_version: headingData.version, - business_unit_id: headingData.business_unit_summary.business_unit_id, + business_unit_id: business_unit_id, business_unit_user_id, - welsh_speaking: headingData.business_unit_summary.welsh_speaking, + welsh_speaking: business_unit_welsh_speaking, }; } From a31e0942b07ec3abdbbe4439b4ce74f57177af69 Mon Sep 17 00:00:00 2001 From: louisbriggs Date: Tue, 31 Mar 2026 16:03:34 +0100 Subject: [PATCH 2/2] Updating unit test and template references to match interface for minor creditor header summary --- ...-acc-minor-creditor-details.component.html | 4 +- ...minor-creditor-details-header.interface.ts | 1 + ...-acc-minor-creditor-details-header.mock.ts | 1 + .../fines-acc-payload.service.spec.ts | 38 +++++++++---------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html index 0cd1606285..78ab9594d9 100644 --- a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html +++ b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/fines-acc-minor-creditor-details.component.html @@ -27,7 +27,7 @@

Business Unit:


- @if (accountData.financials.awarded > 0 || accountData.financials.outstanding > 0) { + @if (accountData.creditor.has_associated_defendant) {

Awarded:

@@ -47,7 +47,7 @@

Business Unit:

{{ accountData.financials.awaiting_payout | monetary }}

- @if (accountData.financials.awarded > 0 || accountData.financials.outstanding > 0) { + @if (accountData.creditor.has_associated_defendant) {

Outstanding:

diff --git a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts index 2e8df3fab7..804fe81d9b 100644 --- a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts +++ b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/interfaces/fines-acc-minor-creditor-details-header.interface.ts @@ -7,6 +7,7 @@ export interface IOpalFinesAccountMinorCreditorDetailsHeader { type: string; display_name: string; }; + has_associated_defendant: boolean; }; party: { party_id: string; diff --git a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts index 73dc031076..72a441f7bd 100644 --- a/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts +++ b/src/app/flows/fines/fines-acc/fines-acc-minor-creditor-details/mocks/fines-acc-minor-creditor-details-header.mock.ts @@ -9,6 +9,7 @@ export const FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK: IOpalFinesAccountMino type: 'MN', display_name: 'Minor Creditor', }, + has_associated_defendant: false, }, business_unit: { business_unit_id: '77', diff --git a/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts b/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts index f7e71413cc..663bf51bef 100644 --- a/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts +++ b/src/app/flows/fines/fines-acc/services/fines-acc-payload.service.spec.ts @@ -220,7 +220,7 @@ describe('FinesAccPayloadService', () => { it('should transform account header for store for a minor creditor (organisation)', () => { mockMacPayloadService.getBusinessUnitBusinessUserId.mockReturnValue( - FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK.business_unit_summary.business_unit_id, + FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK.business_unit.business_unit_id, ); const header: IOpalFinesAccountMinorCreditorDetailsHeader = structuredClone( FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK, @@ -233,17 +233,17 @@ describe('FinesAccPayloadService', () => { account_number: header.creditor.account_number, account_id: account_id, pg_party_id: null, - party_id: header.party_details.party_id, + party_id: header.party.party_id, party_type: header.creditor.account_type.display_name, - party_name: header.party_details.organisation_details?.organisation_name ?? null, + party_name: header.party.organisation_details?.organisation_name ?? null, base_version: header.version, - business_unit_id: header.business_unit_summary.business_unit_id, - business_unit_user_id: header.business_unit_summary.business_unit_id, - welsh_speaking: header.business_unit_summary.welsh_speaking, + business_unit_id: header.business_unit.business_unit_id, + business_unit_user_id: header.business_unit.business_unit_id, + welsh_speaking: header.business_unit.welsh_speaking, }); expect(mockMacPayloadService.getBusinessUnitBusinessUserId).toHaveBeenCalledWith( - Number(header.business_unit_summary.business_unit_id), + Number(header.business_unit.business_unit_id), OPAL_USER_STATE_MOCK, ); expect(mockGlobalStore.userState).toHaveBeenCalled(); @@ -251,19 +251,19 @@ describe('FinesAccPayloadService', () => { it('should transform account header for store for a minor creditor (individual)', () => { mockMacPayloadService.getBusinessUnitBusinessUserId.mockReturnValue( - FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK.business_unit_summary.business_unit_id, + FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK.business_unit.business_unit_id, ); const header: IOpalFinesAccountMinorCreditorDetailsHeader = structuredClone( FINES_ACC_MINOR_CREDITOR_DETAILS_HEADER_MOCK, ); const account_id = 77; - header.party_details.organisation_flag = false; - header.party_details.individual_details = { + header.party.organisation_flag = false; + header.party.individual_details = { title: 'Mr', forenames: 'John', surname: 'Doe', }; - delete header.party_details.organisation_details; + delete header.party.organisation_details; const result: IFinesAccountState = service.transformAccountHeaderForStore(account_id, header, 'minorCreditor'); @@ -271,22 +271,22 @@ describe('FinesAccPayloadService', () => { account_number: header.creditor.account_number, account_id: account_id, pg_party_id: null, - party_id: header.party_details.party_id, + party_id: header.party.party_id, party_type: header.creditor.account_type.display_name, party_name: - header.party_details.individual_details?.title + + header.party.individual_details?.title + ' ' + - header.party_details.individual_details?.forenames + + header.party.individual_details?.forenames + ' ' + - header.party_details.individual_details?.surname?.toUpperCase(), + header.party.individual_details?.surname?.toUpperCase(), base_version: header.version, - business_unit_id: header.business_unit_summary.business_unit_id, - business_unit_user_id: header.business_unit_summary.business_unit_id, - welsh_speaking: header.business_unit_summary.welsh_speaking, + business_unit_id: header.business_unit.business_unit_id, + business_unit_user_id: header.business_unit.business_unit_id, + welsh_speaking: header.business_unit.welsh_speaking, }); expect(mockMacPayloadService.getBusinessUnitBusinessUserId).toHaveBeenCalledWith( - Number(header.business_unit_summary.business_unit_id), + Number(header.business_unit.business_unit_id), OPAL_USER_STATE_MOCK, ); expect(mockGlobalStore.userState).toHaveBeenCalled();