restore: minor auto-detect from DOB and FD/RD account filtering in nominee-tab

- 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 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-05-20 15:10:50 +05:30
co-authored by Claude Sonnet 4.6
parent bf3e26a0d0
commit 6f04c137c5
@@ -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 = '';