feat: add loan button (undo disbursal) (#852)

Fixes: #827
This commit is contained in:
Rishabh Verma
2020-07-14 16:44:26 +05:30
committed by GitHub
parent ffea1b5eaf
commit 39bf327fb2
7 changed files with 103 additions and 4 deletions
@@ -18,5 +18,6 @@
<mifosx-disburse [dataObject]="actionButtonData" *ngIf="actions.disburse"></mifosx-disburse>
<mifosx-withdrawn-by-client *ngIf="actions.withdrawn_by_client"></mifosx-withdrawn-by-client>
<mifosx-add-collateral [dataObject]="actionButtonData" *ngIf="actions.add_collateral"></mifosx-add-collateral>
<mifosx-undo-disbursal *ngIf="actions.undo_disbursal"></mifosx-undo-disbursal>
</mat-card>
</div>
@@ -30,7 +30,8 @@ export class LoanAccountActionsComponent {
view_guarantors: boolean,
create_guarantor: boolean,
disburse: boolean,
withdrawn_by_client: boolean } = {
withdrawn_by_client: boolean,
undo_disbursal: boolean } = {
close: false,
undo_approval: false,
write_off: false,
@@ -48,8 +49,8 @@ export class LoanAccountActionsComponent {
view_guarantors: false,
create_guarantor: false,
disburse: false,
withdrawn_by_client: false };
withdrawn_by_client: false,
undo_disbursal: false };
actionButtonData: any;
actionName: any;
@@ -0,0 +1,17 @@
<div class="container">
<mat-card-content>
<mat-form-field fxLayoutAlign="center">
<mat-label>Note</mat-label>
<textarea matInput [formControl]="note"></textarea>
</mat-form-field>
<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" (click)="submit()" *mifosxHasPermission="'DISBURSALUNDO_LOAN'">Submit</button>
</mat-card-actions>
</mat-card-content>
</div>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UndoDisbursalComponent } from './undo-disbursal.component';
describe('UndoDisbursalComponent', () => {
let component: UndoDisbursalComponent;
let fixture: ComponentFixture<UndoDisbursalComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UndoDisbursalComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UndoDisbursalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,53 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormControl, FormBuilder } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */
import { LoansService } from '../../../loans.service';
/**
* Undo Disbursal component.
*/
@Component({
selector: 'mifosx-undo-disbursal',
templateUrl: './undo-disbursal.component.html',
styleUrls: ['./undo-disbursal.component.scss']
})
export class UndoDisbursalComponent implements OnInit {
/** Loan ID. */
loanId: any;
/** Undo disbursal form. */
note: FormControl;
/**
* @param {FormBuilder} formBuilder Form Builder.
* @param {LoansService} loansService Loans Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private loansService: LoansService,
private router: Router,
private route: ActivatedRoute) {
this.loanId = this.route.parent.snapshot.params['loanId'];
}
/**
* Creates the undo disbursal form.
*/
ngOnInit() {
this.note = this.formBuilder.control('');
}
/**
* Submits the undo disbursal form.
*/
submit() {
this.loansService.loanActionButtons(this.loanId, 'undoDisbursal', {'note': this.note.value}).subscribe((response: any) => {
this.router.navigate(['../general'], { relativeTo: this.route });
});
}
}
+3 -1
View File
@@ -48,6 +48,7 @@ import { DisburseLoanAccountComponent } from './loans-view/loan-account-actions/
import { DisburseComponent } from './loans-view/loan-account-actions/disburse/disburse.component';
import { RejectLoanComponent } from './loans-view/loan-account-actions/reject-loan/reject-loan.component';
import { WithdrawnByClientComponent } from './loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component';
import { UndoDisbursalComponent } from './loans-view/loan-account-actions/undo-disbursal/undo-disbursal.component';
/** Dialog Components */
import { LoansAccountViewGuarantorDetailsDialogComponent } from './custom-dialog/loans-account-view-guarantor-details-dialog/loans-account-view-guarantor-details-dialog.component';
@@ -105,7 +106,8 @@ import { AddCollateralComponent } from './loans-view/loan-account-actions/add-co
RejectLoanComponent,
DisburseComponent,
WithdrawnByClientComponent,
AddCollateralComponent
AddCollateralComponent,
UndoDisbursalComponent,
],
entryComponents: [
LoansAccountAddCollateralDialogComponent,