Support for Charge-off and Undo charge-off to Loan account (#1748)
Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
d294885f00
commit
b2aa39cb67
@@ -0,0 +1,58 @@
|
||||
<div class="container mat-elevation-z8">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="chargeoffLoanForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field (click)="transactionDatePicker.open()">
|
||||
<mat-label>Transaction Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="transactionDatePicker" required
|
||||
formControlName="transactionDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="transactionDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #transactionDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="chargeoffLoanForm.controls.transactionDate.hasError('required')">
|
||||
Transaction Date <strong>is required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Reason for Charge-Off</mat-label>
|
||||
<mat-select formControlName="chargeOffReasonId">
|
||||
<mat-option *ngFor="let chargeOffReason of chargeOffReasonOptions" [value]="chargeOffReason.id">
|
||||
{{ chargeOffReason.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="chargeoffLoanForm.controls.chargeOffReasonId.hasError('required')">
|
||||
Reason for Charge-Off <strong>is required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>External Id</mat-label>
|
||||
<input matInput formControlName="externalId">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Note</mat-label>
|
||||
<textarea matInput formControlName="note" cdkTextareaAutosize cdkAutosizeMinRows="2"></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||
<button type="button" mat-raised-button [routerLink]="['../../general']">Cancel</button>
|
||||
<button mat-raised-button color="primary" [disabled]="!chargeoffLoanForm.valid"
|
||||
*mifosxHasPermission="'CHARGEOFF_LOAN'">Submit</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ChargeOffComponent } from './charge-off.component';
|
||||
|
||||
describe('ChargeOffComponent', () => {
|
||||
let component: ChargeOffComponent;
|
||||
let fixture: ComponentFixture<ChargeOffComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ChargeOffComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ChargeOffComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, 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-charge-off',
|
||||
templateUrl: './charge-off.component.html',
|
||||
styleUrls: ['./charge-off.component.scss']
|
||||
})
|
||||
export class ChargeOffComponent 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();
|
||||
/** Repayment Loan Form */
|
||||
chargeoffLoanForm: FormGroup;
|
||||
|
||||
chargeOffReasonOptions: any = [];
|
||||
|
||||
/**
|
||||
* @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: FormBuilder,
|
||||
private loanService: LoansService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dateUtils: Dates,
|
||||
private settingsService: SettingsService) {
|
||||
this.loanId = this.route.snapshot.params['loanId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the repayment loan form
|
||||
* and initialize with the required values
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.maxDate = this.settingsService.businessDate;
|
||||
this.chargeOffReasonOptions = this.dataObject.chargeOffReasonOptions;
|
||||
this.createChargeoffLoanForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the create close form.
|
||||
*/
|
||||
createChargeoffLoanForm() {
|
||||
this.chargeoffLoanForm = this.formBuilder.group({
|
||||
'transactionDate': [this.settingsService.businessDate, Validators.required],
|
||||
'externalId': '',
|
||||
'chargeOffReasonId': '',
|
||||
'note': ''
|
||||
});
|
||||
}
|
||||
|
||||
submit() {
|
||||
const chargeoffLoanFormData = this.chargeoffLoanForm.value;
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const prevTransactionDate: Date = this.chargeoffLoanForm.value.transactionDate;
|
||||
if (chargeoffLoanFormData.transactionDate instanceof Date) {
|
||||
chargeoffLoanFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
|
||||
}
|
||||
const data = {
|
||||
...chargeoffLoanFormData,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
const command = 'charge-off';
|
||||
this.loanService.submitLoanActionButton(this.loanId, data, command)
|
||||
.subscribe((response: any) => {
|
||||
this.router.navigate(['../../transactions'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,3 +25,5 @@
|
||||
<mifosx-approve-loan *ngIf="actions['Approve']" ></mifosx-approve-loan>
|
||||
<mifosx-add-loan-charge *ngIf="actions['Add Loan Charge']"></mifosx-add-loan-charge>
|
||||
<mifosx-edit-repayment-schedule *ngIf="actions['Edit Repayment Schedule']"></mifosx-edit-repayment-schedule>
|
||||
<mifosx-charge-off [dataObject]="actionButtonData" *ngIf="actions['Charge-Off']"></mifosx-charge-off>
|
||||
<mifosx-undo-command [actionName]="actionName" *ngIf="actions['Undo Charge-Off']"></mifosx-undo-command>
|
||||
|
||||
@@ -40,7 +40,9 @@ export class LoanAccountActionsComponent {
|
||||
'Merchant Issued Refund': boolean,
|
||||
'Payout Refund': boolean,
|
||||
'Credit Balance Refund': boolean,
|
||||
'Edit Repayment Schedule': boolean
|
||||
'Edit Repayment Schedule': boolean,
|
||||
'Charge-Off': boolean,
|
||||
'Undo Charge-Off': boolean
|
||||
} = {
|
||||
'Close': false,
|
||||
'Undo Approval': false,
|
||||
@@ -69,7 +71,9 @@ export class LoanAccountActionsComponent {
|
||||
'Merchant Issued Refund': false,
|
||||
'Payout Refund': false,
|
||||
'Credit Balance Refund': false,
|
||||
'Edit Repayment Schedule': false
|
||||
'Edit Repayment Schedule': false,
|
||||
'Charge-Off': false,
|
||||
'Undo Charge-Off': false
|
||||
};
|
||||
|
||||
actionButtonData: any;
|
||||
|
||||
+6
-2
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@@ -16,7 +16,7 @@ import { Dates } from 'app/core/utils/dates';
|
||||
templateUrl: './make-repayment.component.html',
|
||||
styleUrls: ['./make-repayment.component.scss']
|
||||
})
|
||||
export class MakeRepaymentComponent implements OnInit {
|
||||
export class MakeRepaymentComponent implements OnInit, OnDestroy {
|
||||
|
||||
@Input() dataObject: any;
|
||||
/** Loan Id */
|
||||
@@ -58,6 +58,10 @@ export class MakeRepaymentComponent implements OnInit {
|
||||
this.setRepaymentLoanDetails();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the create close form.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Dates } from 'app/core/utils/dates';
|
||||
templateUrl: './prepay-loan.component.html',
|
||||
styleUrls: ['./prepay-loan.component.scss']
|
||||
})
|
||||
export class PrepayLoanComponent implements OnInit {
|
||||
export class PrepayLoanComponent implements OnInit, OnDestroy {
|
||||
|
||||
@Input() dataObject: any;
|
||||
/** Loan Id */
|
||||
@@ -66,6 +66,9 @@ export class PrepayLoanComponent implements OnInit {
|
||||
this.prepayData = this.dataObject;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the prepay loan form.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user