diff --git a/src/app/loans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.ts b/src/app/loans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.ts
index 4d82884b7..dc92290cc 100644
--- a/src/app/loans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.ts
+++ b/src/app/loans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.ts
@@ -24,6 +24,7 @@ export class AddInterestPauseComponent implements OnInit {
/** Maximum Date allowed. */
maxDate = new Date();
startDate = new Date();
+ maturityDate: Date | null = null;
/** Interest Pause Loan Form */
interestPauseLoanForm: UntypedFormGroup;
@@ -49,11 +50,10 @@ export class AddInterestPauseComponent implements OnInit {
* and initialize with the required values
*/
ngOnInit() {
+ this.maturityDate = new Date(this.dataObject.timeline.expectedMaturityDate);
this.maxDate = new Date(this.dataObject.timeline.expectedMaturityDate);
this.startDate = new Date(this.settingsService.businessDate);
- if (this.startDate < this.maxDate) {
- this.maxDate = this.startDate;
- } else {
+ if (this.startDate > this.maxDate) {
this.startDate = this.maxDate;
}
this.createInterestPauseLoanForm();
diff --git a/src/app/loans/loans-view/loan-accounts-button-config.ts b/src/app/loans/loans-view/loan-accounts-button-config.ts
index 3cd91f19b..9e9a39855 100644
--- a/src/app/loans/loans-view/loan-accounts-button-config.ts
+++ b/src/app/loans/loans-view/loan-accounts-button-config.ts
@@ -159,10 +159,6 @@ export class LoansAccountButtonConfiguration {
switch (status) {
case 'Active':
this.optionArray = [
- {
- name: 'Add Interest Pause',
- taskPermissionName: 'CREATE_INTEREST_PAUSE',
- },
{
name: 'Waive Interest',
taskPermissionName: 'WAIVEINTERESTPORTION_LOAN',
diff --git a/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.html b/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.html
index eb28313da..9831ad729 100644
--- a/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.html
+++ b/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.html
@@ -23,7 +23,7 @@
|
-
{{ 'labels.heading.Interest Pauses' | translate }}
+
0">{{ 'labels.heading.Interest Pauses' | translate }}
0">
| # |
@@ -45,6 +45,22 @@
{{ item.days | formatNumber }} |
+
+ {{ 'labels.inputs.Actions' | translate }} |
+
+
+
+ |
+
+
diff --git a/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.scss b/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.scss
index 984984957..52cc25774 100644
--- a/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.scss
+++ b/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.scss
@@ -1,5 +1,12 @@
table {
width: 100%;
+
+ .action-button {
+ min-width: 26px;
+ padding: 0 0 3px;
+ margin: 0 2%;
+ line-height: 25px;
+ }
}
.container {
diff --git a/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.ts b/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.ts
index 4ca650000..66f586c84 100644
--- a/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.ts
+++ b/src/app/loans/loans-view/loan-term-variations-tab/loan-term-variations-tab.component.ts
@@ -1,6 +1,14 @@
import { Component } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+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 { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
+import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
+import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
+import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
+import { AnyKindOfDictionary } from 'cypress/types/lodash';
@Component({
selector: 'mifosx-loan-term-variations-tab',
@@ -14,13 +22,22 @@ export class LoanTermVariationsTabComponent {
loanDTermVariationsColumns: string[] = ['termType', 'applicableFrom', 'value', 'specificToInstallment'];
/** Interest Pauses Data */
interestPausesData: any[] = [];
- interestPausesColumns: string[] = ['row', 'startDate', 'endDate', 'days'];
+ interestPausesColumns: string[] = ['row', 'startDate', 'endDate', 'days', 'actions'];
+
+ loanId: number;
+ clientId: AnyKindOfDictionary;
constructor(private route: ActivatedRoute,
- private dates: Dates
+ private router: Router,
+ private dates: Dates,
+ private settingsService: SettingsService,
+ private loansService: LoansService,
+ private dialog: MatDialog
) {
this.interestPausesData = [];
+ this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId');
this.route.data.subscribe((data: { loanDetailsData: any, interestPausesData: any }) => {
+ this.loanId = data.loanDetailsData.id;
this.loanTermVariationsData = data.loanDetailsData.loanTermVariations;
this.interestPausesData = [];
data.interestPausesData?.forEach((item: any) => {
@@ -29,4 +46,76 @@ export class LoanTermVariationsTabComponent {
});
});
}
+
+ manageRequest(variation: any, action: string) {
+ if (action === 'Delete') {
+ this.deleteInterestPause(variation);
+ } else if (action === 'Edit') {
+ this.updateInterestPause(variation);
+ }
+ }
+
+ deleteInterestPause(variation: any) {
+ const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, {
+ data: { deleteContext: `interest pause from ${variation.startDate} to ${variation.endDate}` }
+ });
+ deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
+ if (response.delete) {
+ this.loansService.deleteInterestPause(this.loanId, variation.id).subscribe((response: any) => {
+ this.reload();
+ });
+ }
+ });
+ }
+
+ updateInterestPause(variation: any) {
+ const startDate: Date = this.dates.parseDate(variation.startDate);
+ const endDate: Date = this.dates.parseDate(variation.endDate);
+ const formfields: FormfieldBase[] = [
+ new DatepickerBase({
+ controlName: 'startDate',
+ label: 'Start Date',
+ value: startDate,
+ maxDate: this.settingsService.maxFutureDate,
+ required: true
+ }),
+ new DatepickerBase({
+ controlName: 'endDate',
+ label: 'End Date',
+ value: endDate,
+ maxDate: this.settingsService.maxFutureDate,
+ required: true
+ }),
+ ];
+
+ const data = {
+ title: 'Edit Interest Pause id: ' + variation.id,
+ formfields: formfields,
+ layout: { addButtonText: 'Submit' }
+ };
+ const editDialogRef = this.dialog.open(FormDialogComponent, { data, width: '50rem' });
+ editDialogRef.afterClosed().subscribe((response: any) => {
+ if (response.data) {
+ if (response.data.value.startDate <= response.data.value.endDate) {
+ const locale = this.settingsService.language.code;
+ const dateFormat = this.settingsService.dateFormat;
+ const payload = {
+ startDate: this.dates.formatDate(response.data.value.startDate, dateFormat),
+ endDate: this.dates.formatDate(response.data.value.endDate, dateFormat),
+ locale,
+ dateFormat
+ }
+ this.loansService.updateInterestPause(this.loanId, variation.id, payload).subscribe((response: any) => {
+ this.reload();
+ });
+ }
+ }
+ });
+ }
+
+ private reload() {
+ const url: string = this.router.url;
+ this.router.navigateByUrl(`/clients/${this.clientId}/loans-accounts`, { skipLocationChange: true })
+ .then(() => this.router.navigate([url]));
+ }
}
diff --git a/src/app/loans/loans-view/loans-view.component.ts b/src/app/loans/loans-view/loans-view.component.ts
index 23d4465a4..c2b1366ff 100644
--- a/src/app/loans/loans-view/loans-view.component.ts
+++ b/src/app/loans/loans-view/loans-view.component.ts
@@ -151,6 +151,13 @@ export class LoansViewComponent implements OnInit {
taskPermissionName: 'DISBURSALLASTUNDO_LOAN'
});
}
+ if (this.recalculateInterest) {
+ this.buttonConfig.addButton({
+ name: 'Add Interest Pause',
+ icon: 'calendar',
+ taskPermissionName: 'CREATE_INTEREST_PAUSE'
+ });
+ }
// loan officer not assigned to loan, below logic
// helps to display otherwise not
if (!this.loanDetailsData.loanOfficerName) {
diff --git a/src/app/loans/loans.service.ts b/src/app/loans/loans.service.ts
index f7be0892b..fae5ce905 100644
--- a/src/app/loans/loans.service.ts
+++ b/src/app/loans/loans.service.ts
@@ -285,6 +285,14 @@ export class LoansService {
return this.http.get(`/loans/${loanId}/interest-pauses`);
}
+ updateInterestPause(loanId: number, variationId: number, data?: any): Observable
{
+ return this.http.put(`/loans/${loanId}/interest-pauses/${variationId}`, data);
+ }
+
+ deleteInterestPause(loanId: number, variationId: number): Observable {
+ return this.http.delete(`/loans/${loanId}/interest-pauses/${variationId}`);
+ }
+
/**
* @param {string|number} loanId Loan Id.
* @param {any} foreclosuredata ForeClosure Data