feat(clerk): add collection flow — multi-DR savings to CR GL with maker-checker

- Transaction entry: detect collection mode (N DR savings → 1 CR GL) and disbursement mode (1 DR GL → N CR savings); build dbCr-tagged payload for backend
- Disbursement review: show 'GL Credit (Target)' / 'Debit Entries' labels for collection; fix double-count by summing only DR entries for collection totals; dynamic approve button text
- My disbursement requests: add DR/CR badge column in expanded credit-entries preview
- My requests / withdrawal-requests: minor consistency updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-16 15:28:27 +05:30
co-authored by Claude Sonnet 4.6
parent efb01d5441
commit 6cccb58c04
11 changed files with 345 additions and 102 deletions
@@ -13,7 +13,7 @@
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 2v20M2 12h20" />
</svg>
Disbursement Review
{{ isCollectionMode ? 'Collection Review' : 'Disbursement Review' }}
</button>
<span class="cashier-nav__esc-hint" (click)="backToInbox()">← Back to Inbox</span>
</nav>
@@ -63,11 +63,11 @@
</div>
</div>
<!-- GL Debit row -->
<!-- GL card — Source (disbursement) or Target (collection) -->
<div class="dri-card">
<div class="dri-section-title">
<mat-icon>account_balance</mat-icon>
GL Debit (Source)
{{ isCollectionMode ? 'GL Credit (Target)' : 'GL Debit (Source)' }}
</div>
<div class="dri-detail-grid">
<div class="dri-detail-item">
@@ -79,7 +79,7 @@
<span class="dri-detail-value">{{ request.gl_account_name }}</span>
</div>
<div class="dri-detail-item">
<span class="dri-detail-label">DR Amount</span>
<span class="dri-detail-label">{{ isCollectionMode ? 'CR Amount' : 'DR Amount' }}</span>
<span class="dri-detail-value dri-amount">₹{{ request.dr_amount | number: '1.2-2' }}</span>
</div>
<div class="dri-detail-item">
@@ -95,11 +95,15 @@
</div>
</div>
<!-- Credit entries -->
<!-- Entries table — DR savings (collection) or CR accounts (disbursement) -->
<div class="dri-card">
<div class="dri-section-title">
<mat-icon>account_balance_wallet</mat-icon>
Credit Entries ({{ creditEntries.length }} account{{ creditEntries.length !== 1 ? 's' : '' }})
@if (isCollectionMode) {
Debit Entries ({{ drEntries.length }} account{{ drEntries.length !== 1 ? 's' : '' }} — collect from)
} @else {
Credit Entries ({{ crEntries.length }} account{{ crEntries.length !== 1 ? 's' : '' }})
}
</div>
<table class="dri-cr-table">
<thead>
@@ -108,11 +112,11 @@
<th>Account No</th>
<th>Account Name</th>
<th>Type</th>
<th class="num">Amount (CR)</th>
<th class="num">{{ isCollectionMode ? 'Amount (DR)' : 'Amount (CR)' }}</th>
</tr>
</thead>
<tbody>
@for (entry of creditEntries; track entry.accountId; let i = $index) {
@for (entry of isCollectionMode ? drEntries : crEntries; track entry.accountNo; let i = $index) {
<tr>
<td class="dri-cr-idx">{{ i + 1 }}</td>
<td class="cell-mono">{{ entry.accountNo }}</td>
@@ -124,7 +128,7 @@
</tr>
}
<tr class="dri-cr-total-row">
<td colspan="4" class="dri-cr-total-label">Total Credit</td>
<td colspan="4" class="dri-cr-total-label">{{ isCollectionMode ? 'Total Debit' : 'Total Credit' }}</td>
<td class="num dri-cr-total-amount">₹{{ totalCreditAmount() | number: '1.2-2' }}</td>
</tr>
</tbody>
@@ -167,7 +171,7 @@
@if (!showRejectForm) {
<button type="button" class="dri-btn dri-btn--approve" [disabled]="acting" (click)="approve()">
<mat-icon>check_circle</mat-icon>
{{ acting ? 'Processing…' : 'Approve Disbursement' }}
{{ acting ? 'Processing…' : isCollectionMode ? 'Approve Collection' : 'Approve Disbursement' }}
</button>
<button type="button" class="dri-btn dri-btn--reject" [disabled]="acting" (click)="showRejectForm = true">
<mat-icon>cancel</mat-icon>
@@ -18,11 +18,12 @@ import { of } from 'rxjs';
import { ClerkDisbursementService } from '../../cashier/clerk-disbursement.service';
interface CreditEntry {
accountId: number;
accountId?: number;
accountNo: string;
accountName: string;
accountType: string;
amount: number;
dbCr?: string;
}
@Component({
@@ -69,8 +70,9 @@ export class DisbursementReviewComponent implements OnInit {
this.loading = false;
if (res?.credit_entries) {
try {
this.creditEntries =
const raw: any[] =
typeof res.credit_entries === 'string' ? JSON.parse(res.credit_entries) : res.credit_entries;
this.creditEntries = raw.map((e) => ({ ...e, amount: parseFloat(e.amount) || 0 }));
} catch {
this.creditEntries = [];
}
@@ -112,8 +114,21 @@ export class DisbursementReviewComponent implements OnInit {
});
}
get isCollectionMode(): boolean {
return this.creditEntries.some((e) => e.dbCr === 'Dr');
}
get drEntries(): CreditEntry[] {
return this.creditEntries.filter((e) => e.dbCr === 'Dr');
}
get crEntries(): CreditEntry[] {
return this.creditEntries.filter((e) => e.dbCr !== 'Dr');
}
totalCreditAmount(): number {
return this.creditEntries.reduce((sum, e) => sum + (e.amount ?? 0), 0);
const entries = this.isCollectionMode ? this.drEntries : this.crEntries;
return entries.reduce((sum, e) => sum + (e.amount ?? 0), 0);
}
statusClass(status: string): string {