Ticking "Close this account" on the Transaction Entry Action popup called
GET /clerk/closure-requests/preview/{id} -- a dry run that computed the
payout and immediately rolled it back, so the account's own balance stayed
unchanged until a manager later approved the closure.
Wired to the new POST /clerk/closure-requests/post-interest/{id} instead
(see the matching backend commit), which posts the interest for real and
returns the account's actual resulting balance. Renamed
ClerkClosureRequestService#preview to #postClosureInterest to match, and
reworded the popup copy and loading state so it no longer implies posting
happens later at Save ("posted to the account as of ..." instead of
"calculated to ... and posted the moment you press Save").
Also corrected a stale comment on the balance-check bypass for a pending
closure: it used to justify the bypass by saying interest was NOT YET
posted, which stopped being true the moment the checkbox itself started
posting it for real.
81 lines
3.3 KiB
TypeScript
81 lines
3.3 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 the Clerk Closure Request maker-checker workflow (Cash-only savings account
|
|
* closure). Mirrors ClerkWithdrawalService's shape against the /clerk/closure-requests endpoints. */
|
|
@Injectable({ providedIn: 'root' })
|
|
export class ClerkClosureRequestService {
|
|
private http = inject(HttpClient);
|
|
|
|
submit(data: any): Observable<any> {
|
|
return this.http.post('/clerk/closure-requests', 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/closure-requests/my', { params });
|
|
}
|
|
|
|
getPendingRequests(
|
|
status = 'PENDING',
|
|
offset = 0,
|
|
limit = 20,
|
|
fromDate?: string,
|
|
toDate?: string,
|
|
search?: 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);
|
|
if (search) params = params.set('search', search);
|
|
return this.http.get('/clerk/closure-requests', { params });
|
|
}
|
|
|
|
getById(id: number): Observable<any> {
|
|
return this.http.get(`/clerk/closure-requests/${id}`);
|
|
}
|
|
|
|
/** Posts every rupee of interest the member has earned up to today straight onto the account —
|
|
* the same posting close() itself performs — and returns the resulting real balance. Not a dry
|
|
* run: ticking "Close this account" is meant to credit the interest immediately, not estimate it. */
|
|
postClosureInterest(savingsAccountId: number): Observable<any> {
|
|
return this.http.post(`/clerk/closure-requests/post-interest/${savingsAccountId}`, {});
|
|
}
|
|
|
|
approve(id: number): Observable<any> {
|
|
return this.http.post(`/clerk/closure-requests/${id}/approve`, {});
|
|
}
|
|
|
|
reject(id: number, reason: string): Observable<any> {
|
|
return this.http.post(`/clerk/closure-requests/${id}/reject`, { reason });
|
|
}
|
|
|
|
// Silenced: onTokNoBlur() probes this expecting a possible legitimate 404 (token not from this
|
|
// pool, could be a withdrawal/dividend claim's instead) and shows its own tailored message either way.
|
|
getByToken(token: string): Observable<any> {
|
|
return this.http.get(`/clerk/closure-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/closure-requests/${id}/disburse`, {
|
|
denominationData,
|
|
transactionAmount: transactionAmount != null ? String(transactionAmount) : null
|
|
});
|
|
}
|
|
}
|