feat: add view transactions history (#1157)

Fixes: #1156
This commit is contained in:
Muskan Khedia
2020-07-26 15:25:04 +05:30
committed by GitHub
parent 67a836e3d6
commit 6ad1335d93
14 changed files with 245 additions and 14 deletions
@@ -9,14 +9,16 @@ import { extract } from '../core/i18n/i18n.service';
import { ViewStandingInstructionsComponent } from './view-standing-instructions/view-standing-instructions.component';
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';
import { ListTransactionsComponent } from './list-transactions/list-transactions.component';
/** Custom Resolvers */
import { ViewStandingInstructionsResolver } from './common-resolvers/view-standing-instructions.resolver';
import { StandingInstructionsDataAndTemplateResolver } from './common-resolvers/standing-instructions-data-and-template.resolver';
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';
import { ListTransactionsResolver } from './common-resolvers/list-transactions.resolver';
/** Loans Route. */
const routes: Routes = [
@@ -66,7 +68,15 @@ const routes: Routes = [
resolve: {
standingInstructionsDataAndTemplate: StandingInstructionsDataAndTemplateResolver,
},
}
},
{
path: 'list-account-transactions',
data: { title: extract('List Account Transactions'), breadcrumb: 'List Account Transactions', routeParamBreadcrumb: 'List Account Transactions' },
component: ListTransactionsComponent,
resolve: {
listTransactionData: ListTransactionsResolver
}
},
]
},
]
@@ -80,7 +90,8 @@ const routes: Routes = [
ViewStandingInstructionsResolver,
StandingInstructionsDataAndTemplateResolver,
StandingInstructionsTemplateResolver,
MakeAccountTransferTemplateResolver
MakeAccountTransferTemplateResolver,
ListTransactionsResolver
]
})
@@ -14,6 +14,7 @@ import { EditStandingInstructionsComponent } from './edit-standing-instructions/
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';
import { ListTransactionsComponent } from './list-transactions/list-transactions.component';
/**
* Account Transfers Module
@@ -27,7 +28,8 @@ import { ListStandingInstructionsComponent } from './list-standing-instructions/
EditStandingInstructionsComponent,
CreateStandingInstructionsComponent,
MakeAccountTransersComponent,
ListStandingInstructionsComponent
ListStandingInstructionsComponent,
ListTransactionsComponent
],
providers: [DatePipe]
})
@@ -94,4 +94,13 @@ export class AccountTransfersService {
return this.http.delete(`/standinginstructions/${id}`, { params: httpParams });
}
getStandingInstructionsTransactions(standingInstructionsId: any) {
const httpParams = new HttpParams().set('associations', 'transactions')
.set('dateFormat', 'dd MMMM yyyy')
.set('limit', '14')
.set('locale', 'en')
.set('offset', '0');
return this.http.get(`/standinginstructions/${standingInstructionsId}`, { params: httpParams });
}
}
@@ -0,0 +1,31 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
/** Custom Services */
import { AccountTransfersService } from '../account-transfers.service';
/**
* View Standing Instructions resolver.
*/
@Injectable()
export class ListTransactionsResolver implements Resolve<Object> {
/**
* @param {accountTransfersService} AccountTransfersService Account Transfers service.
*/
constructor(private accountTransfersService: AccountTransfersService) { }
/**
* Returns the Standing Instructions Data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const id = route.parent.paramMap.get('standingInstructionsId');
return this.accountTransfersService.getStandingInstructionsTransactions(id);
}
}
@@ -60,7 +60,9 @@ export class EditStandingInstructionsComponent implements OnInit {
this.createEditStandingInstructionsForm();
const presentDate = new Date();
const n = presentDate.getFullYear();
this.standingInstructionsData.recurrenceOnMonthDay.push(n);
if (this.standingInstructionsData.recurrenceOnMonthDay) {
this.standingInstructionsData.recurrenceOnMonthDay.push(n);
}
this.editStandingInstructionsForm.patchValue({
'name': this.standingInstructionsData.name,
'applicant': this.standingInstructionsData.fromClient.displayName,
@@ -81,7 +83,7 @@ export class EditStandingInstructionsComponent implements OnInit {
'recurrenceType': this.standingInstructionsData.recurrenceType.id,
'recurrenceInterval': this.standingInstructionsData.recurrenceInterval,
'recurrenceFrequency': this.standingInstructionsData.recurrenceFrequency.id,
'recurrenceOnMonthDay': new Date(this.standingInstructionsData.recurrenceOnMonthDay)
'recurrenceOnMonthDay': this.standingInstructionsData.recurrenceOnMonthDay && new Date(this.standingInstructionsData.recurrenceOnMonthDay)
});
}
@@ -20,6 +20,8 @@
</mat-form-field>
</div>
<mat-divider [inset]="true"></mat-divider>
<mat-form-field fxFlex="30%">
<mat-label>Type</mat-label>
<mat-select [formControl]="transferType">
@@ -14,3 +14,7 @@ table {
line-height: 25px;
}
}
.mat-divider {
border-top-color: #ffffff;
}
@@ -11,7 +11,7 @@ import { AccountTransfersService } from '../account-transfers.service';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Recurring Deposits Standing Instructions Tab
* Lists all the standing intructions of particular ID
*/
@Component({
selector: 'mifosx-list-standing-instructions',
@@ -36,6 +36,14 @@ export class ListStandingInstructionsComponent implements OnInit {
clientName: any;
/** Transfer Type Options Data */
transferTypeDatas: any;
/** Account Type */
accountType: any;
/** Account Type ID */
accountTypeId: string;
/** Id */
id: any;
/** Is from Client? */
isFromClient: Boolean;
/** Data source for instructions table. */
dataSource = new MatTableDataSource();
/** Columns to be displayed in instructions table. */
@@ -45,14 +53,13 @@ export class ListStandingInstructionsComponent implements OnInit {
@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`.
* Retrieves Standing Instructions Data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {MatDialog} route Mat Dialog
* @param {AccountTransfersService} accountTransfersService Account Transfers Service
*/
constructor(private route: ActivatedRoute,
private accountTransfersService: AccountTransfersService,
@@ -113,6 +120,7 @@ export class ListStandingInstructionsComponent implements OnInit {
});
}
/** Deletes selected Standing Instruction */
deleteStandingInstruction(instructionId: any) {
const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `standing instruction id: ${instructionId}` }
@@ -0,0 +1,73 @@
<div class="container m-b-20">
<mat-card class="mat-elevation-z8">
<mat-card-content>
<div fxLayout="row wrap" class="content">
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
From Account
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ listTransactionData.fromAccount.accountNo }}({{ listTransactionData.fromAccountType.value }})
</div>
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
To Account
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ listTransactionData.toAccount.accountNo }}({{ listTransactionData.toAccountType.value }})
</div>
<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Destination
</div>
<div fxFlex="25%" fxFlex.lt-md="50%">
{{ listTransactionData.toClient.displayName }}
</div>
</div>
</mat-card-content>
</mat-card>
</div>
<div class="mat-elevation-z8 container">
<table mat-table [dataSource]="dataSource">
<ng-container matColumnDef="transactionDate">
<th mat-header-cell *matHeaderCellDef> Transaction Date </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.transferDate | date }} </td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef> Amount </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.transferAmount }} </td>
</ng-container>
<ng-container matColumnDef="notes">
<th mat-header-cell *matHeaderCellDef> Notes </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.transferDescription }} </td>
</ng-container>
<ng-container matColumnDef="reversed">
<th mat-header-cell *matHeaderCellDef> Reversed </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.reversed ? 'Yes' : 'No' }} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;">
</tr>
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
</div>
@@ -0,0 +1,17 @@
.content {
div {
line-height: 3rem;
&.header {
font-weight: 500;
}
}
}
table {
width: 100%;
.select-row:hover {
cursor: pointer;
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListTransactionsComponent } from './list-transactions.component';
describe('ListTransactionsComponent', () => {
let component: ListTransactionsComponent;
let fixture: ComponentFixture<ListTransactionsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListTransactionsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListTransactionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,46 @@
/** 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-transactions',
templateUrl: './list-transactions.component.html',
styleUrls: ['./list-transactions.component.scss']
})
export class ListTransactionsComponent {
/** List Transactions Data */
listTransactionData: any;
/** Data source for instructions table. */
dataSource = new MatTableDataSource();
/** Columns to be displayed in instructions table. */
displayedColumns: string[] = ['transactionDate', 'amount', 'notes', 'reversed'];
/** Paginator for centers table. */
@ViewChild(MatPaginator) paginator: MatPaginator;
/**
* Retrieves Recurring Deposits Account Data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: { listTransactionData: any }) => {
this.listTransactionData = data.listTransactionData;
this.dataSource = new MatTableDataSource(this.listTransactionData.transactions.pageItems);
this.dataSource.paginator = this.paginator;
});
}
}
@@ -3,7 +3,7 @@
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;
Edit
</button>
<button mat-raised-button color="primary">
<button mat-raised-button color="primary" [routerLink]="['../', 'list-account-transactions']">
View Transactions History
</button>
</div>
@@ -21,5 +21,6 @@
<mifosx-undo-disbursal *ngIf="actions.undo_disbursal"></mifosx-undo-disbursal>
<mifosx-loan-screen-reports [dataObject]="actionButtonData" *ngIf="actions.loan_screen_reports"></mifosx-loan-screen-reports>
<mifosx-approve-loan *ngIf="actions.approve" ></mifosx-approve-loan>
<mifosx-add-loan-charge *ngIf="actions.add_loan_charge"></mifosx-add-loan-charge>
</mat-card>
</div>