- Add 'Modify Application' button in kebab menu for rejected accounts (all 4 types)
- Rewrite edit components with tab-based UI matching create form
- Pre-populate all create-time values in edit form: product, account status,
customer segment, account type, joint holders, nominees, introducer,
deposit account link, senior citizen rate, tenure, flags (msme/balanceSwap/autoDebit)
- Fix edit mode detection using accountNo presence
- Add preselectedIntroducer @Input to IntroducerSearchComponent for pre-fill
- Support both camelCase and lowercase keys for joint holders (MySQL queryForList)
- Fix account number display: actual accountNo before previewAccountNo
- Fix cbsAccountType restore: cbsAccountType only, avoid Fineract enum object
- Add nominees fetch via /clients/{id}/nominees API in all 4 edit components
- Fix RD/FD Interest Rate Chart: SimpleChanges to prevent reset race condition
- Pre-check Senior Citizen checkbox in edit form from isSeniorCitizen DB field
- Auto-calculate rate when tenure pre-filled in edit mode
- FD calculator: use backend calculate-fd-interest API for all compounding types
- Support interestCompoundingPeriodInMonths=0 (daily) in FD calculator API
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
187 lines
6.1 KiB
TypeScript
187 lines
6.1 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/.
|
|
*/
|
|
|
|
/** Angular Imports */
|
|
import { Injectable, inject } from '@angular/core';
|
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
|
|
/** rxjs Imports */
|
|
import { Observable } from 'rxjs';
|
|
|
|
/**
|
|
* Fixed Deposits Service.
|
|
*/
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class FixedDepositsService {
|
|
private http = inject(HttpClient);
|
|
|
|
/**
|
|
* @param accountId Account Id.
|
|
* @returns {Observable<any>} Fixed Deposits data.
|
|
*/
|
|
getFixedDepositsAccountData(accountId: string): Observable<any> {
|
|
const httpParams = new HttpParams().set('associations', 'all');
|
|
return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams });
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId fixed deposits account Id
|
|
* @returns {Observable<any>}
|
|
*/
|
|
deleteFixedDepositsAccount(accountId: string): Observable<any> {
|
|
return this.http.delete(`/fixeddepositaccounts/${accountId}`);
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId Account Id
|
|
* @param {string} command Command
|
|
* @param {any} data Data
|
|
* @returns {Observable<any>}
|
|
*/
|
|
executeFixedDepositsAccountCommand(accountId: string, command: string, data: any): Observable<any> {
|
|
const httpParams = new HttpParams().set('command', command);
|
|
return this.http.post(`/fixeddepositaccounts/${accountId}`, data, { params: httpParams });
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId Fixed Deposits Account Id
|
|
* @param {string} transactionId Transaction Id
|
|
* @returns {Observable<any>}
|
|
*/
|
|
getFixedDepositsAccountTransaction(accountId: string, transactionId: string): Observable<any> {
|
|
return this.http.get(`/fixeddepositaccounts/${accountId}/transactions/${transactionId}`);
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId Fixed Deposits Account Id
|
|
* @param {string} command Command
|
|
* @param {any} data Data
|
|
* @param {string} transactionId Transaction Id
|
|
* @returns {Observable<any>}
|
|
*/
|
|
executeFixedDepositsAccountTransactionsCommand(
|
|
accountId: string,
|
|
command: string,
|
|
data: any,
|
|
transactionId?: any
|
|
): Observable<any> {
|
|
const httpParams = new HttpParams().set('command', command);
|
|
return this.http.post(`/fixeddepositaccounts/${accountId}/transactions/${transactionId}`, data, {
|
|
params: httpParams
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId Fixed Deposits Account Id
|
|
* @returns {Observable<any>}
|
|
*/
|
|
getFixedDepositsAccountClosureTemplate(accountId: string): Observable<any> {
|
|
const httpParams = new HttpParams().set('command', 'close');
|
|
return this.http.get(`/fixeddepositaccounts/${accountId}/template`, { params: httpParams });
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId Fixed Deposits Account Id
|
|
* @returns {Observable<any>}
|
|
*/
|
|
getFixedDepositsAccountTransactionTemplate(accountId: string): Observable<any> {
|
|
return this.http.get(`/fixeddepositaccounts/${accountId}/transactions/template`);
|
|
}
|
|
|
|
/**
|
|
* @param clientId Client Id assosciated with fixed deposits account.
|
|
* @returns {Observable<any>} Fixed Deposits account template.
|
|
*/
|
|
getFixedDepositsAccountTemplate(clientId: string, productId?: string): Observable<any> {
|
|
let httpParams = new HttpParams().set('clientId', clientId);
|
|
httpParams = productId ? httpParams.set('productId', productId) : httpParams;
|
|
return this.http.get('/fixeddepositaccounts/template', { params: httpParams });
|
|
}
|
|
|
|
/**
|
|
* @param {string} accountId Fixed Deposits Account Id
|
|
* @returns {Observable<any>}
|
|
*/
|
|
getFixedDepositsAccountAndTemplate(accountId: any) {
|
|
const httpParams = new HttpParams().set('associations', 'charges,+linkedAccount').set('template', 'true');
|
|
return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams });
|
|
}
|
|
|
|
/**
|
|
* Calculate FD maturity using backend formula.
|
|
* When submittedOnDate + daysInYear are provided, uses exact calendar-based calculation
|
|
* matching the actual account creation engine.
|
|
*/
|
|
calculateFixedDepositInterest(params: {
|
|
principalAmount: number;
|
|
annualInterestRate: number;
|
|
tenureInMonths: number;
|
|
interestCompoundingPeriodInMonths: number;
|
|
interestPostingPeriodInMonths: number;
|
|
submittedOnDate?: string; // yyyy-MM-dd — enables exact calendar calculation
|
|
daysInYear?: number; // 360 or 365
|
|
}): Observable<any> {
|
|
let httpParams = new HttpParams();
|
|
Object.entries(params).forEach(
|
|
([
|
|
key,
|
|
val
|
|
]) => {
|
|
if (val !== undefined && val !== null) {
|
|
httpParams = httpParams.set(key, String(val));
|
|
}
|
|
}
|
|
);
|
|
return this.http.get(`/fixeddepositaccounts/calculate-fd-interest`, { params: httpParams });
|
|
}
|
|
|
|
/**
|
|
* @param fixedDepositAccount Fixed Deposit Account
|
|
* @returns {Observable<any>}
|
|
*/
|
|
createFixedDepositAccount(fixedDepositAccount: any): Observable<any> {
|
|
return this.http.post(`/fixeddepositaccounts`, fixedDepositAccount);
|
|
}
|
|
|
|
/**
|
|
* @param {any} accountId Account Id
|
|
* @param {any} fixedDepositAccount Fixed Deposit Account
|
|
* @returns {Observable<any>}
|
|
*/
|
|
updateFixedDepositAccount(accountId: any, fixedDepositAccount: any): Observable<any> {
|
|
return this.http.put(`/fixeddepositaccounts/${accountId}`, fixedDepositAccount);
|
|
}
|
|
|
|
/**
|
|
* @param clientId Client Id
|
|
* @param clientName Client Name
|
|
* @param fromAccountId Account Id
|
|
* @param locale Locale
|
|
* @param dateFormat Date Format
|
|
* @returns {Observable<any>} Standing Instructions
|
|
*/
|
|
getStandingInstructions(
|
|
clientId: string,
|
|
clientName: string,
|
|
fromAccountId: string,
|
|
locale: string,
|
|
dateFormat: string
|
|
): Observable<any> {
|
|
const httpParams = new HttpParams()
|
|
.set('clientId', clientId)
|
|
.set('clientName', clientName)
|
|
.set('fromAccountId', fromAccountId)
|
|
.set('fromAccountType', '2')
|
|
.set('locale', locale)
|
|
.set('dateFormat', dateFormat);
|
|
return this.http.get(`/standinginstructions`, { params: httpParams });
|
|
}
|
|
}
|