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:
co-authored by
Claude Sonnet 4.6
parent
bf3e26a0d0
commit
6f04c137c5
@@ -75,6 +75,7 @@ export class NomineeTabComponent implements OnInit {
|
|||||||
nomineeRelationshipId: number | null = null;
|
nomineeRelationshipId: number | null = null;
|
||||||
nomineeShare: number | null = null;
|
nomineeShare: number | null = null;
|
||||||
nomineeIsMinor = false;
|
nomineeIsMinor = false;
|
||||||
|
minorToggleLocked = false;
|
||||||
nomineeSaving = false;
|
nomineeSaving = false;
|
||||||
nomineeRemarks = '';
|
nomineeRemarks = '';
|
||||||
|
|
||||||
@@ -153,13 +154,35 @@ export class NomineeTabComponent implements OnInit {
|
|||||||
this.clientsService.getClientAccountData(this.clientId).subscribe({
|
this.clientsService.getClientAccountData(this.clientId).subscribe({
|
||||||
next: (data: any) => {
|
next: (data: any) => {
|
||||||
this.loading = false;
|
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 = [
|
this.accountGroups = [
|
||||||
{
|
{
|
||||||
type: 'savings',
|
type: 'savings',
|
||||||
apiType: 'SB',
|
apiType: 'SB',
|
||||||
label: 'Savings Account',
|
label: 'Savings Account',
|
||||||
icon: 'savings',
|
icon: 'savings',
|
||||||
accounts: this.filterActive(data.savingsAccounts)
|
accounts: this.filterActive(savingsOnly)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'current',
|
type: 'current',
|
||||||
@@ -173,14 +196,14 @@ export class NomineeTabComponent implements OnInit {
|
|||||||
apiType: 'FD',
|
apiType: 'FD',
|
||||||
label: 'Fixed Deposit',
|
label: 'Fixed Deposit',
|
||||||
icon: 'lock',
|
icon: 'lock',
|
||||||
accounts: this.filterActive(data.fixedDepositAccounts)
|
accounts: this.filterActive(fdAccounts)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'rd',
|
type: 'rd',
|
||||||
apiType: 'RD',
|
apiType: 'RD',
|
||||||
label: 'Recurring Deposit',
|
label: 'Recurring Deposit',
|
||||||
icon: 'autorenew',
|
icon: 'autorenew',
|
||||||
accounts: this.filterActive(data.recurringDepositAccounts)
|
accounts: this.filterActive(rdAccounts)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'loan',
|
type: 'loan',
|
||||||
@@ -336,6 +359,9 @@ export class NomineeTabComponent implements OnInit {
|
|||||||
this.selectedClient = client;
|
this.selectedClient = client;
|
||||||
this.searchResults = [];
|
this.searchResults = [];
|
||||||
this.searchText = '';
|
this.searchText = '';
|
||||||
|
this.nomineeIsMinor = false;
|
||||||
|
this.minorToggleLocked = false;
|
||||||
|
this.selectedGuardian = null;
|
||||||
this.fetchClientDetails(client.id);
|
this.fetchClientDetails(client.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +389,7 @@ export class NomineeTabComponent implements OnInit {
|
|||||||
next: (data: any) => {
|
next: (data: any) => {
|
||||||
if (data?.dateOfBirth) {
|
if (data?.dateOfBirth) {
|
||||||
this.selectedClient = { ...this.selectedClient, dateOfBirth: data.dateOfBirth };
|
this.selectedClient = { ...this.selectedClient, dateOfBirth: data.dateOfBirth };
|
||||||
|
this.checkMinorFromDob(data.dateOfBirth);
|
||||||
}
|
}
|
||||||
done();
|
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 ═══
|
// ═══ Guardian ═══
|
||||||
|
|
||||||
onGuardianSearch(text: string): void {
|
onGuardianSearch(text: string): void {
|
||||||
@@ -606,6 +649,7 @@ export class NomineeTabComponent implements OnInit {
|
|||||||
this.nomineeRelationshipId = null;
|
this.nomineeRelationshipId = null;
|
||||||
this.nomineeShare = null;
|
this.nomineeShare = null;
|
||||||
this.nomineeIsMinor = false;
|
this.nomineeIsMinor = false;
|
||||||
|
this.minorToggleLocked = false;
|
||||||
this.nomineeRemarks = '';
|
this.nomineeRemarks = '';
|
||||||
this.selectedGuardian = null;
|
this.selectedGuardian = null;
|
||||||
this.searchText = '';
|
this.searchText = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user