feat: KYC risk profiling, AML flagged transactions bulk review, Risk Review report & Board Resolution register
This commit is contained in:
+309
@@ -0,0 +1,309 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { Component, Inject, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormBuilder, FormArray, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { forkJoin, of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { AmlService } from 'app/aml/aml.service';
|
||||
|
||||
export interface AmlBulkReviewData {
|
||||
alerts: any[];
|
||||
disposition: 'WHITELIST' | 'ESCALATE';
|
||||
}
|
||||
|
||||
/**
|
||||
* One disposition applied to several alerts at once.
|
||||
*
|
||||
* <p>
|
||||
* Low and medium-severity alerts arrive as runs of the same thing - a customer whose ordinary cash
|
||||
* deposits each cross a threshold - and clearing them one dialog at a time is what keeps an officer
|
||||
* from reaching the alert that matters. The reason and evidence are asked once and written against
|
||||
* every alert in the batch, so each still carries its own record of why it was disposed of.
|
||||
*
|
||||
* <p>
|
||||
* High-severity alerts never reach here: the caller will not tick them. An alert in the high band is
|
||||
* a judgement about that particular transaction and gets its own decision.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-aml-bulk-review-dialog',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
MatDialogModule,
|
||||
MatButtonModule,
|
||||
MatCheckboxModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule
|
||||
],
|
||||
template: `
|
||||
<h2 mat-dialog-title>
|
||||
{{ isWhitelist ? 'Whitelist' : 'Escalate' }} {{ data.alerts.length }} Alert{{
|
||||
data.alerts.length === 1 ? '' : 's'
|
||||
}}
|
||||
</h2>
|
||||
<mat-dialog-content>
|
||||
<p class="bk-intro">
|
||||
The same decision, reason and evidence are recorded against each alert below. Every one stays
|
||||
individually auditable.
|
||||
</p>
|
||||
|
||||
<div class="bk-list">
|
||||
<div class="bk-row" *ngFor="let a of data.alerts">
|
||||
<span class="bk-txn">{{ a.transactionType }} #{{ a.transactionId }}</span>
|
||||
<span class="bk-client">{{ a.clientDisplayName }}</span>
|
||||
<span class="bk-rule">{{ a.ruleCode }}</span>
|
||||
<span class="bk-amt">₹{{ a.amount | number: '1.0-0' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form [formGroup]="form">
|
||||
<!-- Clearing an alert has to rest on something. Escalation does not: the officer is saying
|
||||
it needs investigating, which is the opposite of claiming it is explained. -->
|
||||
<div class="bk-evidence" *ngIf="isWhitelist">
|
||||
<div class="bk-label">Evidence relied on</div>
|
||||
<div formArrayName="evidence" class="bk-checks">
|
||||
<mat-checkbox *ngFor="let t of evidenceTypes; let i = index" [formControlName]="i">{{ t }}</mat-checkbox>
|
||||
</div>
|
||||
<p class="bk-err" *ngIf="evidenceMissing">Tick at least one piece of evidence</p>
|
||||
|
||||
<mat-form-field appearance="outline" class="bk-full">
|
||||
<mat-label>Reference (optional)</mat-label>
|
||||
<input matInput formControlName="evidenceRef" maxlength="100" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<mat-form-field appearance="outline" class="bk-full">
|
||||
<mat-label>{{ isWhitelist ? 'Evidence detail' : 'What makes these suspicious?' }}</mat-label>
|
||||
<textarea matInput formControlName="notes" rows="3" maxlength="800"></textarea>
|
||||
<mat-error *ngIf="form.get('notes')?.hasError('required')">A reason is required</mat-error>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
|
||||
<p class="bk-effect" [class.bk-effect--warn]="!isWhitelist">
|
||||
{{
|
||||
isWhitelist
|
||||
? 'Cleared as false positives — no report is filed, and the evidence is retained against each alert.'
|
||||
: 'Each alert opens its own STR case for the Principal Officer.'
|
||||
}}
|
||||
</p>
|
||||
|
||||
<p class="bk-err" *ngIf="errorMessage">{{ errorMessage }}</p>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-stroked-button type="button" (click)="dialogRef.close(false)">Cancel</button>
|
||||
<button
|
||||
mat-flat-button
|
||||
[color]="isWhitelist ? 'primary' : 'warn'"
|
||||
type="button"
|
||||
[disabled]="form.invalid || submitting"
|
||||
(click)="submit()"
|
||||
>
|
||||
{{ submitting ? 'Applying…' : isWhitelist ? 'Whitelist All' : 'Escalate All' }}
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
`,
|
||||
styles: [
|
||||
`
|
||||
.bk-intro {
|
||||
font-size: 13px;
|
||||
color: #64748b;
|
||||
margin: 0 0 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.bk-list {
|
||||
max-height: 190px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 16px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
.bk-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1.4fr 1.6fr 0.9fr;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid #eef2f7;
|
||||
}
|
||||
.bk-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.bk-txn {
|
||||
font-family: 'DM Mono', monospace;
|
||||
color: #334155;
|
||||
}
|
||||
.bk-client {
|
||||
color: #1e293b;
|
||||
}
|
||||
.bk-rule {
|
||||
color: #7c3aed;
|
||||
font-size: 11px;
|
||||
}
|
||||
.bk-amt {
|
||||
text-align: right;
|
||||
font-family: 'DM Mono', monospace;
|
||||
color: #1e293b;
|
||||
}
|
||||
.bk-label {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: #64748b;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.bk-checks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.bk-full {
|
||||
width: 100%;
|
||||
}
|
||||
.bk-effect {
|
||||
font-size: 12.5px;
|
||||
line-height: 1.5;
|
||||
color: #15803d;
|
||||
background: #f0fdf4;
|
||||
border: 1px solid #bbf7d0;
|
||||
border-radius: 6px;
|
||||
padding: 10px 12px;
|
||||
margin: 4px 0 0;
|
||||
}
|
||||
.bk-effect--warn {
|
||||
color: #b91c1c;
|
||||
background: #fef2f2;
|
||||
border-color: #fecaca;
|
||||
}
|
||||
.bk-err {
|
||||
margin: 10px 0 0;
|
||||
color: #b91c1c;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
`
|
||||
]
|
||||
})
|
||||
export class AmlBulkReviewDialogComponent {
|
||||
private fb = inject(FormBuilder);
|
||||
private amlService = inject(AmlService);
|
||||
dialogRef = inject(MatDialogRef<AmlBulkReviewDialogComponent>);
|
||||
|
||||
readonly evidenceTypes = [
|
||||
'Customer explanation obtained',
|
||||
'Source of funds documented',
|
||||
'KYC / identity re-verified',
|
||||
'Consistent with declared income or turnover',
|
||||
'Established business or salary pattern',
|
||||
'Duplicate or system-generated alert',
|
||||
'Other'
|
||||
];
|
||||
|
||||
form: FormGroup;
|
||||
submitting = false;
|
||||
errorMessage = '';
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: AmlBulkReviewData) {
|
||||
this.form = this.fb.group({
|
||||
evidence: this.fb.array(this.evidenceTypes.map(() => false)),
|
||||
evidenceRef: [
|
||||
'',
|
||||
Validators.maxLength(100)
|
||||
],
|
||||
notes: [
|
||||
'',
|
||||
[
|
||||
Validators.required,
|
||||
Validators.maxLength(800)
|
||||
]
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
get isWhitelist(): boolean {
|
||||
return this.data.disposition === 'WHITELIST';
|
||||
}
|
||||
|
||||
get evidenceArray(): FormArray {
|
||||
return this.form.get('evidence') as FormArray;
|
||||
}
|
||||
|
||||
get selectedEvidence(): string[] {
|
||||
return this.evidenceTypes.filter((_, i) => this.evidenceArray.at(i)?.value === true);
|
||||
}
|
||||
|
||||
get evidenceMissing(): boolean {
|
||||
return this.isWhitelist && this.evidenceArray.touched && this.selectedEvidence.length === 0;
|
||||
}
|
||||
|
||||
/** Exactly what is written to each alert, so the record reads the same as a single review. */
|
||||
private composedNotes(): string {
|
||||
const v = this.form.value;
|
||||
const detail = (v.notes || '').trim();
|
||||
if (!this.isWhitelist) {
|
||||
return detail ? `Grounds: ${detail}` : '';
|
||||
}
|
||||
const parts: string[] = [];
|
||||
if (this.selectedEvidence.length) {
|
||||
parts.push(`Evidence: ${this.selectedEvidence.join('; ')}`);
|
||||
}
|
||||
if (v.evidenceRef) {
|
||||
parts.push(`Ref: ${(v.evidenceRef || '').trim()}`);
|
||||
}
|
||||
const head = parts.join(' | ');
|
||||
const composed = head && detail ? `${head} — ${detail}` : head || detail;
|
||||
// Batch note, so each alert says it was disposed of alongside others rather than on its own.
|
||||
return `${composed} [batch of ${this.data.alerts.length}]`.slice(0, 1000);
|
||||
}
|
||||
|
||||
submit(): void {
|
||||
this.evidenceArray.markAllAsTouched();
|
||||
if (this.form.invalid || (this.isWhitelist && this.selectedEvidence.length === 0)) {
|
||||
this.form.markAllAsTouched();
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
this.errorMessage = '';
|
||||
const notes = this.composedNotes();
|
||||
|
||||
// Each alert is reviewed on its own call: one that fails - already disposed of by someone else,
|
||||
// say - must not take the rest of the batch with it. Failures are counted and reported.
|
||||
forkJoin(
|
||||
this.data.alerts.map((a) =>
|
||||
this.amlService
|
||||
.reviewAlert(a.id, this.data.disposition, notes)
|
||||
.pipe(catchError(() => of({ __failed: true, id: a.id })))
|
||||
)
|
||||
).subscribe((results: any[]) => {
|
||||
this.submitting = false;
|
||||
const failed = results.filter((r) => r?.__failed).length;
|
||||
if (failed === results.length) {
|
||||
this.errorMessage = 'None of the alerts could be updated. They may already have been reviewed.';
|
||||
return;
|
||||
}
|
||||
if (failed > 0) {
|
||||
this.errorMessage = `${results.length - failed} updated, ${failed} could not be — those may already have been reviewed.`;
|
||||
// Still closes as done: most of the batch landed, and the list behind must refresh.
|
||||
setTimeout(() => this.dialogRef.close(true), 2200);
|
||||
return;
|
||||
}
|
||||
this.dialogRef.close(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
+258
-14
@@ -60,23 +60,113 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Severity mix of what the table is showing -->
|
||||
<!-- Severity mix of what the table is showing. Each tile narrows the table to its own band;
|
||||
clicking the one already in force clears it, as does Total Flagged. -->
|
||||
<div class="risk-summary">
|
||||
<div *ngFor="let tier of riskSummary" class="risk-tile" [ngClass]="tier.cls">
|
||||
<button
|
||||
*ngFor="let tier of riskSummary"
|
||||
type="button"
|
||||
class="risk-tile"
|
||||
[ngClass]="tier.cls"
|
||||
[class.tile-active]="isSeverityActive(tier.key)"
|
||||
[disabled]="tier.count === 0 && !isSeverityActive(tier.key)"
|
||||
[matTooltip]="isSeverityActive(tier.key) ? 'Show every severity again' : 'Show only ' + tier.label + ' alerts'"
|
||||
(click)="setSeverity(tier.key)"
|
||||
>
|
||||
<span class="risk-tile-n">{{ tier.count }}</span>
|
||||
<span class="risk-tile-l">{{ tier.label }}</span>
|
||||
</div>
|
||||
<div *ngIf="unclassifiedCount > 0" class="risk-tile risk-none" matTooltip="Raised by a user, not by a catalog rule">
|
||||
</button>
|
||||
<button
|
||||
*ngIf="unclassifiedCount > 0"
|
||||
type="button"
|
||||
class="risk-tile risk-none"
|
||||
[class.tile-active]="isSeverityActive(0)"
|
||||
matTooltip="Raised by a user, not by a catalog rule"
|
||||
(click)="setSeverity(0)"
|
||||
>
|
||||
<span class="risk-tile-n">{{ unclassifiedCount }}</span>
|
||||
<span class="risk-tile-l">Unclassified</span>
|
||||
</div>
|
||||
<div class="risk-tile risk-total">
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="risk-tile risk-total"
|
||||
[class.tile-active]="activeSeverity === null"
|
||||
matTooltip="Show every severity"
|
||||
(click)="clearSeverity()"
|
||||
>
|
||||
<span class="risk-tile-n">{{ summaryTotal }}</span>
|
||||
<span class="risk-tile-l">Total Flagged</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<table mat-table [dataSource]="alerts" class="flagged-table mat-elevation-z1">
|
||||
<!-- Appears only once something is ticked, so the table does not carry a permanently empty bar. -->
|
||||
@if (selectedCount > 0) {
|
||||
<div class="bulk-bar">
|
||||
<span class="bulk-count">{{ selectedCount }} selected</span>
|
||||
<span class="bulk-note">Low / medium only — a transaction that tripped a high-severity rule is decided on its own.</span>
|
||||
<span class="bulk-spacer"></span>
|
||||
<button mat-stroked-button type="button" (click)="selectedIds.clear()">Clear</button>
|
||||
<button
|
||||
mat-stroked-button
|
||||
color="primary"
|
||||
type="button"
|
||||
*mifosxHasPermission="'REVIEW_AML_ALERT'"
|
||||
(click)="reviewSelected('WHITELIST')"
|
||||
>
|
||||
Whitelist {{ selectedCount }}
|
||||
</button>
|
||||
<button
|
||||
mat-flat-button
|
||||
color="warn"
|
||||
type="button"
|
||||
*mifosxHasPermission="'REVIEW_AML_ALERT'"
|
||||
(click)="reviewSelected('ESCALATE')"
|
||||
>
|
||||
Escalate {{ selectedCount }}
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- multiTemplateDataRows: each alert renders through both row definitions — the alert row and its
|
||||
detail row beneath it. Without it MatTable renders one row per alert, the two definitions both
|
||||
claim it, and the table throws rather than rendering anything. All three tabs share one tab
|
||||
group, so that error blanked Repeat Customers and Rules Master as well. -->
|
||||
<table mat-table [dataSource]="alerts" multiTemplateDataRows class="flagged-table mat-elevation-z1">
|
||||
<!-- Ticked for a batch decision. Disabled where the transaction tripped a high-severity rule,
|
||||
where nothing it matched carried a severity (the CTR rules), or where it is already decided. -->
|
||||
<ng-container matColumnDef="select">
|
||||
<th mat-header-cell *matHeaderCellDef class="select-cell">
|
||||
<!-- Hidden outright when nothing here can be batched — filtered to high severity, say. -->
|
||||
@if (selectableRows.length) {
|
||||
<mat-checkbox
|
||||
[checked]="allSelectableSelected"
|
||||
(change)="toggleSelectAll()"
|
||||
matTooltip="Select every low / medium alert on this page"
|
||||
></mat-checkbox>
|
||||
}
|
||||
</th>
|
||||
<td mat-cell *matCellDef="let alert" class="select-cell" (click)="$event.stopPropagation()">
|
||||
<!-- No checkbox at all where the transaction cannot be part of a batch. A disabled box still
|
||||
reads as "this could be ticked", and on a high-severity row that is the wrong thing to
|
||||
suggest: the decision is never a batch one. A dash says the column does not apply. -->
|
||||
@if (isSelectable(alert)) {
|
||||
<mat-checkbox [checked]="isSelected(alert)" (change)="toggleSelected(alert)"></mat-checkbox>
|
||||
} @else {
|
||||
<span
|
||||
class="select-na"
|
||||
[matTooltip]="
|
||||
isHighSeverity(alert)
|
||||
? 'High severity — this transaction is decided on its own'
|
||||
: !canReview(alert)
|
||||
? 'Already decided'
|
||||
: 'A CTR is a statutory return, not a graded suspicion — decided on its own'
|
||||
"
|
||||
>—</span
|
||||
>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- When the engine raised the alert -->
|
||||
<ng-container matColumnDef="raisedOn">
|
||||
<th mat-header-cell *matHeaderCellDef>Raised On</th>
|
||||
@@ -113,6 +203,142 @@
|
||||
<div class="stacked-cell">
|
||||
<span class="rule-code">{{ alert.ruleCode }}</span>
|
||||
<span class="cell-sub">{{ alert.ruleDescription }}</span>
|
||||
<!-- The transaction is one case under one rule, but an analyst still needs to see
|
||||
everything it tripped — a deposit can be both reportable and on a new account. The
|
||||
detail row carries each one with its own severity; this is only the count. -->
|
||||
@if (matchedRuleCount(alert) > 1) {
|
||||
<button type="button" class="rule-more" (click)="toggleExpanded(alert); $event.stopPropagation()">
|
||||
<mat-icon>{{ isExpanded(alert) ? 'expand_less' : 'expand_more' }}</mat-icon>
|
||||
{{ matchedRuleCount(alert) }} rules matched
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- The expanded pane. One cell spanning the table, collapsed to zero height until its row is
|
||||
opened, so the detail sits directly under the row it belongs to. -->
|
||||
<ng-container matColumnDef="expandedDetail">
|
||||
<!-- No header cell: this column never appears in the header row, only in its own data row. -->
|
||||
<td mat-cell *matCellDef="let alert" [attr.colspan]="displayedColumns.length" class="detail-cell">
|
||||
<!-- The pane is inside a row that toggles on click, so anything interactive in here must keep its own
|
||||
clicks from reaching it — otherwise ticking a rule closes the pane. -->
|
||||
<div class="detail-pane" [class.detail-open]="isExpanded(alert)" (click)="$event.stopPropagation()">
|
||||
@if (isExpanded(alert)) {
|
||||
<div class="detail-inner">
|
||||
<div class="detail-head">
|
||||
<span>Rules matched by {{ alert.transactionType | lowercase }} #{{ alert.transactionId }} — {{ amount(alert) }}</span>
|
||||
@if (selectableRulesOf(alert).length > 1) {
|
||||
<button type="button" class="rule-select-all" (click)="toggleAllRules(alert)">
|
||||
{{ allRulesSelected(alert) ? 'Clear all' : 'Select all open' }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<!-- Governing rule first: it is the one the alert was raised under, and the one the
|
||||
disposition is recorded against. -->
|
||||
@for (rule of matchedRules(alert); track rule.ruleCode) {
|
||||
<div
|
||||
class="detail-rule"
|
||||
[class.detail-rule-governing]="rule.governing"
|
||||
[class.detail-rule-decided]="rule.disposition"
|
||||
>
|
||||
<!-- One checkbox per rule: a transaction can trip six rules where five are explained by the
|
||||
customer's business and the sixth is not, and those are different decisions. A rule already
|
||||
decided shows its verdict instead. -->
|
||||
@if (isRuleSelectable(rule)) {
|
||||
<mat-checkbox
|
||||
[checked]="isRuleSelected(rule)"
|
||||
(change)="toggleRuleSelected(rule)"
|
||||
*mifosxHasPermission="'REVIEW_AML_ALERT'"
|
||||
></mat-checkbox>
|
||||
} @else if (!isGradedRule(rule)) {
|
||||
<!-- A statutory return, not a graded suspicion: filed on the amount whatever the officer decides
|
||||
about the transaction, so there is nothing here to tick. -->
|
||||
<mat-icon
|
||||
class="rule-decided-icon decided-statutory"
|
||||
matTooltip="A statutory return — filed on the amount, whatever is decided about this transaction. Nothing to review here."
|
||||
matTooltipClass="evidence-tooltip"
|
||||
>
|
||||
gavel
|
||||
</mat-icon>
|
||||
} @else {
|
||||
<mat-icon
|
||||
class="rule-decided-icon"
|
||||
[class.decided-escalated]="rule.disposition === 'ESCALATE' && rule.directlyDecided"
|
||||
[class.decided-carried]="!rule.directlyDecided"
|
||||
[matTooltip]="
|
||||
(rule.directlyDecided ? ruleDispositionLabel(rule) : 'Closed with the case') +
|
||||
(rule.reviewedByUsername ? ' by ' + rule.reviewedByUsername : '') +
|
||||
(rule.reviewNotes ? ' — ' + rule.reviewNotes : '')
|
||||
"
|
||||
matTooltipClass="evidence-tooltip"
|
||||
>
|
||||
{{ !rule.directlyDecided ? 'remove_circle_outline' : rule.disposition === 'ESCALATE' ? 'report' : 'verified' }}
|
||||
</mat-icon>
|
||||
}
|
||||
<span class="sev-chip" [ngClass]="severityClass(rule.riskCategory)">{{ severityLabel(rule.riskCategory) }}</span>
|
||||
<div class="detail-rule-text">
|
||||
<span class="detail-rule-code">
|
||||
{{ rule.ruleCode }}
|
||||
@if (rule.governing) {
|
||||
<span class="governing-tag" matTooltip="The alert is raised and decided under this rule">governing</span>
|
||||
}
|
||||
<!-- Says where a statutory rule actually goes, so the absence of a checkbox does not read as the
|
||||
transaction being unreported. -->
|
||||
@if (!isGradedRule(rule)) {
|
||||
<span class="ctr-tag" matTooltip="Goes to the monthly CTR filing for FIU-IND, not to an STR">
|
||||
→ CTR filing
|
||||
</span>
|
||||
}
|
||||
<!-- The rule the officer named reads as their decision; a rule closed alongside it says so,
|
||||
because an audit of the finding turns on which one they put their name to. -->
|
||||
@if (rule.disposition) {
|
||||
<span
|
||||
class="rule-verdict"
|
||||
[class.verdict-escalated]="rule.disposition === 'ESCALATE'"
|
||||
[class.verdict-carried]="!rule.directlyDecided"
|
||||
[matTooltip]="
|
||||
rule.directlyDecided
|
||||
? ruleDispositionLabel(rule) +
|
||||
(rule.reviewedByUsername ? ' by ' + rule.reviewedByUsername : '')
|
||||
: 'Closed with the transaction when another rule was marked suspicious — not decided on its own'
|
||||
"
|
||||
>
|
||||
{{ rule.directlyDecided ? ruleDispositionLabel(rule) : 'Closed with case' }}
|
||||
</span>
|
||||
}
|
||||
</span>
|
||||
<span class="detail-rule-desc">{{ rule.ruleDescription }}</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Acts on the ticked rules only. The alert's own status follows from what is left undecided, so
|
||||
clearing five of six rules leaves the case open on the sixth. -->
|
||||
@if (selectedRuleCount > 0) {
|
||||
<div class="rule-action-bar" *mifosxHasPermission="'REVIEW_AML_ALERT'">
|
||||
<span class="rule-action-count">{{ selectedRuleCount }} rule{{ selectedRuleCount > 1 ? 's' : '' }} selected</span>
|
||||
<span class="bulk-spacer"></span>
|
||||
<button mat-stroked-button type="button" (click)="selectedRuleCodes.clear()">Clear</button>
|
||||
<button mat-stroked-button color="primary" type="button" (click)="reviewSelectedRules(alert, 'WHITELIST')">
|
||||
Whitelist
|
||||
</button>
|
||||
<button mat-flat-button color="warn" type="button" (click)="reviewSelectedRules(alert, 'ESCALATE')">
|
||||
Suspicious
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
<div class="detail-foot">
|
||||
@if (isHighSeverity(alert)) {
|
||||
A high-severity rule fired, so this transaction is decided on its own rather than in a batch.
|
||||
} @else if (!alert.highestSeverity) {
|
||||
A statutory return rather than a graded suspicion — decided on its own.
|
||||
} @else {
|
||||
Every rule here is low or medium, so this transaction can be decided together with others.
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
@@ -132,7 +358,7 @@
|
||||
<!-- Disposition. Hidden once an alert is already whitelisted or escalated. -->
|
||||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef class="col-center">Action</th>
|
||||
<td mat-cell *matCellDef="let alert" class="col-center actions-cell">
|
||||
<td mat-cell *matCellDef="let alert" class="col-center actions-cell" (click)="$event.stopPropagation()">
|
||||
<ng-container *ngIf="canReview(alert); else reviewed">
|
||||
<!-- Same gate the FIU-IND register uses; the endpoint enforces REVIEW_AML_ALERT server side,
|
||||
so without this a user who cannot review still sees buttons that only fail on click. -->
|
||||
@@ -180,15 +406,33 @@
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns" class="alert-row" [class.row-new]="isNew(row)"></tr>
|
||||
<!-- Clicking anywhere on the row opens its detail. The checkbox and the action buttons stop the
|
||||
event themselves, so ticking a row or disposing of it does not also expand it. -->
|
||||
<tr
|
||||
mat-row
|
||||
*matRowDef="let row; columns: displayedColumns"
|
||||
class="alert-row"
|
||||
[class.row-new]="isNew(row)"
|
||||
[class.row-expanded]="isExpanded(row)"
|
||||
(click)="toggleExpanded(row)"
|
||||
></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="detail-row"></tr>
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons class="flagged-paginator"></mat-paginator>
|
||||
<!-- pageSize stated explicitly: without it the paginator starts at 0, and anything that touches the
|
||||
paginator before the data source has bound to it leaves that 0 in force, which pages every row
|
||||
out of the table. -->
|
||||
<mat-paginator
|
||||
[pageSize]="10"
|
||||
[pageSizeOptions]="[10, 25, 50, 100]"
|
||||
showFirstLastButtons
|
||||
class="flagged-paginator"
|
||||
></mat-paginator>
|
||||
|
||||
<div *ngIf="alerts.data.length === 0 && !loading" class="no-alerts-message">
|
||||
<mat-icon>{{ activeStatus ? 'filter_alt_off' : 'verified_user' }}</mat-icon>
|
||||
<span *ngIf="!activeStatus"
|
||||
<mat-icon>{{ activeStatus || activeSeverity !== null ? 'filter_alt_off' : 'verified_user' }}</mat-icon>
|
||||
<span *ngIf="!activeStatus && activeSeverity === null"
|
||||
>No transactions flagged. The feed updates automatically as the engine raises alerts.</span
|
||||
>
|
||||
<span *ngIf="activeStatus">No alerts in this status.</span>
|
||||
<span *ngIf="activeStatus || activeSeverity !== null">No alerts match the filters in force.</span>
|
||||
</div>
|
||||
|
||||
+366
-1
@@ -196,15 +196,43 @@
|
||||
padding: 0 0 16px;
|
||||
}
|
||||
|
||||
/* A button, not a div: each tile narrows the table to its own severity band. */
|
||||
.risk-tile {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-left-width: 4px;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
font-family: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
box-shadow 0.15s,
|
||||
transform 0.1s;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
box-shadow: 0 2px 8px rgb(15 23 42 / 12%);
|
||||
}
|
||||
|
||||
&:active:not(:disabled) {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
/* A band with nothing in it would filter to an empty table. */
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
/* The band currently narrowing the table. The ring reads on every tile colour, where a
|
||||
background change would fight the severity tint each tile already carries. */
|
||||
.risk-tile.tile-active {
|
||||
box-shadow: 0 0 0 2px #1a237e;
|
||||
}
|
||||
|
||||
.risk-tile-n {
|
||||
@@ -293,8 +321,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.alert-row:hover {
|
||||
.alert-row {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
/* The open row and its pane read as one block. */
|
||||
.alert-row.row-expanded {
|
||||
background: #f8fafc;
|
||||
|
||||
td {
|
||||
border-bottom-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/* A newly arrived alert stays tinted until acknowledged. */
|
||||
@@ -380,6 +421,285 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Quieter than the governing rule: it is context on one case, not a second case. */
|
||||
.rule-also {
|
||||
margin-top: 3px;
|
||||
color: #92400e;
|
||||
background: #fffbeb;
|
||||
border: 1px solid #fde68a;
|
||||
border-radius: 4px;
|
||||
padding: 1px 6px;
|
||||
font-size: 11px;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
/* Says how many rules fired and opens the detail. Replaces the block of codes that used to sit in
|
||||
this cell: the codes belong in the pane, where each can carry its own severity. */
|
||||
.rule-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
margin-top: 4px;
|
||||
padding: 2px 8px 2px 4px;
|
||||
align-self: flex-start;
|
||||
border: 1px solid #fde68a;
|
||||
border-radius: 999px;
|
||||
background: #fffbeb;
|
||||
color: #92400e;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
|
||||
mat-icon {
|
||||
font-size: 15px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #fef3c7;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Expanded detail ─────────────────────────────────────────────────────────────────────── */
|
||||
|
||||
.detail-row {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.detail-cell {
|
||||
padding: 0 !important;
|
||||
border-bottom: none !important;
|
||||
}
|
||||
|
||||
/* Animating max-height rather than height: the pane's height depends on how many rules fired, and
|
||||
a transition needs a figure to move between. */
|
||||
.detail-pane {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.2s ease;
|
||||
background: #f8fafc;
|
||||
|
||||
/* Generous enough for a transaction that tripped every rule it could, plus the action bar. Too low
|
||||
silently clips the last rule, which is the one an officer most needs to see. */
|
||||
&.detail-open {
|
||||
max-height: 1200px;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-inner {
|
||||
padding: 14px 16px 16px 60px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.detail-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: #64748b;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.rule-select-all {
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #1a237e;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
/* A rule that already carries a verdict is context, not a choice. */
|
||||
.detail-rule-decided {
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.rule-decided-icon {
|
||||
flex: none;
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: #15803d;
|
||||
cursor: help;
|
||||
|
||||
&.decided-escalated {
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
/* Closed alongside another rule rather than judged on its own — stated, but not as a verdict. */
|
||||
&.decided-carried {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
/* A statutory return: not the officer's decision at all. */
|
||||
&.decided-statutory {
|
||||
color: #475569;
|
||||
}
|
||||
}
|
||||
|
||||
/* Where a statutory rule goes, said next to the rule rather than left to be inferred from a
|
||||
missing checkbox. */
|
||||
.ctr-tag {
|
||||
margin-left: 6px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 4px;
|
||||
background: #e2e8f0;
|
||||
color: #334155;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rule-verdict {
|
||||
margin-left: 6px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 4px;
|
||||
background: #dcfce7;
|
||||
color: #15803d;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
|
||||
&.verdict-escalated {
|
||||
background: #fee2e2;
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
/* Wins over the disposition colours above: this rule was not itself the finding, and colouring it
|
||||
like one would claim the officer condemned it. */
|
||||
&.verdict-carried {
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
/* Acts on the ticked rules only, and sits with them rather than at the top of the table. */
|
||||
.rule-action-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #bfdbfe;
|
||||
border-radius: 8px;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.rule-action-count {
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
color: #1e3a8a;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.detail-rule {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 7px 10px;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
|
||||
& + & {
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
/* The rule the alert was raised under, and the one the disposition is recorded against. */
|
||||
.detail-rule-governing {
|
||||
border-color: #cbd5e1;
|
||||
box-shadow: inset 3px 0 0 #1a237e;
|
||||
}
|
||||
|
||||
.detail-rule-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.detail-rule-code {
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.detail-rule-desc {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.governing-tag {
|
||||
margin-left: 6px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 4px;
|
||||
background: #e0e7ff;
|
||||
color: #3730a3;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Severity of one rule inside the pane. Same colours as the summary tiles, so a band reads the
|
||||
same wherever it appears. */
|
||||
.sev-chip {
|
||||
flex: none;
|
||||
min-width: 62px;
|
||||
text-align: center;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
|
||||
&.sev-high {
|
||||
background: #fee2e2;
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
&.sev-medium {
|
||||
background: #fef3c7;
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
&.sev-low {
|
||||
background: #dcfce7;
|
||||
color: #15803d;
|
||||
}
|
||||
|
||||
&.sev-none {
|
||||
background: #e2e8f0;
|
||||
color: #475569;
|
||||
}
|
||||
}
|
||||
|
||||
/* Why this transaction can or cannot be decided in a batch, said where the officer is deciding. */
|
||||
.detail-foot {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #475569;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.rule-code {
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -537,3 +857,48 @@
|
||||
background: #fff;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
/* Batch disposition bar — only rendered while rows are ticked. */
|
||||
.bulk-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 16px;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #bfdbfe;
|
||||
border-radius: 10px;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.bulk-count {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #1e3a8a;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Says why some rows cannot be ticked, where the officer is looking rather than in a tooltip. */
|
||||
.bulk-note {
|
||||
font-size: 12px;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.bulk-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.select-cell {
|
||||
width: 44px;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
/* Stands in for the checkbox on a row that cannot be batched, so the column still reads as a
|
||||
column rather than leaving a hole the eye has to account for. */
|
||||
.select-na {
|
||||
display: inline-block;
|
||||
width: 18px;
|
||||
text-align: center;
|
||||
color: #cbd5e1;
|
||||
cursor: help;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
+419
-19
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, OnDestroy, inject, ViewChild } from '@angular/core';
|
||||
import { Component, OnInit, AfterViewInit, OnDestroy, inject, ViewChild } from '@angular/core';
|
||||
import { MatTableModule, MatTableDataSource } from '@angular/material/table';
|
||||
import { MatPaginatorModule, MatPaginator } from '@angular/material/paginator';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -15,6 +15,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Subject, timer, of } from 'rxjs';
|
||||
import { switchMap, takeUntil, catchError, filter } from 'rxjs/operators';
|
||||
@@ -24,6 +25,7 @@ import { AmlService } from '../../../aml/aml.service';
|
||||
import { AlertService } from '../../../core/alert/alert.service';
|
||||
import { HasPermissionDirective } from '../../../directives/has-permission/has-permission.directive';
|
||||
import { AmlReviewAlertDialogComponent } from './aml-review-alert-dialog.component';
|
||||
import { AmlBulkReviewDialogComponent } from './aml-bulk-review-dialog.component';
|
||||
|
||||
/**
|
||||
* Live feed of transactions the AML rule engine has flagged.
|
||||
@@ -48,10 +50,11 @@ import { AmlReviewAlertDialogComponent } from './aml-review-alert-dialog.compone
|
||||
MatTooltipModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatDialogModule,
|
||||
MatCheckboxModule,
|
||||
HasPermissionDirective
|
||||
]
|
||||
})
|
||||
export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
export class AmlFlaggedTransactionsComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
private amlService = inject(AmlService);
|
||||
private dialog = inject(MatDialog);
|
||||
private alertService = inject(AlertService);
|
||||
@@ -62,6 +65,7 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
|
||||
alerts = new MatTableDataSource<any>([]);
|
||||
displayedColumns: string[] = [
|
||||
'select',
|
||||
'raisedOn',
|
||||
'transaction',
|
||||
'client',
|
||||
@@ -71,6 +75,283 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
'actions'
|
||||
];
|
||||
|
||||
/**
|
||||
* Alerts ticked for a single disposition across several transactions.
|
||||
*
|
||||
* <p>
|
||||
* Low and medium-severity alerts arrive in numbers and are mostly the same decision repeated -
|
||||
* a run of ordinary cash deposits that each tripped a threshold. Dealing with them one dialog at
|
||||
* a time is what stops an officer getting to the one alert that matters. High severity is
|
||||
* deliberately excluded: an alert that reached the high band is a judgement about that customer's
|
||||
* transaction, and it gets its own decision.
|
||||
*/
|
||||
selectedIds = new Set<number>();
|
||||
|
||||
/** m_client_risk_rule.risk_category — 3 is the high band. */
|
||||
private static readonly HIGH_SEVERITY = 3;
|
||||
|
||||
/**
|
||||
* Whether any rule this transaction matched reached the high band.
|
||||
*
|
||||
* <p>
|
||||
* Read from highestSeverity, not from the governing rule's own riskCategory. One transaction
|
||||
* raises one alert under whichever rule most warrants attention, and a statutory CTR outranks
|
||||
* everything — so a high-severity rule can sit in "also matched" while the row itself reports the
|
||||
* CTR, which carries no severity at all. Judging the row by the governing rule would offer such a
|
||||
* transaction up for a batch decision.
|
||||
*/
|
||||
isHighSeverity(alert: any): boolean {
|
||||
return Number(alert?.highestSeverity) === AmlFlaggedTransactionsComponent.HIGH_SEVERITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* The band this alert counts as, for the summary tiles.
|
||||
*
|
||||
* <p>
|
||||
* The same figure the checkbox is gated on, so the tiles and the table cannot disagree. Reading
|
||||
* riskCategory here put a ₹12,00,000 cash deposit that had tripped a high-severity rule under
|
||||
* "Unclassified", because the alert reports under the statutory CTR and a CTR carries no band of
|
||||
* its own. Alerts raised before highest_severity existed fall back to the governing rule's band.
|
||||
*/
|
||||
private severityBand(alert: any): number {
|
||||
const worst = Number(alert?.highestSeverity);
|
||||
if (worst === 1 || worst === 2 || worst === 3) {
|
||||
return worst;
|
||||
}
|
||||
const governing = Number(alert?.riskCategory);
|
||||
if (governing === 1 || governing === 2 || governing === 3) {
|
||||
return governing;
|
||||
}
|
||||
// 0, never NaN: the Unclassified tile filters on this value, and NaN === NaN is false, so a
|
||||
// NaN band would leave that tile showing a count it could never select.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only an open alert whose every matched rule sits in the low or medium band can be swept up with
|
||||
* others.
|
||||
*
|
||||
* <p>
|
||||
* Two things are held back. A transaction that tripped any high-severity rule, because that is a
|
||||
* judgement about the transaction itself. And one where no matched rule carried a severity at
|
||||
* all, which is how the CTR rules arrive - they are not graded, being returns the bank owes
|
||||
* rather than suspicions. Neither belongs in a batch disposed of on a single reason.
|
||||
*/
|
||||
isSelectable(alert: any): boolean {
|
||||
const band = Number(alert?.highestSeverity);
|
||||
const graded = band === 1 || band === 2;
|
||||
return this.canReview(alert) && graded;
|
||||
}
|
||||
|
||||
/** The alert whose detail row is open. One at a time: this is a reading pane, not a comparison. */
|
||||
expandedId: number | null = null;
|
||||
|
||||
|
||||
toggleExpanded(alert: any): void {
|
||||
this.expandedId = this.expandedId === alert.id ? null : alert.id;
|
||||
// Ticks belong to the alert they were made on, not to whichever pane is open next.
|
||||
this.selectedRuleCodes.clear();
|
||||
}
|
||||
|
||||
isExpanded(alert: any): boolean {
|
||||
return this.expandedId === alert.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every rule the transaction matched, governing one first.
|
||||
*
|
||||
* <p>
|
||||
* Served by the API. The fallback rebuilds the list from the flat fields for an alert read before the API carried
|
||||
* it, so an older row still expands to something rather than appearing to have matched nothing.
|
||||
*/
|
||||
matchedRules(alert: any): { ruleCode: string; ruleDescription: string; riskCategory: number | null; governing: boolean }[] {
|
||||
if (Array.isArray(alert?.matchedRules) && alert.matchedRules.length) {
|
||||
return alert.matchedRules;
|
||||
}
|
||||
const rules = [
|
||||
{
|
||||
ruleCode: alert?.ruleCode,
|
||||
ruleDescription: alert?.ruleDescription,
|
||||
riskCategory: alert?.riskCategory ?? null,
|
||||
governing: true
|
||||
}
|
||||
];
|
||||
for (const code of String(alert?.alsoMatchedRules || '')
|
||||
.split(',')
|
||||
.map((c: string) => c.trim())
|
||||
.filter((c: string) => c)) {
|
||||
rules.push({ ruleCode: code, ruleDescription: code, riskCategory: null, governing: false });
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
/** How many rules the transaction matched, for the count shown on the collapsed row. */
|
||||
matchedRuleCount(alert: any): number {
|
||||
return this.matchedRules(alert).length;
|
||||
}
|
||||
|
||||
severityLabel(band: number | null | undefined): string {
|
||||
switch (Number(band)) {
|
||||
case 1:
|
||||
return 'Low';
|
||||
case 2:
|
||||
return 'Medium';
|
||||
case 3:
|
||||
return 'High';
|
||||
default:
|
||||
return 'Statutory';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rule codes ticked inside the open detail pane.
|
||||
*
|
||||
* <p>
|
||||
* Cleared whenever a different alert is opened: the codes are only meaningful against the alert they were ticked on,
|
||||
* and carrying them across would apply one transaction's selection to another's rules.
|
||||
*/
|
||||
selectedRuleCodes = new Set<string>();
|
||||
|
||||
isRuleSelected(rule: any): boolean {
|
||||
return this.selectedRuleCodes.has(rule.ruleCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this rule is the officer's to decide.
|
||||
*
|
||||
* <p>
|
||||
* A rule already decided keeps its verdict. A rule with no severity band is not a graded suspicion at all - the CTR
|
||||
* rules are statutory returns the bank owes FIU-IND on any cash transaction at or above ten lakh, filed on the
|
||||
* amount whether or not the customer is above suspicion. There is no "whitelist" for one: clearing the transaction
|
||||
* does not stop the CTR, and escalating it does not describe what the rule found.
|
||||
*/
|
||||
isRuleSelectable(rule: any): boolean {
|
||||
return !rule?.disposition && this.isGradedRule(rule);
|
||||
}
|
||||
|
||||
/** A rule that carries a severity band, as against a statutory reporting rule that carries none. */
|
||||
isGradedRule(rule: any): boolean {
|
||||
const band = Number(rule?.riskCategory);
|
||||
return band === 1 || band === 2 || band === 3;
|
||||
}
|
||||
|
||||
toggleRuleSelected(rule: any): void {
|
||||
if (!this.isRuleSelectable(rule)) {
|
||||
return;
|
||||
}
|
||||
if (this.selectedRuleCodes.has(rule.ruleCode)) {
|
||||
this.selectedRuleCodes.delete(rule.ruleCode);
|
||||
} else {
|
||||
this.selectedRuleCodes.add(rule.ruleCode);
|
||||
}
|
||||
}
|
||||
|
||||
selectableRulesOf(alert: any): any[] {
|
||||
return this.matchedRules(alert).filter((r) => this.isRuleSelectable(r));
|
||||
}
|
||||
|
||||
get selectedRuleCount(): number {
|
||||
return this.selectedRuleCodes.size;
|
||||
}
|
||||
|
||||
allRulesSelected(alert: any): boolean {
|
||||
const open = this.selectableRulesOf(alert);
|
||||
return open.length > 0 && open.every((r) => this.selectedRuleCodes.has(r.ruleCode));
|
||||
}
|
||||
|
||||
toggleAllRules(alert: any): void {
|
||||
if (this.allRulesSelected(alert)) {
|
||||
this.selectedRuleCodes.clear();
|
||||
return;
|
||||
}
|
||||
for (const rule of this.selectableRulesOf(alert)) {
|
||||
this.selectedRuleCodes.add(rule.ruleCode);
|
||||
}
|
||||
}
|
||||
|
||||
ruleDispositionLabel(rule: any): string {
|
||||
return rule?.disposition === 'ESCALATE' ? 'Escalated' : rule?.disposition === 'WHITELIST' ? 'Whitelisted' : '';
|
||||
}
|
||||
|
||||
severityClass(band: number | null | undefined): string {
|
||||
switch (Number(band)) {
|
||||
case 1:
|
||||
return 'sev-low';
|
||||
case 2:
|
||||
return 'sev-medium';
|
||||
case 3:
|
||||
return 'sev-high';
|
||||
default:
|
||||
return 'sev-none';
|
||||
}
|
||||
}
|
||||
|
||||
isSelected(alert: any): boolean {
|
||||
return this.selectedIds.has(alert.id);
|
||||
}
|
||||
|
||||
toggleSelected(alert: any): void {
|
||||
if (!this.isSelectable(alert)) {
|
||||
return;
|
||||
}
|
||||
if (this.selectedIds.has(alert.id)) {
|
||||
this.selectedIds.delete(alert.id);
|
||||
} else {
|
||||
this.selectedIds.add(alert.id);
|
||||
}
|
||||
}
|
||||
|
||||
/** The rows a "select all" would act on: what is on screen, open, and below the high band. */
|
||||
get selectableRows(): any[] {
|
||||
return this.alerts.data.filter((a) => this.isSelectable(a));
|
||||
}
|
||||
|
||||
get allSelectableSelected(): boolean {
|
||||
const rows = this.selectableRows;
|
||||
return rows.length > 0 && rows.every((a) => this.selectedIds.has(a.id));
|
||||
}
|
||||
|
||||
toggleSelectAll(): void {
|
||||
if (this.allSelectableSelected) {
|
||||
this.selectedIds.clear();
|
||||
return;
|
||||
}
|
||||
for (const a of this.selectableRows) {
|
||||
this.selectedIds.add(a.id);
|
||||
}
|
||||
}
|
||||
|
||||
get selectedCount(): number {
|
||||
return this.selectedIds.size;
|
||||
}
|
||||
|
||||
private selectedAlerts(): any[] {
|
||||
return this.alerts.data.filter((a) => this.selectedIds.has(a.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops ticks that no longer stand, after every poll.
|
||||
*
|
||||
* <p>
|
||||
* The feed refreshes itself every few seconds while the officer works. Without this, an alert
|
||||
* another officer disposed of in the meantime — or one the status filter has since hidden — stays
|
||||
* in the set, and the bar goes on offering to decide it: the count reads higher than the ticks on
|
||||
* screen, and the batch carries alerts nobody chose.
|
||||
*/
|
||||
private pruneSelection(): void {
|
||||
const stillSelectable = new Set(this.selectableRows.map((a) => a.id));
|
||||
for (const id of Array.from(this.selectedIds)) {
|
||||
if (!stillSelectable.has(id)) {
|
||||
this.selectedIds.delete(id);
|
||||
}
|
||||
}
|
||||
// Same for the open detail pane: an alert filtered away or disposed of elsewhere should not
|
||||
// leave the table holding a pane for a row that is no longer on it.
|
||||
if (this.expandedId !== null && !this.alerts.data.some((a) => a.id === this.expandedId)) {
|
||||
this.expandedId = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Every alert as returned, before the status filter narrows the table. */
|
||||
private allAlerts: any[] = [];
|
||||
|
||||
@@ -84,12 +365,19 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
activeStatus = '';
|
||||
private statusCounts: Record<string, number> = {};
|
||||
|
||||
/**
|
||||
* The severity tile currently narrowing the table: 1 Low, 2 Medium, 3 High, 0 unclassified, or
|
||||
* null for all. Independent of {@link activeStatus} — the two compose, so an officer can ask for
|
||||
* the high-severity alerts that are still open.
|
||||
*/
|
||||
activeSeverity: number | null = null;
|
||||
|
||||
/**
|
||||
* Severity mix of the flagged transactions currently in the table. riskCategory is the severity
|
||||
* of the rule that fired, resolved server-side from the originating catalog entry — the same
|
||||
* field the Rules Master tab shows in its Risk Category column.
|
||||
*/
|
||||
riskSummary: { label: string; count: number; cls: string }[] = [];
|
||||
riskSummary: { key: number; label: string; count: number; cls: string }[] = [];
|
||||
/** Alerts whose rule has no catalog ancestor (MANUAL_REFERRAL), so no severity to report. */
|
||||
unclassifiedCount = 0;
|
||||
|
||||
@@ -106,6 +394,18 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
||||
|
||||
/**
|
||||
* Binds the paginator as soon as the view exists.
|
||||
*
|
||||
* <p>
|
||||
* The first poll can return before the view has initialised, and until this the data source was
|
||||
* only ever wired up as a side effect of a later filter pass — so the table could render every
|
||||
* alert unpaginated, then jump once the next poll arrived.
|
||||
*/
|
||||
ngAfterViewInit(): void {
|
||||
this.alerts.paginator = this.paginator;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.fetch();
|
||||
timer(AmlFlaggedTransactionsComponent.POLL_INTERVAL_MS, AmlFlaggedTransactionsComponent.POLL_INTERVAL_MS)
|
||||
@@ -158,7 +458,22 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
|
||||
setStatus(key: string): void {
|
||||
this.activeStatus = key;
|
||||
this.applyStatusFilter();
|
||||
this.applyStatusFilter(true);
|
||||
}
|
||||
|
||||
/** Clicking the tile already in force clears it, so the same click both narrows and undoes. */
|
||||
setSeverity(band: number): void {
|
||||
this.activeSeverity = this.activeSeverity === band ? null : band;
|
||||
this.applyStatusFilter(true);
|
||||
}
|
||||
|
||||
isSeverityActive(band: number): boolean {
|
||||
return this.activeSeverity === band;
|
||||
}
|
||||
|
||||
clearSeverity(): void {
|
||||
this.activeSeverity = null;
|
||||
this.applyStatusFilter(true);
|
||||
}
|
||||
|
||||
statusCount(key: string): number {
|
||||
@@ -203,47 +518,63 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
this.allAlerts = list;
|
||||
this.recomputeStatusCounts();
|
||||
this.applyStatusFilter();
|
||||
this.pruneSelection();
|
||||
this.lastUpdated = new Date();
|
||||
}
|
||||
|
||||
private applyStatusFilter(): void {
|
||||
this.alerts.data = this.activeStatus
|
||||
/**
|
||||
* @param resetPage
|
||||
* true only when the user changed a filter. A poll must not reset the page: the feed
|
||||
* refreshes every few seconds, and an officer reading page 3 would be thrown back to
|
||||
* page 1 each time. Nor may it touch the paginator before the data source has bound to
|
||||
* it — doing that on the first pass left pageSize at 0 and emptied the table.
|
||||
*/
|
||||
private applyStatusFilter(resetPage = false): void {
|
||||
const byStatus = this.activeStatus
|
||||
? this.allAlerts.filter((a) => a.status === this.activeStatus)
|
||||
: this.allAlerts;
|
||||
this.alerts.data =
|
||||
this.activeSeverity === null ? byStatus : byStatus.filter((a) => this.severityBand(a) === this.activeSeverity);
|
||||
if (!this.alerts.paginator && this.paginator) {
|
||||
this.alerts.paginator = this.paginator;
|
||||
}
|
||||
this.recomputeRiskSummary();
|
||||
if (resetPage && this.alerts.paginator) {
|
||||
// Otherwise a filter applied while on page 2 leaves the table blank on a one-page result.
|
||||
this.alerts.paginator.firstPage();
|
||||
}
|
||||
// Counted before the severity filter, so every tile keeps its real figure and stays clickable.
|
||||
// Counting the filtered rows would zero the other tiles the moment one was picked, leaving no
|
||||
// way back to them.
|
||||
this.recomputeRiskSummary(byStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counted over the rows the status filter leaves visible, not the whole set — a summary that
|
||||
* disagreed with the table underneath it would be worse than no summary.
|
||||
*/
|
||||
private recomputeRiskSummary(): void {
|
||||
const pool = this.alerts.data;
|
||||
private recomputeRiskSummary(pool: any[]): void {
|
||||
const tiers = [
|
||||
{ key: 3, label: 'High Risk', cls: 'risk-high' },
|
||||
{ key: 2, label: 'Medium Risk', cls: 'risk-medium' },
|
||||
{ key: 1, label: 'Low Risk', cls: 'risk-low' }
|
||||
];
|
||||
this.riskSummary = tiers.map((t) => ({
|
||||
key: t.key,
|
||||
label: t.label,
|
||||
cls: t.cls,
|
||||
count: pool.filter((a) => Number(a.riskCategory) === t.key).length
|
||||
count: pool.filter((a) => this.severityBand(a) === t.key).length
|
||||
}));
|
||||
// Anything outside 1-3, including null, so the tiles always reconcile to the total.
|
||||
this.unclassifiedCount = pool.filter(
|
||||
(a) => ![
|
||||
1,
|
||||
2,
|
||||
3
|
||||
].includes(Number(a.riskCategory))
|
||||
).length;
|
||||
// Band 0 is everything ungraded, so the tiles always reconcile to the total.
|
||||
this.unclassifiedCount = pool.filter((a) => this.severityBand(a) === 0).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything the status filter leaves, whatever severity tile is in force — so the tiles still
|
||||
* add up to the total while one of them is narrowing the table, and the total reads as the way
|
||||
* back to all of them.
|
||||
*/
|
||||
get summaryTotal(): number {
|
||||
return this.alerts.data.length;
|
||||
return this.activeStatus ? this.allAlerts.filter((a) => a.status === this.activeStatus).length : this.allAlerts.length;
|
||||
}
|
||||
|
||||
private recomputeStatusCounts(): void {
|
||||
@@ -330,4 +661,73 @@ export class AmlFlaggedTransactionsComponent implements OnInit, OnDestroy {
|
||||
this.fetch();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies one disposition to every ticked alert.
|
||||
*
|
||||
* <p>
|
||||
* Each still goes through the review dialog's own requirements - a reason, and for a whitelist
|
||||
* the evidence behind it - asked once and recorded against every alert in the batch. That is the
|
||||
* point of the batch: the officer is making one decision about one kind of activity, not the same
|
||||
* decision twenty times.
|
||||
*/
|
||||
/**
|
||||
* Applies one disposition to the rules ticked inside the open pane.
|
||||
*
|
||||
* <p>
|
||||
* The alert's own status is left to the server, which derives it from what remains: whitelisting five of six rules
|
||||
* leaves the case open on the sixth rather than closing it.
|
||||
*/
|
||||
reviewSelectedRules(alert: any, disposition: 'WHITELIST' | 'ESCALATE'): void {
|
||||
const codes = Array.from(this.selectedRuleCodes);
|
||||
if (!codes.length) {
|
||||
return;
|
||||
}
|
||||
this.dialog
|
||||
.open(AmlReviewAlertDialogComponent, {
|
||||
width: '560px',
|
||||
maxWidth: '95vw',
|
||||
autoFocus: false,
|
||||
disableClose: true,
|
||||
data: { alert, disposition, ruleCodes: codes }
|
||||
})
|
||||
.afterClosed()
|
||||
.subscribe((result: string | undefined) => {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
this.alertService.alert({
|
||||
type: disposition === 'WHITELIST' ? 'Rules Whitelisted' : 'Rules Escalated',
|
||||
message: `${codes.length} rule${codes.length > 1 ? 's' : ''} on ${alert.transactionType} #${alert.transactionId} ${
|
||||
disposition === 'WHITELIST' ? 'cleared' : 'escalated'
|
||||
}.`
|
||||
});
|
||||
this.selectedRuleCodes.clear();
|
||||
// The alert's status may have changed with the last rule decided, so re-read rather than patching locally.
|
||||
this.fetch();
|
||||
});
|
||||
}
|
||||
|
||||
reviewSelected(disposition: 'WHITELIST' | 'ESCALATE'): void {
|
||||
const batch = this.selectedAlerts();
|
||||
if (!batch.length) {
|
||||
return;
|
||||
}
|
||||
this.dialog
|
||||
.open(AmlBulkReviewDialogComponent, {
|
||||
width: '620px',
|
||||
maxWidth: '95vw',
|
||||
autoFocus: false,
|
||||
disableClose: true,
|
||||
data: { alerts: batch, disposition }
|
||||
})
|
||||
.afterClosed()
|
||||
.subscribe((done: boolean | undefined) => {
|
||||
if (!done) {
|
||||
return;
|
||||
}
|
||||
this.selectedIds.clear();
|
||||
this.fetch();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+18
-1
@@ -31,6 +31,11 @@ import { AmlService } from '../../../aml/aml.service';
|
||||
export interface AmlReviewDialogData {
|
||||
alert: any;
|
||||
disposition: 'WHITELIST' | 'ESCALATE';
|
||||
/**
|
||||
* The rules being decided, when the officer picked some inside the expanded pane rather than acting on the whole
|
||||
* transaction. Absent means the decision covers the alert and every rule under it.
|
||||
*/
|
||||
ruleCodes?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,6 +167,13 @@ export class AmlReviewAlertDialogComponent {
|
||||
}
|
||||
|
||||
get title(): string {
|
||||
// Named differently when only some of the transaction's rules are being decided, so the officer is not told they
|
||||
// are clearing a transaction when five of its six rules stay open.
|
||||
const n = this.data.ruleCodes?.length ?? 0;
|
||||
if (n > 0) {
|
||||
const subject = n === 1 ? 'Rule' : `${n} Rules`;
|
||||
return this.isWhitelist ? `Whitelist ${subject}` : `Mark ${subject} as Suspicious`;
|
||||
}
|
||||
return this.isWhitelist ? 'Whitelist Transaction' : 'Mark as Suspicious';
|
||||
}
|
||||
|
||||
@@ -181,7 +193,12 @@ export class AmlReviewAlertDialogComponent {
|
||||
|
||||
this.submitting = true;
|
||||
this.errorMessage = '';
|
||||
this.amlService.reviewAlert(this.data.alert.id, this.data.disposition, this.composedNotes).subscribe({
|
||||
// Deciding named rules within the alert rather than the whole alert, when the caller passed some. The evidence
|
||||
// requirements are the same either way, which is why this dialog serves both.
|
||||
const request = this.data.ruleCodes?.length
|
||||
? this.amlService.reviewAlertRules(this.data.alert.id, this.data.ruleCodes, this.data.disposition, this.composedNotes)
|
||||
: this.amlService.reviewAlert(this.data.alert.id, this.data.disposition, this.composedNotes);
|
||||
request.subscribe({
|
||||
next: () => {
|
||||
this.submitting = false;
|
||||
this.dialogRef.close(this.data.disposition);
|
||||
|
||||
Reference in New Issue
Block a user