refactor: existing savings account actions (#941)

Fixes: #940
This commit is contained in:
Karan Takalkar
2020-06-28 17:13:05 +05:30
committed by GitHub
parent af5f9995f0
commit 35a25e018f
31 changed files with 294 additions and 275 deletions
@@ -216,24 +216,26 @@
<ng-container matColumnDef="Actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let element">
<button *ngIf="element.status.active" class="account-action-button" mat-raised-button color="primary">
<button *ngIf="element.status.active" class="account-action-button" mat-raised-button color="primary"
(click)="routeEdit($event)" [routerLink]="['../','savingsaccounts', element.id, 'actions', 'Deposit']">
<i class="fa fa-arrow-up"></i>
</button>
<button *ngIf="element.status.active" class="account-action-button" mat-raised-button color="primary">
<button *ngIf="element.status.active" class="account-action-button" mat-raised-button color="primary"
(click)="routeEdit($event)" [routerLink]="['../','savingsaccounts', element.id, 'actions', 'Withdrawal']">
<i class="fa fa-arrow-down"></i>
</button>
<button *ngIf="element.status.submittedAndPendingApproval" class="account-action-button" mat-raised-button
color="primary" [routerLink]="['../','savingsaccounts', element.id, 'actions', 'Approve']">
color="primary" (click)="routeEdit($event)" [routerLink]="['../','savingsaccounts', element.id, 'actions', 'Approve']">
<i class="fa fa-check"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary"
[routerLink]="['../','savingsaccounts', element.id, 'actions', 'Undo Approval']">
(click)="routeEdit($event)" [routerLink]="['../','savingsaccounts', element.id, 'actions', 'Undo Approval']">
<i class="fa fa-undo"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary"
[routerLink]="['../','savingsaccounts', element.id, 'actions', 'Activate']">
(click)="routeEdit($event)" [routerLink]="['../','savingsaccounts', element.id, 'actions', 'Activate']">
<i class="fa fa-check-circle"></i>
</button>
</td>
@@ -300,15 +302,15 @@
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let element">
<button *ngIf="element.status.submittedAndPendingApproval" class="account-action-button" mat-raised-button
color="primary" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Approve']">
color="primary" (click)="routeEdit($event)" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Approve']">
<i class="fa fa-check"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Undo Approval']">
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Undo Approval']">
<i class="fa fa-undo"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Activate']">
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Activate']">
<i class="fa fa-check-circle"></i>
</button>
</td>
@@ -81,4 +81,14 @@ export class GeneralTabComponent {
});
}
/**
* Stops the propagation to view pages.
* @param $event Mouse Event
*/
routeEdit($event: MouseEvent) {
$event.stopPropagation();
}
}
@@ -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<AddSavingsChargeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddSavingsChargeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddSavingsChargeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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<Object> {
/**
* @param {SavingsService} savingsService Savings service.
*/
constructor(private savingsService: SavingsService) { }
/**
* Returns the Savings Account Transaction Template.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const savingAccountId = route.paramMap.get('savingAccountId');
return this.savingsService.getSavingsTransactionTemplateResource(savingAccountId);
}
}
@@ -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<Object> {
/**
* @param {SavingsService} SavingsService Savings service.
*/
constructor(private savingsService: SavingsService) { }
/**
* Returns the Savings account actions data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
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;
}
}
}
@@ -25,7 +25,7 @@ export class SavingsAccountViewResolver implements Resolve<Object> {
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const savingAccountId = route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId');
const savingAccountId = route.paramMap.get('savingAccountId');
return this.savingsService.getSavingsAccountData(savingAccountId);
}
@@ -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<Object> {
/**
* @param {SavingsService} SavingsService savings service.
*/
constructor(private savingsService: SavingsService) {}
/**
* Returns the Savings Charge Template.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const savingAccountId = route.paramMap.get('savingAccountId');
return this.savingsService.getSavingsChargeTemplateResource(savingAccountId);
}
}
@@ -80,7 +80,7 @@
</div>
<mat-card-actions fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!savingsChargeForm.valid">Submit</button>
</mat-card-actions>
@@ -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<AddChargeSavingsAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddChargeSavingsAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddChargeSavingsAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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 });
});
}
}
@@ -1,8 +1,10 @@
<mifosx-approve-savings-account *ngIf="actions['Approve']"></mifosx-approve-savings-account>
<mifosx-reject-savings-account *ngIf="actions['Reject']"></mifosx-reject-savings-account>
<mifosx-withdraw-savings-account *ngIf="actions['Withdraw']"></mifosx-withdraw-savings-account>
<mifosx-activate-savings-account *ngIf="actions['Activate']"></mifosx-activate-savings-account>
<mifosx-undo-approval-savings-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-savings-account>
<mifosx-post-interest-as-on-savings-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-savings-account>
<mifosx-savings-account-assign-staff [savingsAccountData]="savingsAccountData" *ngIf="actions['Assign Staff']"></mifosx-savings-account-assign-staff>
<mifosx-savings-account-assign-staff *ngIf="actions['Assign Staff']"></mifosx-savings-account-assign-staff>
<mifosx-savings-account-unassign-staff *ngIf="actions['Unassign Staff']"></mifosx-savings-account-unassign-staff>
<mifosx-withdraw-by-client-savings-account *ngIf="actions['Withdraw By Client']"></mifosx-withdraw-by-client-savings-account>
<mifosx-add-charge-savings-account *ngIf="actions['Add Charge']"></mifosx-add-charge-savings-account>
<mifosx-savings-transactions *ngIf="actions['Withdrawal'] || actions['Deposit']"></mifosx-savings-transactions>
@@ -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;
}
}
@@ -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;
});
}
/**
@@ -1,83 +1,89 @@
<div class="container">
<h2 mat-title *ngIf="transactionType.withdrawal">Withdraw Money From Saving Account</h2>
<h2 mat-title *ngIf="transactionType.deposit">Deposit Money To Saving Account</h2>
<form [formGroup]="savingAccountTransactionForm" (ngSubmit)="submit()">
<mat-card>
<mat-card-content fxLayout="column">
<h2 mat-title *ngIf="transactionType.withdrawal">Withdraw Money From Saving Account</h2>
<h2 mat-title *ngIf="transactionType.deposit">Deposit Money To Saving Account</h2>
<mat-form-field>
<mat-label>Transaction Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="dueDatePicker"
formControlName="transactionDate" required>
<mat-datepicker-toggle matSuffix [for]="dueDatePicker"></mat-datepicker-toggle>
<mat-datepicker #dueDatePicker></mat-datepicker>
<mat-error *ngIf="savingAccountTransactionForm.controls.transactionDate.hasError('required')">
Transaction Date is <strong>required</strong>
</mat-error>
</mat-form-field>
<form [formGroup]="savingAccountTransactionForm" (ngSubmit)="submit()">
<mat-form-field>
<mat-label>Transaction Amount</mat-label>
<input type="number" formControlName="transactionAmount" required matInput />
<mat-error *ngIf="savingAccountTransactionForm.controls.transactionAmount.hasError('required')">
Transaction Amount is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-card-content fxLayout="column">
<mat-form-field>
<mat-label>Payment Type</mat-label>
<mat-select formControlName="paymentTypeId">
<mat-option *ngFor="let paymentType of paymentTypeOptions" [value]="paymentType.id">
{{ paymentType.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label>Transaction Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="dueDatePicker"
formControlName="transactionDate" required>
<mat-datepicker-toggle matSuffix [for]="dueDatePicker"></mat-datepicker-toggle>
<mat-datepicker #dueDatePicker></mat-datepicker>
<mat-error *ngIf="savingAccountTransactionForm.controls.transactionDate.hasError('required')">
Transaction Date is <strong>required</strong>
</mat-error>
</mat-form-field>
<div fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column">
<mat-label fxFlexAlign="center">Show Payment Details</mat-label>
<button type="button" mat-mini-fab color="primary" (click)="addPaymentDetails()">
<fa-icon icon="plus-circle" size="lg"></fa-icon>
</button>
</div>
<mat-form-field>
<mat-label>Transaction Amount</mat-label>
<input type="number" formControlName="transactionAmount" required matInput />
<mat-error *ngIf="savingAccountTransactionForm.controls.transactionAmount.hasError('required')">
Transaction Amount is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Payment Type</mat-label>
<mat-select formControlName="paymentTypeId">
<mat-option *ngFor="let paymentType of paymentTypeOptions" [value]="paymentType.id">
{{ paymentType.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['accountNumber']">
<mat-label>Account Number</mat-label>
<input type="number" formControlName="accountNumber" matInput />
</mat-form-field>
<div fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column">
<mat-label fxFlexAlign="center">Show Payment Details</mat-label>
<button type="button" mat-mini-fab color="primary" (click)="addPaymentDetails()">
<fa-icon icon="plus-circle" size="lg"></fa-icon>
</button>
</div>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['checkNumber']">
<mat-label>Cheque</mat-label>
<input type="number" formControlName="checkNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['accountNumber']">
<mat-label>Account Number</mat-label>
<input type="number" formControlName="accountNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['routingCode']">
<mat-label>Routing Code</mat-label>
<input formControlName="routingCode" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['checkNumber']">
<mat-label>Cheque</mat-label>
<input type="number" formControlName="checkNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['receiptNumber']">
<mat-label>Receipt Number</mat-label>
<input formControlName="receiptNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['routingCode']">
<mat-label>Routing Code</mat-label>
<input formControlName="routingCode" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['bankNumber']">
<mat-label>Bank</mat-label>
<input formControlName="bankNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['receiptNumber']">
<mat-label>Receipt Number</mat-label>
<input formControlName="receiptNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="savingAccountTransactionForm.controls['bankNumber']">
<mat-label>Bank</mat-label>
<input formControlName="bankNumber" matInput />
</mat-form-field>
<mat-form-field>
<mat-label>Notes</mat-label>
<textarea formControlName="note" matInput></textarea>
</mat-form-field>
<mat-form-field>
<mat-label>Notes</mat-label>
<textarea formControlName="note" matInput></textarea>
</mat-form-field>
<mat-card-actions fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!savingAccountTransactionForm.valid">Submit</button>
</mat-card-actions>
<mat-card-actions fxLayoutGap="5px" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center">
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!savingAccountTransactionForm.valid">Submit</button>
</mat-card-actions>
</mat-card-content>
</form>
</mat-card>
</mat-card-content>
</form>
</div>
@@ -1,3 +1,3 @@
.container{
width: 70%;
.container {
width: 37rem;
}
@@ -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 });
});
}
}
@@ -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<WithdrawByClientSavingsAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ WithdrawByClientSavingsAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WithdrawByClientSavingsAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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() {
@@ -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<WithdrawSavingsAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ WithdrawSavingsAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WithdrawSavingsAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -79,16 +79,16 @@
</span>
<span *ngIf="savingsAccountData.status.value === 'Active' && charge.amountOutstanding !== 0">
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Pay Charge"
*mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="payCharge(charge.id)">
*mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="routeEdit($event); payCharge(charge.id)">
<i class="fa fa-dollar"></i>
</button>
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Waive Charge"
*mifosxHasPermission="'WAIVE_SAVINGSACCOUNTCHARGE'" (click)="waiveCharge(charge.id)">
*mifosxHasPermission="'WAIVE_SAVINGSACCOUNTCHARGE'" (click)="routeEdit($event); waiveCharge(charge.id)">
<i class="fa fa-flag"></i>
</button>
<ng-container *ngIf="isRecurringCharge(charge)">
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Inactivate Charge"
*mifosxHasPermission="'INACTIVATE_SAVINGSACCOUNTCHARGE'" (click)="inactivateCharge(charge.id)">
*mifosxHasPermission="'INACTIVATE_SAVINGSACCOUNTCHARGE'" (click)="routeEdit($event); inactivateCharge(charge.id)">
<i class="fa fa-ban"></i>
</button>
</ng-container>
@@ -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]));
}
}
@@ -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;
@@ -114,7 +114,7 @@ export class SavingsButtonsConfiguration {
taskPermissionName: 'REJECT_SAVINGSACCOUNT'
},
{
name: 'Withdraw',
name: 'Withdraw By Client',
taskPermissionName: 'WITHDRAW_SAVINGSACCOUNT'
},
{
@@ -1,7 +1,7 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<span *ngIf="savingsAccountData.status.value === 'Active' && chargeData.amountOutstanding !== 0">
<div *ngIf="savingsAccountData.status.value === 'Active' && chargeData.amountOutstanding !== 0"
fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<button mat-raised-button color="accent" *mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="payCharge()">
<fa-icon icon="dollar-sign"></fa-icon>&nbsp;&nbsp;
Pay Charge
@@ -16,7 +16,6 @@
Inactivate Charge
</button>
</span>
</span>
</div>
<div class="container">
@@ -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;
});
}
+12 -10
View File
@@ -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 {}
+5 -5
View File
@@ -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,
-10
View File
@@ -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<any>}
*/
makeTransaction(action: string, savingAccountId: string, transactionData: any): Observable<any> {
return this.http.post(`/savingsaccounts/${savingAccountId}/transactions?command=${action}`, transactionData);
}
/**
* @param {string} savingAccountId saving account id.
* @returns {Observable<any>}