From 1c453d1b2c9b4d4a800da8c5c41fc11c5a1d606d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alberto=20Hern=C3=A1ndez?= <44206706+josehernandezfintecheandomx@users.noreply.github.com> Date: Sat, 29 Apr 2023 20:48:20 -0600 Subject: [PATCH] Fix to sort loan charges by due date (#1744) Co-authored-by: Jose Alberto Hernandez --- .../charges-tab/charges-tab.component.html | 2 +- .../charges-tab/charges-tab.component.ts | 4 +- .../manage-scheduler-jobs.component.html | 73 +++++++++------ .../manage-scheduler-jobs.component.ts | 89 +++++++++---------- 4 files changed, 95 insertions(+), 73 deletions(-) diff --git a/src/app/loans/loans-view/charges-tab/charges-tab.component.html b/src/app/loans/loans-view/charges-tab/charges-tab.component.html index 79bac5f5f..52c464b2b 100644 --- a/src/app/loans/loans-view/charges-tab/charges-tab.component.html +++ b/src/app/loans/loans-view/charges-tab/charges-tab.component.html @@ -88,6 +88,6 @@ - + diff --git a/src/app/loans/loans-view/charges-tab/charges-tab.component.ts b/src/app/loans/loans-view/charges-tab/charges-tab.component.ts index a22c73115..cf1ed53aa 100644 --- a/src/app/loans/loans-view/charges-tab/charges-tab.component.ts +++ b/src/app/loans/loans-view/charges-tab/charges-tab.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; -import { MatTableDataSource, MatTable } from '@angular/material/table'; +import { MatTableDataSource } from '@angular/material/table'; /** Custom Services */ import { LoansService } from 'app/loans/loans.service'; @@ -65,6 +65,7 @@ export class ChargesTabComponent implements OnInit { this.status = this.loanDetails.status.value; let actionFlag; 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') { actionFlag = true; } else { @@ -72,6 +73,7 @@ export class ChargesTabComponent implements OnInit { } 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.paginator = this.paginator; this.dataSource.sort = this.sort; diff --git a/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.html b/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.html index ba4c4c743..2efc9dd8e 100644 --- a/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.html +++ b/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.html @@ -1,15 +1,16 @@
-
-

Scheduler Status:{{ schedulerActive ? 'Active' : 'Inactive' }}

-
- - +
+

Scheduler Status:{{ schedulerActive ? 'Active' : 'Inactive' }} +

+
+ +
@@ -35,13 +36,14 @@ - - + @@ -51,6 +53,16 @@ {{ job.displayName }} + + Active ? + +
+ +
+ +
+ Next Run {{ job.nextRunTime }} @@ -110,10 +122,10 @@ - +

Template

+

This is the template I am trying to use. Is that fine.

+ + + - +

Search bar to filter jobs.

- - - + + +
-

List of all scheduled batch jobs Schedular Jobs

+

List of all scheduled batch jobs Schedular + Jobs

- - + +
diff --git a/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.ts b/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.ts index 925532d6b..c6d20ea67 100644 --- a/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.ts +++ b/src/app/system/manage-jobs/scheduler-jobs/manage-scheduler-jobs.component.ts @@ -8,7 +8,6 @@ import { SelectionModel } from '@angular/cdk/collections'; import { MatDialog } from '@angular/material/dialog'; /** rxjs Imports */ -import { of } from 'rxjs'; import { SystemService } from '../../system.service'; /** Custom Services */ @@ -33,7 +32,7 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit { /** Scheduler data */ schedulerData: any; /** 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. */ dataSource: MatTableDataSource; /** Initialize Selection */ @@ -66,11 +65,11 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit { * @param {PopoverService} popoverService PopoverService. */ constructor(private route: ActivatedRoute, - private systemService: SystemService, - private router: Router, - private dialog: MatDialog, - private configurationWizardService: ConfigurationWizardService, - private popoverService: PopoverService) { + private systemService: SystemService, + private router: Router, + private dialog: MatDialog, + private configurationWizardService: ConfigurationWizardService, + private popoverService: PopoverService) { this.route.data.subscribe((data: { jobsScheduler: any }) => { if (data.jobsScheduler) { this.jobData = data.jobsScheduler[0]; @@ -100,8 +99,8 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit { */ masterToggle() { this.isAllSelected() ? - this.selection.clear() : - this.dataSource.data.forEach(row => this.selection.select(row)); + this.selection.clear() : + this.dataSource.data.forEach(row => this.selection.select(row)); } /** @@ -117,44 +116,44 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit { */ setJobs() { this.systemService.getJobs() - .subscribe((jobData: any) => { - this.dataSource = new MatTableDataSource(jobData); - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; - this.jobsCounter = jobData.length; - this.selection.clear(); - this.dataSource.sortingDataAccessor = (item, property) => { - switch (property) { - case 'previousRunStatus': return item.lastRunHistory.status; - case 'errorLog': return item.lastRunHistory.status; - case 'previousRunTime': return new Date(item.lastRunHistory.jobRunStartTime); - case 'nextRunTime': return new Date(item.nextRunTime); - default: return item[property]; - } - }; - }); + .subscribe((jobData: any) => { + this.dataSource = new MatTableDataSource(jobData); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + this.jobsCounter = jobData.length; + this.selection.clear(); + this.dataSource.sortingDataAccessor = (item, property) => { + switch (property) { + case 'previousRunStatus': return item.lastRunHistory.status; + case 'errorLog': return item.lastRunHistory.status; + case 'previousRunTime': return new Date(item.lastRunHistory.jobRunStartTime); + case 'nextRunTime': return new Date(item.nextRunTime); + default: return item[property]; + } + }; + }); } getScheduler() { this.systemService.getScheduler() - .subscribe((schedulerData: any) => { - this.schedulerData = schedulerData; - this.schedulerActive = this.schedulerData.active; - }); + .subscribe((schedulerData: any) => { + this.schedulerData = schedulerData; + this.schedulerActive = this.schedulerData.active; + }); } suspendScheduler(): void { this.systemService.runCommandOnScheduler('stop') - .subscribe(() => { - this.getScheduler(); - }); + .subscribe(() => { + this.getScheduler(); + }); } activateScheduler(): void { this.systemService.runCommandOnScheduler('start') - .subscribe(() => { - this.getScheduler(); - }); + .subscribe(() => { + this.getScheduler(); + }); } runSelectedJobs(): void { @@ -216,7 +215,7 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit { * Next Step (Accounting) Dialog Configuration Wizard. */ openNextStepDialog() { - const nextStepDialogRef = this.dialog.open( NextStepDialogComponent, { + const nextStepDialogRef = this.dialog.open(NextStepDialogComponent, { data: { nextStepName: 'Setup Accounting', previousStepName: 'System', @@ -224,16 +223,16 @@ export class ManageSchedulerJobsComponent implements OnInit, AfterViewInit { }, }); nextStepDialogRef.afterClosed().subscribe((response: { nextStep: boolean }) => { - if (response.nextStep) { - this.configurationWizardService.showSchedulerJobsPage = false; - this.configurationWizardService.showSchedulerJobsList = false; - this.configurationWizardService.showChartofAccounts = true; - this.router.navigate(['/accounting']); + if (response.nextStep) { + this.configurationWizardService.showSchedulerJobsPage = false; + this.configurationWizardService.showSchedulerJobsList = false; + this.configurationWizardService.showChartofAccounts = true; + this.router.navigate(['/accounting']); } else { - this.configurationWizardService.showSchedulerJobsPage = false; - this.configurationWizardService.showSchedulerJobsList = false; - this.router.navigate(['/home']); + this.configurationWizardService.showSchedulerJobsPage = false; + this.configurationWizardService.showSchedulerJobsList = false; + this.router.navigate(['/home']); } }); -} + } }