Skip to content

Commit 675dafd

Browse files
WEB-331: Introduce loan reaging preview
1 parent 9caac8c commit 675dafd

File tree

20 files changed

+180
-7
lines changed

20 files changed

+180
-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
}
@@ -79,6 +82,33 @@ export class LoanReagingComponent implements OnInit {
7982
});
8083
}
8184

85+
preview(): void {
86+
const reagingLoanFormData = this.reagingLoanForm.value;
87+
const locale = this.settingsService.language.code;
88+
const dateFormat = this.settingsService.dateFormat;
89+
const startDate: Date = this.reagingLoanForm.value.startDate;
90+
if (reagingLoanFormData.startDate instanceof Date) {
91+
reagingLoanFormData.startDate = this.dateUtils.formatDate(startDate, dateFormat);
92+
}
93+
const data = {
94+
...reagingLoanFormData,
95+
dateFormat,
96+
locale
97+
};
98+
99+
this.loanService.getReAgePreview(this.loanId, data).subscribe((response: any) => {
100+
this.dialog.open(ReAgePreviewDialogComponent, {
101+
data: {
102+
repaymentSchedule: response,
103+
currencyCode: response.currency?.code || 'USD'
104+
},
105+
width: '95%',
106+
maxWidth: '1400px',
107+
height: '90vh'
108+
});
109+
});
110+
}
111+
82112
submit(): void {
83113
const reagingLoanFormData = this.reagingLoanForm.value;
84114
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,24 @@ 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+
let httpParams = new HttpParams();
252+
253+
Object.keys(data).forEach(key => {
254+
if (data[key] !== null && data[key] !== undefined && data[key] !== '') {
255+
httpParams = httpParams.set(key, data[key].toString());
256+
}
257+
});
258+
259+
return this.http.get(`/loans/${loanId}/transactions/reage-preview`, { params: httpParams });
260+
}
261+
244262
getLoanScreenReportsData(): Observable<any> {
245263
const httpParams = new HttpParams().set('entityId', '1').set('typeId', '0');
246264
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
@@ -425,6 +425,7 @@
425425
"GSIM Application": "Aplikace GSIM",
426426
"Generate Report": "Vygenerovat zprávu",
427427
"Get Parameters": "Získat parametry",
428+
"Go back": "Vrátit se",
428429
"Go to next step": "Přejděte k dalšímu kroku",
429430
"Group Loan Application": "Žádost o skupinovou půjčku",
430431
"Group Saving Application": "Aplikace pro ukládání skupin",
@@ -459,6 +460,7 @@
459460
"Pie Chart": "Koláčový graf",
460461
"Post Dividend": "Vyplácet dividendu",
461462
"Previous": "Předchozí",
463+
"Preview": "Náhled",
462464
"Print": "Tisk",
463465
"Proceed": "Pokračovat",
464466
"Productive Collection Sheet": "Produktivní kolekce list",
@@ -1069,6 +1071,7 @@
10691071
"Reject Checker": "Odmítnout kontrolu",
10701072
"Release Amount": "Částka uvolnění",
10711073
"Repaid Every": "Splaceno každý",
1074+
"Repayment Schedule Preview": "Náhled splátkového kalendáře",
10721075
"Report Parameter": "Parametr sestavy",
10731076
"Reschedule Loan": "Přeplánovací půjčka",
10741077
"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
@@ -425,6 +425,7 @@
425425
"GSIM Application": "GSIM-Anwendung",
426426
"Generate Report": "Bericht generieren",
427427
"Get Parameters": "Parameter abrufen",
428+
"Go back": "Zurück",
428429
"Go to next step": "Gehen Sie zum nächsten Schritt",
429430
"Group Loan Application": "Gruppenkreditantrag",
430431
"Group Saving Application": "Gruppenspeicheranwendung",
@@ -459,6 +460,7 @@
459460
"Pie Chart": "Kuchendiagramm",
460461
"Post Dividend": "Post-Dividende",
461462
"Previous": "Vorherige",
463+
"Preview": "Vorschau",
462464
"Print": "Drucken",
463465
"Proceed": "Fortfahren",
464466
"Productive Collection Sheet": "Produktives Sammlungsblatt",
@@ -1070,6 +1072,7 @@
10701072
"Reject Checker": "Überprüfung ablehnen",
10711073
"Release Amount": "Freigabebetrag",
10721074
"Repaid Every": "Alle zurückgezahlt",
1075+
"Repayment Schedule Preview": "Rückzahlungsplan Vorschau",
10731076
"Report Parameter": "Berichtsparameter",
10741077
"Reschedule Loan": "Darlehen neu plant",
10751078
"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
@@ -426,6 +426,7 @@
426426
"GSIM Application": "GSIM Application",
427427
"Generate Report": "Generate Report",
428428
"Get Parameters": "Get Parameters",
429+
"Go back": "Go back",
429430
"Go to next step": "Go to next step",
430431
"Group Loan Application": "Group Loan Application",
431432
"Group Saving Application": "Group Saving Application",
@@ -460,6 +461,7 @@
460461
"Pie Chart": "Pie Chart",
461462
"Post Dividend": "Post Dividend",
462463
"Previous": "Previous",
464+
"Preview": "Preview",
463465
"Print": "Print",
464466
"Proceed": "Proceed",
465467
"Productive Collection Sheet": "Productive Collection Sheet",
@@ -1075,6 +1077,7 @@
10751077
"Reject Checker": "Reject Checker",
10761078
"Release Amount": "Release Amount",
10771079
"Repaid Every": "Repaid Every",
1080+
"Repayment Schedule Preview": "Repayment Schedule Preview",
10781081
"Report Parameter": "Report Parameter",
10791082
"Reschedule Loan": "Reschedule Loan",
10801083
"Revert Transaction": "Revert Transaction",

0 commit comments

Comments
 (0)