Cash claims now require a token at claim submission; a cashier redeems it at Transaction Entry to record physical hand-over, mirroring the existing clerk-withdrawal-request flow -- no double-disbursement, and the manager never hands over cash directly at approval time. Also: dividend-claim tokens fall back through the same TOK. NO. lookup used for withdrawal requests, silenced against the global error interceptor since the caller already handles every outcome; the account summary card now shows "Dividend Claim" instead of a misleading "A/c Savings" label when resolving one; and cash amounts are floored to whole rupees client-side to match cash's whole-rupee denominations. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
69 lines
2.8 KiB
TypeScript
69 lines
2.8 KiB
TypeScript
/**
|
|
* 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 { Injectable, inject } from '@angular/core';
|
|
import { HttpClient, HttpContext, HttpParams } from '@angular/common/http';
|
|
import { Observable } from 'rxjs';
|
|
import { SILENT_HTTP_ERROR } from '../core/http/silent-error.token';
|
|
|
|
/** HTTP service for Clerk Withdrawal Request maker-checker workflow. */
|
|
@Injectable({ providedIn: 'root' })
|
|
export class ClerkWithdrawalService {
|
|
private http = inject(HttpClient);
|
|
|
|
submit(data: any): Observable<any> {
|
|
return this.http.post('/clerk/withdrawal-requests', data);
|
|
}
|
|
|
|
update(id: number, data: any): Observable<any> {
|
|
return this.http.put(`/clerk/withdrawal-requests/${id}`, data);
|
|
}
|
|
|
|
getMyRequests(status?: string, offset = 0, limit = 20, fromDate?: string, toDate?: string): Observable<any> {
|
|
let params = new HttpParams().set('offset', String(offset)).set('limit', String(limit));
|
|
if (status) params = params.set('status', status);
|
|
if (fromDate) params = params.set('fromDate', fromDate);
|
|
if (toDate) params = params.set('toDate', toDate);
|
|
return this.http.get('/clerk/withdrawal-requests/my', { params });
|
|
}
|
|
|
|
getPendingRequests(status = 'PENDING', offset = 0, limit = 20, fromDate?: string, toDate?: string): Observable<any> {
|
|
let params = new HttpParams().set('status', status).set('offset', String(offset)).set('limit', String(limit));
|
|
if (fromDate) params = params.set('fromDate', fromDate);
|
|
if (toDate) params = params.set('toDate', toDate);
|
|
return this.http.get('/clerk/withdrawal-requests', { params });
|
|
}
|
|
|
|
getById(id: number): Observable<any> {
|
|
return this.http.get(`/clerk/withdrawal-requests/${id}`);
|
|
}
|
|
|
|
approve(id: number): Observable<any> {
|
|
return this.http.post(`/clerk/withdrawal-requests/${id}/approve`, {});
|
|
}
|
|
|
|
reject(id: number, reason: string): Observable<any> {
|
|
return this.http.post(`/clerk/withdrawal-requests/${id}/reject`, { reason });
|
|
}
|
|
|
|
// Silenced: onTokNoBlur() probes this expecting a possible legitimate 404 (token not from this
|
|
// pool, could be a dividend claim's instead) and shows its own tailored message either way.
|
|
getByToken(token: string): Observable<any> {
|
|
return this.http.get(`/clerk/withdrawal-requests/by-token/${encodeURIComponent(token)}`, {
|
|
context: new HttpContext().set(SILENT_HTTP_ERROR, true)
|
|
});
|
|
}
|
|
|
|
disburse(id: number, denominationData: string | null, transactionAmount?: number): Observable<any> {
|
|
return this.http.post(`/clerk/withdrawal-requests/${id}/disburse`, {
|
|
denominationData,
|
|
transactionAmount: transactionAmount != null ? String(transactionAmount) : null
|
|
});
|
|
}
|
|
}
|