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
@@ -28,4 +28,5 @@
<mifosx-charge-off [dataObject]="actionButtonData" *ngIf="actions['Charge-Off']"></mifosx-charge-off>
<mifosx-undo-command [actionName]="actionName" *ngIf="actions['Undo Charge-Off']"></mifosx-undo-command>
<mifosx-asset-transfer-loan *ngIf="actions['Sell Loan'] || actions['Buy Back Loan']"></mifosx-asset-transfer-loan>
<mifosx-loan-reaging [dataObject]="actionButtonData" *ngIf="actions['Re-Age']"></mifosx-loan-reaging>
<mifosx-loan-reaging [dataObject]="actionButtonData" *ngIf="actions['Re-Age']"></mifosx-loan-reaging>
<mifosx-loan-reamortize [dataObject]="actionButtonData" *ngIf="actions['Re-Amortize']"></mifosx-loan-reamortize>
@@ -0,0 +1,26 @@
<div class="container mat-elevation-z8">
<mat-card>
<form [formGroup]="reamortizeLoanForm" (ngSubmit)="submit()">
<mat-card-content>
<div fxLayout="column">
<mat-form-field>
<mat-label>{{"labels.inputs.External Id" | translate}}</mat-label>
<input matInput formControlName="externalId">
</mat-form-field>
</div>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../../general']">{{"labels.buttons.Cancel" |
translate}}</button>
<button mat-raised-button color="primary" [disabled]="!reamortizeLoanForm.valid"
*mifosxHasPermission="'REAMORTIZE_LOAN'">{{"labels.buttons.Submit" | translate}}</button>
</mat-card-actions>
</mat-card-content>
</form>
</mat-card>
</div>
@@ -0,0 +1,3 @@
.container {
max-width: 37rem;
}
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoanReamortizeComponent } from './loan-reamortize.component';
describe('LoanReamortizeComponent', () => {
let component: LoanReamortizeComponent;
let fixture: ComponentFixture<LoanReamortizeComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoanReamortizeComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(LoanReamortizeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,45 @@
import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { LoansService } from 'app/loans/loans.service';
@Component({
selector: 'mifosx-loan-reamortize',
templateUrl: './loan-reamortize.component.html',
styleUrls: ['./loan-reamortize.component.scss']
})
export class LoanReamortizeComponent implements OnInit {
@Input() dataObject: any;
/** Loan Id */
loanId: string;
/** ReAmortize Loan Form */
reamortizeLoanForm: UntypedFormGroup;
constructor(private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute,
private router: Router,
private loanService: LoansService) {
this.loanId = this.route.snapshot.params['loanId'];
}
ngOnInit(): void {
this.createReAmortizeLoanForm();
}
createReAmortizeLoanForm() {
this.reamortizeLoanForm = this.formBuilder.group({
'externalId': ''
});
}
submit(): void {
const data = this.reamortizeLoanForm.value;
this.loanService.submitLoanActionButton(this.loanId, data, 'reAmortize')
.subscribe((response: any) => {
this.router.navigate(['../../transactions'], { relativeTo: this.route });
});
}
}
@@ -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();
});
}
@@ -41,6 +41,9 @@
.reage {
color: $status-reage;
}
.reamortize {
color: $status-reamortize;
}
}
}
@@ -145,6 +145,9 @@ export class TransactionsTabComponent implements OnInit {
if (this.isReAge(transaction.type)) {
return 'reage';
}
if (this.isReAmortize(transaction.type)) {
return 'reamortize';
}
return '';
}
@@ -216,6 +219,10 @@ export class TransactionsTabComponent implements OnInit {
return (transactionType.code === 'loanTransactionType.reAge');
}
private isReAmortize(transactionType: any): boolean {
return (transactionType.code === 'loanTransactionType.reAmortize');
}
private reload() {
const clientId = this.route.parent.parent.snapshot.params['clientId'];
const loanId = this.route.parent.parent.snapshot.params['loanId'];
+3 -1
View File
@@ -81,6 +81,7 @@ import { ExternalAssetTransferComponent } from './loans-view/external-asset-owne
import { TranslateModule } from '@ngx-translate/core';
import { LoanDelinquencyActionDialogComponent } from './custom-dialog/loan-delinquency-action-dialog/loan-delinquency-action-dialog.component';
import { LoanReagingComponent } from './loans-view/loan-account-actions/loan-reaging/loan-reaging.component';
import { LoanReamortizeComponent } from './loans-view/loan-account-actions/loan-reamortize/loan-reamortize.component';
/**
* Loans Module
@@ -165,7 +166,8 @@ import { LoanReagingComponent } from './loans-view/loan-account-actions/loan-rea
ExternalAssetOwnerTabComponent,
ExternalAssetTransferComponent,
LoanDelinquencyActionDialogComponent,
LoanReagingComponent
LoanReagingComponent,
LoanReamortizeComponent
],
providers: [ ],
})
@@ -56,4 +56,5 @@ export interface LoanTransactionType {
chargeoff: boolean;
downPayment: boolean;
reAge: boolean;
reAmortize: boolean;
}
+3 -2
View File
@@ -67,14 +67,15 @@ $status-active: #00ce00;
$status-inactive: #666f73;
$status-deleted: #000000;
$status-pending: #ffa500;
$status-approved: #0f36e4;
$status-approved: #4461e2;
$status-chargeoff: #f39c12;
$status-overpaid: #800080;
$status-downpayment: #16a085;
$status-reage: #e08e0b;
$status-reamortize: #4461e2;
$status-active-overdue: #ff0000;
$status-matured: #ff4000;
$state-done: #00ce00;
$state-done: #2af72a;
$status-transfer-progress:#FF4000;
$status-transfer-hold:#DF0101;
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "produkty",
"Profile": "Profil",
"Re-Age": "Stárnutí",
"Re-Amortize": "Amortizovat",
"Recover From Guarantor": "Vymáhání od ručitele",
"Recovery Payment": "Platba obnovy",
"Reject": "Odmítnout",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Zrušit schválení",
"Undo Disbursal": "Zrušit výplatu",
"Undo Re-Age": "Zrušit Stárnutí",
"Undo Re-Amortize": "Zrušit Amortizovat",
"User Management": "správa uživatelů",
"User Panel": "Uživatelský panel",
"Users": "Uživatelé",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Produkte",
"Profile": "Profil",
"Re-Age": "Altern",
"Re-Amortize": "Amortisieren",
"Recover From Guarantor": "Rückforderung vom Bürgen",
"Recovery Payment": "Wiederherstellungszahlung",
"Reject": "Ablehnen",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Genehmigung rückgängig machen",
"Undo Disbursal": "Auszahlung rückgängig machen",
"Undo Re-Age": "Altern rückgängig machen",
"Undo Re-Amortize": "Amortisieren rückgängig machen",
"User Management": "Benutzerverwaltung",
"User Panel": "Benutzerbereich",
"Users": "Benutzer",
+2
View File
@@ -2145,6 +2145,7 @@
"Products": "Products",
"Profile": "Profile",
"Re-Age": "Re-Age",
"Re-Amortize": "Re-Amortize",
"Recover From Guarantor": "Recover From Guarantor",
"Recovery Payment": "Recovery Payment",
"Reject": "Reject",
@@ -2167,6 +2168,7 @@
"Undo Approval": "Undo Approval",
"Undo Disbursal": "Undo Disbursal",
"Undo Re-Age": "Undo Re-Age",
"Undo Re-Amortize": "Undo Re-Amortize",
"User Management": "User Management",
"User Panel": "User Panel",
"Users": "Users",
+3 -1
View File
@@ -2145,7 +2145,8 @@
"Prepay Loan": "Prepagar crédito",
"Products": "Productos",
"Profile": "Perfil",
"Re-Age": "Envejecimiento",
"Re-Age": "Re-Envejecer",
"Re-Amortize": "Re-Amortizar",
"Recover From Guarantor": "Recuperar del Garante",
"Recovery Payment": "Pago de recuperación",
"Reject": "Rechazar",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Deshacer aprobación",
"Undo Disbursal": "Deshacer desembolso",
"Undo Re-Age": "Deshacer Envejecimiento",
"Undo Re-Amortize": "Deshacer Amortizar",
"User Management": "Gestión de usuarios",
"User Panel": "Panel de usuario",
"Users": "Usuarios",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Des produits",
"Profile": "Profil",
"Re-Age": "Vieillissement",
"Re-Amortize": "Amortir",
"Recover From Guarantor": "Récupération auprès du garant",
"Recovery Payment": "Paiement de récupération",
"Reject": "Rejeter",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Annuler l'approbation",
"Undo Disbursal": "Annuler le décaissement",
"Undo Re-Age": "Annuler le Vieillissement",
"Undo Re-Amortize": "Annuler le Amortir",
"User Management": "Gestion des utilisateurs",
"User Panel": "Panneau utilisateur",
"Users": "Utilisateurs",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Prodotti",
"Profile": "Profilo",
"Re-Age": "Invecchiamento",
"Re-Amortize": "Ammortizzare",
"Recover From Guarantor": "Recupero dal garante",
"Recovery Payment": "Pagamento di recupero",
"Reject": "Rifiutare",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Annulla l'approvazione",
"Undo Disbursal": "Annullare l'esborso",
"Undo Re-Age": "Annullare l'invecchiamento",
"Undo Re-Amortize": "Annullare l'ammortizzare",
"User Management": "Gestione utenti",
"User Panel": "Pannello Utente",
"Users": "Utenti",
+2
View File
@@ -2147,6 +2147,7 @@
"Products": "제품",
"Profile": "프로필",
"Re-Age": "노화",
"Re-Amortize": "상각합니다",
"Recover From Guarantor": "보증인으로부터의 회복",
"Reject": "거부하다",
"Reports": "보고서",
@@ -2168,6 +2169,7 @@
"Undo Approval": "승인 취소",
"Undo Disbursal": "지급 취소",
"Undo Re-Age": "노화 취소",
"Undo Re-Amortize": "상각합니다 취소",
"User Management": "사용자 관리",
"User Panel": "사용자 패널",
"Users": "사용자",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Produktai",
"Profile": "Profilis",
"Re-Age": "Senėjimas",
"Re-Amortize": "Amortize",
"Recover From Guarantor": "Išieškojimas iš garanto",
"Recovery Payment": "Išieškojimo mokėjimas",
"Reject": "Atmesti",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Anuliuoti patvirtinimą",
"Undo Disbursal": "Anuliuoti išmokėjimą",
"Undo Re-Age": "Anuliuoti senėjimas",
"Undo Re-Amortize": "Anuliuoti amortize",
"User Management": "Vartotojo valdymas",
"User Panel": "Vartotojo skydelis",
"Users": "Vartotojai",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Produkti",
"Profile": "Profils",
"Re-Age": "Novecošanās",
"Re-Amortize": "Amortizēt",
"Recover From Guarantor": "Atgūšana no galvotāja",
"Recovery Payment": "Atgūšanas maksājums",
"Reject": "Noraidīt",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Atsaukt apstiprinājumu",
"Undo Disbursal": "Atsaukt izmaksu",
"Undo Re-Age": "Atsaukt novecošanās",
"Undo Re-Amortize": "Atsaukt amortizēt",
"User Management": "Lietotāju pārvaldība",
"User Panel": "Lietotāja panelis",
"Users": "Lietotāji",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "उत्पादनहरू",
"Profile": "प्रोफाइल",
"Re-Age": "बुढ्यौडो",
"Re-Amortize": "परिणत गर्नुहोस्",
"Recover From Guarantor": "ग्यारेन्टरबाट रिकभरी",
"Recovery Payment": "रिकभरी भुक्तानी",
"Reject": "अस्वीकार गर्नुहोस्",
@@ -2168,6 +2169,7 @@
"Undo Approval": "अनुमोदन अनडू गर्नुहोस्",
"Undo Disbursal": "वितरण पूर्ववत गर्नुहोस्",
"Undo Re-Age": "बुढ्यौडो अनडू",
"Undo Re-Amortize": "परिणत गर्नुहोस् अनडू",
"User Management": "प्रयोगकर्ता व्यवस्थापन",
"User Panel": "प्रयोगकर्ता प्यानल",
"Users": "प्रयोगकर्ताहरू",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Produtos",
"Profile": "Perfil",
"Re-Age": "Envelhecimento",
"Re-Amortize": "Amortizar",
"Recover From Guarantor": "Recuperação do Fiador",
"Recovery Payment": "Pagamento de recuperação",
"Reject": "Rejeitar",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Desfazer aprovação",
"Undo Disbursal": "Desfazer desembolso",
"Undo Re-Age": "Desfazer envelhecimento",
"Undo Re-Amortize": "Desfazer amortizar",
"User Management": "Gerenciamento de usuários",
"User Panel": "Painel do usuário",
"Users": "Usuários",
+2
View File
@@ -2146,6 +2146,7 @@
"Products": "Bidhaa",
"Profile": "Wasifu",
"Re-Age": "Kuzeeka",
"Re-Amortize": "Adize",
"Recover From Guarantor": "Urejeshaji Kutoka kwa Mdhamini",
"Recovery Payment": "Malipo ya uokoaji",
"Reject": "Kataa",
@@ -2168,6 +2169,7 @@
"Undo Approval": "Tendua Uidhinishaji",
"Undo Disbursal": "Tendua Utoaji",
"Undo Re-Age": "Tendua Kuzeeka",
"Undo Re-Amortize": "Tendua Adize",
"User Management": "Usimamizi wa Mtumiaji",
"User Panel": "Jopo la Mtumiaji",
"Users": "Watumiaji",