@@ -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 { LoansService } from '../loans.service';
|
||||
|
||||
/**
|
||||
* Clients data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class LoanDetailsChargesResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {LoansService} LoansService Loans service.
|
||||
*/
|
||||
constructor(private loansService: LoansService) { }
|
||||
|
||||
/**
|
||||
* Returns the Loans with Association data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const loanId = route.parent.paramMap.get('loanId');
|
||||
return this.loansService.getLoanAccountAssociationDetails(loanId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,12 +20,12 @@ export class LoanDetailsResolver implements Resolve<Object> {
|
||||
constructor(private loansService: LoansService) { }
|
||||
|
||||
/**
|
||||
* Returns the Loans data.
|
||||
* Returns the Loans with Association data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const loanId = route.paramMap.get('loanId');
|
||||
return this.loansService.getLoanAccountDetails(loanId);
|
||||
return this.loansService.getLoanAccountAssociationDetails(loanId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import { LoanChargeTemplateResolver } from './common-resolvers/loan-charge-templ
|
||||
import { LoanDetailsResolver } from './common-resolvers/loan-details.resolver';
|
||||
import { LoanDetailsGeneralResolver } from './common-resolvers/loan-details-general.resolver';
|
||||
import { LoanNotesResolver } from './common-resolvers/loan-notes-resolver';
|
||||
import { ChargesTabComponent } from './loans-view/charges-tab/charges-tab.component';
|
||||
import { LoanDetailsChargesResolver } from './common-resolvers/loan-details-charges.resolver';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@@ -47,6 +49,14 @@ const routes: Routes = [
|
||||
loanDetailsData: LoanDetailsGeneralResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'charges',
|
||||
component: ChargesTabComponent,
|
||||
data: { title: extract('Charges'), breadcrumb: 'Charges', routeParamBreadcrumb: false },
|
||||
resolve: {
|
||||
loanDetailsAssociationData: LoanDetailsChargesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'notes',
|
||||
component: NotesTabComponent,
|
||||
@@ -75,7 +85,8 @@ const routes: Routes = [
|
||||
LoanChargeTemplateResolver,
|
||||
LoanDetailsGeneralResolver,
|
||||
LoanDetailsResolver,
|
||||
LoanNotesResolver
|
||||
LoanNotesResolver,
|
||||
LoanDetailsChargesResolver
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<div class="container">
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.name }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="feepenalty">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Fee/Penalty </th>
|
||||
<td mat-cell *matCellDef="let charge">
|
||||
<span *ngIf="charge.penalty">Penalty</span>
|
||||
<span *ngIf="!charge.penalty">Fee</span>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="paymentdueat">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Payment due at </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.chargeTimeType.value }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="dueasof">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Due as of </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.dueDate| date }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="calculationtype">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Calculation Type </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.chargeCalculationType.value }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="due">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Due </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.currency.displaySymbol }}{{ charge.amount| number }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="paid">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Paid </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.currency.displaySymbol }}{{ charge.amountPaid| number }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="waived">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Waived </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.currency.displaySymbol }}{{ charge.amountWaived| number }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="outstanding">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Outstanding </th>
|
||||
<td mat-cell *matCellDef="let charge"> {{ charge.currency.displaySymbol }}{{ charge.amountOutstanding| number }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Actions </th>
|
||||
<td mat-cell *matCellDef="let charge">
|
||||
<button class="charges-action-button" mat-raised-button color="primary" *ngIf="status === 'Submitted and pending approval'">
|
||||
<i class="fa fa-edit" matTooltip="edit"></i>
|
||||
</button>
|
||||
<button class="charges-action-button" mat-raised-button color="warning" *ngIf="status === 'Submitted and pending approval'">
|
||||
<i class="fa fa-trash-o" matTooltip="delete"></i>
|
||||
</button>
|
||||
<button class="charges-action-button" mat-raised-button color="primary" *ngIf="!charge.actionFlag">
|
||||
<i class="fa fa-flag"></i>
|
||||
</button>
|
||||
<button class="charges-action-button" mat-raised-button color="success" *ngIf="charge.chargePayable && status=='Active'">
|
||||
Pay
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
table {
|
||||
width: 100%;
|
||||
margin-top: 3%;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ChargesTabComponent } from './charges-tab.component';
|
||||
|
||||
describe('ChargesTabComponent', () => {
|
||||
let component: ChargesTabComponent;
|
||||
let fixture: ComponentFixture<ChargesTabComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ChargesTabComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ChargesTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-charges-tab',
|
||||
templateUrl: './charges-tab.component.html',
|
||||
styleUrls: ['./charges-tab.component.scss']
|
||||
})
|
||||
export class ChargesTabComponent implements OnInit {
|
||||
|
||||
/** Loan Details Data */
|
||||
loanDetails: any;
|
||||
/** Charges Data */
|
||||
chargesData: any;
|
||||
/** Status */
|
||||
status: any;
|
||||
/** Columns to be displayed in codes table. */
|
||||
displayedColumns: string[] = ['name', 'feepenalty', 'paymentdueat', 'dueasof', 'calculationtype', 'due', 'paid', 'waived', 'outstanding', 'actions'];
|
||||
/** Data source for codes table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for codes table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for codes table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the codes data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { loanDetailsAssociationData: any }) => {
|
||||
this.loanDetails = data.loanDetailsAssociationData;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.chargesData = this.loanDetails.charges;
|
||||
this.status = this.loanDetails.status.value;
|
||||
let actionFlag;
|
||||
this.chargesData.forEach((element: any) => {
|
||||
if (element.paid || element.waived || element.chargeTimeType.value === 'Disbursement' || this.loanDetails.status.value !== 'Active') {
|
||||
actionFlag = true;
|
||||
} else {
|
||||
actionFlag = false;
|
||||
}
|
||||
element.actionFlag = actionFlag;
|
||||
});
|
||||
this.dataSource = new MatTableDataSource(this.chargesData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,6 +58,11 @@
|
||||
<a mat-tab-link [routerLink]="['./accountdetail']" routerLinkActive #accountdetail="routerLinkActive" [active]="accountdetail.isActive">
|
||||
Account Details
|
||||
</a>
|
||||
<ng-container *ngIf="loanDetailsData.charges">
|
||||
<a mat-tab-link [routerLink]="['./charges']" routerLinkActive #charges="routerLinkActive" [active]="charges.isActive">
|
||||
Charges
|
||||
</a>
|
||||
</ng-container>
|
||||
<a mat-tab-link *mifosxHasPermission="'READ_LOANNOTE'" [routerLink]="['./notes']" routerLinkActive #notes="routerLinkActive" [active]="notes.isActive">
|
||||
Notes
|
||||
</a>
|
||||
|
||||
@@ -14,6 +14,7 @@ import { LoansViewComponent } from './loans-view/loans-view.component';
|
||||
import { GeneralTabComponent } from './loans-view/general-tab/general-tab.component';
|
||||
import { AccountDetailsComponent } from './loans-view/account-details/account-details.component';
|
||||
import { NotesTabComponent } from './loans-view/notes-tab/notes-tab.component';
|
||||
import { ChargesTabComponent } from './loans-view/charges-tab/charges-tab.component';
|
||||
|
||||
/**
|
||||
* Loans Module
|
||||
@@ -28,6 +29,7 @@ import { NotesTabComponent } from './loans-view/notes-tab/notes-tab.component';
|
||||
GeneralTabComponent,
|
||||
AccountDetailsComponent,
|
||||
NotesTabComponent,
|
||||
ChargesTabComponent,
|
||||
],
|
||||
providers: [DatePipe],
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -29,10 +29,25 @@ export class LoansService {
|
||||
return this.http.post(`/loans/${loanId}/${resourceType}`, loanCharge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Loan Account Details
|
||||
* @param loanId Loan Id
|
||||
*/
|
||||
getLoanAccountDetails(loanId: string) {
|
||||
return this.http.get(`/loans/${loanId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Loans details with httpParams
|
||||
* @param loanId Loan ID
|
||||
*/
|
||||
getLoanAccountAssociationDetails(loanId: string) {
|
||||
const httpParams = new HttpParams()
|
||||
.set('associations', 'all')
|
||||
.set('exclude', 'guarantors,futureSchedule');
|
||||
return this.http.get(`/loans/${loanId}`, {params: httpParams});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loanId Loan Id
|
||||
* @returns The notes for particular loan
|
||||
|
||||
Reference in New Issue
Block a user