Allow Loan re-amortize transaction

This commit is contained in:
Jose Alberto Hernandez
2024-03-06 12:46:04 +01:00
committed by Adam Saghy
parent a4fbde1edc
commit f52efaef44
23 changed files with 180 additions and 19 deletions
@@ -49,6 +49,7 @@ export class LoansViewComponent implements OnInit {
loanStatus: LoanStatus;
currency: Currency;
loanReAged = false;
loanReAmortized = false;
constructor(private route: ActivatedRoute,
private router: Router,
@@ -61,11 +62,17 @@ export class LoansViewComponent implements OnInit {
this.loanDisplayArrearsDelinquency = data.loanArrearsDelinquencyConfig.value || 0;
this.loanStatus = this.loanDetailsData.status;
this.currency = this.loanDetailsData.currency;
this.loanDetailsData.transactions.some((lt: LoanTransaction) => {
if (lt.type.reAge) {
this.loanReAged = true;
}
});
if (this.loanStatus.active) {
this.loanDetailsData.transactions.forEach((lt: LoanTransaction) => {
if (!lt.manuallyReversed) {
if (lt.type.reAge) {
this.loanReAged = true;
} else if (lt.type.reAmortize) {
this.loanReAmortized = true;
}
}
});
}
});
this.loanId = this.route.snapshot.params['loanId'];
this.clientId = this.loanDetailsData.clientId;
@@ -74,7 +81,7 @@ export class LoansViewComponent implements OnInit {
ngOnInit() {
this.recalculateInterest = this.loanDetailsData.recalculateInterest || true;
this.status = this.loanDetailsData.status.value;
if (this.loanDetailsData.status.active && this.loanDetailsData.multiDisburseLoan) {
if (this.loanStatus.active && this.loanDetailsData.multiDisburseLoan) {
if (this.loanDetailsData && this.loanDetailsData.transactions) {
this.loanDetailsData.transactions.forEach((transaction: any) => {
if (transaction.type.disbursement) {
@@ -185,11 +192,25 @@ export class LoansViewComponent implements OnInit {
taskPermissionName: 'UNDO_REAGE_LOAN',
});
}
if (!this.loanReAmortized) {
this.buttonConfig.addButton({
name: 'Re-Amortize',
icon: 'calendar-alt',
taskPermissionName: 'REAMORTIZE_LOAN',
});
} else {
this.buttonConfig.addButton({
name: 'Undo Re-Amortize',
icon: 'undo',
taskPermissionName: 'UNDO_REAMORTIZE_LOAN',
});
}
}
}
loanAction(button: string) {
switch (button) {
loanAction(actionName: string) {
switch (actionName) {
case 'Recover From Guarantor':
this.recoverFromGuarantor();
break;
@@ -204,10 +225,11 @@ export class LoansViewComponent implements OnInit {
this.router.navigate(['transfer-funds/make-account-transfer'], { relativeTo: this.route, queryParams: queryParams });
break;
case 'Undo Re-Age':
this.undoReAge();
case 'Undo Re-Amortize':
this.undoReAgeOrReAmortize(actionName);
break;
default:
this.router.navigate(['actions', button], { relativeTo: this.route });
this.router.navigate(['actions', actionName], { relativeTo: this.route });
break;
}
}
@@ -239,15 +261,18 @@ export class LoansViewComponent implements OnInit {
}
}
undoReAge(): void {
undoReAgeOrReAmortize(actionName: string): void {
actionName = actionName.replace('Undo ', '');
const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: { heading: this.translateService.instant('labels.heading.Undo Transaction'),
dialogContext: this.translateService.instant('labels.dialogContext.Are you sure you want undo the transaction type') + ' ReAge'
data: {
heading: this.translateService.instant('labels.heading.Undo Transaction'),
dialogContext: this.translateService.instant('labels.dialogContext.Are you sure you want undo the transaction type') + ' ' + this.translateService.instant('labels.menus.' + actionName)
}
});
undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.confirm) {
this.loansService.executeLoansAccountTransactionsCommand(String(this.loanId), 'undoReAge', {}).subscribe(() => {
const undoCommand = actionName === 'Re-Age' ? 'undoReAge' : 'undoReAmortize';
this.loansService.executeLoansAccountTransactionsCommand(String(this.loanId), undoCommand, {}).subscribe(() => {
this.reload();
});
}