From efdd779aa9d51cf5cef0719b9482d96407f65b91 Mon Sep 17 00:00:00 2001 From: Karan Takalkar Date: Tue, 25 Aug 2020 17:46:54 +0530 Subject: [PATCH] refactor: savings module (#1226) See: #1196 --- src/app/centers/centers-routing.module.ts | 2 +- .../centers-view/centers-view.component.html | 4 +- .../general-tab/general-tab.component.html | 48 ++++++++----------- .../general-tab/general-tab.component.ts | 9 ++++ src/app/clients/clients-routing.module.ts | 2 +- .../clients-view/clients-view.component.html | 2 +- .../general-tab/general-tab.component.html | 15 +++--- src/app/groups/groups-routing.module.ts | 2 +- .../general-tab/general-tab.component.html | 20 ++++---- .../general-tab/general-tab.component.ts | 8 ++++ .../groups-view/groups-view.component.html | 8 ++-- .../notifications-page.component.ts | 2 +- .../savings-account-actions.resolver.ts | 10 +++- .../savings-account-template.resolver.ts | 5 +- .../create-savings-account.component.ts | 6 ++- .../edit-savings-account.component.ts | 6 ++- ...y-annual-fees-savings-account.component.ts | 4 +- .../close-savings-account.component.ts | 6 +-- .../savings-account-charges-step.component.ts | 12 +---- .../savings-account-details-step.component.ts | 5 +- .../charges-tab/charges-tab.component.ts | 4 +- .../savings-account-view.component.html | 2 +- .../savings-account-view.component.ts | 19 ++++++-- .../transactions-tab.component.html | 2 +- .../transactions-tab.component.ts | 2 +- .../view-charge/view-charge.component.ts | 6 +-- src/app/savings/savings-routing.module.ts | 11 ++--- src/app/savings/savings.service.ts | 6 +-- .../search-page/search-page.component.ts | 2 +- .../notifications-tray.component.ts | 2 +- 30 files changed, 129 insertions(+), 103 deletions(-) diff --git a/src/app/centers/centers-routing.module.ts b/src/app/centers/centers-routing.module.ts index 5b4a91e21..4ae5eac9a 100644 --- a/src/app/centers/centers-routing.module.ts +++ b/src/app/centers/centers-routing.module.ts @@ -108,7 +108,7 @@ const routes: Routes = [ } }, { - path: 'savingsaccounts', + path: 'savings-accounts', loadChildren: () => import('../savings/savings.module').then(m => m.SavingsModule) } ] diff --git a/src/app/centers/centers-view/centers-view.component.html b/src/app/centers/centers-view/centers-view.component.html index c30c1fee5..6a7096627 100644 --- a/src/app/centers/centers-view/centers-view.component.html +++ b/src/app/centers/centers-view/centers-view.component.html @@ -65,7 +65,9 @@ - + diff --git a/src/app/centers/centers-view/general-tab/general-tab.component.html b/src/app/centers/centers-view/general-tab/general-tab.component.html index 2d0d69361..ddeacc84f 100644 --- a/src/app/centers/centers-view/general-tab/general-tab.component.html +++ b/src/app/centers/centers-view/general-tab/general-tab.component.html @@ -19,6 +19,7 @@ +

Groups

@@ -49,6 +50,7 @@
+
@@ -78,63 +80,51 @@ - Actions - - - - - - - - - - - - - - - - - - - - - - - - + - - + diff --git a/src/app/centers/centers-view/general-tab/general-tab.component.ts b/src/app/centers/centers-view/general-tab/general-tab.component.ts index 77b24712c..a0b853c5c 100644 --- a/src/app/centers/centers-view/general-tab/general-tab.component.ts +++ b/src/app/centers/centers-view/general-tab/general-tab.component.ts @@ -45,4 +45,13 @@ export class GeneralTabComponent implements OnInit { ngOnInit() { } + + /** + * Stops the propagation to view pages. + * @param $event Mouse Event + */ + routeEdit($event: MouseEvent) { + $event.stopPropagation(); + } + } diff --git a/src/app/clients/clients-routing.module.ts b/src/app/clients/clients-routing.module.ts index 03fe2ce99..4e34e12fb 100644 --- a/src/app/clients/clients-routing.module.ts +++ b/src/app/clients/clients-routing.module.ts @@ -238,7 +238,7 @@ const routes: Routes = [ loadChildren: () => import('../deposits/fixed-deposits/fixed-deposits.module').then(m => m.FixedDepositsModule) }, { - path: 'savingsaccounts', + path: 'savings-accounts', loadChildren: () => import('../savings/savings.module').then(m => m.SavingsModule) }, { diff --git a/src/app/clients/clients-view/clients-view.component.html b/src/app/clients/clients-view/clients-view.component.html index 2fc184f02..081f63cf9 100644 --- a/src/app/clients/clients-view/clients-view.component.html +++ b/src/app/clients/clients-view/clients-view.component.html @@ -63,7 +63,7 @@ Applications - + diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.html b/src/app/clients/clients-view/general-tab/general-tab.component.html index bb2ecdfd5..97d8ac985 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.html +++ b/src/app/clients/clients-view/general-tab/general-tab.component.html @@ -262,25 +262,25 @@ Actions @@ -288,12 +288,11 @@ + [routerLink]="['../', 'savings-accounts', row.id, 'transactions']"> - @@ -314,7 +313,7 @@ - +
diff --git a/src/app/groups/groups-routing.module.ts b/src/app/groups/groups-routing.module.ts index cc069e606..ada35628a 100644 --- a/src/app/groups/groups-routing.module.ts +++ b/src/app/groups/groups-routing.module.ts @@ -139,7 +139,7 @@ const routes: Routes = [ loadChildren: () => import('../loans/loans.module').then(m => m.LoansModule) }, { - path: 'savingsaccounts', + path: 'savings-accounts', loadChildren: () => import('../savings/savings.module').then(m => m.SavingsModule) } ] diff --git a/src/app/groups/groups-view/general-tab/general-tab.component.html b/src/app/groups/groups-view/general-tab/general-tab.component.html index 1588249ce..99139b457 100644 --- a/src/app/groups/groups-view/general-tab/general-tab.component.html +++ b/src/app/groups/groups-view/general-tab/general-tab.component.html @@ -233,29 +233,33 @@ Actions - - - - + @@ -280,7 +284,7 @@ - + diff --git a/src/app/groups/groups-view/general-tab/general-tab.component.ts b/src/app/groups/groups-view/general-tab/general-tab.component.ts index 35efeff05..0f23eb687 100644 --- a/src/app/groups/groups-view/general-tab/general-tab.component.ts +++ b/src/app/groups/groups-view/general-tab/general-tab.component.ts @@ -67,4 +67,12 @@ export class GeneralTabComponent { this.showClosedSavingAccounts = !this.showClosedSavingAccounts; } + /** + * Stops the propagation to view pages. + * @param $event Mouse Event + */ + routeEdit($event: MouseEvent) { + $event.stopPropagation(); + } + } diff --git a/src/app/groups/groups-view/groups-view.component.html b/src/app/groups/groups-view/groups-view.component.html index 50677f6a4..bdc35d759 100644 --- a/src/app/groups/groups-view/groups-view.component.html +++ b/src/app/groups/groups-view/groups-view.component.html @@ -66,12 +66,12 @@ - - + + - + diff --git a/src/app/notifications/notifications-page/notifications-page.component.ts b/src/app/notifications/notifications-page/notifications-page.component.ts index fd725e5e1..c1b84d058 100644 --- a/src/app/notifications/notifications-page/notifications-page.component.ts +++ b/src/app/notifications/notifications-page/notifications-page.component.ts @@ -34,7 +34,7 @@ export class NotificationsPageComponent implements OnInit { 'shareAccount' : '/shares-accounts/', 'fixedDeposit' : '/fixed-deposits-accounts/', 'recurringDepositAccount': '/recurringdeposits/', - 'savingsAccount' : '/savingsaccounts/', + 'savingsAccount' : '/savings-accounts/', 'shareProduct': '/products/share-products/', 'loanProduct' : '/products/loan-products/' }; diff --git a/src/app/savings/common-resolvers/savings-account-actions.resolver.ts b/src/app/savings/common-resolvers/savings-account-actions.resolver.ts index d34e6da64..8e484b2bd 100644 --- a/src/app/savings/common-resolvers/savings-account-actions.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-actions.resolver.ts @@ -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 { 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; } diff --git a/src/app/savings/common-resolvers/savings-account-template.resolver.ts b/src/app/savings/common-resolvers/savings-account-template.resolver.ts index 02cc338af..bb5f9638e 100644 --- a/src/app/savings/common-resolvers/savings-account-template.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-template.resolver.ts @@ -25,8 +25,9 @@ export class SavingsAccountTemplateResolver implements Resolve { * @returns {Observable} */ resolve(route: ActivatedRouteSnapshot): Observable { - 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); } } diff --git a/src/app/savings/create-savings-account/create-savings-account.component.ts b/src/app/savings/create-savings-account/create-savings-account.component.ts index 7f65d3611..9b36615ba 100644 --- a/src/app/savings/create-savings-account/create-savings-account.component.ts +++ b/src/app/savings/create-savings-account/create-savings-account.component.ts @@ -103,7 +103,6 @@ export class CreateSavingsAccountComponent { const monthDayFormat = 'dd MMMM'; const savingsAccount = { ...this.savingsAccount, - clientId: this.savingsAccountTemplate.clientId, charges: this.savingsAccount.charges.map((charge: any) => ({ chargeId: charge.id, amount: charge.amount, @@ -116,6 +115,11 @@ export class CreateSavingsAccountComponent { monthDayFormat, locale }; + if (this.savingsAccountTemplate.clientId) { + savingsAccount.clientId = this.savingsAccountTemplate.clientId; + } else { + savingsAccount.groupId = this.savingsAccountTemplate.groupId; + } this.savingsService.createSavingsAccount(savingsAccount).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); }); diff --git a/src/app/savings/edit-savings-account/edit-savings-account.component.ts b/src/app/savings/edit-savings-account/edit-savings-account.component.ts index 6420eb753..0013ec29c 100644 --- a/src/app/savings/edit-savings-account/edit-savings-account.component.ts +++ b/src/app/savings/edit-savings-account/edit-savings-account.component.ts @@ -108,7 +108,6 @@ export class EditSavingsAccountComponent { const monthDayFormat = 'dd MMMM'; const savingsAccount = { ...this.savingsAccount, - clientId: this.savingsAccountAndTemplate.clientId, charges: this.savingsAccount.charges.map((charge: any) => ({ chargeId: charge.id, amount: charge.amount, @@ -121,6 +120,11 @@ export class EditSavingsAccountComponent { monthDayFormat, locale }; + if (this.savingsAccountAndTemplate.clientId) { + savingsAccount.clientId = this.savingsAccountAndTemplate.clientId; + } else { + savingsAccount.groupId = this.savingsAccountAndTemplate.groupId; + } this.savingsService.updateSavingsAccount(this.savingsAccountAndTemplate.id, savingsAccount).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts index 710f9772b..02caab90f 100644 --- a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts @@ -43,8 +43,8 @@ export class ApplyAnnualFeesSavingsAccountComponent implements OnInit { private route: ActivatedRoute, private router: Router) { this.accountId = this.route.parent.snapshot.params['savingAccountId']; - this.route.parent.data.subscribe((data: { savingsAccountData: any }) => { - this.savingsAccountData = data.savingsAccountData; + this.route.data.subscribe((data: { savingsAccountActionData: any }) => { + this.savingsAccountData = data.savingsAccountActionData; }); } diff --git a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts index 3b7bd97e5..f1a343efd 100644 --- a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts @@ -45,10 +45,8 @@ export class CloseSavingsAccountComponent implements OnInit { private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { savingsAccountActionData: any }) => { - this.paymentTypeOptions = data.savingsAccountActionData.paymentTypeOptions; - }); - this.route.parent.data.subscribe((data: { savingsAccountData: any }) => { - this.transactionAmount = data.savingsAccountData.summary.accountBalance; + this.paymentTypeOptions = data.savingsAccountActionData[0].paymentTypeOptions; + this.transactionAmount = data.savingsAccountActionData[1].summary.accountBalance; }); this.accountId = this.route.parent.snapshot.params['savingAccountId']; } diff --git a/src/app/savings/savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component.ts index 12ebab3ce..c6e491f20 100644 --- a/src/app/savings/savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component.ts @@ -5,7 +5,6 @@ import { FormControl } from '@angular/forms'; import { DatePipe } from '@angular/common'; /** Custom Dialogs */ -import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; /** Custom Models */ @@ -180,15 +179,8 @@ export class SavingsAccountChargesStepComponent implements OnInit, OnChanges { * @param {any} charge Charge */ deleteCharge(charge: any) { - const deleteChargeDialogRef = this.dialog.open(DeleteDialogComponent, { - data: { deleteContext: `charge ${charge.name}` } - }); - deleteChargeDialogRef.afterClosed().subscribe((response: any) => { - if (response.delete) { - this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1); - this.chargesDataSource = this.chargesDataSource.concat([]); - } - }); + this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1); + this.chargesDataSource = this.chargesDataSource.concat([]); this.pristine = false; } diff --git a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts index 302cee550..7006f21a9 100644 --- a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts @@ -74,9 +74,10 @@ export class SavingsAccountDetailsStepComponent implements OnInit { * Fetches savings account product template on productId value changes */ buildDependencies() { - const clientId = this.savingsAccountTemplate.clientId; + const entityId = this.savingsAccountTemplate.clientId || this.savingsAccountTemplate.groupId; this.savingsAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => { - this.savingsService.getSavingsAccountTemplate(clientId, productId).subscribe((response: any) => { + this.savingsService.getSavingsAccountTemplate(entityId, productId, this.savingsAccountTemplate.groupId ? true : false) + .subscribe((response: any) => { this.savingsAccountProductTemplate.emit(response); this.fieldOfficerData = response.fieldOfficerOptions; if (!this.isFieldOfficerPatched && this.savingsAccountTemplate.fieldOfficerId) { diff --git a/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts b/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts index 1e6055e1b..f48845a69 100644 --- a/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts +++ b/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts @@ -248,9 +248,9 @@ export class ChargesTabComponent implements OnInit { * TODO: Replace by a custom reload component instead of hard-coded back-routing. */ private reload() { - const clientId = this.savingsAccountData.clientId; const url: string = this.router.url; - this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true}) + const refreshUrl: string = this.router.url.slice(0, this.router.url.indexOf('savings-accounts') + 'savings-accounts'.length); + this.router.navigateByUrl(refreshUrl, {skipLocationChange: true}) .then(() => this.router.navigate([url])); } diff --git a/src/app/savings/savings-account-view/savings-account-view.component.html b/src/app/savings/savings-account-view/savings-account-view.component.html index e5b84440a..796d59ab6 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.html +++ b/src/app/savings/savings-account-view/savings-account-view.component.html @@ -21,7 +21,7 @@

- Account #: {{savingsAccountData.accountNo}} | Client Name: {{savingsAccountData.clientName}}
+ Account #: {{savingsAccountData.accountNo}} | {{entityType}} Name: {{savingsAccountData.clientName || savingsAccountData.groupName}}
Current Balance: {{savingsAccountData.currency.displaySymbol}} {{savingsAccountData.summary.accountBalance}}
Available Balance: {{savingsAccountData.currency.displaySymbol}} {{savingsAccountData.summary.availableBalance}}
diff --git a/src/app/savings/savings-account-view/savings-account-view.component.ts b/src/app/savings/savings-account-view/savings-account-view.component.ts index d14801564..130a4ce80 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.ts +++ b/src/app/savings/savings-account-view/savings-account-view.component.ts @@ -29,6 +29,8 @@ export class SavingsAccountViewComponent implements OnInit { savingsDatatables: any; /** Button Configurations */ buttonConfig: SavingsButtonsConfiguration; + /** Entity Type */ + entityType: string; /** * Fetches savings account data from `resolve` @@ -44,6 +46,13 @@ export class SavingsAccountViewComponent implements OnInit { this.savingsAccountData = data.savingsAccountData; this.savingsDatatables = data.savingsDatatables; }); + if (this.router.url.includes('clients')) { + this.entityType = 'Client'; + } else if (this.router.url.includes('groups')) { + this.entityType = 'Group'; + } else if (this.router.url.includes('centers')) { + this.entityType = 'Center'; + } } ngOnInit() { @@ -101,13 +110,13 @@ export class SavingsAccountViewComponent implements OnInit { /** - * Refetches data fot the component + * Refetches data foe the component * TODO: Replace by a custom reload component instead of hard-coded back-routing. */ - reload() { - const clientId = this.savingsAccountData.clientId; + private reload() { const url: string = this.router.url; - this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true}) + const refreshUrl: string = this.router.url.slice(0, this.router.url.indexOf('savings-accounts') + 'savings-accounts'.length); + this.router.navigateByUrl(refreshUrl, {skipLocationChange: true}) .then(() => this.router.navigate([url])); } @@ -135,7 +144,7 @@ export class SavingsAccountViewComponent implements OnInit { this.router.navigate([`actions/Withdrawal`], { relativeTo: this.route }); break; case 'Modify Application': - this.router.navigate(['edit-savings-account'], { relativeTo: this.route }); + this.router.navigate(['edit'], { relativeTo: this.route }); break; case 'Delete': this.deleteSavingsAccount(); diff --git a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.html b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.html index 6567c826f..336fa45e7 100644 --- a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.html +++ b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.html @@ -5,7 +5,7 @@

All Transactions

- +
diff --git a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts index 9f2aa7aeb..3c9439bab 100644 --- a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts +++ b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts @@ -29,7 +29,7 @@ export class TransactionsTabComponent implements OnInit { constructor(private route: ActivatedRoute, private router: Router) { this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => { - this.transactionsData = data.savingsAccountData.transactions.filter((transaction: any) => !transaction.reversed); + this.transactionsData = data.savingsAccountData.transactions?.filter((transaction: any) => !transaction.reversed); this.status = data.savingsAccountData.status.value; }); } diff --git a/src/app/savings/savings-account-view/view-charge/view-charge.component.ts b/src/app/savings/savings-account-view/view-charge/view-charge.component.ts index eef77026d..d0f7808d8 100644 --- a/src/app/savings/savings-account-view/view-charge/view-charge.component.ts +++ b/src/app/savings/savings-account-view/view-charge/view-charge.component.ts @@ -49,7 +49,7 @@ export class ViewChargeComponent { this.route.data.subscribe((data: { savingsAccountCharge: any }) => { this.chargeData = data.savingsAccountCharge; }); - this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => { + this.route.data.subscribe((data: { savingsAccountData: any }) => { this.savingsAccountData = data.savingsAccountData; }); } @@ -194,9 +194,9 @@ export class ViewChargeComponent { * TODO: Replace by a custom reload component instead of hard-coded back-routing. */ private reload() { - const clientId = this.savingsAccountData.clientId; const url: string = this.router.url.replace(`/${this.chargeData.id}`, ''); - this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true}) + const refreshUrl: string = this.router.url.slice(0, this.router.url.indexOf('savings-accounts') + 'savings-accounts'.length); + this.router.navigateByUrl(refreshUrl, {skipLocationChange: true}) .then(() => this.router.navigate([url])); } diff --git a/src/app/savings/savings-routing.module.ts b/src/app/savings/savings-routing.module.ts index a5dd0ff41..0743f5d48 100644 --- a/src/app/savings/savings-routing.module.ts +++ b/src/app/savings/savings-routing.module.ts @@ -32,14 +32,14 @@ import { SavingsAccountActionsResolver } from './common-resolvers/savings-accoun import { SavingsTransactionRecieptResolver } from './common-resolvers/savings-transaction-reciept.resolver'; import { SavingsAccountTransactionTemplateResolver } from './common-resolvers/savings-account-transaction-template.resolver'; - +/** Savings Routes */ const routes: Routes = [ { path: '', data: { title: extract('All Savings'), breadcrumb: 'Savings', routeParamBreadcrumb: false }, children: [ { - path: 'create-savings-account', + path: 'create', data: { title: extract('Create Savings Account'), breadcrumb: 'Create Savings Account' }, component: CreateSavingsAccountComponent, resolve: { @@ -49,14 +49,12 @@ const routes: Routes = [ { path: ':savingAccountId', data: { title: extract('Saving Account View'), routeParamBreadcrumb: 'savingAccountId' }, - resolve: { - savingsAccountData: SavingsAccountViewResolver - }, children: [ { path: '', component: SavingsAccountViewComponent, resolve: { + savingsAccountData: SavingsAccountViewResolver, savingsDatatables: SavingsDatatablesResolver }, children: [ @@ -101,7 +99,7 @@ const routes: Routes = [ ] }, { - path: 'edit-savings-account', + path: 'edit', data: { title: extract('Edit Savings Account'), breadcrumb: 'Edit', routeParamBreadcrumb: false }, component: EditSavingsAccountComponent, resolve: { @@ -164,6 +162,7 @@ const routes: Routes = [ data: { routeParamBreadcrumb: 'id' }, component: ViewChargeComponent, resolve: { + savingsAccountData: SavingsAccountViewResolver, savingsAccountCharge: SavingsAccountChargeResolver } } diff --git a/src/app/savings/savings.service.ts b/src/app/savings/savings.service.ts index 94ebf49f8..f9836d399 100644 --- a/src/app/savings/savings.service.ts +++ b/src/app/savings/savings.service.ts @@ -140,11 +140,11 @@ export class SavingsService { } /** - * @param clientId Client Id assosciated with savings account. + * @param entityId Entity Id assosciated with savings account. * @returns {Observable} Savings account template. */ - getSavingsAccountTemplate(clientId: string, productId?: string): Observable { - let httpParams = new HttpParams().set('clientId', clientId); + getSavingsAccountTemplate(entityId: string, productId?: string, isGroup?: boolean): Observable { + let httpParams = new HttpParams().set( isGroup ? 'groupId' : 'clientId', entityId); httpParams = productId ? httpParams.set('productId', productId) : httpParams; return this.http.get('/savingsaccounts/template', { params: httpParams }); } diff --git a/src/app/search/search-page/search-page.component.ts b/src/app/search/search-page/search-page.component.ts index 42f1afb41..be891e64e 100644 --- a/src/app/search/search-page/search-page.component.ts +++ b/src/app/search/search-page/search-page.component.ts @@ -51,7 +51,7 @@ export class SearchPageComponent { this.router.navigate(['clients', entity.parentId, 'shares-accounts', entity.entityId]); break; case 'SAVING': - this.router.navigate(['clients', entity.parentId, 'savingsaccounts', entity.entityId]); + this.router.navigate(['clients', entity.parentId, 'savings-accounts', entity.entityId]); break; case 'LOAN': this.router.navigate(['clients', entity.parentId, 'loans', entity.entityId]); diff --git a/src/app/shared/notifications-tray/notifications-tray.component.ts b/src/app/shared/notifications-tray/notifications-tray.component.ts index b41b2c7fd..26c824ed6 100644 --- a/src/app/shared/notifications-tray/notifications-tray.component.ts +++ b/src/app/shared/notifications-tray/notifications-tray.component.ts @@ -39,7 +39,7 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy { 'shareAccount' : '/shares-accounts/', 'fixedDeposit' : '/fixed-deposits-accounts/', 'recurringDepositAccount': '/recurringdeposits/', - 'savingsAccount' : '/savingsaccounts/', + 'savingsAccount' : '/savings-accounts/', 'shareProduct': '/products/share-products/', 'loanProduct' : '/products/loan-products/' };