Files
cbsnexora/src/app/organization/organization.service.ts
T

1006 lines
32 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';
/** Custom Imports. */
import { SettingsService } from 'app/settings/settings.service';
/**
* Organization service.
*/
@Injectable({
providedIn: 'root'
})
export class OrganizationService {
private http = inject(HttpClient);
private settingsService = inject(SettingsService);
/**
* @returns {Observable<any>} Loan Provisioning Criteria data
*/
getProvisioningCriterias(): Observable<any> {
return this.http.get('/provisioningcriteria');
}
/**
* @returns {Observable<any>} Loan Provisioning Criteria template.
*/
getProvisioningCriteriaTemplate(): Observable<any> {
return this.http.get('/provisioningcriteria/template');
}
/**
* @param {string} provisioningId Provisioning ID of Loan Provisioning Criteria.
* @returns {Observable<any>} Provisioning Criteria.
*/
getProvisioningCriteria(provisioningId: string, template: boolean = false): Observable<any> {
const httpParams = new HttpParams().set('template', template.toString());
return this.http.get(`/provisioningcriteria/${provisioningId}`, { params: httpParams });
}
/**
* @param {any} criteriaData Provisioning Criteria to be created.
* @returns {Observable<any>}
*/
createProvisioningCriteria(criteriaData: any): Observable<any> {
return this.http.post('/provisioningcriteria', criteriaData);
}
/**
* @param {any} criteriaId Criteria Id
* @param {any} criteriaData Provisioning Criteria to be created.
* @returns {Observable<any>}
*/
updateProvisioningCriteria(criteriaId: any, criteriaData: any): Observable<any> {
return this.http.put(`/provisioningcriteria/${criteriaId}`, criteriaData);
}
/**
* @param {string} provisioningId Provisioning ID of provisioning criteria to be deleted.
* @returns {Observable<any>}
*/
deleteProvisioningCriteria(criteriaId: string): Observable<any> {
return this.http.delete(`/provisioningcriteria/${criteriaId}`);
}
/**
* @returns {Observable<any>} Offices data
*/
getOffices(): Observable<any> {
return this.http.get('/offices');
}
/**
* Get Office Template.
* @param {string} officeId Office Id of the office selected.
* @returns {Observable<any>} Office Template.
*/
getOfficeTemplate(officeId: string): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId.toString());
return this.http.get(`/loans/loanreassignment/template`, { params: httpParams });
}
/**
* Get Officer Template.
* @param officerId Officer Id.
* @param officeId Office Id.
*/
getOfficerTemplate(officerId: string, officeId: string): Observable<any> {
const httpParams = new HttpParams()
.set('fromLoanOfficerId', officerId.toString())
.set('officeId', officeId.toString());
return this.http.get('/loans/loanreassignment/template', { params: httpParams });
}
/**
* Bulk Loan Reassignment.
* @param loanData Load Data to be created.
* @returns {Observable<any>}
*/
createLoanReassignment(loanData: any): Observable<any> {
return this.http.post('/loans/loanreassignment', loanData);
}
/**
* @param {string} officeId Office ID of Office.
* @param {boolean} template
* @returns {Observable<any>} Office.
*/
getOffice(officeId: string, template: boolean = false): Observable<any> {
const httpParams = new HttpParams().set('template', template.toString());
return this.http.get(`/offices/${officeId}`, { params: httpParams });
}
/**
* @param {any} office Office to be created.
* @returns {Observable<any>}
*/
createOffice(office: any): Observable<any> {
return this.http.post('/offices', office);
}
/**
* @param {any} office Office to be updated.
* @param {string} officeId Office Id
* @returns {Observable<any>}
*/
updateOffice(officeId: string, office: any): Observable<any> {
return this.http.put(`/offices/${officeId}`, office);
}
/**
* Delete an office. Fineract enforces referential integrity server-side
* (rejects when staff / sub-offices / linked clients exist) — the UI also
* pre-checks staff count for a better experience.
* @param {string} officeId Office Id to remove.
* @returns {Observable<any>}
*/
deleteOffice(officeId: string): Observable<any> {
return this.http.delete(`/offices/${officeId}`);
}
/**
* @returns {Observable<any>}
*/
getOfficeDatatables(): Observable<any> {
const httpParams = new HttpParams().set('apptable', 'm_office');
return this.http.get(`/datatables`, { params: httpParams });
}
/**
* @param officeId Office Id of office to get datatable for.
* @param datatableName Data table name.
* @returns {Observable<any>}
*/
getOfficeDatatable(officeId: string, datatableName: string): Observable<any> {
const httpParams = new HttpParams().set('genericResultSet', 'true');
return this.http.get(`/datatables/${datatableName}/${officeId}`, { params: httpParams });
}
/**
* @param officeId Office Id of office to get add datatable entry for.
* @param datatableName Data Table name.
* @param data Data.
* @returns {Observable<any>}
*/
addOfficeDatatableEntry(officeId: string, datatableName: string, data: any): Observable<any> {
const httpParams = new HttpParams().set('genericResultSet', 'true');
return this.http.post(`/datatables/${datatableName}/${officeId}`, data, { params: httpParams });
}
/**
* @param officeId Office Id of office to get add datatable entry for.
* @param datatableName Data Table name.
* @param data Data.
* @returns {Observable<any>}
*/
editOfficeDatatableEntry(officeId: string, datatableName: string, data: any): Observable<any> {
const httpParams = new HttpParams().set('genericResultSet', 'true');
return this.http.put(`/datatables/${datatableName}/${officeId}`, data, { params: httpParams });
}
/**
* @param officeId Office Id of office to get add datatable entry for.
* @param datatableName Data Table name.
* @returns {Observable<any>}
*/
deleteDatatableContent(officeId: string, datatableName: string): Observable<any> {
const httpParams = new HttpParams().set('genericResultSet', 'true');
return this.http.delete(`/datatables/${datatableName}/${officeId}`, { params: httpParams });
}
/**
* @returns {Observable<any>} Employees data
*/
getEmployees(): Observable<any> {
const httpParams = new HttpParams().set('status', 'all');
return this.http.get('/staff', { params: httpParams });
}
/**
* @param {any} employee Employee to be created.
* @returns {Observable<any>}
*/
createEmployee(employee: any): Observable<any> {
return this.http.post('/staff', employee);
}
/**
* @param {string} employeeId Employee ID of employee.
* @param {boolean} template
* @returns {Observable<any>} Employee.
*/
getEmployee(employeeId: string, template: boolean = true): Observable<any> {
const httpParams = new HttpParams().set('template', template.toString());
return this.http.get(`/staff/${employeeId}`, { params: httpParams });
}
/**
* @returns {Observable<any>} Currencies data
*/
getCurrencies(): Observable<any> {
return this.http.get('/currencies');
}
/**
* @param {any[]} currencies
* @returns {Observable<any>} Currencies data
*/
updateCurrencies(currencies: any[]): Observable<any> {
return this.http.put('/currencies', { currencies });
}
/**
* @returns {Observable<any>} SMS Campaigns data
*/
getSmsCampaigns(): Observable<any> {
return this.http.get('/smscampaigns');
}
/**
* @param {string} smsCampaignId SMS Campaign ID of SMS Campaign.
* @returns {Observable<any>} SMS Campaign.
*/
getSmsCampaign(campaignId: string): Observable<any> {
return this.http.get(`/smscampaigns/${campaignId}`);
}
/**
* @param {any} campaign Campaign to be created.
* @returns {Observable<any>}
*/
createSmsCampaign(campaign: any): Observable<any> {
return this.http.post('/smscampaigns', campaign);
}
/**
* @param {any} campaign Campaign to be updated.
* @returns {Observable<any>}
*/
updateSmsCampaign(campaign: any, campaignId: string): Observable<any> {
return this.http.put(`/smscampaigns/${campaignId}`, campaign);
}
/**
* @param {any} campaign Campaign to be deleted.
* @returns {Observable<any>}
*/
deleteSmsCampaign(campaignId: string): Observable<any> {
return this.http.delete(`/smscampaigns/${campaignId}`);
}
/**
* @returns {Observable<any>} SMS Campaign template
*/
getSmsCampaignTemplate(): Observable<any> {
return this.http.get('/smscampaigns/template');
}
/**
* @param {string} campaignId Campaign Id
* @param {any} data Data
* @param {string} command Command
* @returns {Observable<any>}
*/
executeSmsCampaignCommand(campaignId: string, data: any, command: string): Observable<any> {
const httpParams = new HttpParams().set('command', command.toString());
return this.http.post(`/smscampaigns/${campaignId}`, data, { params: httpParams });
}
/**
* @param {any} SMS
* @returns {Observable<any>} Messages Data
*/
getMessagebyStatus(SMS: any): Observable<any> {
let httpParams = new HttpParams()
.set('status', SMS.status.toString())
.set('locale', SMS.locale)
.set('dateFormat', SMS.dateFormat);
httpParams = SMS.fromDate ? httpParams.set('fromDate', SMS.fromDate) : httpParams;
httpParams = SMS.toDate ? httpParams.set('toDate', SMS.toDate) : httpParams;
return this.http.get(`/sms/${SMS.id}/messageByStatus`, { params: httpParams });
}
/**
* @returns {Observable<any>} Adhoc Queries data
*/
getAdhocQueries(): Observable<any> {
return this.http.get('/adhocquery');
}
/**
* @param {string} adhocQueryId Adhoc Query ID of adhoc query.
* @returns {Observable<any>} Adhoc query.
*/
getAdhocQuery(adhocQueryId: string): Observable<any> {
return this.http.get(`/adhocquery/${adhocQueryId}`);
}
/**
* @returns {Observable<any>} Adhoc query Template data
*/
getAdhocQueryTemplate(): Observable<any> {
return this.http.get(`/adhocquery/template`);
}
/**
* @param {string} adhocQueryId Adhoc Query ID of adhoc query.
* @returns {Observable<any>} Adhoc query and template.
*/
getAdhocQueryAndTemplate(adhocQueryId: string): Observable<any> {
const httpParams = new HttpParams().set('template', 'true');
return this.http.get(`/adhocquery/${adhocQueryId}`, { params: httpParams });
}
/**
* @param {any} adhocQuery Adhoc Query to be created.
* @returns {Observable<any>}
*/
createAdhocQuery(adhocQuery: any): Observable<any> {
return this.http.post('/adhocquery', adhocQuery);
}
/**
* @param {any} queryId Query Id
* @param {any} adhocQuery Adhoc Query to be created.
* @returns {Observable<any>}
*/
updateAdhocQuery(queryId: any, adhocQuery: any): Observable<any> {
return this.http.put(`/adhocquery/${queryId}`, adhocQuery);
}
/**
* @param {string} adhocQueryId Adhoc Query ID of adhoc query to be deleted.
* @returns {Observable<any>}
*/
deleteAdhocQuery(adhocQueryId: string): Observable<any> {
return this.http.delete(`/adhocquery/${adhocQueryId}`);
}
/**
* @returns {Observable<any>} Tellers data
*/
getTellers(): Observable<any> {
return this.http.get('/tellers');
}
/**
* @param {string} tellerId Teller ID of teller.
* @returns {Observable<any>} Teller.
*/
getTeller(tellerId: string): Observable<any> {
return this.http.get(`/tellers/${tellerId}`);
}
/**
* @param {string} tellerId Teller ID of teller.
* @returns {Observable<any>} Cashier data.
*/
getCashiers(tellerId: string): Observable<any> {
return this.http.get(`/tellers/${tellerId}/cashiers`);
}
/**
* @param {string} tellerId Teller ID of teller.
* @param {string} cashierId Cashier ID of cashier
* @returns {Observable<any>} Cashier data.
*/
getCashier(tellerId: string, cashierId: string): Observable<any> {
return this.http.get(`/tellers/${tellerId}/cashiers/${cashierId}`);
}
/**
* @param {string} tellerId Teller Id
* @param {string} cashierId Cashier Id
* @param {string} currencyCode Currency Code
* @returns {Observable<any>}
*/
getCashierSummaryAndTransactions(tellerId: string, cashierId: string, currencyCode: string): Observable<any> {
const httpParams = new HttpParams().set('currencyCode', currencyCode);
return this.http.get(`/tellers/${tellerId}/cashiers/${cashierId}/summaryandtransactions`, { params: httpParams });
}
/**
* Get Cashier Transaction template.
* @param {string} tellerId Teller Id.
* @param {string} cashierId Cashier Id.
* @returns {Observable<any>} Cashier Transaction data.
*/
getCashierTransactionTemplate(tellerId: string, cashierId: string): Observable<any> {
return this.http.get(`/tellers/${tellerId}/cashiers/${cashierId}/transactions/template`);
}
/**
* @param {string} tellerId Teller Id
* @param {any} cashier Cashier
* @returns {Observable<any>}
*/
createCashier(tellerId: string, cashier: any): Observable<any> {
return this.http.post(`/tellers/${tellerId}/cashiers`, cashier);
}
/**
* @param {string} tellerId Teller ID of teller.
* @param {string} cashierId Cashier ID of cashier
* @returns {Observable<any>}
*/
deleteCashier(tellerId: string, cashierId: string): Observable<any> {
return this.http.delete(`/tellers/${tellerId}/cashiers/${cashierId}`);
}
/**
* @param {string} tellerId Teller Id.
* @param {string} cashierId Cashier Id.
* @param {string} cashData Cash Data.
* @returns {Observable<any>}
*/
settleCash(tellerId: string, cashierId: string, cashData: any): Observable<any> {
const httpParams = new HttpParams().set('command', 'settle');
return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/settle`, cashData, { params: httpParams });
}
/**
* @param {string} tellerId Teller Id.
* @param {string} cashierId Cashier Id.
* @param {string} cashData Cash Data.
* @returns {Observable<any>}
*/
allocateCash(tellerId: string, cashierId: string, cashData: any): Observable<any> {
const httpParams = new HttpParams().set('command', 'allocate');
return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/allocate`, cashData, { params: httpParams });
}
/** Get Cashier Template.
* @param tellerId Teller ID.
* @returns {Observable<any>} Cashier template.
*/
getCashierTemplate(tellerId: string): Observable<any> {
return this.http.get(`/tellers/${tellerId}/cashiers/template`);
}
/**
* Update Cashier.
* @param tellerId Teller Id.
* @param cashierId Cashier Id.
* @param cashierData Cashier data to be updated.
* @returns {Observable<any>}
*/
updateCashier(tellerId: string, cashierId: string, cashierData: any): Observable<any> {
return this.http.put(`/tellers/${tellerId}/cashiers/${cashierId}`, cashierData);
}
/**
* @param {string} tellerId Teller ID of teller to be deleted.
* @returns {Observable<any>}
*/
deleteTeller(tellerId: string): Observable<any> {
return this.http.delete(`/tellers/${tellerId}`);
}
/**
* @param {any} teller Teller to be created.
* @returns {Observable<any>}
*/
createTeller(teller: any): Observable<any> {
return this.http.post('/tellers', teller);
}
/**
* @returns {Observable<any>} Payment Types data
*/
getPaymentTypes(): Observable<any> {
return this.http.get('/paymenttypes');
}
/**
* @returns {Observable<any>} Payment Types data
*/
getPaymentTypesWithCode(): Observable<any> {
return this.http.get('/paymenttypes?onlyWithCode=true');
}
/**
* @param {any} paymentType Payment type to be created.
* @returns {Observable<any>}
*/
createPaymentType(paymentType: any): Observable<any> {
return this.http.post('/paymenttypes', paymentType);
}
/**
* @param {string} paymentTypeId Payment type ID of payment type to be deleted.
* @returns {Observable<any>}
*/
deletePaymentType(paymentTypeId: string): Observable<any> {
return this.http.delete(`/paymenttypes/${paymentTypeId}`);
}
/**
* @param {string} paymentTypeId Payment type ID of payment type.
* @returns {Observable<any>} Payment type.
*/
getPaymentType(paymentTypeId: string): Observable<any> {
return this.http.get(`/paymenttypes/${paymentTypeId}`);
}
/**
* @param {string} paymentTypeId Payment type ID of Payment Type to be edited.
* @returns {Observable<any>}
*/
updatePaymentType(paymentTypeId: string, paymentType: any): Observable<any> {
return this.http.put(`/paymenttypes/${paymentTypeId}`, paymentType);
}
/**
* @returns {Observable<any>} Password Preferences Template data
*/
getPasswordPreferencesTemplate(): Observable<any> {
return this.http.get('/passwordpreferences/template');
}
/**
* @param {any} passwordPreferences Password Preferences data.
* @returns {Observable<any>}
*/
updatePasswordPreferences(passwordPreferences: any): Observable<any> {
return this.http.put('/passwordpreferences', passwordPreferences);
}
/**
* @param {number} offset Page offset.
* @param {number} limit Number of entries within the page.
* @returns {Observable<any>} Entity Data Table Checks data.
*/
getEntityDataTableChecks(offset: number = 0, limit: number = -1): Observable<any> {
const httpParams = new HttpParams().set('offset', offset.toString()).set('limit', limit.toString());
return this.http.get('/entityDatatableChecks', { params: httpParams });
}
/**
* Get Entity Data Table Checks Template.
*/
getEntityDataTableChecksTemplate(): Observable<any> {
return this.http.get('/entityDatatableChecks/template');
}
/**
* Create Entity Data Table Checks.
* @param entityData Data to be passed.
*/
createEntityDataTableChecks(entityData: any): Observable<any> {
return this.http.post('/entityDatatableChecks', entityData);
}
/**
* @param {string} entityDataTableCheckId Entity Data Table Check ID of entity data table to be deleted.
* @returns {Observable<any>}
*/
deleteEntityDataTableCheck(entityDataTableCheckId: string): Observable<any> {
return this.http.delete(`/entityDatatableChecks/${entityDataTableCheckId}`);
}
/**
* @returns {Observable<any>} Working days data.
*/
getWorkingDays(): Observable<any> {
return this.http.get('/workingdays');
}
/**
* @param {any} workingDays Working days data.
* @returns {Observable<any>}
*/
updateWorkingDays(workingDays: any): Observable<any> {
return this.http.put('/workingdays', workingDays);
}
/**
* @param {string} officeId Office ID of Holidays.
* @returns {Observable<any>} Holidays data.
*/
getHolidays(officeId: string): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId.toString());
return this.http.get('/holidays', { params: httpParams });
}
/**
* Get Holiday data.
* @param holidayId Holiday Id of holidays.
* @returns {Observable<any>} Holiday data.
*/
getHoliday(holidayId: string): Observable<any> {
return this.http.get(`/holidays/${holidayId}`);
}
/**
* Get Holiday template.
* @returns {Observable<any>} Holiday data.
*/
getHolidayTemplate(): Observable<any> {
return this.http.get('/holidays/template');
}
/**
* Create Holiday.
* @param holidayData Holiday data to be created.
* @returns {Observable<any>}
*/
createHoliday(holidayData: any): Observable<any> {
return this.http.post('/holidays', holidayData);
}
/**
* Update Holiday.
* @param holidayId Holiday Id to be updated.
* @param holidayData Holiday data to be updated.
* @returns {Observable<any>}
*/
updateHoliday(holidayId: any, holidayData: any): Observable<any> {
return this.http.put(`/holidays/${holidayId}`, holidayData);
}
/**
* Delete Holiday.
* @param holidayId Holiday Id to be deleted.
* @returns {Observable<any>} Resource Id.
*/
deleteHoliday(holidayId: string): Observable<any> {
return this.http.delete(`/holidays/${holidayId}`);
}
/**
* Activate Holiday.
* @param holidayId Holiday Id to be deleted.
* @returns {Observable<any>} Resource Id.
*/
activateHoliday(holidayId: string): Observable<any> {
const httpParams = new HttpParams().set('command', 'activate');
return this.http.post(`/holidays/${holidayId}`, null, { params: httpParams });
}
/**
* @param {any} employeeId Employee ID of Employee to be edited.
* @returns {Observable<any>}
*/
updateEmployee(employeeId: string, employee: any): Observable<any> {
return this.http.put(`/staff/${employeeId}`, employee);
}
/**
* @param {string} tellerId Teller ID of Teller to be edited.
* @returns {Observable<any>}
*/
updateTeller(tellerId: string, teller: any): Observable<any> {
return this.http.put(`/tellers/${tellerId}`, teller);
}
/**
* @returns {Observable<any>} Funds data
*/
getFunds(): Observable<any> {
return this.http.get('/funds');
}
/**
* @returns {Observable<any>} Fund data
*/
getFund(fundId: string): Observable<any> {
return this.http.get(`/funds/${fundId}`);
}
/**
* @param {any} fund Fund to be created.
* @returns {Observable<any>}
*/
createFund(fund: any): Observable<any> {
return this.http.post('/funds', fund);
}
/**
* @param {string} fundId Fund Id
* @param {any} fundData Fund Data
* @returns {Observable<any>}
*/
editFund(fundId: string, fundData: any): Observable<any> {
return this.http.put(`/funds/${fundId}`, fundData);
}
getStaffs(officeId: any): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId).set('status', 'all');
return this.http.get(`/staff`, { params: httpParams });
}
getCenters(officeId: any): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId).set('status', 'all');
return this.http.get(`/centers`, { params: httpParams });
}
getGroups(officeId: any): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId).set('status', 'all');
return this.http.get(`/groups`, { params: httpParams });
}
/**
* @param {number | string} officeId ID of office to retrieve staff from.
* @param {boolean} [isLoanOfficer] Optional flag to filter by loan officer status.
* @returns {Observable<any>} Staff data.
*/
getStaff(officeId: number | string, isLoanOfficer?: boolean): Observable<any> {
let httpParams = new HttpParams().set('officeId', officeId.toString()).set('status', 'active');
if (isLoanOfficer !== undefined) {
httpParams = httpParams.set('isLoanOfficer', isLoanOfficer.toString());
}
return this.http.get('/staff', { params: httpParams });
}
/**
* @param {string} entity Entity to get imports data for.
* @returns {Observable<any>} Imports data.
*/
getImports(entity: string): Observable<any> {
const httpParams = new HttpParams().set('entityType', entity);
return this.http.get('/imports', { params: httpParams });
}
/**
* @returns {Observable<any>}
*/
getAdvanceSearchTemplate(): Observable<any> {
return this.http.get('/search/template');
}
/**
* @returns {Observable<any>}
*/
retrieveAdvanceSearchResults(queryObject: any): Observable<any> {
return this.http.post('/search/advance', queryObject);
}
/**
* @returns {Observable<any>}
*/
getStandingInstructionTemplate(): Observable<any> {
return this.http.get('/standinginstructions/template');
}
/**
* @param {any} instruction
* @returns {Observable<any>} Standing Instructions
*/
getStandingInstructions(instruction: any): Observable<any> {
let httpParams = new HttpParams();
for (const key in instruction) {
if (instruction[key] !== '' && instruction[key] !== null) {
httpParams = httpParams.set(key, instruction[key]);
}
}
return this.http.get(`/standinginstructionrunhistory`, { params: httpParams });
}
/**
* @param urlSuffix of Bulk-Import
* @param officeId Office ID for template retrieval
* @param staffId Staff ID for template retrieval
* @param legalFormType Legal Form type fortemplate retrieval
* @returns {Observable<any>} Import Template
*/
getImportTemplate(urlSuffix: string, officeId: any, staffId: any, legalFormType: string): Observable<any> {
let httpParams = new HttpParams()
.set('tenantIdentifier', 'default')
.set('locale', this.settingsService.language.code)
.set('dateFormat', this.settingsService.dateFormat);
if (officeId) {
httpParams = httpParams.set('officeId', officeId.toString());
}
if (staffId) {
httpParams = httpParams.set('staffId', staffId.toString());
}
if (legalFormType.length) {
httpParams = httpParams.set('legalFormType', legalFormType);
}
return this.http.get(`${urlSuffix}/downloadtemplate`, {
params: httpParams,
responseType: 'arraybuffer',
observe: 'response'
});
}
/**
* @param {any} id Import ID for document retrieval
* @returns {Observable<any>} Import Document
*/
getImportDocument(id: any): Observable<any> {
const httpParams = new HttpParams().set('importDocumentId', id).set('tenantIdentifier', 'default');
return this.http.get('/imports/downloadOutputTemplate', {
params: httpParams,
responseType: 'arraybuffer',
observe: 'response'
});
}
/**
* @param {File} file File to be uploaded
* @param {string} urlSuffix URL suffix
* @param {string} legalFormType Legal Form type for file upload
* @returns {Observable<any>}
*/
uploadImportDocument(file: File, urlSuffix: string, legalFormType: string): Observable<any> {
let httpParams = new HttpParams();
if (legalFormType.length) {
httpParams = httpParams.set('legalFormType', legalFormType);
}
const formData = new FormData();
formData.append('file', file);
formData.append('locale', this.settingsService.language.code);
formData.append('dateFormat', this.settingsService.dateFormat);
return this.http.post(`${urlSuffix}/uploadtemplate`, formData, { params: httpParams });
}
/**
* @returns {Observable<any>} Loan Originators data
*/
getLoanOriginators(): Observable<any> {
return this.http.get('/loan-originators');
}
/**
* @returns {Observable<any>} Loan Originators Template data
*/
getLoanOriginatorsTemplate(): Observable<any> {
return this.http.get('/loan-originators/template');
}
/**
* @returns {Observable<any>} Loan Originator data
*/
getLoanOriginator(originatorId: string): Observable<any> {
return this.http.get(`/loan-originators/${originatorId}`);
}
/**
* @returns {Observable<any>}
*/
createLoanOriginator(payload: any): Observable<any> {
return this.http.post(`/loan-originators`, payload);
}
/**
* @returns {Observable<any>}
*/
updateLoanOriginator(originatorId: number, payload: any): Observable<any> {
return this.http.put(`/loan-originators/${originatorId}`, payload);
}
/**
* @returns {Observable<any>}
*/
deleteLoanOriginator(originatorId: number): Observable<any> {
return this.http.delete(`/loan-originators/${originatorId}`);
}
// ── Institution Profile ──
/** @returns {Observable<any>} The bank's own profile (name, legal name, code, contact...). */
getInstitutionProfile(): Observable<any> {
return this.http.get('/institutionprofile');
}
/** @returns {Observable<any>} */
updateInstitutionProfile(payload: any): Observable<any> {
return this.http.put('/institutionprofile', payload);
}
// ── Branch Profile ──
/** @returns {Observable<any[]>} Every office joined with its branch profile fields, if any. */
getBranchProfiles(): Observable<any> {
return this.http.get('/branchprofile');
}
/** @returns {Observable<any>} One office's branch profile, joined with its office fields. */
getBranchProfile(officeId: number): Observable<any> {
const params = new HttpParams().set('officeId', String(officeId));
return this.http.get('/branchprofile', { params });
}
/** @returns {Observable<any>} */
updateBranchProfile(officeId: number, payload: any): Observable<any> {
return this.http.put(`/branchprofile/${officeId}`, payload);
}
// ── Clearing GL Configuration ──
/** @returns {Observable<any[]>} Every clearing role (CTS/NACH/RTGS...) and its mapped GL account, if any. */
getClearingGlConfig(): Observable<any> {
return this.http.get('/clearingglconfig');
}
/** @returns {Observable<any>} Selectable GL accounts for mapping a clearing role. */
getClearingGlConfigTemplate(): Observable<any> {
return this.http.get('/clearingglconfig/template');
}
/** @returns {Observable<any>} */
updateClearingGlConfig(configKey: string, glAccountId: number | null): Observable<any> {
return this.http.put(`/clearingglconfig/${configKey}`, { glAccountId });
}
// ── RBI Reserve Configuration (Form 1 CRR / Form 9 SLR) ──
/**
* @returns {Observable<any>} `{ rates[], glRoles[] }` — the effective-dated CRR/SLR percentages
* and the GL accounts mapped to each reserve role. Roles with nothing mapped are included, so
* the screen can show the gaps rather than hide them.
*/
getRbiReserveConfig(): Observable<any> {
return this.http.get('/rbireserveconfig');
}
/** @returns {Observable<any>} Selectable (postable, non-header) GL accounts plus the rate types. */
getRbiReserveConfigTemplate(): Observable<any> {
return this.http.get('/rbireserveconfig/template');
}
/**
* Replaces the entire set of GL accounts mapped to one reserve role.
*
* Each mapping carries the portion of the account's balance the role takes and, on a liability
* head, whether that portion is a demand or a time liability. RBI treats part of a savings balance
* as demand and the rest as time, so the same account is sent twice under one role with different
* classes - which is why this is a list of mappings rather than a list of account ids.
*
* @param {string} configKey A built-in role (CASH_IN_HAND, BALANCE_WITH_OTHER_BANKS,
* DEMAND_TIME_LIABILITIES, SLR_INVESTMENTS) or the key of a head an administrator added.
*/
updateRbiReserveGlRole(
configKey: string,
mappings: { glAccountId: number; weightPercentage: number; liabilityClass: string | null }[]
): Observable<any> {
return this.http.put(`/rbireserveconfig/gl/${configKey}`, { mappings, locale: 'en' });
}
/**
* Adds a head to a return - a reserve, a tax payable, anything the bank's chart carries that the
* built-in roles do not name. `usage` states how the return consumes it: LIABILITY, ASSET_NET,
* MAINTAINED or MEMO.
*/
createRbiReserveRole(role: { label: string; description: string; group: string; usage: string }): Observable<any> {
return this.http.post('/rbireserveconfig/role', { ...role, locale: 'en' });
}
/** Removes an administrator-defined head and the accounts pinned to it. */
deleteRbiReserveRole(roleId: number): Observable<any> {
return this.http.delete(`/rbireserveconfig/role/${roleId}`);
}
/**
* Sets a CRR or SLR rate with effect from a date. Restating an existing effective date edits that
* row; a new date adds one, so past returns keep the rate that was actually in force.
*/
upsertRbiReserveRate(rateType: string, percentage: number, effectiveFrom: string): Observable<any> {
return this.http.post('/rbireserveconfig/rate', {
rateType,
percentage,
effectiveFrom,
locale: 'en',
dateFormat: 'yyyy-MM-dd'
});
}
/** @returns {Observable<any>} */
deleteRbiReserveRate(rateId: number): Observable<any> {
return this.http.delete(`/rbireserveconfig/rate/${rateId}`);
}
}