feat(cashier): denomination overdraft validation, exchange detail fix, cash exchange in reports

- Savings/Current/FD/RD withdrawal forms: card-style overdraft warning when
  requested denomination count exceeds cashier stock; submit blocked on overdraft
- Cash History detail view: show both RECEIVED and GIVEN denomination breakdowns
  for Cash Exchange (previously only RECEIVED side was displayed)
- Closing Cash Report: add Cash Exchanges section (denomination-wise received/given/net)
- Excess Transaction Report: include cash exchanges >= threshold with Type badge
  (Exchange/Txn) and ID Proof column for RBI/AML compliance
- cashier-shared.scss: etr-badge and closing-exchange-head styles
- Cash Exchange entry: overdraft warning redesigned to cx-overdraft-card BEM layout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-01 10:10:17 +05:30
co-authored by Claude Sonnet 4.6
parent 51495f8eb8
commit f291e4da5b
24 changed files with 1339 additions and 25 deletions
@@ -52,6 +52,12 @@
<ng-container *ngTemplateOutlet="txnTable; context: { rows: interCashier }"></ng-container>
</div>
</mat-tab>
<mat-tab label="Cash Exchanges ({{ exchanges.length }})">
<div class="pg-tab-body">
<ng-container *ngTemplateOutlet="txnTable; context: { rows: exchanges }"></ng-container>
</div>
</mat-tab>
</mat-tab-group>
</div>
@@ -122,7 +128,13 @@
<!-- Header -->
<div class="detail-panel__head">
<div class="detail-panel__title">
<mat-icon>{{ detail.row.type === 'settlement' ? 'account_balance_wallet' : 'swap_horiz' }}</mat-icon>
<mat-icon>{{
detail.row.type === 'settlement'
? 'account_balance_wallet'
: detail.row.type === 'exchange'
? 'currency_exchange'
: 'swap_horiz'
}}</mat-icon>
<div>
<span class="detail-panel__type">{{ typeLabel(detail.row.type) }}</span>
<span class="detail-panel__id">#{{ detail.row.id }}</span>
@@ -241,8 +253,163 @@
@if (detail.loading) {
<div class="pg-empty" style="padding: 20px 0">Loading denomination details…</div>
} @else if (detail.denominations.length === 0) {
} @else if (
detail.row.type === 'exchange' &&
detail.receivedDenominations.length === 0 &&
detail.givenDenominations.length === 0
) {
<div class="pg-empty" style="padding: 20px 0">No denomination data recorded.</div>
} @else if (detail.row.type !== 'exchange' && detail.denominations.length === 0) {
<div class="pg-empty" style="padding: 20px 0">No denomination data recorded.</div>
} @else if (detail.row.type === 'exchange') {
<!-- RECEIVED from customer -->
<div class="cx-dir-label cx-dir-label--received"><mat-icon>south</mat-icon> Received from Customer</div>
@if (notes(detail.receivedDenominations).length > 0) {
<div class="detail-denom-kind-label">Notes</div>
<table class="pg-table detail-denom-table">
<thead>
<tr>
<th>Denomination</th>
<th style="text-align: center">Count</th>
<th class="num">Total</th>
</tr>
</thead>
<tbody>
@for (d of notes(detail.receivedDenominations); track d.denominationValue) {
<tr>
<td>
<span class="pg-chip">₹{{ d.denominationValue }}</span>
</td>
<td style="text-align: center; font-weight: 600">{{ d.count }}</td>
<td class="num">₹{{ d.totalAmount | number: '1.2-2' }}</td>
</tr>
}
</tbody>
<tfoot>
<tr class="detail-denom-total">
<td><strong>Subtotal</strong></td>
<td style="text-align: center">
<strong>{{ totalCount(notes(detail.receivedDenominations)) }}</strong>
</td>
<td class="num">
<strong>₹{{ subtotal(notes(detail.receivedDenominations)) | number: '1.2-2' }}</strong>
</td>
</tr>
</tfoot>
</table>
}
@if (coins(detail.receivedDenominations).length > 0) {
<div class="detail-denom-kind-label">Coins</div>
<table class="pg-table detail-denom-table">
<thead>
<tr>
<th>Denomination</th>
<th style="text-align: center">Count</th>
<th class="num">Total</th>
</tr>
</thead>
<tbody>
@for (d of coins(detail.receivedDenominations); track d.denominationValue) {
<tr>
<td>
<span class="pg-chip pg-chip--coin">₹{{ d.denominationValue }}</span>
</td>
<td style="text-align: center; font-weight: 600">{{ d.count }}</td>
<td class="num">₹{{ d.totalAmount | number: '1.2-2' }}</td>
</tr>
}
</tbody>
<tfoot>
<tr class="detail-denom-total">
<td><strong>Subtotal</strong></td>
<td style="text-align: center">
<strong>{{ totalCount(coins(detail.receivedDenominations)) }}</strong>
</td>
<td class="num">
<strong>₹{{ subtotal(coins(detail.receivedDenominations)) | number: '1.2-2' }}</strong>
</td>
</tr>
</tfoot>
</table>
}
<!-- GIVEN to customer -->
<div class="cx-dir-label cx-dir-label--given"><mat-icon>north</mat-icon> Given to Customer</div>
@if (notes(detail.givenDenominations).length > 0) {
<div class="detail-denom-kind-label">Notes</div>
<table class="pg-table detail-denom-table">
<thead>
<tr>
<th>Denomination</th>
<th style="text-align: center">Count</th>
<th class="num">Total</th>
</tr>
</thead>
<tbody>
@for (d of notes(detail.givenDenominations); track d.denominationValue) {
<tr>
<td>
<span class="pg-chip">₹{{ d.denominationValue }}</span>
</td>
<td style="text-align: center; font-weight: 600">{{ d.count }}</td>
<td class="num">₹{{ d.totalAmount | number: '1.2-2' }}</td>
</tr>
}
</tbody>
<tfoot>
<tr class="detail-denom-total">
<td><strong>Subtotal</strong></td>
<td style="text-align: center">
<strong>{{ totalCount(notes(detail.givenDenominations)) }}</strong>
</td>
<td class="num">
<strong>₹{{ subtotal(notes(detail.givenDenominations)) | number: '1.2-2' }}</strong>
</td>
</tr>
</tfoot>
</table>
}
@if (coins(detail.givenDenominations).length > 0) {
<div class="detail-denom-kind-label">Coins</div>
<table class="pg-table detail-denom-table">
<thead>
<tr>
<th>Denomination</th>
<th style="text-align: center">Count</th>
<th class="num">Total</th>
</tr>
</thead>
<tbody>
@for (d of coins(detail.givenDenominations); track d.denominationValue) {
<tr>
<td>
<span class="pg-chip pg-chip--coin">₹{{ d.denominationValue }}</span>
</td>
<td style="text-align: center; font-weight: 600">{{ d.count }}</td>
<td class="num">₹{{ d.totalAmount | number: '1.2-2' }}</td>
</tr>
}
</tbody>
<tfoot>
<tr class="detail-denom-total">
<td><strong>Subtotal</strong></td>
<td style="text-align: center">
<strong>{{ totalCount(coins(detail.givenDenominations)) }}</strong>
</td>
<td class="num">
<strong>₹{{ subtotal(coins(detail.givenDenominations)) | number: '1.2-2' }}</strong>
</td>
</tr>
</tfoot>
</table>
}
<!-- Grand total -->
<div class="detail-denom-grand-total">
<span>Grand Total</span>
<span>{{ totalCount(detail.receivedDenominations) }} notes/coins</span>
<span>₹{{ detail.row.amount | number: '1.2-2' }}</span>
</div>
} @else {
<!-- Notes -->
@if (notes(detail.denominations).length > 0) {
@@ -312,6 +312,38 @@
border-color: #fcd34d;
}
// Cash exchange direction labels
.cx-dir-label {
display: flex;
align-items: center;
gap: 6px;
margin: 8px 20px 4px;
padding: 6px 10px;
border-radius: 6px;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.06em;
mat-icon {
font-size: 14px;
height: 14px;
width: 14px;
}
&--received {
background: #eff6ff;
color: #1d4ed8;
border: 1px solid #bfdbfe;
}
&--given {
background: #fef3c7;
color: #92400e;
border: 1px solid #fcd34d;
}
}
.pg-btn--danger {
background: linear-gradient(135deg, #ef4444, #b91c1c);
color: #fff;
@@ -30,7 +30,7 @@ interface TxnRow {
reversedBy: number | null;
reversedAt: string | null;
reverseReason: string | null;
type: 'transfer' | 'settlement' | 'inter';
type: 'transfer' | 'settlement' | 'inter' | 'exchange';
}
interface DenomDetail {
@@ -45,6 +45,8 @@ interface DenomDetail {
interface DetailView {
row: TxnRow;
denominations: DenomDetail[];
receivedDenominations: DenomDetail[];
givenDenominations: DenomDetail[];
morningTotal: number;
loading: boolean;
}
@@ -73,6 +75,7 @@ export class CashHistoryComponent implements OnInit {
transfers: TxnRow[] = [];
settlements: TxnRow[] = [];
interCashier: TxnRow[] = [];
exchanges: TxnRow[] = [];
loading = false;
private denomKindMap = new Map<number, 'note' | 'coin'>();
@@ -98,8 +101,9 @@ export class CashHistoryComponent implements OnInit {
forkJoin({
transfers: this.service.getCashTransfers().pipe(catchError(() => of([]))),
settlements: this.service.getCashSettlements().pipe(catchError(() => of([]))),
inter: this.service.getInterCashierTransfers().pipe(catchError(() => of([])))
}).subscribe(({ transfers, settlements, inter }) => {
inter: this.service.getInterCashierTransfers().pipe(catchError(() => of([]))),
exchanges: this.service.getCashExchanges().pipe(catchError(() => of([])))
}).subscribe(({ transfers, settlements, inter, exchanges }) => {
this.transfers = (transfers as any[]).map((t) => ({
id: t.id,
date: t.transferDate,
@@ -146,12 +150,34 @@ export class CashHistoryComponent implements OnInit {
reverseReason: i.reverseReason ?? null,
type: 'inter'
}));
this.exchanges = (exchanges as any[]).map((e) => ({
id: e.id,
date: e.exchangeDate,
fromParty: e.accountNo ? `Account ${e.accountNo}` : 'Walk-in Customer',
toParty: e.performedByUsername || '—',
amount: e.exchangeAmount,
note: e.note,
isReversed: e.isReversed ?? false,
performedByUsername: e.performedByUsername,
createdAt: e.createdAt,
reversedBy: e.reversedBy ?? null,
reversedAt: e.reversedAt ?? null,
reverseReason: e.reverseReason ?? null,
type: 'exchange'
}));
this.loading = false;
});
}
viewDetail(row: TxnRow): void {
this.detail = { row, denominations: [], morningTotal: 0, loading: true };
this.detail = {
row,
denominations: [],
receivedDenominations: [],
givenDenominations: [],
morningTotal: 0,
loading: true
};
if (row.type === 'settlement' && row.fromCashierId) {
forkJoin({
@@ -180,18 +206,27 @@ export class CashHistoryComponent implements OnInit {
let obs$;
if (row.type === 'transfer') obs$ = this.service.getCashTransferById(row.id);
else if (row.type === 'settlement') obs$ = this.service.getCashSettlementById(row.id);
else if (row.type === 'exchange') obs$ = this.service.getCashExchange(row.id);
else obs$ = this.service.getInterCashierById(row.id);
obs$.pipe(catchError(() => of(null))).subscribe((data: any) => {
if (this.detail) {
this.detail.denominations = ((data?.details || []) as any[]).map((d: any) => ({
const mapDenom = (d: any): DenomDetail => ({
denominationId: d.denominationId ?? null,
denominationValue: d.denominationValue,
kind: this.denomKindMap.get(d.denominationId) ?? (d.denominationValue <= 5 ? 'coin' : 'note'),
morningCount: 0,
count: d.count,
totalAmount: d.totalAmount
}));
});
if (row.type === 'exchange') {
const all: any[] = data?.details || [];
this.detail.receivedDenominations = all.filter((d: any) => d.direction === 'RECEIVED').map(mapDenom);
this.detail.givenDenominations = all.filter((d: any) => d.direction === 'GIVEN').map(mapDenom);
this.detail.denominations = this.detail.receivedDenominations;
} else {
this.detail.denominations = (data?.details || []).map(mapDenom);
}
this.detail.loading = false;
}
});
@@ -223,6 +258,7 @@ export class CashHistoryComponent implements OnInit {
let obs$;
if (type === 'transfer') obs$ = this.service.reverseCashTransfer(id, reason);
else if (type === 'settlement') obs$ = this.service.reverseCashSettlement(id, reason);
else if (type === 'exchange') obs$ = this.service.reverseCashExchange(id, reason);
else obs$ = this.service.reverseInterCashierTransfer(id, reason);
obs$.pipe(catchError(() => of(null))).subscribe((res: any) => {
@@ -236,7 +272,10 @@ export class CashHistoryComponent implements OnInit {
}
typeLabel(type: string): string {
return type === 'transfer' ? 'Cash Transfer' : type === 'settlement' ? 'Cash Settlement' : 'Inter-Cashier Transfer';
if (type === 'transfer') return 'Cash Transfer';
if (type === 'settlement') return 'Cash Settlement';
if (type === 'exchange') return 'Cash Exchange';
return 'Inter-Cashier Transfer';
}
notes(denoms: DenomDetail[]): DenomDetail[] {