Skip to content

Commit d533301

Browse files
WEB-331: Introduce loan reaging preview
1 parent f763365 commit d533301

File tree

20 files changed

+172
-7
lines changed

20 files changed

+172
-7
lines changed

src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@
8484
>
8585
{{ 'labels.buttons.Submit' | translate }}
8686
</button>
87+
<button
88+
type="button"
89+
mat-raised-button
90+
color="accent"
91+
[disabled]="!reagingLoanForm.valid"
92+
*mifosxHasPermission="'REAGING_LOAN'"
93+
(click)="preview()"
94+
>
95+
{{ 'labels.buttons.Preview' | translate }}
96+
</button>
8797
</mat-card-actions>
8898
</mat-card-content>
8999
</form>

src/app/loans/loans-view/loan-account-actions/loan-reaging/loan-reaging.component.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Component, Input, OnInit } from '@angular/core';
22
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
33
import { ActivatedRoute, Router } from '@angular/router';
4+
import { MatDialog } from '@angular/material/dialog';
45
import { Dates } from 'app/core/utils/dates';
56
import { LoansService } from 'app/loans/loans.service';
67
import { SettingsService } from 'app/settings/settings.service';
78
import { OptionData } from 'app/shared/models/option-data.model';
89
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
10+
import { ReAgePreviewDialogComponent } from './re-age-preview-dialog/re-age-preview-dialog.component';
911

1012
@Component({
1113
selector: 'mifosx-loan-reaging',
@@ -37,7 +39,8 @@ export class LoanReagingComponent implements OnInit {
3739
private router: Router,
3840
private settingsService: SettingsService,
3941
private loanService: LoansService,
40-
private dateUtils: Dates
42+
private dateUtils: Dates,
43+
private dialog: MatDialog
4144
) {
4245
this.loanId = this.route.snapshot.params['loanId'];
4346
}
@@ -80,6 +83,33 @@ export class LoanReagingComponent implements OnInit {
8083
});
8184
}
8285

