feat: cashier denomination-wise opening & closing balance panels in all deposit/withdrawal forms

OVERVIEW
--------
Added real-time cashier cash position display inside the denomination breakdown
panel of all 4 transaction entry screens: Savings, Current Account, Recurring
Deposit, and Fixed Deposit. Shows opening balance at the top and projected
closing balance at the bottom after factoring in the current transaction.

BACKEND INTEGRATION
-------------------
- New CashierService (src/app/cashier/cashier.service.ts)
  getCashierPositionForMe(asOfDate?) calls GET /cashreports/cashier-position/me
  Returns denomination-wise opening cash position for the logged-in cashier user.
  Non-cashier users receive empty denominations array; UI hides panels silently.

OPENING BALANCE CARD (top of denomination panel)
-------------------------------------------------
- Loaded on ngOnInit() via loadOpeningPosition() in all 4 component .ts files
- Notes and Coins displayed in separate labeled pill sections
- Each pill shows: Rs{value} x{count} format
- Card is hidden entirely if the logged-in user is not a cashier

CLOSING BALANCE CARD (below tally / Apply button)
--------------------------------------------------
- Computed getter closingDenoms() merges opening position with entered denominations
  deposit:    closingCount = openCount + enteredCount
  withdrawal: closingCount = openCount - enteredCount
- Notes and Coins in separate labeled pill sections (identical format to opening)
- Entered/changed denominations (delta != 0): full opacity + bold font weight
- Untouched denominations (delta = 0): 38% opacity, clearly dimmed, no borders
- closingTotal = openingTotal +/- denominationTotal shown in card header
- Card turns green for positive closing balance, red for negative

COMPONENTS UPDATED
------------------
- savings-account-transactions       (.ts / .html / .scss)
- current-account-transactions       (.ts / .html / .scss)
- deposit-recurring-deposits-account (.ts / .html / .scss)
- fixed-deposits-cash-transaction    (.ts / .html / .scss)

