From 86af298366e5c3980c03e1f8948e84489b5da3eb Mon Sep 17 00:00:00 2001
From: Muskan Khedia <36980003+muskankhedia@users.noreply.github.com>
Date: Sat, 4 Jul 2020 10:01:26 +0530
Subject: [PATCH] feat: add recurring deposit account tab (standing
instruction) (#984)
Fixes: #982
---
...rring-deposits-account-view.component.html | 6 ++
.../standing-instructions-tab.component.html | 74 +++++++++++++++++++
.../standing-instructions-tab.component.scss | 19 +++++
...tanding-instructions-tab.component.spec.ts | 25 +++++++
.../standing-instructions-tab.component.ts | 62 ++++++++++++++++
.../recurring-deposits-routing.module.ts | 11 ++-
.../recurring-deposits.module.ts | 4 +-
.../recurring-deposits.service.ts | 29 ++++++--
8 files changed, 220 insertions(+), 10 deletions(-)
create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html
create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.scss
create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.spec.ts
create mode 100644 src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.html
index 27fad52bd..ce1f2e6e5 100644
--- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.html
+++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.html
@@ -207,6 +207,12 @@
Transactions
+
+
+ Standing Instructions
+
+
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html
new file mode 100644
index 000000000..84c0a7698
--- /dev/null
+++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html
@@ -0,0 +1,74 @@
+
+
+
+
All Standing Instructions
+
+
+
+
+
+
+
+ | Client |
+ {{instruction.fromClient.displayName}}-{{instruction.fromClient.id}}
+ |
+
+
+
+ From Account |
+ {{instruction.fromAccount.accountNo}}
+ ({{instruction.fromAccountType.value}}) |
+
+
+
+ Beneficiary |
+ {{instruction.toClient.displayName}} |
+
+
+
+ To Account |
+ {{instruction.toAccount.accountNo}}
+ ({{instruction.toAccountType.value}}) |
+
+
+
+ Amount |
+ {{instruction.instructionType.value}}/{{instruction.amount}} |
+
+
+
+ Validity |
+ {{instruction.validFrom | date}} to {{instruction.validTill | date}}
+ |
+
+
+
+ Actions |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.scss b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.scss
new file mode 100644
index 000000000..aaafd7b18
--- /dev/null
+++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.scss
@@ -0,0 +1,19 @@
+.tab-container {
+ padding: 1%;
+ margin: 1%;
+ h3 {
+ margin:1% auto;
+ }
+ .action-button {
+ margin-left: auto;
+ }
+ table {
+ width: 100%;
+ .account-action-button{
+ min-width: 26px;
+ padding: 0 6px;
+ margin: 4px;
+ line-height: 25px;
+ }
+ }
+}
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.spec.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.spec.ts
new file mode 100644
index 000000000..f3997e094
--- /dev/null
+++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { StandingInstructionsTabComponent } from './standing-instructions-tab.component';
+
+describe('StandingInstructionsTabComponent', () => {
+ let component: StandingInstructionsTabComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ StandingInstructionsTabComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(StandingInstructionsTabComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts
new file mode 100644
index 000000000..c7393565d
--- /dev/null
+++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts
@@ -0,0 +1,62 @@
+/** Angular Imports */
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { MatTableDataSource, MatTable } from '@angular/material';
+import { ActivatedRoute } from '@angular/router';
+
+/** Custom Services */
+import { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service';
+
+/**
+ * Recurring Deposits Standing Instructions Tab
+ */
+@Component({
+ selector: 'mifosx-standing-instructions-tab',
+ templateUrl: './standing-instructions-tab.component.html',
+ styleUrls: ['./standing-instructions-tab.component.scss']
+})
+export class StandingInstructionsTabComponent implements OnInit {
+
+ /** Recurring Deposits Data */
+ recurringDepositsData: any;
+ /** Instructions Data */
+ instructionsData: 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;
+
+ /**
+ * Retrieves Recurring Deposits Account Data from `resolve`.
+ * @param {ActivatedRoute} route Activated Route.
+ */
+ constructor(private route: ActivatedRoute,
+ private recurringDepositsService: RecurringDepositsService) {
+ this.route.parent.data.subscribe((data: { recurringDepositsAccountData: any }) => {
+ this.recurringDepositsData = data.recurringDepositsAccountData;
+ });
+ }
+
+ ngOnInit() {
+ this.getStandingInstructions();
+ }
+
+ /**
+ * Retrieves standing instructions and initializes instructions table.
+ */
+ getStandingInstructions() {
+ const clientId = this.recurringDepositsData.clientId;
+ const clientName = this.recurringDepositsData.clientName;
+ const accountId = this.recurringDepositsData.id;
+ const locale = 'en';
+ const dateFormat = 'dd MMMM yyyy';
+ this.recurringDepositsService.getStandingInstructions(clientId, clientName, accountId, locale, dateFormat).subscribe((response: any) => {
+ this.instructionsData = response.pageItems;
+ this.dataSource.data = this.instructionsData;
+ this.instructionTableRef.renderRows();
+ });
+ }
+
+}
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-routing.module.ts b/src/app/deposits/recurring-deposits/recurring-deposits-routing.module.ts
index f88966540..5da891e44 100644
--- a/src/app/deposits/recurring-deposits/recurring-deposits-routing.module.ts
+++ b/src/app/deposits/recurring-deposits/recurring-deposits-routing.module.ts
@@ -13,6 +13,7 @@ import { TransactionsTabComponent } from './recurring-deposits-account-view/tran
/** Custom Resolvers */
import { RecurringDepositsAccountViewResolver } from './common-resolvers/recurring-deposits-account-view.resolver';
import { RecurringDepositsAccountDataResolver } from './common-resolvers/recurring-deposits-account-data.resolver';
+import { StandingInstructionsTabComponent } from './recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component';
const routes: Routes = [
{
@@ -42,7 +43,15 @@ const routes: Routes = [
resolve: {
recurringDepositsAccountData: RecurringDepositsAccountDataResolver
}
- }
+ },
+ {
+ path: 'standing-instructions',
+ component: StandingInstructionsTabComponent,
+ data: { title: extract('Recurring Deposit Account Standing Instructions'), breadcrumb: 'Standing Instructions', routeParamBreadcrumb: false },
+ resolve: {
+ recurringDepositsAccountData: RecurringDepositsAccountDataResolver
+ }
+ },
]
}
]
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits.module.ts b/src/app/deposits/recurring-deposits/recurring-deposits.module.ts
index 7040346dd..912342b27 100644
--- a/src/app/deposits/recurring-deposits/recurring-deposits.module.ts
+++ b/src/app/deposits/recurring-deposits/recurring-deposits.module.ts
@@ -12,6 +12,7 @@ import { DirectivesModule } from '../../directives/directives.module';
import { RecurringDepositsAccountViewComponent } from './recurring-deposits-account-view/recurring-deposits-account-view.component';
import { InterestRateChartTabComponent } from './recurring-deposits-account-view/interest-rate-chart-tab/interest-rate-chart-tab.component';
import { TransactionsTabComponent } from './recurring-deposits-account-view/transactions-tab/transactions-tab.component';
+import { StandingInstructionsTabComponent } from './recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component';
/**
* RecurringDeposits Module
@@ -28,7 +29,8 @@ import { TransactionsTabComponent } from './recurring-deposits-account-view/tran
declarations: [
RecurringDepositsAccountViewComponent,
InterestRateChartTabComponent,
- TransactionsTabComponent
+ TransactionsTabComponent,
+ StandingInstructionsTabComponent
],
providers: [DatePipe]
})
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits.service.ts b/src/app/deposits/recurring-deposits/recurring-deposits.service.ts
index 8abe9e8d5..1349378d2 100644
--- a/src/app/deposits/recurring-deposits/recurring-deposits.service.ts
+++ b/src/app/deposits/recurring-deposits/recurring-deposits.service.ts
@@ -15,18 +15,31 @@ export class RecurringDepositsService {
constructor(private http: HttpClient) {}
- /**
- * @param {string} recurringDepositAccountId is recurringDeposit account's Id.
- * @returns {Observable}
- */
- // getRecurringDepositsTransactionTemplateResource(recurringDepositAccountId: string): Observable {
- // return this.http.get(`/recurringDepositsaccounts/${recurringDepositAccountId}/transactions/template`);
- // }
-
getRecurringDepositsAccountData(recurringDepositAccountId: any) {
const httpParams = new HttpParams()
.set('associations', 'all');
return this.http.get(`/recurringdepositaccounts/${recurringDepositAccountId}`, { params: httpParams });
}
+ /**
+ * @param clientId Client Id
+ * @param clientName Client Name
+ * @param fromAccountId Account Id
+ * @param locale Locale
+ * @param dateFormat Date Format
+ * @returns {Observable} Standing Instructions
+ */
+ getStandingInstructions(
+ clientId: string, clientName: string, fromAccountId: string,
+ locale: string, dateFormat: string): Observable {
+ const httpParams = new HttpParams()
+ .set('clientId', clientId)
+ .set('clientName', clientName)
+ .set('fromAccountId', fromAccountId)
+ .set('fromAccountType', '2')
+ .set('locale', locale)
+ .set('dateFormat', dateFormat);
+ return this.http.get(`/standinginstructions`, { params: httpParams });
+ }
+
}