Loan Reschedule management in Loan Account (#1637)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-01-10 00:22:30 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 1bccd96c37
commit 08a327fdbf
15 changed files with 306 additions and 20 deletions
@@ -0,0 +1,67 @@
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { Dates } from 'app/core/utils/dates';
import { LoansService } from 'app/loans/loans.service';
import { SettingsService } from 'app/settings/settings.service';
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
@Component({
selector: 'mifosx-reschedule-loan-tab',
templateUrl: './reschedule-loan-tab.component.html',
styleUrls: ['./reschedule-loan-tab.component.scss']
})
export class RescheduleLoanTabComponent implements OnInit {
loanRescheduleData: any;
loanRescheduleDataColumns: string[] = ['id', 'rescheduleFromDate', 'reason', 'status', 'updatedOnDate', 'actions'];
clientId: any;
constructor(private route: ActivatedRoute,
private router: Router,
private loansServices: LoansService,
private settingsService: SettingsService,
private dateUtils: Dates,
private dialog: MatDialog) {
this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId');
this.route.parent.data.subscribe((data: { loanRescheduleData: any }) => {
this.loanRescheduleData = data.loanRescheduleData;
});
}
ngOnInit(): void {
}
manageRequest(request: any, command: string): void {
const approveLoanRescheduleDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: { heading: `${command} Loan Reschedule`, dialogContext: `Are you sure you want ${command} the Loan Reschedule ${request.id}` }
});
approveLoanRescheduleDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
if (response.confirm) {
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const payload = {
dateFormat,
locale
};
if (command === 'Approve') {
payload['approvedOnDate'] = this.dateUtils.formatDate(this.settingsService.businessDate, dateFormat);
} else {
payload['rejectedOnDate'] = this.dateUtils.formatDate(this.settingsService.businessDate, dateFormat);
}
this.loansServices.applyCommandLoanRescheduleRequests(request.id, command.toLowerCase(), payload).subscribe((result: any) => {
this.reload();
});
}
});
}
/**
* Refetches data fot the component
*/
private reload() {
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${this.clientId}/loans-accounts`, { skipLocationChange: true })
.then(() => this.router.navigate([url]));
}
}