feat: add list view standing instructions (#1152)

Fixes: #267
This commit is contained in:
Muskan Khedia
2020-07-23 17:22:28 +05:30
committed by GitHub
parent 63a9e46fc2
commit cb62fefbfa
18 changed files with 410 additions and 18 deletions
@@ -16,6 +16,7 @@ import { StandingInstructionsDataAndTemplateResolver } from './common-resolvers/
import { StandingInstructionsTemplateResolver } from './common-resolvers/standing-instructions-template.resolver';
import { MakeAccountTransersComponent } from './make-account-transers/make-account-transers.component';
import { MakeAccountTransferTemplateResolver } from './common-resolvers/make-account-transfer-template.resolver';
import { ListStandingInstructionsComponent } from './list-standing-instructions/list-standing-instructions.component';
/** Loans Route. */
const routes: Routes = [
@@ -38,6 +39,14 @@ const routes: Routes = [
accountTransferTemplate: MakeAccountTransferTemplateResolver
}
},
{
path: 'list-standing-instructions',
data: { title: extract('List Standing Instructions'), breadcrumb: 'List Standing Instructions', routeParamBreadcrumb: 'List Standing Instructions' },
component: ListStandingInstructionsComponent,
resolve: {
standingIntructionsTemplate: StandingInstructionsTemplateResolver
}
},
{
path: ':standingInstructionsId',
data: { title: extract('Standing Instructions'), routeParamBreadcrumb: 'standingInstructionsId' },
@@ -59,7 +68,7 @@ const routes: Routes = [
},
}
]
}
},
]
},
];
@@ -13,6 +13,7 @@ import { ViewStandingInstructionsComponent } from './view-standing-instructions/
import { EditStandingInstructionsComponent } from './edit-standing-instructions/edit-standing-instructions.component';
import { CreateStandingInstructionsComponent } from './create-standing-instructions/create-standing-instructions.component';
import { MakeAccountTransersComponent } from './make-account-transers/make-account-transers.component';
import { ListStandingInstructionsComponent } from './list-standing-instructions/list-standing-instructions.component';
/**
* Account Transfers Module
@@ -25,7 +26,8 @@ import { MakeAccountTransersComponent } from './make-account-transers/make-accou
ViewStandingInstructionsComponent,
EditStandingInstructionsComponent,
CreateStandingInstructionsComponent,
MakeAccountTransersComponent
MakeAccountTransersComponent,
ListStandingInstructionsComponent
],
providers: [DatePipe]
})
@@ -69,4 +69,29 @@ export class AccountTransfersService {
return this.http.post(`/accounttransfers`, data);
}
/**
* @param clientId Client Id
* @param clientName Client Name
* @param fromAccountId Account Id
* @param locale Locale
* @param dateFormat Date Format
* @returns {Observable<any>} Standing Instructions
*/
getStandingInstructions(searchData: any): Observable<any> {
let httpParams = new HttpParams();
const propNames = Object.getOwnPropertyNames(searchData);
for (let i = 0; i < propNames.length; i++) {
const propName = propNames[i];
if (!(searchData[propName] === '' || searchData[propName] === undefined || searchData[propName] === null)) {
httpParams = httpParams.set(propName, searchData[propName]);
}
}
return this.http.get(`/standinginstructions`, { params: httpParams });
}
deleteStandingInstrucions(id: any) {
const httpParams = new HttpParams().set('command', 'delete');
return this.http.delete(`/standinginstructions/${id}`, { params: httpParams });
}
}
@@ -0,0 +1,109 @@
<mat-card class="container">
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
<div fxFlexFill *ngIf="isFromClient">
<span fxFlex="40%">
<h3 class="mat-h3">Client Name</h3>
</span>
<span fxFlex="60%">
<h3 class="mat-h3">{{ clientName }}</h3>
</span>
</div>
<div fxFlexFill *ngIf="!isFromClient">
<mat-form-field fxFlex="30%">
<input matInput placeholder="ClientName" [formControl]="clientNameControl">
</mat-form-field>
<mat-form-field fxFlex="30%">
<input matInput placeholder="From Client Id" [formControl]="fromClientId">
</mat-form-field>
</div>
<mat-form-field fxFlex="30%">
<mat-label>Type</mat-label>
<mat-select [formControl]="transferType">
<mat-option *ngFor="let transferTypeData of transferTypeDatas" [value]="transferTypeData.id">
{{ transferTypeData.value }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="30%">
<input matInput placeholder="From Account Id" [formControl]="fromAccountId">
</mat-form-field>
<button mat-raised-button color="primary" (click)="filterStandingInstructions()" class="filter-button">
&nbsp;&nbsp;Filter
</button>
</div>
<table mat-table #instructionsTable [dataSource]="dataSource">
<ng-container matColumnDef="client">
<th mat-header-cell *matHeaderCellDef> Client </th>
<td mat-cell *matCellDef="let instruction">{{instruction.fromClient.displayName}}-{{instruction.fromClient.id}}
</td>
</ng-container>
<ng-container matColumnDef="fromAccount">
<th mat-header-cell *matHeaderCellDef> From Account </th>
<td mat-cell *matCellDef="let instruction">{{instruction.fromAccount.accountNo}}
({{instruction.fromAccountType.value}})</td>
</ng-container>
<ng-container matColumnDef="beneficiary">
<th mat-header-cell *matHeaderCellDef> Beneficiary </th>
<td mat-cell *matCellDef="let instruction">{{instruction.toClient.displayName}}</td>
</ng-container>
<ng-container matColumnDef="toAccount">
<th mat-header-cell *matHeaderCellDef> To Account </th>
<td mat-cell *matCellDef="let instruction">{{instruction.toAccount.accountNo}}
({{instruction.toAccountType.value}})</td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef> Amount </th>
<td mat-cell *matCellDef="let instruction">{{instruction.instructionType.value}}/{{instruction.amount}}</td>
</ng-container>
<ng-container matColumnDef="validity">
<th mat-header-cell *matHeaderCellDef> Validity </th>
<td mat-cell *matCellDef="let instruction">{{instruction.validFrom | date}} to {{instruction.validTill | date}}
</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let instruction">
<span *ngIf="instruction.status.value!=='Deleted'">
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Edit Standing Instruction"
*mifosxHasPermission="'UPDATE_STANDINGINSTRUCTION'"
[routerLink]="['../', instruction.id, 'edit']">
<i class="fa fa-edit"></i>
</button>
</span>
<span *ngIf="instruction.status.value!=='Deleted'">
<button class="account-action-button" mat-raised-button color="warn" matTooltip="Delete Standing Instruction"
*mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'" (click)="deleteStandingInstruction(instruction.id)">
<i class="fa fa-times"></i>
</button>
</span>
<button class="account-action-button" mat-raised-button color="primary" matTooltip="View Standing Instruction"
*mifosxHasPermission="'READ_STANDINGINSTRUCTION'"
[routerLink]="['../', instruction.id, 'view']">
<i class="fa fa-eye"></i>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSize]="10" [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
</mat-card>
@@ -0,0 +1,16 @@
.container {
.filter-button{
height: 2.5rem;
margin-top: 1rem;
}
}
table {
width: 100%;
.account-action-button{
min-width: 26px;
padding: 0 6px;
margin: 4px;
line-height: 25px;
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListStandingInstructionsComponent } from './list-standing-instructions.component';
describe('ListStandingInstructionsComponent', () => {
let component: ListStandingInstructionsComponent;
let fixture: ComponentFixture<ListStandingInstructionsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListStandingInstructionsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListStandingInstructionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,129 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatTable, MatPaginator, MatDialog } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
import { FormControl } from '@angular/forms';
/** Custom Services */
import { AccountTransfersService } from '../account-transfers.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Recurring Deposits Standing Instructions Tab
*/
@Component({
selector: 'mifosx-list-standing-instructions',
templateUrl: './list-standing-instructions.component.html',
styleUrls: ['./list-standing-instructions.component.scss']
})
export class ListStandingInstructionsComponent implements OnInit {
/** Recurring Deposits Data */
standingIntructionsTemplateData: any;
/** Instructions Data */
instructionsData: any[];
/** Name form control. */
transferType = new FormControl();
/** ExternalId form control. */
fromAccountId = new FormControl();
/** Name form control. */
clientNameControl = new FormControl();
/** ExternalId form control. */
fromClientId = new FormControl();
/** Client Name */
clientName: any;
/** Transfer Type Options Data */
transferTypeDatas: any;
/** Data source for instructions table. */
dataSource = new MatTableDataSource();
/** Columns to be displayed in instructions table. */
displayedColumns: string[] = ['client', 'fromAccount', 'beneficiary', 'toAccount', 'amount', 'validity', 'actions'];
/** Instruction Table Reference */
@ViewChild('instructionsTable') instructionTableRef: MatTable<Element>;
/** Paginator for centers table. */
@ViewChild(MatPaginator) paginator: MatPaginator;
accountType: any;
accountTypeId: string;
id: any;
isFromClient: Boolean;
/**
* Retrieves Recurring Deposits Account Data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private accountTransfersService: AccountTransfersService,
private dialog: MatDialog) {
this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => {
this.standingIntructionsTemplateData = data.standingIntructionsTemplate;
if (data.standingIntructionsTemplate.fromClient) {
this.clientName = this.standingIntructionsTemplateData.fromClient.displayName;
console.log('here');
this.getStandingInstructions();
}
this.setParams();
this.transferTypeDatas = this.standingIntructionsTemplateData.transferTypeOptions;
});
}
ngOnInit() {
}
setParams() {
this.accountType = this.route.snapshot.queryParams['accountType'];
switch (this.accountType) {
case 'fromloans':
this.accountTypeId = '1';
break;
case 'fromsavings':
this.accountTypeId = '2';
break;
default:
this.accountTypeId = '0';
}
this.isFromClient = this.route.parent.parent.snapshot.params['clientId'] ? true : false;
}
filterStandingInstructions() {
this.getStandingInstructions();
}
/**
* Retrieves standing instructions and initializes instructions table.
*/
getStandingInstructions() {
const searchData = {
clientId : this.standingIntructionsTemplateData.fromClient.id || this.fromClientId.value,
clientName: this.standingIntructionsTemplateData.fromClient.displayName || this.clientNameControl.value,
locale : 'en',
dateFormat : 'dd MMMM yyyy',
limit: 14,
offset: 0,
fromAccountType: this.accountTypeId,
fromAccountId: this.fromAccountId.value,
fromTransferType: this.transferType.value
};
this.accountTransfersService.getStandingInstructions(searchData).subscribe((response: any) => {
this.instructionsData = response.pageItems;
this.dataSource.data = this.instructionsData;
this.instructionTableRef.renderRows();
});
}
deleteStandingInstruction(instructionId: any) {
const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `standing instruction id: ${instructionId}` }
});
deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountTransfersService.deleteStandingInstrucions(instructionId)
.subscribe(() => {});
}
});
}
}
+1 -1
View File
@@ -242,7 +242,7 @@ const routes: Routes = [
{
path: 'standing-instructions',
loadChildren: '../account-transfers/account-transfers.module#AccountTransfersModule'
},
}
]
}
]
@@ -37,7 +37,8 @@
<button mat-raised-button>+ Deposit</button>
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
<mat-menu #More="matMenu">
<button mat-menu-item (click)="doAction('Create Standing Instructions')">Create Standing Instructions</button>
<button mat-menu-item (click)="doAction('Create Standing Instructions')" *mifosxHasPermission="'READ_STANDINGINSTRUCTION'">Create Standing Instructions</button>
<span *ngIf="clientViewData.status.value!='Transfer on hold'"><button mat-menu-item (click)="doAction('View Standing Instructions')" *mifosxHasPermission="'CREATE_STANDINGINSTRUCTION'">View Standing Instructions</button></span>
<button mat-menu-item [routerLink]="['sharesaccounts', 'create-shares-account']">New Share Account</button>
<button mat-menu-item [routerLink]="['recurringdeposits', 'create-recurring-deposits-account']">New Recurring Deposit Account</button>
<button mat-menu-item [routerLink]="['fixed-deposits-accounts', 'create-fixed-deposit-account']">New Fixed Deposits Account</button>
@@ -96,8 +96,12 @@ export class ClientsViewComponent implements OnInit {
this.deleteProfileImage();
break;
case 'Create Standing Instructions':
const queryParams: any = { officeId: this.clientViewData.officeId, accountType: 'fromsavings' };
this.router.navigate(['standing-instructions/create-standing-instructions'], { relativeTo: this.route, queryParams: queryParams });
const createStandingInstructionsQueryParams: any = { officeId: this.clientViewData.officeId, accountType: 'fromsavings' };
this.router.navigate(['standing-instructions/create-standing-instructions'], { relativeTo: this.route, queryParams: createStandingInstructionsQueryParams });
break;
case 'View Standing Instructions':
const viewStandingInstructionsQueryParams: any = { officeId: this.clientViewData.officeId, accountType: 'fromsavings' };
this.router.navigate(['standing-instructions/list-standing-instructions'], { relativeTo: this.route, queryParams: viewStandingInstructionsQueryParams });
break;
}
}
@@ -49,7 +49,7 @@
</span>
<span *ngIf="instruction.status.value!=='Deleted'">
<button class="account-action-button" mat-raised-button color="warn" matTooltip="Delete Standing Instruction"
*mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'">
*mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'" (click)="deleteStandingInstruction(instruction.id)">
<i class="fa fa-times"></i>
</button>
</span>
@@ -1,10 +1,14 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatTable } from '@angular/material';
import { MatTableDataSource, MatTable, MatDialog } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service';
import { AccountTransfersService } from 'app/account-transfers/account-transfers.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Fixed Deposits Standing Instructions Tab
@@ -41,7 +45,9 @@ export class StandingInstructionsTabComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private fixedDepositsService: FixedDepositsService) {
private fixedDepositsService: FixedDepositsService,
private dialog: MatDialog,
private accountTransfersService: AccountTransfersService) {
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
this.fixedDepositsData = data.fixedDepositsAccountData;
});
@@ -67,4 +73,16 @@ export class StandingInstructionsTabComponent implements OnInit {
});
}
deleteStandingInstruction(instructionId: any) {
const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `standing instruction id: ${instructionId}` }
});
deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountTransfersService.deleteStandingInstrucions(instructionId)
.subscribe(() => { });
}
});
}
}
@@ -54,7 +54,7 @@
</span>
<span *ngIf="instruction.status.value!=='Deleted'">
<button class="account-action-button" mat-raised-button color="warn"
matTooltip="Delete Standing Instruction" *mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'">
matTooltip="Delete Standing Instruction" *mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'" (click)="deleteStandingInstruction(instruction.id)">
<i class="fa fa-times"></i>
</button>
</span>
@@ -1,10 +1,14 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatTable } from '@angular/material';
import { MatTableDataSource, MatTable, MatDialog } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service';
import { AccountTransfersService } from 'app/account-transfers/account-transfers.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Recurring Deposits Standing Instructions Tab
@@ -33,7 +37,9 @@ export class StandingInstructionsTabComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private recurringDepositsService: RecurringDepositsService) {
private recurringDepositsService: RecurringDepositsService,
private dialog: MatDialog,
private accountTransfersService: AccountTransfersService) {
this.route.parent.data.subscribe((data: { recurringDepositsAccountData: any }) => {
this.recurringDepositsData = data.recurringDepositsAccountData;
});
@@ -59,4 +65,16 @@ export class StandingInstructionsTabComponent implements OnInit {
});
}
deleteStandingInstruction(instructionId: any) {
const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `standing instruction id: ${instructionId}` }
});
deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountTransfersService.deleteStandingInstrucions(instructionId)
.subscribe(() => { });
}
});
}
}
@@ -56,7 +56,7 @@
</span>
<span *ngIf="instruction.status.value!=='Deleted'">
<button class="account-action-button" mat-raised-button color="warn"
matTooltip="Delete Standing Instruction" *mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'">
matTooltip="Delete Standing Instruction" *mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'" (click)="deleteStandingInstruction(instruction.id)">
<i class="fa fa-times"></i>
</button>
</span>
@@ -1,10 +1,14 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatTable } from '@angular/material';
import { MatTableDataSource, MatTable, MatDialog } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { LoansService } from 'app/loans/loans.service';
import { AccountTransfersService } from 'app/account-transfers/account-transfers.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Loans Standing Instructions Tab
@@ -33,7 +37,9 @@ export class StandingInstructionsTabComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private loansService: LoansService) {
private loansService: LoansService,
private dialog: MatDialog,
private accountTransfersService: AccountTransfersService) {
this.route.parent.data.subscribe((data: { loanDetailsData: any }) => {
this.loanDetailsData = data.loanDetailsData;
});
@@ -59,4 +65,16 @@ export class StandingInstructionsTabComponent implements OnInit {
});
}
deleteStandingInstruction(instructionId: any) {
const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `standing instruction id: ${instructionId}` }
});
deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountTransfersService.deleteStandingInstrucions(instructionId)
.subscribe(() => { });
}
});
}
}
@@ -49,7 +49,7 @@
</span>
<span *ngIf="instruction.status.value!=='Deleted'">
<button class="account-action-button" mat-raised-button color="warn" matTooltip="Delete Standing Instruction"
*mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'">
*mifosxHasPermission="'DELETE_STANDINGINSTRUCTION'" (click)="deleteStandingInstruction(instruction.id)">
<i class="fa fa-times"></i>
</button>
</span>
@@ -1,10 +1,14 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatTable } from '@angular/material';
import { MatTableDataSource, MatTable, MatDialog } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
import { AccountTransfersService } from 'app/account-transfers/account-transfers.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Savings Standing Instructions Tab
@@ -41,7 +45,9 @@ export class StandingInstructionsTabComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute,
private savingsService: SavingsService) {
private savingsService: SavingsService,
private dialog: MatDialog,
private accountTransfersService: AccountTransfersService) {
this.route.parent.data.subscribe((data: { savingsAccountData: any }) => {
this.savingsData = data.savingsAccountData;
});
@@ -67,4 +73,16 @@ export class StandingInstructionsTabComponent implements OnInit {
});
}
deleteStandingInstruction(instructionId: any) {
const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `standing instruction id: ${instructionId}` }
});
deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.accountTransfersService.deleteStandingInstrucions(instructionId)
.subscribe(() => { });
}
});
}
}