feat(cashier): complete maker-checker withdrawal disbursement flow

- Clerk manually enters token no with today-date unique validation (backend enforced)
- Cashier token lookup: auto-fill amount/account, lock amount field, status-specific errors
- Confirm dialog shows CASH DISBURSEMENT (blue) with no balance re-deduction warning
- Disbursement denomination saved to m_savings_txn_denomination for vault position update
- Block direct cashier withdrawal without approved maker-checker token
- DISBURSED status shown in My Requests and Checker inbox views with cashier/time info
- Remove getNextToken() service method and m_daily_token_counter table (0326 migration)
- Race condition protection: UPDATE WHERE status=APPROVED prevents double disbursement

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-11 15:57:33 +05:30
co-authored by Claude Sonnet 4.6
parent de420bb8ab
commit 61cb09f352
26 changed files with 4822 additions and 248 deletions
@@ -0,0 +1,168 @@
<!--
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/.
-->
<div class="cv-tab-content wri-tab">
<!-- ── TITLE BAR ── -->
<div class="wri-action-bar">
<div class="wri-action-bar__left">
<mat-icon class="wri-action-bar__icon">account_balance_wallet</mat-icon>
<div>
<div class="wri-action-bar__title">Withdrawal Requests</div>
<div class="wri-action-bar__sub">Review, approve or reject clerk withdrawal requests.</div>
</div>
</div>
</div>
<!-- ── FILTER BAR ── -->
<div class="wri-filter-bar">
<select class="wri-filter-select" [(ngModel)]="filterStatus" (change)="onFilterChange()">
@for (opt of statusOptions; track opt.value) {
<option [value]="opt.value">{{ opt.label }}</option>
}
</select>
<span class="wri-fb-sep"></span>
<div class="wri-presets">
@for (p of datePresets; track p.key) {
<button
type="button"
class="wri-preset-chip"
[class.wri-preset-chip--active]="activePreset === p.key"
(click)="applyPreset(p.key)"
>
{{ p.label }}
</button>
}
</div>
<span class="wri-fb-sep"></span>
<div class="wri-date-range">
<div class="wri-date-box">
<span class="wri-date-box__lbl">From</span>
<input
class="wri-date-box__input"
[matDatepicker]="fromPicker"
[(ngModel)]="fromDate"
[max]="maxDate"
(dateChange)="onFromDateChange()"
readonly
/>
<button type="button" class="wri-date-box__btn" (click)="fromPicker.open()">
<mat-icon>event</mat-icon>
</button>
<mat-datepicker #fromPicker></mat-datepicker>
</div>
<span class="wri-date-range__sep">—</span>
<div class="wri-date-box">
<span class="wri-date-box__lbl">To</span>
<input
class="wri-date-box__input"
[matDatepicker]="toPicker"
[(ngModel)]="toDate"
[min]="fromDate"
[max]="maxDate"
(dateChange)="onToDateChange()"
readonly
/>
<button type="button" class="wri-date-box__btn" (click)="toPicker.open()">
<mat-icon>event</mat-icon>
</button>
<mat-datepicker #toPicker></mat-datepicker>
</div>
</div>
<button type="button" class="wri-btn wri-btn--refresh" (click)="load()" [disabled]="loading">
<mat-icon>refresh</mat-icon>
</button>
</div>
<!-- ── TABLE ── -->
@if (loading) {
<div class="empty-state">
<p class="empty-title">Loading…</p>
</div>
} @else if (loaded && requests.length === 0) {
<div class="empty-state">
<i class="fas fa-inbox empty-icon"></i>
<p class="empty-title">No withdrawal requests</p>
<p class="empty-text">
@if (filterStatus === 'PENDING') {
There are no pending withdrawal requests waiting for review.
} @else {
No {{ filterStatus | lowercase }} withdrawal requests found.
}
</p>
</div>
} @else {
<div class="wri-table-wrap">
<table class="wri-table">
<thead>
<tr>
<th class="wri-th-id">#</th>
<th>Account No</th>
<th>Client Name</th>
<th class="num">Amount</th>
<th>Payment Mode</th>
<th>Clerk</th>
<th>Reviewed By</th>
<th>Cashier / Disbursed</th>
<th>Submitted At</th>
<th>Status</th>
<th class="wri-th-action">Action</th>
</tr>
</thead>
<tbody>
@for (r of requests; track r.id) {
<tr class="wri-row" [class.wri-row--disbursed]="r.status === 'DISBURSED'" (click)="review(r)">
<td class="cell-mono">{{ r.id }}</td>
<td class="cell-mono">{{ r.account_no }}</td>
<td class="wri-client">{{ r.client_name }}</td>
<td class="num wri-amount">₹{{ r.amount | number: '1.2-2' }}</td>
<td>{{ r.payment_type_name || 'Cash' }}</td>
<td>{{ r.clerk_name }}</td>
<td>{{ r.manager_name || r.manager_username || '—' }}</td>
<td class="wri-cashier-cell">
@if (r.status === 'DISBURSED') {
<div class="wri-cashier-info">
<span class="wri-cashier-name">{{ r.disbursed_by }}</span>
<span class="wri-dt">{{ formatDateTime(r.disbursed_at) }}</span>
</div>
} @else {
<span class="wri-none">—</span>
}
</td>
<td class="wri-dt">{{ formatDateTime(r.submitted_at) }}</td>
<td>
<span class="wri-status" [ngClass]="statusClass(r.status)">
{{ statusLabel(r.status) }}
</span>
</td>
<td class="wri-action-cell" (click)="$event.stopPropagation()">
<button type="button" class="wri-btn wri-btn--review" (click)="review(r)">
<mat-icon>rate_review</mat-icon>
Review
</button>
</td>
</tr>
}
</tbody>
</table>
</div>
<mat-paginator
[length]="totalRecords"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
[pageIndex]="pageIndex"
showFirstLastButtons
(page)="onPageChange($event)"
></mat-paginator>
}
</div>
@@ -0,0 +1,413 @@
/**
* 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/.
*/
:host {
display: block;
}
.wri-tab {
padding: 0;
}
.wri-action-bar {
display: flex;
align-items: center;
padding: 14px 20px;
background: #fff;
border-bottom: 1px solid #e2e8f0;
&__left {
display: flex;
align-items: center;
gap: 12px;
}
&__icon {
font-size: 28px;
width: 28px;
height: 28px;
color: #0f4f3c;
}
&__title {
font-size: 15px;
font-weight: 700;
color: #0d1b2a;
}
&__sub {
font-size: 12px;
color: #64748b;
margin-top: 2px;
}
}
.wri-filter-bar {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 20px;
background: #f8fafc;
border-bottom: 1px solid #e2e8f0;
flex-wrap: wrap;
}
.wri-fb-sep {
width: 1px;
height: 22px;
background: #e2e8f0;
flex-shrink: 0;
margin: 0 4px;
}
.wri-filter-label {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 11px;
font-weight: 600;
color: #64748b;
}
.wri-filter-select {
height: 34px;
min-width: 130px;
padding: 0 10px;
border: 1px solid #e2e8f0;
border-radius: 7px;
font-size: 13px;
color: #0d1b2a;
font-family: inherit;
background: #fff;
cursor: pointer;
&:focus {
outline: none;
border-color: #0f4f3c;
}
}
.wri-presets {
display: inline-flex;
gap: 4px;
align-items: center;
}
.wri-preset-chip {
height: 28px;
padding: 0 12px;
border-radius: 14px;
border: 1px solid #e2e8f0;
background: #fff;
font-size: 12px;
font-weight: 600;
font-family: inherit;
color: #475569;
cursor: pointer;
transition: all 0.15s;
white-space: nowrap;
&:hover {
border-color: #0f4f3c;
color: #0f4f3c;
background: #f0fdf4;
}
&--active {
background: #0f4f3c;
border-color: #0f4f3c;
color: #fff;
&:hover {
background: #0a3d2e;
}
}
}
.wri-date-range {
display: inline-flex;
align-items: center;
gap: 4px;
&__sep {
color: #94a3b8;
font-size: 16px;
font-weight: 300;
padding: 0 2px;
user-select: none;
}
}
.wri-date-box {
display: inline-flex;
align-items: center;
gap: 4px;
height: 34px;
padding: 0 6px 0 10px;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #fff;
transition: border-color 0.15s;
&:hover {
border-color: #cbd5e1;
}
&:focus-within {
border-color: #0f4f3c;
}
&__lbl {
font-size: 11px;
font-weight: 600;
color: #94a3b8;
white-space: nowrap;
user-select: none;
letter-spacing: 0.03em;
}
&__input {
border: none;
outline: none;
font-size: 13px;
width: 76px;
color: #0d1b2a;
font-family: inherit;
background: transparent;
cursor: pointer;
&::placeholder {
color: #cbd5e1;
}
}
&__btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border: none;
background: none;
cursor: pointer;
color: #94a3b8;
padding: 0;
border-radius: 4px;
mat-icon {
font-size: 16px;
width: 16px;
height: 16px;
}
&:hover {
color: #0f4f3c;
background: #f0fdf4;
}
}
}
.wri-btn {
display: inline-flex;
align-items: center;
gap: 6px;
border-radius: 7px;
font-family: inherit;
font-weight: 600;
cursor: pointer;
border: 1px solid #e2e8f0;
transition: background 0.15s;
height: 32px;
padding: 0 12px;
font-size: 13px;
background: #fff;
color: #0d1b2a;
mat-icon {
font-size: 16px;
width: 16px;
height: 16px;
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
&--refresh {
padding: 0 8px;
color: #64748b;
&:hover:not(:disabled) {
background: #f1f5f9;
}
}
&--review {
background: #0f4f3c;
color: #fff;
border-color: #0f4f3c;
&:hover {
background: #0a3d2e;
}
}
}
.wri-table-wrap {
overflow-x: auto;
}
.wri-table {
width: 100%;
border-collapse: collapse;
font-size: 13px;
th,
td {
padding: 10px 14px;
text-align: left;
border-bottom: 1px solid #f1f5f9;
}
th {
font-size: 11px;
font-weight: 700;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.06em;
background: #f8fafc;
white-space: nowrap;
}
.num {
text-align: right;
}
}
.wri-row {
cursor: pointer;
transition: background 0.1s;
&:hover td {
background: #f0fdf4;
}
}
.wri-th-id {
width: 60px;
}
.wri-th-action {
width: 100px;
text-align: center;
}
.wri-action-cell {
text-align: center;
}
.wri-client {
font-weight: 500;
}
.wri-amount {
font-weight: 700;
color: #0f4f3c;
}
.wri-dt {
font-size: 12px;
color: #64748b;
white-space: nowrap;
}
.wri-status {
display: inline-flex;
align-items: center;
padding: 2px 10px;
border-radius: 20px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
white-space: nowrap;
&--pending {
background: #fef3c7;
color: #92400e;
}
&--approved {
background: #dcfce7;
color: #166534;
}
&--rejected {
background: #fee2e2;
color: #991b1b;
}
&--disbursed {
background: #e0f2fe;
color: #0369a1;
}
}
.wri-row--disbursed td {
background: #f0f9ff;
}
.wri-cashier-cell {
min-width: 120px;
}
.wri-cashier-info {
display: flex;
flex-direction: column;
gap: 2px;
}
.wri-cashier-name {
font-size: 12px;
font-weight: 600;
color: #0369a1;
}
.wri-none {
color: #94a3b8;
}
.cell-mono {
font-family: 'Courier New', monospace;
font-size: 12px;
}
// Empty state (re-use checker inbox styles)
.empty-state {
text-align: center;
padding: 48px 24px;
color: #94a3b8;
.empty-icon {
font-size: 40px;
color: #cbd5e1;
}
.empty-title {
font-size: 16px;
font-weight: 600;
color: #64748b;
margin: 12px 0 4px;
}
.empty-text {
font-size: 13px;
color: #94a3b8;
margin: 0;
}
}
@@ -0,0 +1,220 @@
/**
* 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 { Router, RouterModule } from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { MatNativeDateModule } from '@angular/material/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import { ClerkWithdrawalService } from '../../../cashier/clerk-withdrawal.service';
import { SettingsService } from '../../../settings/settings.service';
@Component({
selector: 'mifosx-withdrawal-requests',
templateUrl: './withdrawal-requests.component.html',
styleUrls: ['./withdrawal-requests.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
RouterModule,
MatIconModule,
MatPaginatorModule,
MatSnackBarModule,
MatNativeDateModule,
MatFormFieldModule,
MatInputModule,
MatDatepickerModule
]
})
export class WithdrawalRequestsComponent implements OnInit {
private service = inject(ClerkWithdrawalService);
private router = inject(Router);
private snackBar = inject(MatSnackBar);
private settingsService = inject(SettingsService);
requests: any[] = [];
totalRecords = 0;
pageSize = 20;
pageIndex = 0;
pageSizeOptions = [
10,
20,
50
];
filterStatus = 'PENDING';
fromDate: Date | null = null;
toDate: Date | null = null;
maxDate!: Date;
activePreset: string = 'today';
loading = false;
loaded = false;
readonly datePresets = [
{ key: 'today', label: 'Today' },
{ key: 'week', label: 'This Week' },
{ key: 'month', label: 'This Month' },
{ key: 'all', label: 'All' }
];
get statusOptions(): { value: string; label: string }[] {
return [
{ value: 'PENDING', label: 'Pending' },
{ value: 'APPROVED', label: 'Approved' },
{ value: 'REJECTED', label: 'Rejected' },
{ value: 'DISBURSED', label: 'Disbursed' }
];
}
ngOnInit(): void {
const today = new Date(this.settingsService.businessDate);
today.setHours(0, 0, 0, 0);
this.maxDate = today;
this.applyPreset('today');
}
load(): void {
this.loading = true;
this.service
.getPendingRequests(
this.filterStatus,
this.pageIndex * this.pageSize,
this.pageSize,
this.isoDate(this.fromDate),
this.isoDate(this.toDate)
)
.pipe(catchError(() => of({ pageItems: [], totalFilteredRecords: 0 })))
.subscribe((res: any) => {
this.requests = res?.pageItems ?? [];
this.totalRecords = Number(res?.totalFilteredRecords ?? 0);
this.loading = false;
this.loaded = true;
});
}
onPageChange(event: PageEvent): void {
this.pageSize = event.pageSize;
this.pageIndex = event.pageIndex;
this.load();
}
onFilterChange(): void {
this.pageIndex = 0;
this.load();
}
onFromDateChange(): void {
this.activePreset = '';
if (this.fromDate && this.toDate && this.fromDate > this.toDate) {
this.toDate = new Date(this.fromDate);
}
this.pageIndex = 0;
this.load();
}
onToDateChange(): void {
this.activePreset = '';
this.pageIndex = 0;
this.load();
}
applyPreset(key: string): void {
this.activePreset = key;
const today = new Date(this.settingsService.businessDate);
today.setHours(0, 0, 0, 0);
if (key === 'today') {
this.fromDate = new Date(today);
this.toDate = new Date(today);
} else if (key === 'week') {
const start = new Date(today);
start.setDate(today.getDate() - today.getDay());
this.fromDate = start;
this.toDate = new Date(today);
} else if (key === 'month') {
this.fromDate = new Date(today.getFullYear(), today.getMonth(), 1);
this.toDate = new Date(today);
} else {
this.fromDate = null;
this.toDate = null;
}
this.pageIndex = 0;
this.load();
}
private isoDate(d: Date | null): string | undefined {
if (!d) return undefined;
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
return `${y}-${m}-${day}`;
}
review(req: any): void {
this.router.navigate([
'/checker-inbox-and-tasks/withdrawal-requests',
req.id,
'review'
]);
}
statusClass(status: string): string {
const map: Record<string, string> = {
PENDING: 'wri-status--pending',
APPROVED: 'wri-status--approved',
REJECTED: 'wri-status--rejected',
DISBURSED: 'wri-status--disbursed'
};
return map[status] ?? '';
}
statusLabel(status: string): string {
const map: Record<string, string> = {
PENDING: 'Pending',
APPROVED: 'Approved',
REJECTED: 'Rejected',
DISBURSED: 'Disbursed'
};
return map[status] ?? status;
}
formatDate(val: any): string {
if (!val) return '—';
try {
const d = new Date(val);
return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' });
} catch {
return String(val);
}
}
formatDateTime(val: any): string {
if (!val) return '—';
try {
const d = new Date(val);
return d.toLocaleString('en-IN', {
day: '2-digit',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
} catch {
return String(val);
}
}
}
@@ -106,6 +106,18 @@
<fa-icon icon="ban" class="ac-tab__ic"></fa-icon>
<span>Reject Account</span>
</a>
<a
mat-tab-link
class="ac-tab"
[routerLink]="['./withdrawal-requests']"
routerLinkActive
#withdrawalRequests="routerLinkActive"
[active]="withdrawalRequests.isActive"
*mifosxHasPermission="'ALL_FUNCTIONS_READ'"
>
<fa-icon icon="money-bill-wave" class="ac-tab__ic"></fa-icon>
<span>Withdrawal Requests</span>
</a>
</nav>
<mat-tab-nav-panel #tabPanel>
+17
View File
@@ -16,6 +16,7 @@ import { Route } from '../core/route/route.service';
/** Custom Components */
import { CheckerInboxAndTasksComponent } from './checker-inbox-and-tasks/checker-inbox-and-tasks.component';
import { CheckerInboxComponent } from './checker-inbox-and-tasks-tabs/checker-inbox/checker-inbox.component';
import { WithdrawalRequestsComponent } from './checker-inbox-and-tasks-tabs/withdrawal-requests/withdrawal-requests.component';
import { ClientApprovalComponent } from './checker-inbox-and-tasks-tabs/client-approval/client-approval.component';
import { LoanApprovalComponent } from './checker-inbox-and-tasks-tabs/loan-approval/loan-approval.component';
import { LoanDisbursalComponent } from './checker-inbox-and-tasks-tabs/loan-disbursal/loan-disbursal.component';
@@ -101,6 +102,11 @@ const routes: Routes = [
resolve: {
rejectedAccountsData: GetRejectedAccounts
}
},
{
path: 'withdrawal-requests',
component: WithdrawalRequestsComponent,
data: { title: 'Withdrawal Requests' }
}
]
},
@@ -116,6 +122,17 @@ const routes: Routes = [
}
}
]
},
{
path: 'checker-inbox-and-tasks/withdrawal-requests',
children: [
{
path: ':id/review',
loadComponent: () =>
import('../clerk/withdrawal-review/withdrawal-review.component').then((m) => m.WithdrawalReviewComponent),
data: { title: 'Review Withdrawal Request', breadcrumb: 'Review Withdrawal' }
}
]
}
])
];