refactor: savings module (#1226)

See: #1196
This commit is contained in:
Karan Takalkar
2020-08-25 17:46:54 +05:30
committed by GitHub
parent f215e1aa96
commit efdd779aa9
30 changed files with 129 additions and 103 deletions
@@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
import { Observable, forkJoin } from 'rxjs';
/** Custom Services */
import { SavingsService } from '../savings.service';
@@ -34,8 +34,14 @@ export class SavingsAccountActionsResolver implements Resolve<Object> {
return this.savingsService.getSavingsChargeTemplateResource(savingAccountId);
case 'Withdrawal':
case 'Deposit':
case 'Close':
return this.savingsService.getSavingsTransactionTemplateResource(savingAccountId);
case 'Close':
return forkJoin([
this.savingsService.getSavingsTransactionTemplateResource(savingAccountId),
this.savingsService.getSavingsAccountData(savingAccountId)
]);
case 'Apply Annual Fees':
return this.savingsService.getSavingsAccountData(savingAccountId);
default:
return undefined;
}
@@ -25,8 +25,9 @@ export class SavingsAccountTemplateResolver implements Resolve<Object> {
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const clientId = route.parent.parent.paramMap.get('clientId');
return this.savingsService.getSavingsAccountTemplate(clientId);
const entityId = route.paramMap.get('clientId') || route.paramMap.get('groupId') || route.paramMap.get('centerId');
const isGroup = (route.paramMap.get('groupId') || route.paramMap.get('centerId')) ? true : false;
return this.savingsService.getSavingsAccountTemplate(entityId, undefined, isGroup);
}
}