The Clerk Dashboard's standalone Share Withdrawal Request form never offered a GL settlement destination -- it always submitted SAVINGS, silently, while the Cashier's Transaction Entry screen already let a clerk pick any postable GL account on its CR row. Added the same "Settlement Destination" choice (Savings / GL Account) with a searchable GL selector here too, so both entry points to the same backend endpoint behave the same way. Both share-withdrawal confirm dialogs (savings settlement and GL settlement, in transaction-entry.component.ts) now call the backend's new preview-validate endpoint before showing the confirm dialog, so a clerk sees the same checklist a manager will see on approval -- a missing GL mapping, an unverified KYC, an open AML alert -- before committing to the request, not after a manager has already spent time reviewing it. A failing check is shown, not blocked: real hard rules are still enforced server-side at approve(). Guarded with a 5s timeout and a fallback message so a slow or unavailable check can never leave the dialog looking stuck. error-handler.interceptor.ts: a document/signature attachment whose row survives but whose file is missing from the content store now resolves to a silent 404 (matching the existing image-fetch handling) instead of surfacing a raw error. Background GET failures (500/501/503) on calls a component already recovers from (photo, attachment, notes, standing instructions, ...) now surface as a corner toast instead of a blocking modal that has to be dismissed -- a write action's failure (POST/PUT/DELETE) still gets the centred, must-acknowledge dialog, since that is the one thing the user was waiting on. Also surfaces the backend's real message on a 500 instead of a hardcoded generic sentence. Backend counterpart: ClerkShareWithdrawalRequestApiResource (preview-validate endpoint, shared buildShareWithdrawalChecks()) and DocumentReadPlatformServiceImpl (missing-file 404) land separately. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
68 lines
2.6 KiB
TypeScript
68 lines
2.6 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, HttpParams } from '@angular/common/http';
|
|
import { Observable } from 'rxjs';
|
|
|
|
/** HTTP service for the Share Withdrawal (redeem shares) maker-checker workflow — mirrors
|
|
* ClerkWithdrawalService (cash withdrawal), adapted for shares. */
|
|
@Injectable({ providedIn: 'root' })
|
|
export class ClerkShareWithdrawalService {
|
|
private http = inject(HttpClient);
|
|
|
|
submit(data: any): Observable<any> {
|
|
return this.http.post('/clerk/share-withdrawal-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/share-withdrawal-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/share-withdrawal-requests', { params });
|
|
}
|
|
|
|
getById(id: number): Observable<any> {
|
|
return this.http.get(`/clerk/share-withdrawal-requests/${id}`);
|
|
}
|
|
|
|
validate(id: number): Observable<any> {
|
|
return this.http.post(`/clerk/share-withdrawal-requests/${id}/validate`, {});
|
|
}
|
|
|
|
/** Runs the exact same checklist approve() will run, against a draft that hasn't been submitted
|
|
* yet — so the clerk sees it in the confirm dialog, before committing to the request. */
|
|
previewValidate(data: any): Observable<any> {
|
|
return this.http.post('/clerk/share-withdrawal-requests/preview-validate', data);
|
|
}
|
|
|
|
approve(id: number): Observable<any> {
|
|
return this.http.post(`/clerk/share-withdrawal-requests/${id}/approve`, {});
|
|
}
|
|
|
|
reject(id: number, reason: string): Observable<any> {
|
|
return this.http.post(`/clerk/share-withdrawal-requests/${id}/reject`, { reason });
|
|
}
|
|
}
|