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 903c22478..726fe439e 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 @@ -216,24 +216,26 @@ Actions - - @@ -300,15 +302,15 @@ Actions diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.ts b/src/app/clients/clients-view/general-tab/general-tab.component.ts index db01fff81..59d6ee5f1 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.ts +++ b/src/app/clients/clients-view/general-tab/general-tab.component.ts @@ -81,4 +81,14 @@ export class GeneralTabComponent { }); } + + /** + * Stops the propagation to view pages. + * @param $event Mouse Event + */ + routeEdit($event: MouseEvent) { + $event.stopPropagation(); + } + + } diff --git a/src/app/savings/add-savings-charge/add-savings-charge.component.spec.ts b/src/app/savings/add-savings-charge/add-savings-charge.component.spec.ts deleted file mode 100644 index 316b6be53..000000000 --- a/src/app/savings/add-savings-charge/add-savings-charge.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AddSavingsChargeComponent } from './add-savings-charge.component'; - -describe('AddSavingsChargeComponent', () => { - let component: AddSavingsChargeComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AddSavingsChargeComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AddSavingsChargeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/savings/common-resolvers/saving-transaction-template.resolver.ts b/src/app/savings/common-resolvers/saving-transaction-template.resolver.ts deleted file mode 100644 index 9ba849cff..000000000 --- a/src/app/savings/common-resolvers/saving-transaction-template.resolver.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** Angular Imports */ -import { Injectable } from '@angular/core'; -import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; - -/** rxjs Imports */ -import { Observable } from 'rxjs'; - -/** Custom Services */ -import { SavingsService } from '../savings.service'; - -/** - * Savings Account Transaction Template data resolver. - */ -@Injectable() -export class SavingAccountTransactionTemplateResolver implements Resolve { - - /** - * @param {SavingsService} savingsService Savings service. - */ - constructor(private savingsService: SavingsService) { } - - /** - * Returns the Savings Account Transaction Template. - * @returns {Observable} - */ - resolve(route: ActivatedRouteSnapshot): Observable { - const savingAccountId = route.paramMap.get('savingAccountId'); - return this.savingsService.getSavingsTransactionTemplateResource(savingAccountId); - } -} diff --git a/src/app/savings/common-resolvers/savings-account-actions.resolver.ts b/src/app/savings/common-resolvers/savings-account-actions.resolver.ts new file mode 100644 index 000000000..cabd13903 --- /dev/null +++ b/src/app/savings/common-resolvers/savings-account-actions.resolver.ts @@ -0,0 +1,43 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SavingsService } from '../savings.service'; + +/** + * Savings Account Actions data resolver. + */ +@Injectable() +export class SavingsAccountActionsResolver implements Resolve { + + /** + * @param {SavingsService} SavingsService Savings service. + */ + constructor(private savingsService: SavingsService) { } + + /** + * Returns the Savings account actions data. + * @param {ActivatedRouteSnapshot} route Route Snapshot + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const actionName = route.paramMap.get('name'); + const savingAccountId = route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId'); + switch (actionName) { + case 'Assign Staff': + return this.savingsService.getSavingsAccountAndTemplate(savingAccountId, true); + case 'Add Charge': + return this.savingsService.getSavingsChargeTemplateResource(savingAccountId); + case 'Withdrawal': + case 'Deposit': + return this.savingsService.getSavingsTransactionTemplateResource(savingAccountId); + default: + return undefined; + } + } + +} diff --git a/src/app/savings/common-resolvers/savings-account-view.resolver.ts b/src/app/savings/common-resolvers/savings-account-view.resolver.ts index 1eb6c420d..b01f4346c 100644 --- a/src/app/savings/common-resolvers/savings-account-view.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-view.resolver.ts @@ -25,7 +25,7 @@ export class SavingsAccountViewResolver implements Resolve { * @returns {Observable} */ resolve(route: ActivatedRouteSnapshot): Observable { - const savingAccountId = route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId'); + const savingAccountId = route.paramMap.get('savingAccountId'); return this.savingsService.getSavingsAccountData(savingAccountId); } diff --git a/src/app/savings/common-resolvers/savings-charge-template.resolver.ts b/src/app/savings/common-resolvers/savings-charge-template.resolver.ts deleted file mode 100644 index e9d1c485b..000000000 --- a/src/app/savings/common-resolvers/savings-charge-template.resolver.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** Angular Imports */ -import { Injectable } from '@angular/core'; -import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; - -/** rxjs Imports */ -import { Observable } from 'rxjs'; - -/** Custom Services */ -import { SavingsService } from '../savings.service'; - -/** - * Savings Charge Template data resolver. - */ -@Injectable() -export class SavingsChargeTemplateResolver implements Resolve { - - /** - * @param {SavingsService} SavingsService savings service. - */ - constructor(private savingsService: SavingsService) {} - - /** - * Returns the Savings Charge Template. - * @returns {Observable} - */ - resolve(route: ActivatedRouteSnapshot): Observable { - const savingAccountId = route.paramMap.get('savingAccountId'); - return this.savingsService.getSavingsChargeTemplateResource(savingAccountId); - } -} diff --git a/src/app/savings/add-savings-charge/add-savings-charge.component.html b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html similarity index 99% rename from src/app/savings/add-savings-charge/add-savings-charge.component.html rename to src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html index 6bcfb3ae0..a9ba9e5a8 100644 --- a/src/app/savings/add-savings-charge/add-savings-charge.component.html +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html @@ -80,7 +80,7 @@ - + diff --git a/src/app/savings/add-savings-charge/add-savings-charge.component.scss b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.scss similarity index 58% rename from src/app/savings/add-savings-charge/add-savings-charge.component.scss rename to src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.scss index 1cbc977c5..aeead06e0 100644 --- a/src/app/savings/add-savings-charge/add-savings-charge.component.scss +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.scss @@ -1,3 +1,3 @@ -.container{ +.container { width: 37rem; } diff --git a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.spec.ts b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.spec.ts new file mode 100644 index 000000000..df3c99d52 --- /dev/null +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AddChargeSavingsAccountComponent } from './add-charge-savings-account.component'; + +describe('AddChargeSavingsAccountComponent', () => { + let component: AddChargeSavingsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AddChargeSavingsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddChargeSavingsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/add-savings-charge/add-savings-charge.component.ts b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts similarity index 82% rename from src/app/savings/add-savings-charge/add-savings-charge.component.ts rename to src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts index 61f995e56..108150083 100644 --- a/src/app/savings/add-savings-charge/add-savings-charge.component.ts +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts @@ -5,17 +5,17 @@ import { Router, ActivatedRoute } from '@angular/router'; import { DatePipe } from '@angular/common'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsService } from '../../savings.service'; /** * Add Savings Charge component. */ @Component({ - selector: 'mifosx-add-savings-charge', - templateUrl: './add-savings-charge.component.html', - styleUrls: ['./add-savings-charge.component.scss'] + selector: 'mifosx-add-charge-savings-account', + templateUrl: './add-charge-savings-account.component.html', + styleUrls: ['./add-charge-savings-account.component.scss'] }) -export class AddSavingsChargeComponent implements OnInit { +export class AddChargeSavingsAccountComponent implements OnInit { /** Minimum Due Date allowed. */ minDate = new Date(2000, 0, 1); @@ -31,11 +31,12 @@ export class AddSavingsChargeComponent implements OnInit { chargeDetails: any; /** - * Retrieves the savings charge template data from `resolve`. - * @param {FormBuilder} formBuilder Form Builder. - * @param {AccountingService} accountingService Accounting Service. - * @param {ActivatedRoute} route Activated Route. - * @param {Router} router Router for navigation. + * Retrieves charge template data from `resolve` + * @param {FormBuilder} formBuilder Form Builder + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + * @param {DatePipe} datePipe Date Pipe + * @param {SavingsService} savingsService Savings Service */ constructor( private formBuilder: FormBuilder, @@ -44,10 +45,10 @@ export class AddSavingsChargeComponent implements OnInit { private datePipe: DatePipe, private savingsService: SavingsService ) { - this.route.data.subscribe((data: { savingsChargeTemplate: any }) => { - this.savingsChargeOptions = data.savingsChargeTemplate.chargeOptions; + this.route.data.subscribe((data: { savingsAccountActionData: any }) => { + this.savingsChargeOptions = data.savingsAccountActionData.chargeOptions; }); - this.savingAccountId = this.route.snapshot.params['savingAccountId']; + this.savingAccountId = this.route.parent.snapshot.params['savingAccountId']; } /** @@ -131,8 +132,9 @@ export class AddSavingsChargeComponent implements OnInit { } } } - this.savingsService.createSavingsCharge(this.savingAccountId, 'charges', savingsCharge).subscribe(res => { - // this.router.navigate(['../'], { relativeTo: this.route }); + this.savingsService.createSavingsCharge(this.savingAccountId, 'charges', savingsCharge).subscribe( () => { + this.router.navigate(['../../'], { relativeTo: this.route }); }); } + } diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.html b/src/app/savings/saving-account-actions/saving-account-actions.component.html index 0a3927c03..f7f091dd8 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.html +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.html @@ -1,8 +1,10 @@ - - + + + + diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.ts b/src/app/savings/saving-account-actions/saving-account-actions.component.ts index 17d112e87..933354c80 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.ts +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.ts @@ -1,7 +1,6 @@ /** Angular Imports */ import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { SavingsService } from '../savings.service'; /** * Savings account actions component. @@ -13,41 +12,39 @@ import { SavingsService } from '../savings.service'; }) export class SavingAccountActionsComponent { - /** Savings Account Data */ - savingsAccountData: any; /** Flag object to store possible actions and render appropriate UI to the user */ actions: { 'Approve': boolean 'Reject': boolean - 'Withdraw': boolean + 'Withdrawal': boolean + 'Deposit': boolean 'Activate': boolean 'Undo Approval': boolean 'Post Interest As On': boolean - 'Assign Staff': boolean + 'Assign Staff': boolean // savings account and template + 'Add Charge': boolean 'Unassign Staff': boolean + 'Withdraw By Client': boolean } = { 'Approve': false, 'Reject': false, - 'Withdraw': false, + 'Withdrawal': false, + 'Deposit': false, 'Activate': false, 'Undo Approval': false, 'Post Interest As On': false, 'Assign Staff': false, - 'Unassign Staff': false + 'Add Charge': false, + 'Unassign Staff': false, + 'Withdraw By Client': false }; /** * @param {ActivatedRoute} route Activated Route - * @param {SavingsService} savingsService Savings Service */ - constructor(private route: ActivatedRoute, - private savingsService: SavingsService) { + constructor(private route: ActivatedRoute) { const name = this.route.snapshot.params['name']; - const accountId = this.route.parent.snapshot.params['savingAccountId']; - this.savingsService.getSavingsAccountAndTemplate(accountId, true).subscribe((response: any) => { - this.savingsAccountData = response; - this.actions[name] = true; - }); + this.actions[name] = true; } } diff --git a/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts b/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts index f4d3c3fe9..aada31b9a 100644 --- a/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts @@ -17,9 +17,6 @@ import { SavingsService } from 'app/savings/savings.service'; }) export class SavingsAccountAssignStaffComponent implements OnInit { - /** Savings Account Data */ - @Input() savingsAccountData: any; - /** Minimum date allowed. */ minDate = new Date(2000, 0, 1); /** Maximum date allowed. */ @@ -30,6 +27,8 @@ export class SavingsAccountAssignStaffComponent implements OnInit { accountId: any; /** Field Officer Data */ fieldOfficerData: any; + /** Savings Account Data */ + savingsAccountData: any; /** * @param {FormBuilder} formBuilder Form Builder @@ -44,6 +43,9 @@ export class SavingsAccountAssignStaffComponent implements OnInit { private route: ActivatedRoute, private router: Router) { this.accountId = this.route.parent.snapshot.params['savingAccountId']; + this.route.data.subscribe((data: { savingsAccountActionData: any }) => { + this.savingsAccountData = data.savingsAccountActionData; + }); } /** diff --git a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.html b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.html index efa867a14..7240be343 100644 --- a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.html +++ b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.html @@ -1,83 +1,89 @@
-

Withdraw Money From Saving Account

-

Deposit Money To Saving Account

-
+ - +

Withdraw Money From Saving Account

+

Deposit Money To Saving Account

- - Transaction Date - - - - - Transaction Date is required - - + - - Transaction Amount - - - Transaction Amount is required - - + - - Payment Type - - - {{ paymentType.name }} - - - + + Transaction Date + + + + + Transaction Date is required + + -
- Show Payment Details - -
+ + Transaction Amount + + + Transaction Amount is required + + + + Payment Type + + + {{ paymentType.name }} + + + - - Account Number - - +
+ Show Payment Details + +
- - Cheque - - + + Account Number + + - - Routing Code - - + + Cheque + + - - Receipt Number - - + + Routing Code + + - - Bank - - + + Receipt Number + + + + Bank + + - - Notes - - + + Notes + + - - - - + + + + + +
+ + + +
- -
+ \ No newline at end of file diff --git a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.scss b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.scss index 5f97c79c5..aeead06e0 100644 --- a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.scss +++ b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.scss @@ -1,3 +1,3 @@ -.container{ - width: 70%; +.container { + width: 37rem; } diff --git a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts index dcb39868d..cc8b30166 100644 --- a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts @@ -53,20 +53,18 @@ export class SavingsAccountTransactionsComponent implements OnInit { private router: Router, private datePipe: DatePipe, private savingsService: SavingsService) { - this.route.data.subscribe((data: { savingAccountTransactionTemplate: any }) => { - this.paymentTypeOptions = data.savingAccountTransactionTemplate.paymentTypeOptions; + this.route.data.subscribe((data: { savingsAccountActionData: any }) => { + this.paymentTypeOptions = data.savingsAccountActionData.paymentTypeOptions; }); + this.transactionCommand = this.route.snapshot.params['name'].toLowerCase(); + this.transactionType[this.transactionCommand] = true; + this.savingAccountId = this.route.parent.snapshot.params['savingAccountId']; } /** * Creates the Saving account transaction form when component loads. */ ngOnInit() { - this.route.queryParams.subscribe(params => { - this.transactionType[params.type] = true; - this.transactionCommand = params.type; - }); - this.savingAccountId = this.route.snapshot.params['savingAccountId']; this.createSavingAccountTransactionForm(); } @@ -115,8 +113,8 @@ export class SavingsAccountTransactionsComponent implements OnInit { const transactionData = this.savingAccountTransactionForm.value; transactionData.locale = 'en'; transactionData.dateFormat = dateFormat; - this.savingsService.makeTransaction(this.transactionCommand, this.savingAccountId, transactionData).subscribe(res => { - this.router.navigate(['../'], { relativeTo: this.route }); + this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, transactionData).subscribe(res => { + this.router.navigate(['../../'], { relativeTo: this.route }); }); } } diff --git a/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.html b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.html similarity index 100% rename from src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.html rename to src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.html diff --git a/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.scss b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.scss similarity index 100% rename from src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.scss rename to src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.scss diff --git a/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.spec.ts b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.spec.ts new file mode 100644 index 000000000..17287ae32 --- /dev/null +++ b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WithdrawByClientSavingsAccountComponent } from './withdraw-by-client-savings-account.component'; + +describe('WithdrawByClientSavingsAccountComponent', () => { + let component: WithdrawByClientSavingsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WithdrawByClientSavingsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WithdrawByClientSavingsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.ts b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts similarity index 85% rename from src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.ts rename to src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts index 9a4ac6817..c62e96bb6 100644 --- a/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts @@ -8,14 +8,14 @@ import { ActivatedRoute, Router } from '@angular/router'; import { SavingsService } from 'app/savings/savings.service'; /** - * Withdraw Savings Account Component + * Withdraw By Client Savings Account Component */ @Component({ - selector: 'mifosx-withdraw-savings-account', - templateUrl: './withdraw-savings-account.component.html', - styleUrls: ['./withdraw-savings-account.component.scss'] + selector: 'mifosx-withdraw-by-client-savings-account', + templateUrl: './withdraw-by-client-savings-account.component.html', + styleUrls: ['./withdraw-by-client-savings-account.component.scss'] }) -export class WithdrawSavingsAccountComponent implements OnInit { +export class WithdrawByClientSavingsAccountComponent implements OnInit { /** Minimum date allowed. */ minDate = new Date(2000, 0, 1); @@ -59,7 +59,7 @@ export class WithdrawSavingsAccountComponent implements OnInit { } /** - * Submits the form and withdraws the saving account, + * Submits the form and withdraws the saving account by client, * if successful redirects to the saving account. */ submit() { diff --git a/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.spec.ts b/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.spec.ts deleted file mode 100644 index 9a15c22b6..000000000 --- a/src/app/savings/saving-account-actions/withdraw-savings-account/withdraw-savings-account.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { WithdrawSavingsAccountComponent } from './withdraw-savings-account.component'; - -describe('WithdrawSavingsAccountComponent', () => { - let component: WithdrawSavingsAccountComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ WithdrawSavingsAccountComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(WithdrawSavingsAccountComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/savings/savings-account-view/charges-tab/charges-tab.component.html b/src/app/savings/savings-account-view/charges-tab/charges-tab.component.html index 0f78f94cf..dc67c2d87 100644 --- a/src/app/savings/savings-account-view/charges-tab/charges-tab.component.html +++ b/src/app/savings/savings-account-view/charges-tab/charges-tab.component.html @@ -79,16 +79,16 @@ 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 7ea7f5b57..636238327 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 @@ -132,7 +132,7 @@ export class ChargesTabComponent implements OnInit { }; this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'paycharge', dataObject, chargeId) .subscribe(() => { - this.router.navigate(['../'], { relativeTo: this.route }); + this.reload(); }); } }); @@ -148,7 +148,7 @@ export class ChargesTabComponent implements OnInit { if (response.confirm) { this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'waive', {}, chargeId) .subscribe(() => { - this.router.navigate(['../'], { relativeTo: this.route }); + this.reload(); }); } }); @@ -164,7 +164,7 @@ export class ChargesTabComponent implements OnInit { if (response.confirm) { this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'inactivate', {}, chargeId) .subscribe(() => { - this.router.navigate(['../'], { relativeTo: this.route }); + this.reload(); }); } }); @@ -178,4 +178,23 @@ export class ChargesTabComponent implements OnInit { return charge.chargeTimeType.value === 'Monthly Fee' || charge.chargeTimeType.value === 'Annual Fee' || charge.chargeTimeType.value === 'Weekly Fee'; } + /** + * Stops the propagation to view charge page. + * @param $event Mouse Event + */ + routeEdit($event: MouseEvent) { + $event.stopPropagation(); + } + + /** + * Refetches data fot the component + * 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}) + .then(() => this.router.navigate([url])); + } + } 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 9dbf3ded5..875054600 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 @@ -106,14 +106,19 @@ export class SavingsAccountViewComponent implements OnInit { switch (name) { case 'Approve': case 'Reject': - case 'Withdraw': + case 'Deposit': case 'Activate': case 'Undo Approval': case 'Post Interest As On': case 'Assign Staff': + case 'Add Charge': case 'Unassign Staff': + case 'Withdraw By Client': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; + case 'Withdraw': + this.router.navigate([`actions/Withdrawal`], { relativeTo: this.route }); + break; case 'Modify Application': this.router.navigate(['edit-savings-account'], { relativeTo: this.route }); break; diff --git a/src/app/savings/savings-account-view/savings-buttons.config.ts b/src/app/savings/savings-account-view/savings-buttons.config.ts index dffda5d2f..2586bac82 100644 --- a/src/app/savings/savings-account-view/savings-buttons.config.ts +++ b/src/app/savings/savings-account-view/savings-buttons.config.ts @@ -114,7 +114,7 @@ export class SavingsButtonsConfiguration { taskPermissionName: 'REJECT_SAVINGSACCOUNT' }, { - name: 'Withdraw', + name: 'Withdraw By Client', taskPermissionName: 'WITHDRAW_SAVINGSACCOUNT' }, { diff --git a/src/app/savings/savings-account-view/view-charge/view-charge.component.html b/src/app/savings/savings-account-view/view-charge/view-charge.component.html index bcb03508a..451b8e204 100644 --- a/src/app/savings/savings-account-view/view-charge/view-charge.component.html +++ b/src/app/savings/savings-account-view/view-charge/view-charge.component.html @@ -1,7 +1,7 @@ -
- +
-
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 bb8edda36..29d83dc49 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 @@ -45,8 +45,10 @@ export class ViewChargeComponent { private datePipe: DatePipe, private router: Router, public dialog: MatDialog) { - this.route.data.subscribe((data: { savingsAccountCharge: any, savingsAccountData: any }) => { + this.route.data.subscribe((data: { savingsAccountCharge: any }) => { this.chargeData = data.savingsAccountCharge; + }); + this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => { this.savingsAccountData = data.savingsAccountData; }); } diff --git a/src/app/savings/savings-routing.module.ts b/src/app/savings/savings-routing.module.ts index 268a43c3e..cdeb4a4e8 100644 --- a/src/app/savings/savings-routing.module.ts +++ b/src/app/savings/savings-routing.module.ts @@ -9,7 +9,6 @@ import { extract } from '../core/i18n/i18n.service'; import { SavingsAccountViewComponent } from './savings-account-view/savings-account-view.component'; import { TransactionsTabComponent } from './savings-account-view/transactions-tab/transactions-tab.component'; import { SavingAccountActionsComponent } from './saving-account-actions/saving-account-actions.component'; -import { AddSavingsChargeComponent } from './add-savings-charge/add-savings-charge.component'; import { ChargesTabComponent } from './savings-account-view/charges-tab/charges-tab.component'; import { StandingInstructionsTabComponent } from './savings-account-view/standing-instructions-tab/standing-instructions-tab.component'; import { DatatableTabsComponent } from './savings-account-view/datatable-tabs/datatable-tabs.component'; @@ -19,15 +18,14 @@ import { ViewTransactionComponent } from './savings-account-view/view-transactio import { ViewChargeComponent } from './savings-account-view/view-charge/view-charge.component'; /** Custom Resolvers */ -import { SavingAccountTransactionTemplateResolver } from './common-resolvers/saving-transaction-template.resolver'; -import { SavingsChargeTemplateResolver } from './common-resolvers/savings-charge-template.resolver'; import { SavingsAccountViewResolver } from './common-resolvers/savings-account-view.resolver'; import { SavingsDatatableResolver } from './common-resolvers/savings-datatable.resolver'; import { SavingsDatatablesResolver } from './common-resolvers/savings-datatables.resolver'; import { SavingsAccountTemplateResolver } from './common-resolvers/savings-account-template.resolver'; import { SavingsAccountAndTemplateResolver } from './common-resolvers/savings-account-and-template.resolver'; import { SavingsAccountTransactionResolver } from './common-resolvers/savings-account-transaction.resolver'; -import { SavingsAccountChargeResolver} from './common-resolvers/savings-account-charge.resolver'; +import { SavingsAccountChargeResolver } from './common-resolvers/savings-account-charge.resolver'; +import { SavingsAccountActionsResolver } from './common-resolvers/savings-account-actions.resolver'; const routes: Routes = [ { @@ -45,6 +43,9 @@ const routes: Routes = [ { path: ':savingAccountId', data: { title: extract('Saving Account View'), routeParamBreadcrumb: 'savingAccountId' }, + resolve: { + savingsAccountData: SavingsAccountViewResolver + }, children: [ { path: '', @@ -123,7 +124,6 @@ const routes: Routes = [ data: { routeParamBreadcrumb: 'id' }, component: ViewChargeComponent, resolve: { - savingsAccountData: SavingsAccountViewResolver, savingsAccountCharge: SavingsAccountChargeResolver } } @@ -132,7 +132,10 @@ const routes: Routes = [ { path: 'actions/:name', data: { title: extract('Savings Account Actions'), routeParamBreadcrumb: 'name' }, - component: SavingAccountActionsComponent + component: SavingAccountActionsComponent, + resolve: { + savingsAccountActionData: SavingsAccountActionsResolver + } } ] } @@ -143,14 +146,13 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule], declarations: [], - providers: [SavingAccountTransactionTemplateResolver, - SavingsChargeTemplateResolver, - SavingsAccountViewResolver, + providers: [SavingsAccountViewResolver, SavingsDatatablesResolver, SavingsDatatableResolver, SavingsAccountTemplateResolver, SavingsAccountAndTemplateResolver, SavingsAccountTransactionResolver, - SavingsAccountChargeResolver] + SavingsAccountChargeResolver, + SavingsAccountActionsResolver] }) export class SavingsRoutingModule {} diff --git a/src/app/savings/savings.module.ts b/src/app/savings/savings.module.ts index b646eb8bb..bd3ea17c8 100644 --- a/src/app/savings/savings.module.ts +++ b/src/app/savings/savings.module.ts @@ -11,7 +11,6 @@ import { DirectivesModule } from '../directives/directives.module'; /** Custom Components */ import { SavingAccountActionsComponent } from './saving-account-actions/saving-account-actions.component'; import { SavingsAccountTransactionsComponent } from './saving-account-actions/savings-account-transactions/savings-account-transactions.component'; -import { AddSavingsChargeComponent } from './add-savings-charge/add-savings-charge.component'; import { TransactionsTabComponent } from './savings-account-view/transactions-tab/transactions-tab.component'; import { SavingsAccountViewComponent } from './savings-account-view/savings-account-view.component'; import { ChargesTabComponent } from './savings-account-view/charges-tab/charges-tab.component'; @@ -27,7 +26,6 @@ import { SavingsAccountPreviewStepComponent } from './savings-account-stepper/sa import { EditSavingsAccountComponent } from './edit-savings-account/edit-savings-account.component'; import { ApproveSavingsAccountComponent } from './saving-account-actions/approve-savings-account/approve-savings-account.component'; import { RejectSavingsAccountComponent } from './saving-account-actions/reject-savings-account/reject-savings-account.component'; -import { WithdrawSavingsAccountComponent } from './saving-account-actions/withdraw-savings-account/withdraw-savings-account.component'; import { ActivateSavingsAccountComponent } from './saving-account-actions/activate-savings-account/activate-savings-account.component'; import { UndoApprovalSavingsAccountComponent } from './saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component'; import { PostInterestAsOnSavingsAccountComponent } from './saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component'; @@ -40,6 +38,8 @@ import { UndoTransactionDialogComponent } from './savings-account-view/custom-di import { ViewChargeComponent } from './savings-account-view/view-charge/view-charge.component'; import { WaiveChargeDialogComponent } from './savings-account-view/custom-dialogs/waive-charge-dialog/waive-charge-dialog.component'; import { InactivateChargeDialogComponent } from './savings-account-view/custom-dialogs/inactivate-charge-dialog/inactivate-charge-dialog.component'; +import { WithdrawByClientSavingsAccountComponent } from './saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component'; +import { AddChargeSavingsAccountComponent } from './saving-account-actions/add-charge-savings-account/add-charge-savings-account.component'; /** @@ -57,7 +57,6 @@ import { InactivateChargeDialogComponent } from './savings-account-view/custom-d declarations: [ SavingAccountActionsComponent, SavingsAccountTransactionsComponent, - AddSavingsChargeComponent, TransactionsTabComponent, SavingsAccountViewComponent, ChargesTabComponent, @@ -73,7 +72,6 @@ import { InactivateChargeDialogComponent } from './savings-account-view/custom-d EditSavingsAccountComponent, ApproveSavingsAccountComponent, RejectSavingsAccountComponent, - WithdrawSavingsAccountComponent, ActivateSavingsAccountComponent, UndoApprovalSavingsAccountComponent, PostInterestAsOnSavingsAccountComponent, @@ -85,7 +83,9 @@ import { InactivateChargeDialogComponent } from './savings-account-view/custom-d UndoTransactionDialogComponent, ViewChargeComponent, WaiveChargeDialogComponent, - InactivateChargeDialogComponent + InactivateChargeDialogComponent, + WithdrawByClientSavingsAccountComponent, + AddChargeSavingsAccountComponent ], entryComponents: [ CalculateInterestDialogComponent, diff --git a/src/app/savings/savings.service.ts b/src/app/savings/savings.service.ts index af57120c4..eaa6838c8 100644 --- a/src/app/savings/savings.service.ts +++ b/src/app/savings/savings.service.ts @@ -23,16 +23,6 @@ export class SavingsService { return this.http.get(`/savingsaccounts/${savingAccountId}/transactions/template`); } - /** - * @param {string} action transaction type. - * @param {string} savingAccountId saving account id. - * @param {any} transactionData transaction details for saving account. - * @returns {Observable} - */ - makeTransaction(action: string, savingAccountId: string, transactionData: any): Observable { - return this.http.post(`/savingsaccounts/${savingAccountId}/transactions?command=${action}`, transactionData); - } - /** * @param {string} savingAccountId saving account id. * @returns {Observable}