Files
cbsnexora/src/app/cashier/cashier.service.ts
T
Jaanu423andClaude Sonnet 4.6 9094b9a0eb feat(cashier): add full-screen cashier teller workstation dashboard
- Add Transaction Entry screen with full account details panel
  (personal info, joint holders, nominees, KYC, balances)
- Role-based layout: CASHIER role hides nav/sidebar/ticker,
  redirects to /cashier/transaction-entry on login
- Denomination entry with opening/closing position preview
  (notes first then coins, stepper +/- round button inputs)
- Auto-fetch savings/current/FD/RD accounts with associations,
  client KYC, nominees, addresses, family members (S/D/W/H/O)
- Submit deposit/withdrawal via POST /transactions with denominationBreakdown
- Cashier position auto-loads for CASHIER role (no filter dropdowns)
- Pagination added to cash-history tabs and currency-exchange-detail
- Cashier menu simplified for cashier role permissions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 10:59:34 +05:30

192 lines
7.5 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, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
/** HTTP service for the Cashier menu features. */
@Injectable({ providedIn: 'root' })
export class CashierService {
private http = inject(HttpClient);
// ── Active denominations ──
getActiveDenominations(): Observable<any[]> {
return this.http.get<any[]>('/denominationmaster/active');
}
// ── Cash Exchange ──
createCashExchange(data: any): Observable<any> {
return this.http.post('/cashexchange', data);
}
getCashExchanges(offset = 0, limit = 20): Observable<any> {
const params = new HttpParams().set('offset', offset).set('limit', limit);
return this.http.get<any>('/cashexchange', { params });
}
getCashExchange(id: number): Observable<any> {
return this.http.get(`/cashexchange/${id}`);
}
reverseCashExchange(id: number, reason: string): Observable<any> {
return this.http.post(`/cashexchange/${id}/reverse`, { reason });
}
// ── Tellers / Cashiers ──
getTellers(): Observable<any[]> {
return this.http.get<any[]>('/tellers');
}
getAllCashiers(): Observable<any[]> {
return this.http.get<any[]>('/cashiers');
}
getCashiersForTeller(tellerId: number): Observable<any> {
return this.http.get(`/tellers/${tellerId}/cashiers`);
}
// ── Cash Transfer ──
createCashTransfer(data: any): Observable<any> {
return this.http.post('/cashtransfer', data);
}
getCashTransfers(offset = 0, limit = 20): Observable<any> {
const params = new HttpParams().set('offset', offset).set('limit', limit);
return this.http.get<any>('/cashtransfer', { params });
}
getCashTransferById(id: number): Observable<any> {
return this.http.get(`/cashtransfer/${id}`);
}
reverseCashTransfer(id: number, reason: string): Observable<any> {
return this.http.post(`/cashtransfer/${id}/reverse`, { reason });
}
// ── Cash Settlement ──
createCashSettlement(data: any): Observable<any> {
return this.http.post('/cashsettlement', data);
}
getCashSettlements(offset = 0, limit = 20): Observable<any> {
const params = new HttpParams().set('offset', offset).set('limit', limit);
return this.http.get<any>('/cashsettlement', { params });
}
getCashSettlementById(id: number): Observable<any> {
return this.http.get(`/cashsettlement/${id}`);
}
reverseCashSettlement(id: number, reason: string): Observable<any> {
return this.http.post(`/cashsettlement/${id}/reverse`, { reason });
}
// ── Inter-cashier Transfer ──
createInterCashierTransfer(data: any): Observable<any> {
return this.http.post('/cashintercashier', data);
}
getInterCashierTransfers(offset = 0, limit = 20): Observable<any> {
const params = new HttpParams().set('offset', offset).set('limit', limit);
return this.http.get<any>('/cashintercashier', { params });
}
getInterCashierById(id: number): Observable<any> {
return this.http.get(`/cashintercashier/${id}`);
}
reverseInterCashierTransfer(id: number, reason: string): Observable<any> {
return this.http.post(`/cashintercashier/${id}/reverse`, { reason });
}
// ── Reconciliation ──
createReconciliation(data: any): Observable<any> {
return this.http.post('/cashreconciliation', data);
}
getReconciliations(): Observable<any[]> {
return this.http.get<any[]>('/cashreconciliation');
}
getReconciliationById(id: number): Observable<any> {
return this.http.get(`/cashreconciliation/${id}`);
}
getExpectedBalance(cashierId: number, asOfDate?: string): Observable<any> {
let params = new HttpParams().set('cashierId', String(cashierId));
if (asOfDate) params = params.set('asOfDate', asOfDate);
return this.http.get('/cashreconciliation/expected', { params });
}
// ── Reports ──
closingCashReport(date: string): Observable<any> {
const params = new HttpParams().set('date', date);
return this.http.get('/cashreports/closing', { params });
}
excessTransactionReport(threshold: number, fromDate?: string, toDate?: string): Observable<any[]> {
let params = new HttpParams().set('threshold', String(threshold));
if (fromDate) params = params.set('fromDate', fromDate);
if (toDate) params = params.set('toDate', toDate);
return this.http.get<any[]>('/cashreports/excess', { params });
}
cashierPositionReport(cashierId?: number, asOfDate?: string): Observable<any> {
let params = new HttpParams();
if (cashierId) params = params.set('cashierId', String(cashierId));
if (asOfDate) params = params.set('asOfDate', asOfDate);
return this.http.get('/cashreports/cashier-position', { params });
}
getCashierPositionForMe(asOfDate?: string): Observable<any> {
let params = new HttpParams();
if (asOfDate) params = params.set('asOfDate', asOfDate);
return this.http.get('/cashreports/cashier-position/me', { params });
}
getCashierDayStatus(): Observable<any> {
return this.http.get('/cashreports/cashier-day-status');
}
getGlEntries(date: string, cashierId?: number, tellerId?: number): Observable<any> {
let params = new HttpParams().set('date', date);
if (cashierId) params = params.set('cashierId', String(cashierId));
if (tellerId) params = params.set('tellerId', String(tellerId));
return this.http.get('/cashreports/gl-entries', { params });
}
checkSettlement(cashierId: number, date: string): Observable<any> {
const params = new HttpParams().set('cashierId', String(cashierId)).set('date', date);
return this.http.get('/cashsettlement/check', { params });
}
checkReconciliation(cashierId: number, date: string): Observable<any> {
const params = new HttpParams().set('cashierId', String(cashierId)).set('date', date);
return this.http.get('/cashreconciliation/check', { params });
}
getCashierMorningBalance(cashierId: number, date: string): Observable<any> {
const params = new HttpParams().set('cashierId', String(cashierId)).set('date', date);
return this.http.get('/cashreports/cashier-morning', { params });
}
getExpectedBalanceForMe(asOfDate?: string): Observable<any> {
let params = new HttpParams();
if (asOfDate) params = params.set('asOfDate', asOfDate);
return this.http.get('/cashreconciliation/expected/me', { params });
}
// ── Current cashier identity ──
// Returns cashierId + cashierName for the logged-in user, or null if not a cashier.
getCurrentCashierInfo(): Observable<{ cashierId: number; cashierName: string } | null> {
return this.getCashierPositionForMe().pipe(
map((pos: any) => (pos?.cashierId ? { cashierId: pos.cashierId, cashierName: pos.cashierName ?? '' } : null)),
catchError(() => of(null))
);
}
// ── Payment Types ──
getPaymentTypes(): Observable<any[]> {
return this.http.get<any[]>('/paymenttypes');
}
// ── Share Collection ──
getShareAccountForCollection(accountId: string): Observable<any> {
return this.http.get(`/accounts/share/${accountId}`);
}
collectSharePayment(data: any): Observable<any> {
return this.http.post('/cashier/sharecollection', data);
}
getShareCollectionStatus(shareAccountId: number): Observable<any> {
return this.http.get(`/cashier/sharecollection/${shareAccountId}`);
}
}