@@ -32,6 +32,8 @@ export class LoanActionButtonResolver implements Resolve<Object> {
|
||||
// return this.loansService.getLoanActionTemplate(loanId, 'repayment');
|
||||
} else if (loanActionButton === 'waive-interest') {
|
||||
return this.loansService.getLoanActionTemplate(loanId, 'waiveinterest');
|
||||
} else if (loanActionButton === 'write-off') {
|
||||
return this.loansService.getLoanActionTemplate(loanId, 'writeoff');
|
||||
} else {
|
||||
return this.loansService.getLoanActionTemplate(loanId, 'prepayLoan');
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
<mifosx-prepay-loan [dataObject]="actionButtonData" *ngIf="actions.prepay_loan"></mifosx-prepay-loan>
|
||||
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions.make_repayment"></mifosx-make-repayment>
|
||||
<mifosx-waive-interest [dataObject]="actionButtonData" *ngIf="actions.waive_interest"></mifosx-waive-interest>
|
||||
<mifosx-write-off-page [dataObject]="actionButtonData" *ngIf="actions.write_off"></mifosx-write-off-page>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,7 @@ export class LoanAccountActionsComponent {
|
||||
/** flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: { close: boolean,
|
||||
undo_approval: boolean,
|
||||
write_off: boolean,
|
||||
assign_loan_officer: boolean,
|
||||
foreclosure: boolean,
|
||||
prepay_loan: boolean,
|
||||
@@ -22,6 +23,7 @@ export class LoanAccountActionsComponent {
|
||||
waive_interest: boolean } = {
|
||||
close: false,
|
||||
undo_approval: false,
|
||||
write_off: false,
|
||||
assign_loan_officer: false,
|
||||
foreclosure: false,
|
||||
prepay_loan: false,
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<form [formGroup]="writeOffForm" (ngSubmit)="submit()">
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Write off on</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="writeOffDatePicker" required formControlName="transactionDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="writeOffDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #writeOffDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="writeOffForm.controls.transactionDate.hasError('required')">
|
||||
Write Off Date <strong>is required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Amount</mat-label>
|
||||
<input matInput formControlName="amount">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Note</mat-label>
|
||||
<textarea matInput formControlName="note"></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
|
||||
<button mat-raised-button color="primary" (click)="submit()" *mifosxHasPermission="'WRITEOFF_LOAN'">Submit</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</div>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WriteOffPageComponent } from './write-off-page.component';
|
||||
|
||||
describe('WriteOffPageComponent', () => {
|
||||
let component: WriteOffPageComponent;
|
||||
let fixture: ComponentFixture<WriteOffPageComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ WriteOffPageComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(WriteOffPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/** Angular Imports. */
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DatePipe } from '@angular/common';
|
||||
|
||||
/** Custom Services. */
|
||||
import { LoansService } from 'app/loans/loans.service';
|
||||
/**
|
||||
* Write Off component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-write-off-page',
|
||||
templateUrl: './write-off-page.component.html',
|
||||
styleUrls: ['./write-off-page.component.scss']
|
||||
})
|
||||
export class WriteOffPageComponent implements OnInit {
|
||||
|
||||
@Input() dataObject: any;
|
||||
|
||||
/** Write Off form. */
|
||||
writeOffForm: FormGroup;
|
||||
|
||||
/**
|
||||
* Get data from `Resolver`.
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {LoansService} loanService Loan Service.
|
||||
* @param {DatePipe} datePipe Date Pipe.
|
||||
* @param {Router} router Router.
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private loanService: LoansService,
|
||||
private datePipe: DatePipe,
|
||||
private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.setWriteOffForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Write Off form.
|
||||
*/
|
||||
setWriteOffForm() {
|
||||
this.writeOffForm = this.formBuilder.group({
|
||||
'transactionDate': [this.dataObject.date && new Date(this.dataObject.date), Validators.required],
|
||||
'amount': [{value: this.dataObject.amount, disabled: true}],
|
||||
'note': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits write off form.
|
||||
*/
|
||||
submit() {
|
||||
const transactionDate = this.writeOffForm.value.transactionDate;
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
this.writeOffForm.patchValue({
|
||||
transactionDate: this.datePipe.transform(transactionDate, dateFormat)
|
||||
});
|
||||
const loanId = this.route.parent.snapshot.params['loanId'];
|
||||
const writeOffForm = this.writeOffForm.value;
|
||||
delete writeOffForm.amount;
|
||||
writeOffForm.locale = 'en';
|
||||
writeOffForm.dateFormat = dateFormat;
|
||||
this.loanService.submitLoanActionButton(loanId, writeOffForm, 'writeoff').subscribe((response: any) => {
|
||||
this.router.navigate(['../general'], {relativeTo: this.route});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import { PrepayLoanComponent } from './loans-view/loan-account-actions/prepay-lo
|
||||
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';
|
||||
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';
|
||||
|
||||
/**
|
||||
* Loans Module
|
||||
@@ -62,6 +63,7 @@ import { FloatingInterestRatesComponent } from './loans-view/floating-interest-r
|
||||
MakeRepaymentComponent,
|
||||
WaiveInterestComponent,
|
||||
FloatingInterestRatesComponent,
|
||||
WriteOffPageComponent,
|
||||
],
|
||||
providers: [DatePipe],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user