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 982d883c8..ab6647557 100644 --- a/src/app/loans/common-resolvers/loan-action-button.resolver.ts +++ b/src/app/loans/common-resolvers/loan-action-button.resolver.ts @@ -30,6 +30,8 @@ export class LoanActionButtonResolver implements Resolve { return this.loansService.getLoanTemplate(loanId); // } else if (loanActionButton === 'make-repayment') { // return this.loansService.getLoanActionTemplate(loanId, 'repayment'); + } else if (loanActionButton === 'waive-interest') { + return this.loansService.getLoanActionTemplate(loanId, 'waiveinterest'); } else { return this.loansService.getLoanActionTemplate(loanId, 'prepayLoan'); } 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 494f69dd2..316ed790e 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 @@ -6,5 +6,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 4d096e31b..0c428a94f 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 @@ -18,13 +18,15 @@ export class LoanAccountActionsComponent { assign_loan_officer: boolean, foreclosure: boolean, prepay_loan: boolean, - make_repayment: boolean } = { + make_repayment: boolean, + waive_interest: boolean } = { close: false, undo_approval: false, assign_loan_officer: false, foreclosure: false, prepay_loan: false, - make_repayment: false }; + make_repayment: false, + waive_interest: false }; actionButtonData: any; actionName: any; diff --git a/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.html b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.html new file mode 100644 index 000000000..de973ee2b --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.html @@ -0,0 +1,43 @@ +
+ +
+ + + +
+ + + Interest waived on + + + + + Interest Date is required + + + + + Transaction amount + + + Transaction Amount is required + + + + + Note + + + +
+ + + + + + +
+ +
+ +
diff --git a/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.scss b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.spec.ts b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.spec.ts new file mode 100644 index 000000000..1d7c7217a --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WaiveInterestComponent } from './waive-interest.component'; + +describe('WaiveInterestComponent', () => { + let component: WaiveInterestComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WaiveInterestComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WaiveInterestComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts new file mode 100644 index 000000000..b4cb5113c --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts @@ -0,0 +1,78 @@ +/** Angular Imports. */ +import { Component, OnInit, Input } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { Router, ActivatedRoute } from '@angular/router'; +import { DatePipe } from '@angular/common'; + +/** Custom Services. */ +import { LoansService } from 'app/loans/loans.service'; + +/** + * Waive Interest component. + */ +@Component({ + selector: 'mifosx-waive-interest', + templateUrl: './waive-interest.component.html', + styleUrls: ['./waive-interest.component.scss'] +}) +export class WaiveInterestComponent implements OnInit { + + @Input() dataObject: any; + + /** Loan Interest form. */ + loanInterestForm: FormGroup; + /** Minimum Date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum Date allowed. */ + maxDate = new Date(); + + /** + * Get data from `Resolver`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {Router} router Router. + * @param {DatePipe} datePipe DatePipe. + * @param {LoansService} loanService Loan Service. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private formBuilder: FormBuilder, + private router: Router, + private datePipe: DatePipe, + private loanService: LoansService, + private route: ActivatedRoute) { } + + ngOnInit() { + this.setLoanInterestForm(); + } + + /** + * Set Loan Interest form. + */ + setLoanInterestForm() { + this.loanInterestForm = this.formBuilder.group({ + 'transactionAmount': [this.dataObject.amount, Validators.required], + 'transactionDate': [this.dataObject.date && new Date(this.dataObject.date), Validators.required], + 'note': [''] + }); + } + + /** + * Submits loan interest form. + */ + submit() { + const transactionDate = this.loanInterestForm.value.transactionDate; + const transactionAmount = this.loanInterestForm.value.transactionAmount; + const dateFormat = 'dd MMMM yyyy'; + this.loanInterestForm.patchValue({ + transactionDate: this.datePipe.transform(transactionDate, dateFormat), + transactionAmount: parseInt(transactionAmount, 10) + }); + const loanId = this.route.parent.snapshot.params['loanId']; + const loanInterestForm = this.loanInterestForm.value; + loanInterestForm.locale = 'en'; + loanInterestForm.dateFormat = dateFormat; + this.loanService.submitLoanActionButton(loanId, loanInterestForm, 'waiveinterest').subscribe((response: any) => { + this.router.navigate(['../general'], {relativeTo: this.route}); + }); + } + +} diff --git a/src/app/loans/loans.module.ts b/src/app/loans/loans.module.ts index f66eddd45..5eb120545 100644 --- a/src/app/loans/loans.module.ts +++ b/src/app/loans/loans.module.ts @@ -29,6 +29,7 @@ import { AssignLoanOfficerComponent } from './loans-view/loan-account-actions/as import { ForeclosureComponent } from './loans-view/loan-account-actions/foreclosure/foreclosure.component'; import { PrepayLoanComponent } from './loans-view/loan-account-actions/prepay-loan/prepay-loan.component'; import { MakeRepaymentComponent } from './loans-view/loan-account-actions/make-repayment/make-repayment.component'; +import { WaiveInterestComponent } from './loans-view/loan-account-actions/waive-interest/waive-interest.component'; /** * Loans Module @@ -58,6 +59,7 @@ import { MakeRepaymentComponent } from './loans-view/loan-account-actions/make-r ForeclosureComponent, PrepayLoanComponent, MakeRepaymentComponent, + WaiveInterestComponent, ], providers: [DatePipe], })