diff --git a/src/app/loans/common-resolvers/loan-action-button.resolver.ts b/src/app/loans/common-resolvers/loan-action-button.resolver.ts index a0e8c6aa4..21d5c6615 100644 --- a/src/app/loans/common-resolvers/loan-action-button.resolver.ts +++ b/src/app/loans/common-resolvers/loan-action-button.resolver.ts @@ -34,6 +34,10 @@ export class LoanActionButtonResolver implements Resolve { return this.loansService.getLoanActionTemplate(loanId, 'waiveinterest'); } else if (loanActionButton === 'write-off') { return this.loansService.getLoanActionTemplate(loanId, 'writeoff'); + } else if (loanActionButton === 'close') { + return this.loansService.getLoanActionTemplate(loanId, 'close'); + } else if (loanActionButton === 'close-as-rescheduled') { + return this.loansService.getLoanActionTemplate(loanId, 'close-rescheduled'); } else { return this.loansService.getLoanActionTemplate(loanId, 'prepayLoan'); } diff --git a/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.html b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.html new file mode 100644 index 000000000..2a75397fa --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.html @@ -0,0 +1,35 @@ +
+ +
+ + + +
+ + + Closed On + + + + + Closed Date is required + + + + + Note + + + +
+ + + + + + +
+ +
+ +
diff --git a/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.scss b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.spec.ts b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.spec.ts new file mode 100644 index 000000000..f2ece1ef1 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CloseAsRescheduledComponent } from './close-as-rescheduled.component'; + +describe('CloseAsRescheduledComponent', () => { + let component: CloseAsRescheduledComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CloseAsRescheduledComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CloseAsRescheduledComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts new file mode 100644 index 000000000..98f2bb6f3 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts @@ -0,0 +1,74 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { LoansService } from 'app/loans/loans.service'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DatePipe } from '@angular/common'; + +@Component({ + selector: 'mifosx-close-as-rescheduled', + templateUrl: './close-as-rescheduled.component.html', + styleUrls: ['./close-as-rescheduled.component.scss'] +}) +export class CloseAsRescheduledComponent implements OnInit { + + @Input() dataObject: any; + + /** Close form. */ + closeLoanForm: FormGroup; + /** Loan Id */ + loanId: any; + /** Minimum Date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum Date allowed. */ + maxDate = new Date(); + + /** + * @param {FormBuilder} formBuilder Form Builder. + * @param {LoansService} systemService Loan Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private formBuilder: FormBuilder, + private loanService: LoansService, + private route: ActivatedRoute, + private router: Router, + private datePipe: DatePipe) { + this.loanId = this.route.parent.snapshot.params['loanId']; + } + + /** + * Creates the close form. + */ + ngOnInit() { + this.createCloseForm(); + } + + /** + * Creates the create close form. + */ + createCloseForm() { + this.closeLoanForm = this.formBuilder.group({ + 'transactionDate': [new Date(this.dataObject.date) || new Date(), Validators.required], + 'note': [] + }); + } + + /** + * Submits the close form and creates a close, + * if successful redirects to view created close. + */ + submit() { + const transactionDate = this.closeLoanForm.value.transactionDate; + const dateFormat = 'yyyy-MM-dd'; + this.closeLoanForm.patchValue({ + transactionDate: this.datePipe.transform(transactionDate, dateFormat) + }); + const closeForm = this.closeLoanForm.value; + closeForm.locale = 'en'; + closeForm.dateFormat = dateFormat; + this.loanService.submitLoanActionButton(this.loanId, closeForm, 'close-rescheduled') + .subscribe((response: any) => { + this.router.navigate(['../general'], { relativeTo: this.route }); + }); + } +} diff --git a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html index 1f941173d..9f9877ded 100644 --- a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html +++ b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html @@ -1,6 +1,6 @@
- + @@ -8,5 +8,6 @@ +
diff --git a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts index be3138ec3..d34bdcdfc 100644 --- a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts @@ -20,7 +20,8 @@ export class LoanAccountActionsComponent { foreclosure: boolean, prepay_loan: boolean, make_repayment: boolean, - waive_interest: boolean } = { + waive_interest: boolean, + close_as_rescheduled: boolean } = { close: false, undo_approval: false, write_off: false, @@ -28,7 +29,8 @@ export class LoanAccountActionsComponent { foreclosure: false, prepay_loan: false, make_repayment: false, - waive_interest: false }; + waive_interest: false, + close_as_rescheduled: false }; actionButtonData: any; actionName: any; diff --git a/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.html b/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.html index f8870f4ef..087831899 100644 --- a/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.html +++ b/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.html @@ -25,7 +25,7 @@ - + diff --git a/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts b/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts index 2335d44b5..8c8a3faa8 100644 --- a/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts @@ -1,5 +1,5 @@ /** Angular Imports */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; import { LoansService } from 'app/loans/loans.service'; @@ -12,6 +12,8 @@ import { DatePipe } from '@angular/common'; }) export class LoansAccountCloseComponent implements OnInit { + @Input() dataObject: any; + /** Close form. */ closeLoanForm: FormGroup; /** Loan Id */ @@ -47,7 +49,7 @@ export class LoansAccountCloseComponent implements OnInit { */ createCloseForm() { this.closeLoanForm = this.formBuilder.group({ - 'transactionDate': [new Date(), Validators.required], + 'transactionDate': [new Date(this.dataObject.date) || new Date(), Validators.required], 'note': [] }); } diff --git a/src/app/loans/loans-view/loans-view.component.ts b/src/app/loans/loans-view/loans-view.component.ts index 4705cca55..f0a2f403c 100644 --- a/src/app/loans/loans-view/loans-view.component.ts +++ b/src/app/loans/loans-view/loans-view.component.ts @@ -112,6 +112,8 @@ export class LoansViewComponent implements OnInit { loanAction(button: string) { button = button.replace(/\s/g, '-').toLowerCase(); + button = button.replace(/\(/g, ''); + button = button.replace(/\)/g, ''); this.router.navigate([button], { relativeTo: this.route }); } diff --git a/src/app/loans/loans.module.ts b/src/app/loans/loans.module.ts index 9b6d06d1d..5e0a3555a 100644 --- a/src/app/loans/loans.module.ts +++ b/src/app/loans/loans.module.ts @@ -33,6 +33,7 @@ import { WaiveInterestComponent } from './loans-view/loan-account-actions/waive- import { FloatingInterestRatesComponent } from './loans-view/floating-interest-rates/floating-interest-rates.component'; import { WriteOffPageComponent } from './loans-view/loan-account-actions/write-off-page/write-off-page.component'; import { LoanTrancheDetailsComponent } from './loans-view/loan-tranche-details/loan-tranche-details.component'; +import { CloseAsRescheduledComponent } from './loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component'; /** * Loans Module @@ -66,6 +67,7 @@ import { LoanTrancheDetailsComponent } from './loans-view/loan-tranche-details/l FloatingInterestRatesComponent, WriteOffPageComponent, LoanTrancheDetailsComponent, + CloseAsRescheduledComponent, ], providers: [DatePipe], })