From 6f04c137c5d71ee14b7e485c8fadb04efc000d76 Mon Sep 17 00:00:00 2001 From: Jaanu423 Date: Wed, 20 May 2026 15:10:50 +0530 Subject: [PATCH] restore: minor auto-detect from DOB and FD/RD account filtering in nominee-tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Restore checkMinorFromDob() — auto sets nomineeIsMinor + locks toggle when age < 18 - Restore FD/RD account filtering logic (savingsOnly/fdAccounts/rdAccounts) - Reset minorToggleLocked and selectedGuardian on new client select Co-Authored-By: Claude Sonnet 4.6 --- .../nominee-tab/nominee-tab.component.ts | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/src/app/clients/clients-view/nominee-tab/nominee-tab.component.ts b/src/app/clients/clients-view/nominee-tab/nominee-tab.component.ts index 7275b315d..f6b270b3c 100644 --- a/src/app/clients/clients-view/nominee-tab/nominee-tab.component.ts +++ b/src/app/clients/clients-view/nominee-tab/nominee-tab.component.ts @@ -75,6 +75,7 @@ export class NomineeTabComponent implements OnInit { nomineeRelationshipId: number | null = null; nomineeShare: number | null = null; nomineeIsMinor = false; + minorToggleLocked = false; nomineeSaving = false; nomineeRemarks = ''; @@ -153,13 +154,35 @@ export class NomineeTabComponent implements OnInit { this.clientsService.getClientAccountData(this.clientId).subscribe({ next: (data: any) => { this.loading = false; + const allSavings: any[] = data.savingsAccounts || []; + const savingsOnly = allSavings.filter( + (a: any) => + !a.depositType || + a.depositType?.code === 'depositAccountType.savingsDeposit' || + a.depositType?.value === 'Savings Deposit' + ); + const fdAccounts = [ + ...(data.fixedDepositAccounts || []), + ...allSavings.filter( + (a: any) => + a.depositType?.code === 'depositAccountType.fixedDeposit' || a.depositType?.value === 'Fixed Deposit' + ) + ]; + const rdAccounts = [ + ...(data.recurringDepositAccounts || []), + ...allSavings.filter( + (a: any) => + a.depositType?.code === 'depositAccountType.recurringDeposit' || + a.depositType?.value === 'Recurring Deposit' + ) + ]; this.accountGroups = [ { type: 'savings', apiType: 'SB', label: 'Savings Account', icon: 'savings', - accounts: this.filterActive(data.savingsAccounts) + accounts: this.filterActive(savingsOnly) }, { type: 'current', @@ -173,14 +196,14 @@ export class NomineeTabComponent implements OnInit { apiType: 'FD', label: 'Fixed Deposit', icon: 'lock', - accounts: this.filterActive(data.fixedDepositAccounts) + accounts: this.filterActive(fdAccounts) }, { type: 'rd', apiType: 'RD', label: 'Recurring Deposit', icon: 'autorenew', - accounts: this.filterActive(data.recurringDepositAccounts) + accounts: this.filterActive(rdAccounts) }, { type: 'loan', @@ -336,6 +359,9 @@ export class NomineeTabComponent implements OnInit { this.selectedClient = client; this.searchResults = []; this.searchText = ''; + this.nomineeIsMinor = false; + this.minorToggleLocked = false; + this.selectedGuardian = null; this.fetchClientDetails(client.id); } @@ -363,6 +389,7 @@ export class NomineeTabComponent implements OnInit { next: (data: any) => { if (data?.dateOfBirth) { this.selectedClient = { ...this.selectedClient, dateOfBirth: data.dateOfBirth }; + this.checkMinorFromDob(data.dateOfBirth); } done(); }, @@ -418,6 +445,22 @@ export class NomineeTabComponent implements OnInit { }); } + private checkMinorFromDob(dob: any): void { + let birthDate: Date; + if (Array.isArray(dob)) { + birthDate = new Date(dob[0], dob[1] - 1, dob[2]); + } else { + birthDate = new Date(dob); + } + if (isNaN(birthDate.getTime())) return; + const today = new Date(); + let age = today.getFullYear() - birthDate.getFullYear(); + const m = today.getMonth() - birthDate.getMonth(); + if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) age--; + this.nomineeIsMinor = age < 18; + this.minorToggleLocked = true; + } + // ═══ Guardian ═══ onGuardianSearch(text: string): void { @@ -606,6 +649,7 @@ export class NomineeTabComponent implements OnInit { this.nomineeRelationshipId = null; this.nomineeShare = null; this.nomineeIsMinor = false; + this.minorToggleLocked = false; this.nomineeRemarks = ''; this.selectedGuardian = null; this.searchText = '';