diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.html b/src/app/clients/clients-view/general-tab/general-tab.component.html index 042547e4a..18a3d078d 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.html +++ b/src/app/clients/clients-view/general-tab/general-tab.component.html @@ -54,10 +54,10 @@ Actions - - diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.ts b/src/app/clients/clients-view/general-tab/general-tab.component.ts index f5a9f76c6..8ac9c1efd 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.ts +++ b/src/app/clients/clients-view/general-tab/general-tab.component.ts @@ -3,14 +3,18 @@ import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { DatePipe } from '@angular/common'; +/** Custom Services. */ +import { ClientsService } from 'app/clients/clients.service'; - +/** + * General Tab component. + */ @Component({ selector: 'mifosx-general-tab', templateUrl: './general-tab.component.html', styleUrls: ['./general-tab.component.scss'] }) -export class GeneralTabComponent implements OnInit { +export class GeneralTabComponent { openLoansColumns: string[] = ['Account No', 'Loan Account', 'Original Loan', 'Loan Balance', 'Amount Paid', 'Type', 'Actions']; closedLoansColumns: string[] = ['Account No', 'Loan Account', 'Original Loan', 'Loan Balance', 'Amount Paid', 'Type', 'Closed Date']; openSavingsColumns: string[] = ['Account No', 'Saving Account', 'Last Active', 'Balance', 'Actions']; @@ -30,8 +34,7 @@ export class GeneralTabComponent implements OnInit { constructor( private route: ActivatedRoute, - private router: Router, - private datePipe: DatePipe, + private clientService: ClientsService ) { this.route.data.subscribe((data: { clientAccountsData: any, clientChargesData: any, clientSummary: any }) => { this.clientAccountData = data.clientAccountsData; @@ -43,9 +46,6 @@ export class GeneralTabComponent implements OnInit { }); } - ngOnInit() { - } - toggleLoanAccountsOverview() { this.showClosedLoanAccounts = !this.showClosedLoanAccounts; } @@ -57,4 +57,26 @@ export class GeneralTabComponent implements OnInit { this.showClosedShareAccounts = !this.showClosedShareAccounts; } + /** + * Waive Charge. + * @param chargeId Selected Charge Id. + * @param clientId Selected Client Id. + */ + waiveCharge(chargeId: string, clientId: string) { + const charge = { clientId: clientId.toString(), resourceType: chargeId}; + this.clientService.waiveClientCharge(charge).subscribe(() => { + this.getChargeData(clientId); + }); + } + + /** + * Get Charge Data. + * @param clientId Selected Client Id. + */ + getChargeData(clientId: string) { + this.clientService.getClientChargesData(clientId).subscribe((data: any) => { + this.upcomingCharges = data.pageItems; + }); + } + } diff --git a/src/app/clients/clients.service.ts b/src/app/clients/clients.service.ts index 7e00b94fe..95bcd6903 100644 --- a/src/app/clients/clients.service.ts +++ b/src/app/clients/clients.service.ts @@ -67,6 +67,14 @@ export class ClientsService { return this.http.get(`/clients/${clientId}/charges`, { params: httpParams }); } + /** + * @param chargeData Charge Data to be waived. + */ + waiveClientCharge(chargeData: any) { + const httpParams = new HttpParams().set('command', 'waive'); + return this.http.post(`/clients/${chargeData.clientId}/charges/${chargeData.resourceType}`, chargeData, { params: httpParams }); + } + getClientSummary(clientId: string) { const httpParams = new HttpParams().set('R_clientId', clientId) .set('genericResultSet', 'false');