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
@@ -22,6 +22,49 @@
</div>
</header>
<!-- ── Customer Info Bar ── -->
<div class="cx-customer-bar">
<div
class="cx-customer-toggle"
[class.cx-customer-toggle--active]="isAccountHolder"
(click)="toggleAccountHolder()"
>
<mat-icon>{{ isAccountHolder ? 'check_box' : 'check_box_outline_blank' }}</mat-icon>
<span>Account Holder</span>
</div>
@if (isAccountHolder) {
<label class="cx-field cx-field--inline">
<span>Account No.</span>
<input
type="text"
[value]="accountNo"
(input)="accountNo = $any($event.target).value"
placeholder="e.g. 000101234567"
/>
</label>
} @else {
<span class="cx-walk-in"><mat-icon>person_outline</mat-icon> Walk-in Customer</span>
}
@if (needsIdProof) {
<div class="cx-pan-required">
<mat-icon>warning</mat-icon>
<span>Amount ≥ ₹50,000 — Customer PAN / Aadhaar required (RBI)</span>
</div>
<label class="cx-field cx-field--inline cx-field--pan">
<span>PAN / Aadhaar *</span>
<input
type="text"
[value]="customerIdProof"
(input)="customerIdProof = $any($event.target).value"
placeholder="ABCDE1234F"
maxlength="20"
/>
</label>
}
</div>
<div class="cx-cols">
<!-- RECEIVED -->
<section class="cx-col cx-col--received">
@@ -147,14 +190,42 @@
@if (receivedTotal > 0 && !matches) {
<div class="cx-warn"><mat-icon>warning</mat-icon> Received and Given totals must match (net ₹0).</div>
}
@if (hasGivenOverdraft) {
<div class="cx-overdraft-card">
<div class="cx-overdraft-card__title">
<mat-icon class="cx-overdraft-card__ico">block</mat-icon>
<span>Insufficient stock — cannot give to customer</span>
</div>
<div class="cx-overdraft-card__rows">
@for (item of givenOverdraftItems; track item.label) {
<div class="cx-overdraft-card__row">
<span class="cx-overdraft-card__chip">{{ item.label }}</span>
<span class="cx-overdraft-card__stat"
><span class="cx-overdraft-card__lbl">Need</span><strong>{{ item.requested }}</strong></span
>
<span class="cx-overdraft-card__dot">·</span>
<span class="cx-overdraft-card__stat"
><span class="cx-overdraft-card__lbl">Available</span><strong>{{ item.available }}</strong></span
>
<span class="cx-overdraft-card__short">Short: {{ item.requested - item.available }}</span>
</div>
}
</div>
</div>
}
@if (needsIdProof && !customerIdProof.trim()) {
<div class="cx-warn cx-warn--pan">
<mat-icon>badge</mat-icon> Enter customer PAN / Aadhaar to proceed (amount ≥ ₹50,000).
</div>
}
<div class="cx-actions">
<label class="cx-field cx-field--note">
<span>Note</span>
<input type="text" [value]="note" (input)="note = $any($event.target).value" placeholder="Optional" />
</label>
<button type="button" class="cx-btn cx-btn--primary" [disabled]="!matches || saving" (click)="submit()">
<mat-icon>swap_horiz</mat-icon> Confirm Exchange
<button type="button" class="cx-btn cx-btn--primary" [disabled]="!valid || saving" (click)="submit()">
<mat-icon>swap_horiz</mat-icon> {{ saving ? 'Saving…' : 'Confirm Exchange' }}
</button>
</div>
</div>
@@ -73,6 +73,208 @@
}
}
/* ── Customer info bar ── */
.cx-customer-bar {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px;
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 10px;
flex-wrap: wrap;
}
.cx-customer-toggle {
display: flex;
align-items: center;
gap: 6px;
font-size: 13px;
font-weight: 600;
color: #475569;
cursor: pointer;
user-select: none;
mat-icon {
font-size: 20px;
height: 20px;
width: 20px;
color: #94a3b8;
}
&--active {
color: #1e40af;
mat-icon {
color: #1e40af;
}
}
}
.cx-walk-in {
display: flex;
align-items: center;
gap: 4px;
font-size: 12px;
color: #64748b;
mat-icon {
font-size: 16px;
height: 16px;
width: 16px;
}
}
.cx-pan-required {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
background: #fffbeb;
border: 1px solid #fcd34d;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
color: #92400e;
mat-icon {
font-size: 16px;
height: 16px;
width: 16px;
color: #d97706;
}
}
.cx-field--inline {
flex-direction: row;
align-items: center;
gap: 8px;
span {
white-space: nowrap;
}
input {
width: 180px;
}
}
.cx-field--pan input {
width: 160px;
border-color: #fcd34d;
&:focus {
outline: none;
border-color: #d97706;
}
}
.cx-warn--pan {
background: #eff6ff;
border-color: #bfdbfe;
color: #1e40af;
mat-icon {
color: #2563eb;
}
}
.cx-overdraft-card {
background: #fff5f5;
border: 1.5px solid #fca5a5;
border-left: 4px solid #ef4444;
border-radius: 10px;
overflow: hidden;
&__title {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 14px;
font-size: 13px;
font-weight: 700;
color: #7f1d1d;
background: #fef2f2;
border-bottom: 1px solid #fecaca;
}
&__ico {
color: #ef4444;
font-size: 18px;
height: 18px;
width: 18px;
flex-shrink: 0;
}
&__rows {
display: flex;
flex-direction: column;
padding: 4px 0;
}
&__row {
display: flex;
align-items: center;
gap: 10px;
padding: 7px 14px;
font-size: 12.5px;
color: #7f1d1d;
&:not(:last-child) {
border-bottom: 1px dashed #fecaca;
}
}
&__chip {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 3px 10px;
background: linear-gradient(135deg, #fee2e2, #fecaca);
border: 1px solid #fca5a5;
border-radius: 6px;
font-size: 12px;
font-weight: 800;
color: #991b1b;
min-width: 52px;
letter-spacing: 0.01em;
}
&__stat {
display: flex;
align-items: center;
gap: 4px;
strong {
font-weight: 800;
font-variant-numeric: tabular-nums;
}
}
&__lbl {
font-size: 11px;
color: #b91c1c;
font-weight: 600;
}
&__dot {
color: #fca5a5;
font-weight: 700;
font-size: 14px;
}
&__short {
margin-left: auto;
padding: 2px 9px;
background: #fff;
border: 1.5px solid #f87171;
border-radius: 999px;
font-size: 11px;
font-weight: 800;
color: #b91c1c;
}
}
.cx-cols {
display: grid;
grid-template-columns: 1fr 1fr;
@@ -45,7 +45,16 @@ export class CashExchangeEntryComponent implements OnInit {
note = '';
saving = false;
/** All denominations (notes then coins) — used for totals and the submit payload. */
// ── Customer info ──
isAccountHolder = false;
accountNo = '';
customerIdProof = '';
// ── Cashier position (for denomination overdraft check) ──
private availableMap = new Map<number, number>();
positionLoaded = false;
/** All denominations (notes then coins) */
get denoms(): Denom[] {
return [
...this.notes,
@@ -58,7 +67,7 @@ export class CashExchangeEntryComponent implements OnInit {
this.exchangeDate = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
this.service.getActiveDenominations().subscribe({
next: (list) => {
const rows: Denom[] = (list || []).map((x) => ({
const rows: Denom[] = (list || []).map((x: any) => ({
id: x.id,
value: x.denomination,
kind: x.kind,
@@ -72,6 +81,18 @@ export class CashExchangeEntryComponent implements OnInit {
this.coins = [];
}
});
this.service.getCashierPositionForMe().subscribe({
next: (res: any) => {
this.availableMap.clear();
((res?.denominations || []) as any[]).forEach((d: any) => {
if (d.denominationId) this.availableMap.set(Number(d.denominationId), Number(d.count ?? 0));
});
this.positionLoaded = true;
},
error: () => {
this.positionLoaded = true;
}
});
}
countFor(side: 'r' | 'g', d: Denom): number {
@@ -107,23 +128,53 @@ export class CashExchangeEntryComponent implements OnInit {
return this.receivedTotal > 0 && this.receivedTotal === this.givenTotal;
}
/** Above ₹50,000 PAN/ID is mandatory per RBI guideline */
get needsIdProof(): boolean {
return this.receivedTotal >= 50000;
}
/** Denominations where cashier is giving more than currently available. */
get givenOverdraftItems(): Array<{ label: string; available: number; requested: number }> {
if (!this.positionLoaded) return [];
return this.denoms
.map((d) => ({ label: d.label, available: this.availableMap.get(d.id) ?? 0, requested: this.countFor('g', d) }))
.filter((item) => item.requested > 0 && item.requested > item.available);
}
get hasGivenOverdraft(): boolean {
return this.givenOverdraftItems.length > 0;
}
get valid(): boolean {
return this.matches && (!this.needsIdProof || this.customerIdProof.trim().length > 0) && !this.hasGivenOverdraft;
}
toggleAccountHolder(): void {
this.isAccountHolder = !this.isAccountHolder;
if (!this.isAccountHolder) this.accountNo = '';
}
clear(): void {
this.receivedCounts = {};
this.givenCounts = {};
this.note = '';
this.accountNo = '';
this.customerIdProof = '';
this.isAccountHolder = false;
}
submit(): void {
if (!this.matches || this.saving) {
return;
}
if (!this.valid || this.saving) return;
this.saving = true;
const build = (side: 'r' | 'g') =>
this.denoms
.filter((d) => this.countFor(side, d) > 0)
.map((d) => ({ denominationId: d.id, denominationValue: d.value, count: this.countFor(side, d) }));
const payload = {
const payload: any = {
exchangeDate: this.exchangeDate,
note: this.note || null,
customerIdProof: this.customerIdProof.trim() || null,
accountNo: this.isAccountHolder && this.accountNo.trim() ? this.accountNo.trim() : null,
received: build('r'),
given: build('g')
};
@@ -131,7 +182,6 @@ export class CashExchangeEntryComponent implements OnInit {
next: () => {
this.snackBar.open('Cash exchange recorded', 'Close', { duration: 3000 });
this.clear();
this.note = '';
this.saving = false;
},
error: () => {