diff --git a/src/app/loans/loans-routing.module.ts b/src/app/loans/loans-routing.module.ts index 1fca68d3b..fd8652d8d 100644 --- a/src/app/loans/loans-routing.module.ts +++ b/src/app/loans/loans-routing.module.ts @@ -23,6 +23,7 @@ import { LoanTrancheDetailsComponent } from './loans-view/loan-tranche-details/l import { LoanCollateralTabComponent } from './loans-view/loan-collateral-tab/loan-collateral-tab.component'; import { CreateLoansAccountComponent } from './create-loans-account/create-loans-account.component'; import { LoanDocumentsTabComponent } from './loans-view/loan-documents-tab/loan-documents-tab.component'; +import { StandingInstructionsTabComponent } from 'app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component'; /** Custom Resolvers */ import { LoanChargeTemplateResolver } from './common-resolvers/loan-charge-template.resolver'; @@ -157,6 +158,14 @@ const routes: Routes = [ loanNotes: LoanNotesResolver }, }, + { + path: 'standing-instruction', + component: StandingInstructionsTabComponent, + data: { title: extract('Standing Instructions'), breadcrumb: 'Standing Instructions', routeParamBreadcrumb: false }, + resolve: { + loanDetailsData: LoanDetailsGeneralResolver + }, + }, { path: 'datatables', children: [{ diff --git a/src/app/loans/loans-view/loans-view.component.html b/src/app/loans/loans-view/loans-view.component.html index 82815ad37..4897eae77 100644 --- a/src/app/loans/loans-view/loans-view.component.html +++ b/src/app/loans/loans-view/loans-view.component.html @@ -103,6 +103,12 @@ Notes + + + Standing Instruction + + diff --git a/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html new file mode 100644 index 000000000..a3d1d73b4 --- /dev/null +++ b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html @@ -0,0 +1,77 @@ +
+ +
+

All Standing Instructions

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Client {{instruction.fromClient.displayName}}-{{instruction.fromClient.id}} + From Account {{instruction.fromAccount.accountNo}} + ({{instruction.fromAccountType.value}}) Beneficiary + {{instruction.toClient.displayName}} + Own Account + 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/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.scss b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.scss new file mode 100644 index 000000000..aaafd7b18 --- /dev/null +++ b/src/app/loans/loans-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/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.spec.ts b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.spec.ts new file mode 100644 index 000000000..f3997e094 --- /dev/null +++ b/src/app/loans/loans-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/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.ts new file mode 100644 index 000000000..ef723af43 --- /dev/null +++ b/src/app/loans/loans-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 { LoansService } from 'app/loans/loans.service'; + +/** + * Loans 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 { + + /** Loans Data */ + loanDetailsData: 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 Loans Account Data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute, + private loansService: LoansService) { + this.route.parent.data.subscribe((data: { loanDetailsData: any }) => { + this.loanDetailsData = data.loanDetailsData; + }); + } + + ngOnInit() { + this.getStandingInstructions(); + } + + /** + * Retrieves standing instructions and initializes instructions table. + */ + getStandingInstructions() { + const clientId = this.loanDetailsData.clientId; + const clientName = this.loanDetailsData.clientName; + const accountId = this.loanDetailsData.id; + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + this.loansService.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/loans/loans.module.ts b/src/app/loans/loans.module.ts index f431a8f3f..ac46470f9 100644 --- a/src/app/loans/loans.module.ts +++ b/src/app/loans/loans.module.ts @@ -57,6 +57,7 @@ import { LoansAccountViewGuarantorDetailsDialogComponent } from './custom-dialog import { LoansAccountAddCollateralDialogComponent } from './custom-dialog/loans-account-add-collateral-dialog/loans-account-add-collateral-dialog.component'; import { LoansConfirmationDialogBoxComponent } from './custom-dialog/loans-confirmation-dialog-box/loans-confirmation-dialog-box.component'; import { LoanAccountLoadDocumentsDialogComponent } from './custom-dialog/loan-account-load-documents-dialog/loan-account-load-documents-dialog.component'; +import { StandingInstructionsTabComponent } from './loans-view/standing-instructions-tab/standing-instructions-tab.component'; /** * Loans Module @@ -112,6 +113,7 @@ import { LoanAccountLoadDocumentsDialogComponent } from './custom-dialog/loan-ac UndoDisbursalComponent, LoanDocumentsTabComponent, LoanAccountLoadDocumentsDialogComponent, + StandingInstructionsTabComponent, ], entryComponents: [ LoansAccountAddCollateralDialogComponent, diff --git a/src/app/loans/loans.service.ts b/src/app/loans/loans.service.ts index e30719aa3..9f503e3a7 100644 --- a/src/app/loans/loans.service.ts +++ b/src/app/loans/loans.service.ts @@ -297,4 +297,27 @@ export class LoansService { return this.http.post(`/loans/${loanId}/documents`, data); } + /** + * @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', '1') + .set('locale', locale) + .set('dateFormat', dateFormat) + .set('limit', '14') + .set('offset', '0'); + return this.http.get(`/standinginstructions`, { params: httpParams }); + } + }