KYC management: stage-wise notices, pagination, RD base chart
This commit is contained in:
@@ -10,7 +10,8 @@ import { Component, OnInit, OnDestroy, inject, Input, ElementRef, ViewChild } fr
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { HttpClient, HttpContext, HttpParams } from '@angular/common/http';
|
||||
import { SILENT_HTTP_ERROR } from 'app/core/http/silent-error.token';
|
||||
import { catchError, debounceTime, distinctUntilChanged, map, timeout } from 'rxjs/operators';
|
||||
import { forkJoin, of, Subject } from 'rxjs';
|
||||
import { MatDialog, MatDialogModule, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
@@ -2710,7 +2711,11 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
branchNameFor(branchId: number): string {
|
||||
return this.branches.find((b) => b.id === branchId)?.label ?? `Branch ${branchId}`;
|
||||
return (
|
||||
this.seenBranches.find((b) => b.id === branchId)?.name ??
|
||||
this.branches.find((b) => b.id === branchId)?.label ??
|
||||
`Branch ${branchId}`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4349,6 +4354,7 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
this.accountDetails = acc;
|
||||
this.resolveAccountBranch(acc, acTyp, token, this.selectedRow);
|
||||
this.jointHolders = acc.jointHolders ?? [];
|
||||
// GL only: look up the parent (header) GL's name. Never runs for any other account type.
|
||||
this.glParent = null;
|
||||
@@ -4965,6 +4971,75 @@ export class TransactionEntryComponent implements OnInit, OnDestroy {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the account on screen is held at the branch the signed-in user works at: true for their own branch, false for
|
||||
* another branch's, null while either branch is not known (the branch is then shown plain, uncoloured).
|
||||
*/
|
||||
get isOwnBranchAccount(): boolean | null {
|
||||
const mine = this.authService.getCredentials()?.officeId;
|
||||
const accountOffice = this.accountDetails?.officeId ?? this.clientDetails?.officeId;
|
||||
if (mine == null || accountOffice == null) return null;
|
||||
return Number(mine) === Number(accountOffice);
|
||||
}
|
||||
|
||||
/** What the BRANCH selector offers: the offices this login may use, plus the branches of the accounts picked here. */
|
||||
get branchSelectOptions(): { id: number; name: string }[] {
|
||||
const merged = this.branches.map(
|
||||
(branch) => this.seenBranches.find((seen) => seen.id === branch.id) ?? { id: branch.id, name: branch.label }
|
||||
);
|
||||
for (const seen of this.seenBranches) {
|
||||
if (!merged.some((branch) => branch.id === seen.id)) merged.push(seen);
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
/** Branches learned from the accounts picked on this screen; their names are real, whatever the office list says. */
|
||||
private seenBranches: { id: number; name: string }[] = [];
|
||||
|
||||
/**
|
||||
* The branch an account is held at. The savings, FD and RD detail responses carry no office, so the screen fell back
|
||||
* to the client's own branch and an account opened at another branch read as the client's. The client's account list
|
||||
* names each account's branch, so it is read from there. A current account's own response already carries it.
|
||||
*/
|
||||
private resolveAccountBranch(acc: any, acTyp: string, token: number, row: TxnRow | null | undefined): void {
|
||||
if (acc?.officeId != null && acc?.officeName) {
|
||||
this.adoptAccountBranch({ id: Number(acc.officeId), name: String(acc.officeName) }, row);
|
||||
return;
|
||||
}
|
||||
const type = (acTyp ?? '').toUpperCase();
|
||||
if (!acc?.id || !acc?.clientId || ![
|
||||
'SD',
|
||||
'FD',
|
||||
'RD',
|
||||
'CA'
|
||||
].includes(type)) return;
|
||||
this.http
|
||||
.get<any>(`/clients/${acc.clientId}/accounts`, { context: new HttpContext().set(SILENT_HTTP_ERROR, true) })
|
||||
.pipe(catchError(() => of(null)))
|
||||
.subscribe((res) => {
|
||||
// stale: another account was picked while this was loading
|
||||
if (token !== this.searchToken || this.accountDetails?.id !== acc.id) return;
|
||||
const list: any[] = (type === 'CA' ? res?.currentAccounts : res?.savingsAccounts) ?? [];
|
||||
const match = list.find((a: any) => a.id === acc.id);
|
||||
if (match?.officeId != null && match?.officeName) {
|
||||
this.adoptAccountBranch({ id: Number(match.officeId), name: String(match.officeName) }, row);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private adoptAccountBranch(branch: { id: number; name: string }, row: TxnRow | null | undefined): void {
|
||||
this.accountDetails = { ...this.accountDetails, officeId: branch.id, officeName: branch.name };
|
||||
// /offices lists only the signed-in user's own branches, or nothing for a user who may not read offices; the account's
|
||||
// branch must still be selectable, under its real name
|
||||
if (!this.seenBranches.some((b) => b.id === branch.id)) {
|
||||
this.seenBranches = [
|
||||
...this.seenBranches,
|
||||
branch
|
||||
];
|
||||
}
|
||||
if (row) row.br = branch.id;
|
||||
}
|
||||
|
||||
get openingDate(): string {
|
||||
const raw =
|
||||
this.accountDetails?.timeline?.submittedOnDate ??
|
||||
|
||||
Reference in New Issue
Block a user