Fix to sort loan charges by due date (#1744)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-04-29 20:48:20 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent c09bc5c4bc
commit 1c453d1b2c
4 changed files with 95 additions and 73 deletions
@@ -88,6 +88,6 @@
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row" [routerLink]="[row.id]"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row" [routerLink]="[row.id]"></tr>
</table> </table>
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator> <mat-paginator [pageSizeOptions]="[50, 100, 200]" showFirstLastButtons></mat-paginator>
</div> </div>
@@ -4,7 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort'; import { MatSort } from '@angular/material/sort';
import { MatTableDataSource, MatTable } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
/** Custom Services */ /** Custom Services */
import { LoansService } from 'app/loans/loans.service'; import { LoansService } from 'app/loans/loans.service';
@@ -65,6 +65,7 @@ export class ChargesTabComponent implements OnInit {
this.status = this.loanDetails.status.value; this.status = this.loanDetails.status.value;
let actionFlag; let actionFlag;
this.chargesData.forEach((element: any) => { this.chargesData.forEach((element: any) => {
element.dueDate = this.dateUtils.parseDate(element.dueDate);
if (element.paid || element.waived || element.chargeTimeType.value === 'Disbursement' || this.loanDetails.status.value !== 'Active') { if (element.paid || element.waived || element.chargeTimeType.value === 'Disbursement' || this.loanDetails.status.value !== 'Active') {
actionFlag = true; actionFlag = true;
} else { } else {
@@ -72,6 +73,7 @@ export class ChargesTabComponent implements OnInit {
} }
element.actionFlag = actionFlag; element.actionFlag = actionFlag;
}); });
this.chargesData = this.chargesData.sort(function(a: any, b: any) { return b.dueDate - a.dueDate; } );
this.dataSource = new MatTableDataSource(this.chargesData); this.dataSource = new MatTableDataSource(this.chargesData);
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
@@ -1,6 +1,7 @@
<div class="container m-b-20 space-top" fxLayout="row" fxLayoutGap="20px"> <div class="container m-b-20 space-top" fxLayout="row" fxLayoutGap="20px">
<div #schedulerStatus> <div #schedulerStatus>
<h2 class="no-m">Scheduler Status:<span class="m-l-20 m-r-20">{{ schedulerActive ? 'Active' : 'Inactive' }}</span></h2> <h2 class="no-m">Scheduler Status:<span class="m-l-20 m-r-20">{{ schedulerActive ? 'Active' : 'Inactive' }}</span>
</h2>
</div> </div>
<button mat-raised-button class="suspend" (click)="suspendScheduler()" *ngIf="schedulerActive"> <button mat-raised-button class="suspend" (click)="suspendScheduler()" *ngIf="schedulerActive">
<fa-icon icon="times-circle" class="m-r-10"></fa-icon> <fa-icon icon="times-circle" class="m-r-10"></fa-icon>
@@ -35,13 +36,14 @@
<ng-container matColumnDef="select"> <ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef> <th mat-header-cell *matHeaderCellDef>
<mat-checkbox class="m-r-10" (change)="$event ? masterToggle() : null" [checked]="selection.hasValue() && isAllSelected()" <mat-checkbox class="m-r-10" (change)="$event ? masterToggle() : null"
[checked]="selection.hasValue() && isAllSelected()"
[indeterminate]="selection.hasValue() && !isAllSelected()"> [indeterminate]="selection.hasValue() && !isAllSelected()">
</mat-checkbox> </mat-checkbox>
</th> </th>
<td mat-cell *matCellDef="let row"> <td mat-cell *matCellDef="let row">
<mat-checkbox class="m-r-10" (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" <mat-checkbox class="m-r-10" *ngIf="!row.currentlyRunning && row.active" (click)="$event.stopPropagation()"
[checked]="selection.isSelected(row)"> (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)">
</mat-checkbox> </mat-checkbox>
</td> </td>
</ng-container> </ng-container>
@@ -51,6 +53,16 @@
<td mat-cell *matCellDef="let job"> {{ job.displayName }} </td> <td mat-cell *matCellDef="let job"> {{ job.displayName }} </td>
</ng-container> </ng-container>
<ng-container matColumnDef="active">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Active ? </th>
<td mat-cell *matCellDef="let job" class="center">
<div [className]="job.active === true ? 'currently-running' : 'not-currently-running'">
<fa-icon matTooltip="{{ job.active === true ? 'Yes' : 'No' }}" matTooltipPosition="right" icon="circle"
size="lg"></fa-icon>
</div>
</td>
</ng-container>
<ng-container matColumnDef="nextRunTime"> <ng-container matColumnDef="nextRunTime">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Next Run </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Next Run </th>
<td mat-cell *matCellDef="let job"> {{ job.nextRunTime }} </td> <td mat-cell *matCellDef="let job"> {{ job.nextRunTime }} </td>
@@ -124,26 +136,35 @@
<ng-template #templateSchedulerStatus let-data let-popover="popover"> <ng-template #templateSchedulerStatus let-data let-popover="popover">
<h4>Scheduler Status. Button will be used to change the status.</h4> <h4>Scheduler Status. Button will be used to change the status.</h4>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column"> <div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button> <button mat-raised-button color="warn"
(click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary" (click)="popover.close();previousStep()">Back</button> <button mat-raised-button color="primary" (click)="popover.close();previousStep()">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateFilter, filter, 'bottom', true)">Next</button> <button mat-raised-button color="primary"
(click)="popover.close();showPopover(templateFilter, filter, 'bottom', true)">Next</button>
</div> </div>
</ng-template> </ng-template>
<ng-template #templateFilter let-data let-popover="popover"> <ng-template #templateFilter let-data let-popover="popover">
<h4>Search bar to filter jobs.</h4> <h4>Search bar to filter jobs.</h4>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column"> <div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button> <button mat-raised-button color="warn"
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateSchedulerStatus,schedulerStatus, 'bottom', true)">Back</button> (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateJobsTable,jobsTable, 'top', true)">Next</button> <button mat-raised-button color="primary"
(click)="popover.close();showPopover(templateSchedulerStatus,schedulerStatus, 'bottom', true)">Back</button>
<button mat-raised-button color="primary"
(click)="popover.close();showPopover(templateJobsTable,jobsTable, 'top', true)">Next</button>
</div> </div>
</ng-template> </ng-template>
<ng-template #templateJobsTable let-data let-popover="popover"> <ng-template #templateJobsTable let-data let-popover="popover">
<h4>List of all scheduled batch jobs <a href="https://mifosforge.jira.com/wiki/spaces/docs/pages/67895356/Manage+Scheduler+Jobs" target="_blank">Schedular Jobs</a></h4> <h4>List of all scheduled batch jobs <a
href="https://mifosforge.jira.com/wiki/spaces/docs/pages/67895356/Manage+Scheduler+Jobs" target="_blank">Schedular
Jobs</a></h4>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column"> <div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button> <button mat-raised-button color="warn"
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateFilter, filter, 'bottom', true)">Back</button> (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary"
(click)="popover.close();showPopover(templateFilter, filter, 'bottom', true)">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();nextStep()">Next</button> <button mat-raised-button color="primary" (click)="popover.close();nextStep()">Next</button>
</div> </div>
</ng-template> </ng-template>
@@ -8,7 +8,6 @@ import { SelectionModel } from '@angular/cdk/collections';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
/** rxjs Imports */ /** rxjs Imports */
import { of } from 'rxjs';
import { SystemService } from '../../system.service'; import { SystemService } from '../../system.service';
/** Custom Services */ /** Custom Services */
@@ -33,7 +32,7 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit {
/** Scheduler data */ /** Scheduler data */
schedulerData: any; schedulerData: any;
/** Columns to be displayed in manage scheduler jobs table. */ /** Columns to be displayed in manage scheduler jobs table. */
displayedColumns: string[] = ['select', 'displayName', 'nextRunTime', 'previousRunTime', 'previousRunStatus', 'currentlyRunning', 'errorLog']; displayedColumns: string[] = ['select', 'displayName', 'active', 'nextRunTime', 'previousRunTime', 'previousRunStatus', 'currentlyRunning', 'errorLog'];
/** Data source for manage scheduler jobs table. */ /** Data source for manage scheduler jobs table. */
dataSource: MatTableDataSource<any>; dataSource: MatTableDataSource<any>;
/** Initialize Selection */ /** Initialize Selection */