CASHIER MODULE (new - src/app/cashier/)
-----------------------------------------
Full cashier workspace module added to the app:
- cashier.service.ts          API calls (position, transfers, settlement, etc.)
- cashier.module.ts           Angular module declaration
- cashier-routing.module.ts   Lazy-loaded routes
- cashier-position/           Cashier cash position dashboard
- cash-exchange-entry/        Cash exchange denomination entry
- cash-history/               Transaction history per cashier
- cash-settlement/            End-of-day cash settlement
- cash-transfer/              Vault-to-cashier cash transfer
- inter-cashier-transfer/     Transfer between cashier drawers
- reconciliation/             Cash reconciliation with GL
- closing-cash-report/        Closing balance report
- currency-exchange-detail/   Currency exchange breakdown
- excess-transaction-report/  Excess/short transaction report
Module wired into app.module.ts and shell nav (shell.component.html).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-05-28 17:39:31 +05:30
co-authored by Claude Sonnet 4.6
parent 555d9fb4b7
commit 7ccaffa7f1
43 changed files with 5302 additions and 8 deletions
@@ -0,0 +1,216 @@
/**
* 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, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MatIconModule } from '@angular/material/icon';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { MatInputModule } from '@angular/material/input';
import { MatTabsModule } from '@angular/material/tabs';
import { of } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { CashierService } from '../cashier.service';
interface DenomRow {
denominationId: number;
denominationValue: number;
kind: string;
expectedCount: number;
physicalCount: number;
varianceCount: number;
}
interface ReconRecord {
id: number;
reconDate: string;
cashierId: number;
cashierName: string;
expectedAmount: number;
physicalAmount: number;
variance: number;
status: 'OK' | 'SHORT' | 'EXCESS';
performedByUsername: string;
createdAt: string;
}
/** Denomination-wise reconciliation — expected vs physical count per cashier. */
@Component({
selector: 'mifosx-reconciliation',
templateUrl: './reconciliation.component.html',
styleUrls: [
'../cashier-shared.scss',
'./reconciliation.component.scss'
],
standalone: true,
imports: [
CommonModule,
FormsModule,
MatIconModule,
MatSnackBarModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MatTabsModule
]
})
export class ReconciliationComponent implements OnInit {
private service = inject(CashierService);
private snackBar = inject(MatSnackBar);
// ── Entry form ──
tellers: { id: number; name: string }[] = [];
cashiers: { id: number; label: string }[] = [];
selectedTellerId: number | null = null;
selectedCashierId: number | null = null;
cashierName = '';
reconDate = '';
note = '';
rows: DenomRow[] = [];
loadingExpected = false;
saving = false;
// ── History list ──
history: ReconRecord[] = [];
loadingHistory = false;
ngOnInit(): void {
const d = new Date();
this.reconDate = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
this.service
.getTellers()
.pipe(catchError(() => of([] as any[])))
.subscribe((list) => {
this.tellers = (list || []).map((t: any) => ({ id: t.id, name: t.name }));
});
this.loadHistory();
}
onTellerSelect(tellerId: number): void {
this.selectedTellerId = tellerId;
this.selectedCashierId = null;
this.cashierName = '';
this.cashiers = [];
this.rows = [];
if (!tellerId) return;
this.service
.getCashiersForTeller(tellerId)
.pipe(catchError(() => of({ cashiers: [] })))
.subscribe((r: any) => {
this.cashiers = (r?.cashiers || []).map((c: any) => ({ id: c.id, label: c.staffName }));
});
}
onCashierSelect(cashierId: number): void {
this.selectedCashierId = cashierId;
const c = this.cashiers.find((x) => x.id === cashierId);
this.cashierName = c ? c.label : '';
this.rows = [];
this.fetchExpected();
}
fetchExpected(): void {
if (!this.selectedCashierId) return;
this.loadingExpected = true;
this.service
.getExpectedBalance(this.selectedCashierId, this.reconDate)
.pipe(catchError(() => of(null)))
.subscribe((data: any) => {
this.loadingExpected = false;
if (!data) return;
this.rows = (data.denominations || []).map((d: any) => ({
denominationId: d.denominationId || null,
denominationValue: d.denominationValue,
kind: d.kind || 'note',
expectedCount: d.expectedCount || 0,
physicalCount: d.expectedCount || 0,
varianceCount: 0
}));
});
}
updatePhysical(row: DenomRow, raw: any): void {
row.physicalCount = Math.max(0, Math.floor(Number(raw) || 0));
row.varianceCount = row.physicalCount - row.expectedCount;
}
get noteRows(): DenomRow[] {
return this.rows.filter((r) => r.kind !== 'coin');
}
get coinRows(): DenomRow[] {
return this.rows.filter((r) => r.kind === 'coin');
}
get totalExpected(): number {
return this.rows.reduce((s, r) => s + r.denominationValue * r.expectedCount, 0);
}
get totalPhysical(): number {
return this.rows.reduce((s, r) => s + r.denominationValue * r.physicalCount, 0);
}
get totalVariance(): number {
return this.totalPhysical - this.totalExpected;
}
get statusLabel(): string {
const v = this.totalVariance;
return v === 0 ? 'OK' : v > 0 ? 'EXCESS' : 'SHORT';
}
get valid(): boolean {
return !!this.selectedCashierId && this.rows.length > 0;
}
submit(): void {
if (!this.valid || this.saving) return;
this.saving = true;
const payload = {
cashierId: this.selectedCashierId,
tellerId: this.selectedTellerId,
cashierName: this.cashierName,
reconDate: this.reconDate,
note: this.note || null,
denominations: this.rows.map((r) => ({
denominationId: r.denominationId,
denominationValue: r.denominationValue,
expectedCount: r.expectedCount,
physicalCount: r.physicalCount
}))
};
this.service.createReconciliation(payload).subscribe({
next: (res: any) => {
const status = res?.status || 'OK';
this.snackBar.open(`Reconciliation saved — Status: ${status}`, 'Close', {
duration: 4000,
panelClass: status === 'OK' ? ['snack-ok'] : ['snack-warn']
});
this.rows = [];
this.note = '';
this.saving = false;
this.loadHistory();
},
error: () => {
this.saving = false;
}
});
}
loadHistory(): void {
this.loadingHistory = true;
this.service
.getReconciliations()
.pipe(catchError(() => of([])))
.subscribe((list: any[]) => {
this.history = list || [];
this.loadingHistory = false;
});
}
statusClass(status: string): string {
return status === 'OK' ? 'badge-ok' : status === 'EXCESS' ? 'badge-excess' : 'badge-short';
}
}