86+
preview(): void {
87+
const reagingLoanFormData = this.reagingLoanForm.value;
88+
const locale = this.settingsService.language.code;
89+
const dateFormat = this.settingsService.dateFormat;
90+
const startDate: Date = this.reagingLoanForm.value.startDate;
91+
if (reagingLoanFormData.startDate instanceof Date) {
92+
reagingLoanFormData.startDate = this.dateUtils.formatDate(startDate, dateFormat);
93+
}
94+
const data = {
95+
...reagingLoanFormData,
96+
dateFormat,
97+
locale
98+
};
99+
100+
this.loanService.getReAgePreview(this.loanId, data).subscribe((response: any) => {
101+
this.dialog.open(ReAgePreviewDialogComponent, {
102+
data: {
103+
repaymentSchedule: response,
104+
currencyCode: response.currency?.code || 'USD'
105+
},
106+
width: '95%',
107+
maxWidth: '1400px',
108+
height: '90vh'
109+
});
110+
});
111+
}
112+
83113
submit(): void {
84114
const reagingLoanFormData = this.reagingLoanForm.value;
85115
const locale = this.settingsService.language.code;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h1 mat-dialog-title>{{ 'labels.heading.Repayment Schedule Preview' | translate }}</h1>
2+
3+
<mat-dialog-content class="mat-typography">
4+
<mifosx-repayment-schedule-tab
5+
[repaymentScheduleDetails]="repaymentSchedule"
6+
[currencyCode]="currencyCode"
7+
[forEditing]="false"
8+
>
9+
</mifosx-repayment-schedule-tab>
10+
</mat-dialog-content>
11+
12+
<mat-dialog-actions align="end">
13+
<button mat-raised-button (click)="close()">
14+
{{ 'labels.buttons.Go back' | translate }}
15+
</button>
16+
</mat-dialog-actions>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[mat-dialog-title] {
2+
font-size: 20px;
3+
font-weight: 500;
4+
margin: 0;
5+
padding: 24px 24px 16px;
6+
}
7+
8+
mat-dialog-content {
9+
flex: 1;
10+
overflow-y: auto;
11+
padding: 20px;
12+
}
13+
14+
mat-dialog-actions {
15+
padding: 16px 24px;
16+
margin: 0;
17+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Component, Inject } from '@angular/core';
2+
import {
3+
MAT_DIALOG_DATA,
4+
MatDialogRef,
5+
MatDialogTitle,
6+
MatDialogContent,
7+
MatDialogActions
8+
} from '@angular/material/dialog';
9+
import { MatButton } from '@angular/material/button';
10+
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
11+
import { RepaymentScheduleTabComponent } from '../../../repayment-schedule-tab/repayment-schedule-tab.component';
12+
13+
@Component({
14+
selector: 'mifosx-re-age-preview-dialog',
15+
templateUrl: './re-age-preview-dialog.component.html',
16+
styleUrls: ['./re-age-preview-dialog.component.scss'],
17+
imports: [
18+
...STANDALONE_SHARED_IMPORTS,
19+
MatDialogTitle,
20+
MatDialogContent,
21+
MatDialogActions,
22+
MatButton,
23+
RepaymentScheduleTabComponent
24+
]
25+
})
26+
export class ReAgePreviewDialogComponent {
27+
repaymentSchedule: any;
28+
currencyCode: string;
29+
30+
constructor(
31+
public dialogRef: MatDialogRef<ReAgePreviewDialogComponent>,
32+
@Inject(MAT_DIALOG_DATA) public data: any
33+
) {
34+
this.repaymentSchedule = data.repaymentSchedule;
35+
this.currencyCode = data.currencyCode;
36+
}
37+
38+
close(): void {
39+
this.dialogRef.close();
40+
}
41+
}

src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ export class RepaymentScheduleTabComponent implements OnInit, OnChanges {
128128
private dateUtils: Dates,
129129
private dialog: MatDialog
130130
) {
131-
this.route.parent.data.subscribe((data: { loanDetailsData: any }) => {
132-
if (data.loanDetailsData) {
133-
this.currencyCode = data.loanDetailsData.currency.code;
134-
}
135-
this.loanDetailsDataRepaymentSchedule = data.loanDetailsData ? data.loanDetailsData.repaymentSchedule : [];
136-
});
131+
if (this.route.parent) {
132+
this.route.parent.data.subscribe((data: { loanDetailsData: any }) => {
133+
if (data.loanDetailsData) {
134+
this.currencyCode = data.loanDetailsData.currency.code;
135+
}
136+
this.loanDetailsDataRepaymentSchedule = data.loanDetailsData ? data.loanDetailsData.repaymentSchedule : [];
137+
});
138+
}
137139
this.businessDate = this.settingsService.businessDate;
138140
}
139141

src/app/loans/loans.service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ export class LoansService {
241241
return this.http.post(`/loans/${loanId}/transactions`, data, { params: httpParams });
242242
}
243243

244+
/**
245+
* Get Re-Age preview with repayment schedule
246+
* @param loanId Loan Id
247+
* @param data Re-Age data
248+
* @returns Observable with repayment schedule preview
249+
*/
250+
getReAgePreview(loanId: string, data: any): Observable<any> {
251+
return this.http.post(`/loans/${loanId}/transactions/reage-preview`, data);
252+
}
253+
244254
getLoanScreenReportsData(): Observable<any> {
245255
const httpParams = new HttpParams().set('entityId', '1').set('typeId', '0');
246256
return this.http.get(`/templates`, { params: httpParams });

src/assets/translations/cs-CS.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@
423423
"GSIM Application": "Aplikace GSIM",
424424
"Generate Report": "Vygenerovat zprávu",
425425
"Get Parameters": "Získat parametry",
426+
"Go back": "Vrátit se",
426427
"Go to next step": "Přejděte k dalšímu kroku",
427428
"Group Loan Application": "Žádost o skupinovou půjčku",
428429
"Group Saving Application": "Aplikace pro ukládání skupin",
@@ -457,6 +458,7 @@
457458
"Pie Chart": "Koláčový graf",
458459
"Post Dividend": "Vyplácet dividendu",
459460
"Previous": "Předchozí",
461+
"Preview": "Náhled",
460462
"Print": "Tisk",
461463
"Proceed": "Pokračovat",
462464
"Productive Collection Sheet": "Produktivní kolekce list",
@@ -1067,6 +1069,7 @@
10671069
"Reject Checker": "Odmítnout kontrolu",
10681070
"Release Amount": "Částka uvolnění",
10691071
"Repaid Every": "Splaceno každý",
1072+
"Repayment Schedule Preview": "Náhled splátkového kalendáře",
10701073
"Report Parameter": "Parametr sestavy",
10711074
"Reschedule Loan": "Přeplánovací půjčka",
10721075
"Revert Transaction": "Vrátit transakci",

src/assets/translations/de-DE.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@
423423
"GSIM Application": "GSIM-Anwendung",
424424
"Generate Report": "Bericht generieren",
425425
"Get Parameters": "Parameter abrufen",
426+
"Go back": "Zurück",
426427
"Go to next step": "Gehen Sie zum nächsten Schritt",
427428
"Group Loan Application": "Gruppenkreditantrag",
428429
"Group Saving Application": "Gruppenspeicheranwendung",
@@ -457,6 +458,7 @@
457458
"Pie Chart": "Kuchendiagramm",
458459
"Post Dividend": "Post-Dividende",
459460
"Previous": "Vorherige",
461+
"Preview": "Vorschau",
460462
"Print": "Drucken",
461463
"Proceed": "Fortfahren",
462464
"Productive Collection Sheet": "Produktives Sammlungsblatt",
@@ -1068,6 +1070,7 @@
10681070
"Reject Checker": "Überprüfung ablehnen",
10691071
"Release Amount": "Freigabebetrag",
10701072
"Repaid Every": "Alle zurückgezahlt",
1073+
"Repayment Schedule Preview": "Rückzahlungsplan Vorschau",
10711074
"Report Parameter": "Berichtsparameter",
10721075
"Reschedule Loan": "Darlehen neu plant",
10731076
"Revert Transaction": "Transaktion rückgängig machen",

src/assets/translations/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@
424424
"GSIM Application": "GSIM Application",
425425
"Generate Report": "Generate Report",
426426
"Get Parameters": "Get Parameters",
427+
"Go back": "Go back",
427428
"Go to next step": "Go to next step",
428429
"Group Loan Application": "Group Loan Application",
429430
"Group Saving Application": "Group Saving Application",
@@ -458,6 +459,7 @@
458459
"Pie Chart": "Pie Chart",
459460
"Post Dividend": "Post Dividend",
460461
"Previous": "Previous",
462+
"Preview": "Preview",
461463
"Print": "Print",
462464
"Proceed": "Proceed",
463465
"Productive Collection Sheet": "Productive Collection Sheet",
@@ -1073,6 +1075,7 @@
10731075
"Reject Checker": "Reject Checker",
10741076
"Release Amount": "Release Amount",
10751077
"Repaid Every": "Repaid Every",
1078+
"Repayment Schedule Preview": "Repayment Schedule Preview",
10761079
"Report Parameter": "Report Parameter",
10771080
"Reschedule Loan": "Reschedule Loan",
10781081
"Revert Transaction": "Revert Transaction",

0 commit comments

Comments
 (0)