Enhancement loan transactions tab for sort and pagination (#1658)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-01-27 21:32:47 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent a04f426c83
commit 480809c4cc
17 changed files with 87 additions and 44 deletions
@@ -184,7 +184,7 @@
<mat-form-field *ngIf="createClientForm.contains('activationDate')" fxFlex="48%" (click)="activatedOnDatePicker.open()"> <mat-form-field *ngIf="createClientForm.contains('activationDate')" fxFlex="48%" (click)="activatedOnDatePicker.open()">
<mat-label>Activation Date</mat-label> <mat-label>Activation Date</mat-label>
<input matInput [min]="createClientForm.value.submittedOnDate" [max]="createClientForm.value.submittedOnDate" [matDatepicker]="activatedOnDatePicker" required <input matInput [min]="createClientForm.value.submittedOnDate" [max]="maxDate" [matDatepicker]="activatedOnDatePicker" required
formControlName="activationDate"> formControlName="activationDate">
<mat-datepicker-toggle matSuffix [for]="activatedOnDatePicker"></mat-datepicker-toggle> <mat-datepicker-toggle matSuffix [for]="activatedOnDatePicker"></mat-datepicker-toggle>
<mat-datepicker #activatedOnDatePicker></mat-datepicker> <mat-datepicker #activatedOnDatePicker></mat-datepicker>
@@ -4,10 +4,10 @@
<h3>Performance History</h3> <h3>Performance History</h3>
<div fxLayout="row" fxLayoutGap="32px" class="performance-history-container"> <div fxLayout="row" fxLayoutGap="32px" class="performance-history-container">
<p> <p>
# of Repayments :{{loanDetails?.numberOfRepayments}} Repayments : {{loanDetails?.numberOfRepayments | number}}
</p> </p>
<p> <p>
Maturity Date :{{loanDetails?.timeline.expectedMaturityDate | dateFormat}} Maturity Date : {{loanDetails?.timeline.expectedMaturityDate | dateFormat}}
</p> </p>
</div> </div>
</ng-container> </ng-container>
@@ -43,7 +43,7 @@
<div fxFlexFill> <div fxFlexFill>
<span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()"> <span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()">
<mat-slide-toggle [(ngModel)]="showPaymentDetails" [ngModelOptions]="{standalone: true}"> <mat-slide-toggle>
<div [className]="showPaymentDetails ? 'enabled' : 'disabled'"> <div [className]="showPaymentDetails ? 'enabled' : 'disabled'">
<span class="m-l-10">Show Payment Details</span> <span class="m-l-10">Show Payment Details</span>
</div> </div>
@@ -77,7 +77,7 @@
<div fxFlexFill> <div fxFlexFill>
<span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()"> <span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()">
<mat-slide-toggle [(ngModel)]="showPaymentDetails" [ngModelOptions]="{standalone: true}"> <mat-slide-toggle>
<div [className]="showPaymentDetails ? 'enabled' : 'disabled'"> <div [className]="showPaymentDetails ? 'enabled' : 'disabled'">
<span class="m-l-10">Show Payment Details</span> <span class="m-l-10">Show Payment Details</span>
</div> </div>
@@ -83,6 +83,7 @@ export class MakeRepaymentComponent implements OnInit {
*/ */
addPaymentDetails() { addPaymentDetails() {
this.showPaymentDetails = !this.showPaymentDetails; this.showPaymentDetails = !this.showPaymentDetails;
console.log(this.showPaymentDetails);
if (this.showPaymentDetails) { if (this.showPaymentDetails) {
this.repaymentLoanForm.addControl('accountNumber', new FormControl('')); this.repaymentLoanForm.addControl('accountNumber', new FormControl(''));
this.repaymentLoanForm.addControl('checkNumber', new FormControl('')); this.repaymentLoanForm.addControl('checkNumber', new FormControl(''));
@@ -77,7 +77,7 @@
<div fxFlexFill> <div fxFlexFill>
<span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()"> <span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()">
<mat-slide-toggle [(ngModel)]="showPaymentDetails" [ngModelOptions]="{standalone: true}"> <mat-slide-toggle>
<div [className]="showPaymentDetails ? 'enabled' : 'disabled'"> <div [className]="showPaymentDetails ? 'enabled' : 'disabled'">
<span class="m-l-10">Show Payment Details</span> <span class="m-l-10">Show Payment Details</span>
</div> </div>
@@ -38,7 +38,7 @@
<div fxFlexFill> <div fxFlexFill>
<span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()"> <span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()">
<mat-slide-toggle [(ngModel)]="showPaymentDetails" [ngModelOptions]="{standalone: true}"> <mat-slide-toggle>
<div [className]="showPaymentDetails ? 'enabled' : 'disabled'"> <div [className]="showPaymentDetails ? 'enabled' : 'disabled'">
<span class="m-l-10">Show Payment Details</span> <span class="m-l-10">Show Payment Details</span>
</div> </div>
@@ -4,16 +4,20 @@
<mat-card-content> <mat-card-content>
<mat-form-field fxFlex> <div fxLayout="column">
<mat-label>Note</mat-label>
<textarea matInput [formControl]="note"></textarea>
</mat-form-field>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px"> <mat-form-field fxFlex>
<button type="button" mat-raised-button [routerLink]="['../../general']">Cancel</button> <mat-label>Note</mat-label>
<button mat-raised-button color="primary" (click)="submit()" <textarea matInput [formControl]="note"></textarea>
*mifosxHasPermission="'APPROVALUNDO_LOAN'">Submit</button> </mat-form-field>
</mat-card-actions>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../../general']">Cancel</button>
<button mat-raised-button color="primary" (click)="submit()"
*mifosxHasPermission="'APPROVALUNDO_LOAN'">Submit</button>
</mat-card-actions>
</div>
</mat-card-content> </mat-card-content>
@@ -49,7 +49,6 @@ export class LoansViewComponent implements OnInit {
this.loanDetailsData = data.loanDetailsData; this.loanDetailsData = data.loanDetailsData;
this.loanDatatables = data.loanDatatables; this.loanDatatables = data.loanDatatables;
this.loanStatus = this.loanDetailsData.status; this.loanStatus = this.loanDetailsData.status;
console.log(this.loanStatus);
}); });
this.loanId = this.route.snapshot.params['loanId']; this.loanId = this.route.snapshot.params['loanId'];
this.clientId = this.loanDetailsData.clientId; this.clientId = this.loanDetailsData.clientId;
@@ -2,18 +2,18 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px" class="transaction-buttons" *ngIf="checkStatus()"> <div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px" class="transaction-buttons" *ngIf="checkStatus()">
<mat-checkbox [formControl]="hideAccrualsParam" (click)="hideAccruals()" class="accruals">Hide Accruals</mat-checkbox> <mat-checkbox [formControl]="hideAccrualsParam" (click)="hideAccruals()" class="accruals">Hide Accruals</mat-checkbox>
<button mat-raised-button color="primary" [routerLink]="['export']"> <button mat-raised-button color="primary" class="transaction-button" [routerLink]="['export']">
Export Export
</button> </button>
<button mat-raised-button color="primary"> <button mat-raised-button color="primary" class="transaction-button">
View Journal Entries View Journal Entries
</button> </button>
</div> </div>
<table mat-table [dataSource]="showTransactionsData"> <table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> Id </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Id </th>
<td mat-cell *matCellDef="let transaction" [ngClass]="loanTransactionColor(transaction)"> {{ transaction.id }} </td> <td mat-cell *matCellDef="let transaction" [ngClass]="loanTransactionColor(transaction)"> {{ transaction.id }} </td>
</ng-container> </ng-container>
@@ -29,8 +29,8 @@
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="transactionDate"> <ng-container matColumnDef="date">
<th mat-header-cell *matHeaderCellDef> Transaction Date </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Transaction Date </th>
<td mat-cell *matCellDef="let transaction" [ngClass]="loanTransactionColor(transaction)"> {{ transaction.date | dateFormat }} </td> <td mat-cell *matCellDef="let transaction" [ngClass]="loanTransactionColor(transaction)"> {{ transaction.date | dateFormat }} </td>
</ng-container> </ng-container>
@@ -114,4 +114,6 @@
</table> </table>
<mat-paginator [pageSize]="50" [pageSizeOptions]="[50, 100, 200]" showFirstLastButtons></mat-paginator>
</div> </div>
@@ -24,14 +24,25 @@
} }
.strike { .strike {
text-decoration: line-through; text-decoration: line-through;
color: red; color: $status-active-overdue;
} }
.linked { .linked {
color: $status-approved; color: $status-approved;
} }
.accrual {
color: $msg-default;
}
} }
} }
.td-min-space { .td-min-space {
min-width: 60px; min-width: 60px;
} }
.filter-box {
min-width: 280px;
}
.transaction-button {
min-width: 180px;
}
@@ -1,6 +1,9 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import {FormControl} from '@angular/forms'; import { FormControl } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
@Component({ @Component({
selector: 'mifosx-transactions-tab', selector: 'mifosx-transactions-tab',
@@ -11,8 +14,6 @@ export class TransactionsTabComponent implements OnInit {
/** Loan Details Data */ /** Loan Details Data */
transactions: any; transactions: any;
/** Show Transactions Data */
showTransactionsData: any;
/** Temporary Transaction Data */ /** Temporary Transaction Data */
tempTransaction: any; tempTransaction: any;
/** Form control to handle accural parameter */ /** Form control to handle accural parameter */
@@ -20,14 +21,18 @@ export class TransactionsTabComponent implements OnInit {
/** Stores the status of the loan account */ /** Stores the status of the loan account */
status: string; status: string;
/** Columns to be displayed in original schedule table. */ /** Columns to be displayed in original schedule table. */
displayedColumns: string[] = ['id', 'office', 'externalId', 'transactionDate', 'transactionType', 'amount', 'principal', 'interest', 'fee', 'penalties', 'loanBalance', 'actions']; displayedColumns: string[] = ['id', 'office', 'externalId', 'date', 'transactionType', 'amount', 'principal', 'interest', 'fee', 'penalties', 'loanBalance', 'actions'];
dataSource: MatTableDataSource<any>;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ViewChild(MatSort, { static: true }) sort: MatSort;
/** /**
* Retrieves the loans with associations data from `resolve`. * Retrieves the loans with associations data from `resolve`.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
*/ */
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.parent.parent.data.subscribe((data: { loanDetailsData: any }) => { this.route.parent.parent.data.subscribe((data: { loanDetailsData: any }) => {
this.transactions = data.loanDetailsData.transactions; this.transactions = data.loanDetailsData.transactions;
this.tempTransaction = data.loanDetailsData.transactions; this.tempTransaction = data.loanDetailsData.transactions;
@@ -37,12 +42,14 @@ export class TransactionsTabComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.hideAccrualsParam = new FormControl(false); this.hideAccrualsParam = new FormControl(false);
this.dataSource = new MatTableDataSource(this.transactions);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.tempTransaction.forEach((element: any) => { this.tempTransaction.forEach((element: any) => {
if (element.type.accrual) { if (this.isAccrual(element.type)) {
this.tempTransaction = this.removeItem(this.tempTransaction, element); this.tempTransaction = this.removeItem(this.tempTransaction, element);
} }
}); });
this.showTransactionsData = this.transactions;
} }
/** /**
@@ -56,17 +63,21 @@ export class TransactionsTabComponent implements OnInit {
return false; return false;
} }
hideAccruals() { hideAccruals() {
if (!this.hideAccrualsParam.value) { if (!this.hideAccrualsParam.value) {
this.showTransactionsData = this.tempTransaction; this.dataSource = new MatTableDataSource(this.tempTransaction);
} else { } else {
this.showTransactionsData = this.transactions; this.dataSource = new MatTableDataSource(this.transactions);
} }
} }
applyFilter(filterValue: string = '') {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
removeItem(arr: any, item: any) { removeItem(arr: any, item: any) {
return arr.filter((f: any) => f !== item); return arr.filter((f: any) => f !== item);
} }
/** /**
* Show Transactions Details * Show Transactions Details
@@ -94,6 +105,9 @@ export class TransactionsTabComponent implements OnInit {
if (loanTransaction.transactionRelations && loanTransaction.transactionRelations.length > 0) { if (loanTransaction.transactionRelations && loanTransaction.transactionRelations.length > 0) {
return 'linked'; return 'linked';
} }
if (this.isAccrual(loanTransaction.type)) {
return 'accrual';
}
return ''; return '';
} }
@@ -105,4 +119,8 @@ export class TransactionsTabComponent implements OnInit {
$event.stopPropagation(); $event.stopPropagation();
} }
private isAccrual(transactionType: any): boolean {
return (transactionType.accrual || transactionType.code === 'loanTransactionType.overdueCharge');
}
} }
+1 -1
View File
@@ -35,7 +35,7 @@ export class LoansService {
.set('command', 'foreclosure') .set('command', 'foreclosure')
.set('locale', this.settingsService.language.code) .set('locale', this.settingsService.language.code)
.set('dateFormat', this.settingsService.dateFormat) .set('dateFormat', this.settingsService.dateFormat)
.set('transactionDate', this.dateUtils.formatDate(this.settingsService.businessDate, this.settingsService.dateFormat)) .set('transactionDate', this.dateUtils.formatDate(this.settingsService.businessDate, this.settingsService.dateFormat));
return this.http.get(`/loans/${loanId}/transactions/template`, { params: httpParams }); return this.http.get(`/loans/${loanId}/transactions/template`, { params: httpParams });
} }
@@ -45,7 +45,7 @@
<div fxFlexFill> <div fxFlexFill>
<span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()"> <span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()">
<mat-slide-toggle [(ngModel)]="showPaymentDetails" [ngModelOptions]="{standalone: true}"> <mat-slide-toggle>
<div [className]="showPaymentDetails ? 'enabled' : 'disabled'"> <div [className]="showPaymentDetails ? 'enabled' : 'disabled'">
<span class="m-l-10">Show Payment Details</span> <span class="m-l-10">Show Payment Details</span>
</div> </div>
@@ -39,7 +39,7 @@
<div fxFlexFill> <div fxFlexFill>
<span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()"> <span fxFlex="75%" class="expandcollapsebutton m-l-10 m-t-40" (click)="addPaymentDetails()">
<mat-slide-toggle [(ngModel)]="addPaymentDetailsFlag" [ngModelOptions]="{standalone: true}"> <mat-slide-toggle>
<div [className]="addPaymentDetailsFlag ? 'enabled' : 'disabled'"> <div [className]="addPaymentDetailsFlag ? 'enabled' : 'disabled'">
<span class="m-l-10">Show Payment Details</span> <span class="m-l-10">Show Payment Details</span>
</div> </div>
@@ -12,15 +12,15 @@
<div class="mat-elevation-z1 m-b-25"> <div class="mat-elevation-z1 m-b-25">
<table mat-table [dataSource]="dataSource" > <table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> ID </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Id </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.id }} </td> <td mat-cell *matCellDef="let transaction"> {{ transaction.id }} </td>
</ng-container> </ng-container>
<ng-container matColumnDef="transactionDate"> <ng-container matColumnDef="date">
<th mat-header-cell class="center" *matHeaderCellDef> Transaction Date </th> <th mat-header-cell class="center" *matHeaderCellDef mat-sort-header> Transaction Date </th>
<td mat-cell *matCellDef="let transaction"> {{ transaction.date | dateFormat }} </td> <td mat-cell *matCellDef="let transaction"> {{ transaction.date | dateFormat }} </td>
</ng-container> </ng-container>
@@ -58,6 +58,8 @@
</table> </table>
<mat-paginator [pageSize]="50" [pageSizeOptions]="[50, 100, 200]" showFirstLastButtons></mat-paginator>
</div> </div>
</div> </div>
@@ -1,5 +1,7 @@
/** Angular Imports */ /** Angular Imports */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
@@ -21,6 +23,8 @@ export class TransactionsTabComponent implements OnInit {
displayedColumns: string[] = ['id', 'transactionDate', 'transactionType', 'debit', 'credit', 'balance', 'viewReciept']; displayedColumns: string[] = ['id', 'transactionDate', 'transactionType', 'debit', 'credit', 'balance', 'viewReciept'];
/** Data source for transactions table. */ /** Data source for transactions table. */
dataSource: MatTableDataSource<any>; dataSource: MatTableDataSource<any>;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@ViewChild(MatSort, { static: true }) sort: MatSort;
/** /**
* Retrieves savings account data from `resolve`. * Retrieves savings account data from `resolve`.
@@ -36,6 +40,8 @@ export class TransactionsTabComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.dataSource = new MatTableDataSource(this.transactionsData); this.dataSource = new MatTableDataSource(this.transactionsData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
} }
/** /**