From 6ad1335d93f6e444b6048b35a5925197b935d6e4 Mon Sep 17 00:00:00 2001 From: Muskan Khedia <36980003+muskankhedia@users.noreply.github.com> Date: Sun, 26 Jul 2020 15:25:04 +0530 Subject: [PATCH] feat: add view transactions history (#1157) Fixes: #1156 --- .../account-transfers-routing.module.ts | 19 ++++- .../account-transfers.module.ts | 4 +- .../account-transfers.service.ts | 9 +++ .../list-transactions.resolver.ts | 31 ++++++++ .../edit-standing-instructions.component.ts | 6 +- .../list-standing-instructions.component.html | 2 + .../list-standing-instructions.component.scss | 4 + .../list-standing-instructions.component.ts | 20 +++-- .../list-transactions.component.html | 73 +++++++++++++++++++ .../list-transactions.component.scss | 17 +++++ .../list-transactions.component.spec.ts | 25 +++++++ .../list-transactions.component.ts | 46 ++++++++++++ .../view-standing-instructions.component.html | 2 +- .../loan-account-actions.component.html | 1 + 14 files changed, 245 insertions(+), 14 deletions(-) create mode 100644 src/app/account-transfers/common-resolvers/list-transactions.resolver.ts create mode 100644 src/app/account-transfers/list-transactions/list-transactions.component.html create mode 100644 src/app/account-transfers/list-transactions/list-transactions.component.scss create mode 100644 src/app/account-transfers/list-transactions/list-transactions.component.spec.ts create mode 100644 src/app/account-transfers/list-transactions/list-transactions.component.ts diff --git a/src/app/account-transfers/account-transfers-routing.module.ts b/src/app/account-transfers/account-transfers-routing.module.ts index 703475e7c..f01f47747 100644 --- a/src/app/account-transfers/account-transfers-routing.module.ts +++ b/src/app/account-transfers/account-transfers-routing.module.ts @@ -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 ] }) diff --git a/src/app/account-transfers/account-transfers.module.ts b/src/app/account-transfers/account-transfers.module.ts index 389a60b4c..5e0295c92 100644 --- a/src/app/account-transfers/account-transfers.module.ts +++ b/src/app/account-transfers/account-transfers.module.ts @@ -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] }) diff --git a/src/app/account-transfers/account-transfers.service.ts b/src/app/account-transfers/account-transfers.service.ts index 0ecc730ca..6ff5446c9 100644 --- a/src/app/account-transfers/account-transfers.service.ts +++ b/src/app/account-transfers/account-transfers.service.ts @@ -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 }); + } } diff --git a/src/app/account-transfers/common-resolvers/list-transactions.resolver.ts b/src/app/account-transfers/common-resolvers/list-transactions.resolver.ts new file mode 100644 index 000000000..c8e61a71b --- /dev/null +++ b/src/app/account-transfers/common-resolvers/list-transactions.resolver.ts @@ -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 { + + /** + * @param {accountTransfersService} AccountTransfersService Account Transfers service. + */ + constructor(private accountTransfersService: AccountTransfersService) { } + + /** + * Returns the Standing Instructions Data. + * @param {ActivatedRouteSnapshot} route Route Snapshot + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const id = route.parent.paramMap.get('standingInstructionsId'); + return this.accountTransfersService.getStandingInstructionsTransactions(id); + } +} diff --git a/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts b/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts index 8d90fe15d..b432bef96 100644 --- a/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts +++ b/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts @@ -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) }); } diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html index 127e0f3c4..6b7014384 100644 --- a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html @@ -20,6 +20,8 @@ + + Type diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss index 518d702d3..dad0a93cf 100644 --- a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss @@ -14,3 +14,7 @@ table { line-height: 25px; } } + +.mat-divider { + border-top-color: #ffffff; +} diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts index d85d38ba2..b0e4f0aff 100644 --- a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts @@ -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; /** 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}` } diff --git a/src/app/account-transfers/list-transactions/list-transactions.component.html b/src/app/account-transfers/list-transactions/list-transactions.component.html new file mode 100644 index 000000000..65c97289c --- /dev/null +++ b/src/app/account-transfers/list-transactions/list-transactions.component.html @@ -0,0 +1,73 @@ +
+ + + + + +
+ +
+ From Account +
+ +
+ {{ listTransactionData.fromAccount.accountNo }}({{ listTransactionData.fromAccountType.value }}) +
+ +
+ To Account +
+ +
+ {{ listTransactionData.toAccount.accountNo }}({{ listTransactionData.toAccountType.value }}) +
+ +
+ Destination +
+ +
+ {{ listTransactionData.toClient.displayName }} +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Transaction Date {{ transaction.transferDate | date }} Amount {{ transaction.transferAmount }} Notes {{ transaction.transferDescription }} Reversed {{ transaction.reversed ? 'Yes' : 'No' }}
+ + + +
diff --git a/src/app/account-transfers/list-transactions/list-transactions.component.scss b/src/app/account-transfers/list-transactions/list-transactions.component.scss new file mode 100644 index 000000000..2a3da1ac0 --- /dev/null +++ b/src/app/account-transfers/list-transactions/list-transactions.component.scss @@ -0,0 +1,17 @@ +.content { + div { + line-height: 3rem; + + &.header { + font-weight: 500; + } + } +} + +table { + width: 100%; + + .select-row:hover { + cursor: pointer; + } +} diff --git a/src/app/account-transfers/list-transactions/list-transactions.component.spec.ts b/src/app/account-transfers/list-transactions/list-transactions.component.spec.ts new file mode 100644 index 000000000..9222f1315 --- /dev/null +++ b/src/app/account-transfers/list-transactions/list-transactions.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListTransactionsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListTransactionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/account-transfers/list-transactions/list-transactions.component.ts b/src/app/account-transfers/list-transactions/list-transactions.component.ts new file mode 100644 index 000000000..9d0219ae9 --- /dev/null +++ b/src/app/account-transfers/list-transactions/list-transactions.component.ts @@ -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; + }); + } + +} diff --git a/src/app/account-transfers/view-standing-instructions/view-standing-instructions.component.html b/src/app/account-transfers/view-standing-instructions/view-standing-instructions.component.html index 418273221..cce7dc4e8 100644 --- a/src/app/account-transfers/view-standing-instructions/view-standing-instructions.component.html +++ b/src/app/account-transfers/view-standing-instructions/view-standing-instructions.component.html @@ -3,7 +3,7 @@    Edit - diff --git a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html index 0ce3645a6..c5c9fa222 100644 --- a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html +++ b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html @@ -21,5 +21,6 @@ +