-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new interest pause and list existing interest pause periods of th…
…e loan
- Loading branch information
1 parent
a645521
commit d04890f
Showing
37 changed files
with
400 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/app/loans/common-resolvers/loan-term-variations.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** Angular Imports */ | ||
import { Injectable } from '@angular/core'; | ||
import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; | ||
|
||
/** rxjs Imports */ | ||
import { Observable } from 'rxjs'; | ||
|
||
/** Custom Services */ | ||
import { LoansService } from '../loans.service'; | ||
|
||
/** | ||
* Clients data resolver. | ||
*/ | ||
@Injectable() | ||
export class LoanTermVariationsResolver implements Resolve<Object> { | ||
|
||
/** | ||
* @param {LoansService} LoansService Loans service. | ||
*/ | ||
constructor(private loansService: LoansService) { } | ||
|
||
/** | ||
* Returns the Loans with Association data. | ||
* @returns {Observable<any>} | ||
*/ | ||
resolve(route: ActivatedRouteSnapshot): Observable<any> { | ||
const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId'); | ||
if (!isNaN(+loanId)) { | ||
return this.loansService.getInterestPausesOfLoan(loanId); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...oans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<div class="container mat-elevation-z8"> | ||
<mat-card> | ||
<form [formGroup]="interestPauseLoanForm" (ngSubmit)="submit()"> | ||
<mat-card-content> | ||
<div fxLayout="column"> | ||
<mat-form-field (click)="startDatePicker.open()"> | ||
<mat-label>{{ 'labels.inputs.Start Date' | translate }}</mat-label> | ||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="startDatePicker" | ||
required formControlName="startDate" /> | ||
<mat-datepicker-toggle matSuffix [for]="startDatePicker"></mat-datepicker-toggle> | ||
<mat-datepicker #startDatePicker></mat-datepicker> | ||
<mat-error *ngIf="interestPauseLoanForm.controls.startDate.hasError('required')"> | ||
{{ 'labels.inputs.Start Date' | translate | ||
}}<strong>{{ 'labels.commons.required' | translate }}</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
|
||
<mat-form-field (click)="endDatePicker.open()"> | ||
<mat-label>{{ 'labels.inputs.End Date' | translate }}</mat-label> | ||
<input matInput [min]="interestPauseLoanForm.value.startDate" [max]="maxDate" [matDatepicker]="endDatePicker" | ||
required formControlName="endDate" /> | ||
<mat-datepicker-toggle matSuffix [for]="endDatePicker"></mat-datepicker-toggle> | ||
<mat-datepicker #endDatePicker></mat-datepicker> | ||
<mat-error *ngIf="interestPauseLoanForm.controls.endDate.hasError('required')"> | ||
{{ 'labels.inputs.End Date' | translate | ||
}}<strong>{{ 'labels.commons.required' | translate }}</strong> | ||
</mat-error> | ||
</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]="!interestPauseLoanForm.valid" | ||
*mifosxHasPermission="'DISBURSE_LOAN'"> | ||
{{ 'labels.buttons.Submit' | translate }} | ||
</button> | ||
</mat-card-actions> | ||
</mat-card-content> | ||
</form> | ||
</mat-card> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
...oans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.expandcollapsebutton { | ||
margin-top: -7px; | ||
} | ||
|
||
.container { | ||
max-width: 37rem; | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
...s/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { AddInterestPauseComponent } from './add-interest-pause.component'; | ||
|
||
describe('AddInterestPauseComponent', () => { | ||
let component: AddInterestPauseComponent; | ||
let fixture: ComponentFixture<AddInterestPauseComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ AddInterestPauseComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AddInterestPauseComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
96 changes: 96 additions & 0 deletions
96
.../loans/loans-view/loan-account-actions/add-interest-pause/add-interest-pause.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; | ||
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'; | ||
|
||
@Component({ | ||
selector: 'mifosx-add-interest-pause', | ||
templateUrl: './add-interest-pause.component.html', | ||
styleUrls: ['./add-interest-pause.component.scss'] | ||
}) | ||
export class AddInterestPauseComponent implements OnInit { | ||
|
||
@Input() dataObject: any; | ||
/** Loan Id */ | ||
loanId: string; | ||
/** Payment Type Options */ | ||
paymentTypes: any; | ||
/** Show payment details */ | ||
showPaymentDetails = false; | ||
/** Minimum Date allowed. */ | ||
minDate = new Date(2000, 0, 1); | ||
/** Maximum Date allowed. */ | ||
maxDate = new Date(); | ||
startDate = new Date(); | ||
/** Interest Pause Loan Form */ | ||
interestPauseLoanForm: UntypedFormGroup; | ||
|
||
/** | ||
* @param {FormBuilder} formBuilder Form Builder. | ||
* @param {LoansService} loanService Loan Service. | ||
* @param {ActivatedRoute} route Activated Route. | ||
* @param {Router} router Router for navigation. | ||
* @param {SettingsService} settingsService Settings Service | ||
*/ | ||
constructor(private formBuilder: UntypedFormBuilder, | ||
private loanService: LoansService, | ||
private route: ActivatedRoute, | ||
private router: Router, | ||
private dateUtils: Dates, | ||
private settingsService: SettingsService) { | ||
|
||
this.loanId = this.route.snapshot.params['loanId']; | ||
} | ||
|
||
/** | ||
* Creates the Interest Pause loan form | ||
* and initialize with the required values | ||
*/ | ||
ngOnInit() { | ||
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 { | ||
this.startDate = this.maxDate; | ||
} | ||
this.createInterestPauseLoanForm(); | ||
} | ||
|
||
/** | ||
* Creates the Interest Pause loan form. | ||
*/ | ||
createInterestPauseLoanForm() { | ||
this.interestPauseLoanForm = this.formBuilder.group({ | ||
'startDate': [this.startDate, Validators.required], | ||
'endDate': [this.startDate, Validators.required] | ||
}); | ||
} | ||
|
||
/** Submits the Interest Pause form */ | ||
submit() { | ||
const interestPauseLoanFormData = this.interestPauseLoanForm.value; | ||
const locale = this.settingsService.language.code; | ||
const dateFormat = this.settingsService.dateFormat; | ||
const startDate: Date = this.interestPauseLoanForm.value.startDate; | ||
if (interestPauseLoanFormData.startDate instanceof Date) { | ||
interestPauseLoanFormData.startDate = this.dateUtils.formatDate(startDate, dateFormat); | ||
} | ||
const endDate: Date = this.interestPauseLoanForm.value.endDate; | ||
if (interestPauseLoanFormData.endDate instanceof Date) { | ||
interestPauseLoanFormData.endDate = this.dateUtils.formatDate(endDate, dateFormat); | ||
} | ||
const data = { | ||
...interestPauseLoanFormData, | ||
dateFormat, | ||
locale | ||
}; | ||
this.loanService.addInterestPauseToLoan(this.loanId, data ) | ||
.subscribe((response: any) => { | ||
this.router.navigate(['../../term-variations'], { relativeTo: this.route }); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.