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
@@ -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: () => {