diff --git a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts index 178ead97b..ceeb3a3db 100644 --- a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts @@ -57,7 +57,7 @@ export class DisburseComponent implements OnInit { } /** - * Creates the create close form. + * Creates the disbursement loan form. */ createDisbursementLoanForm() { this.disbursementLoanForm = this.formBuilder.group({ 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 6631e0449..66285e9c2 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 @@ -16,5 +16,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 fdbb256da..08860ebfc 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 @@ -28,7 +28,8 @@ export class LoanAccountActionsComponent { recovery_payment: boolean, view_guarantors: boolean, create_guarantor: boolean, - disburse: boolean } = { + disburse: boolean, + withdrawn_by_client: boolean } = { close: false, undo_approval: false, write_off: false, @@ -44,7 +45,8 @@ export class LoanAccountActionsComponent { recovery_payment: false, view_guarantors: false, create_guarantor: false, - disburse: false }; + disburse: false, + withdrawn_by_client: false }; actionButtonData: any; actionName: any; diff --git a/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.html b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.html new file mode 100644 index 000000000..f7cf1e210 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.html @@ -0,0 +1,35 @@ +
+ +
+ + + +
+ + + Withdrawn On + + + + + Withdrawn On Date is required + + + + + Note + + + +
+ + + + + + +
+ +
+ +
diff --git a/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.scss b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.spec.ts b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.spec.ts new file mode 100644 index 000000000..c23137af1 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WithdrawnByClientComponent } from './withdrawn-by-client.component'; + +describe('WithdrawnByClientComponent', () => { + let component: WithdrawnByClientComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WithdrawnByClientComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WithdrawnByClientComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts new file mode 100644 index 000000000..6808a1a02 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts @@ -0,0 +1,80 @@ +/** Angular Imports */ +import { Component, OnInit, Input } from '@angular/core'; +import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; + +/** Custom Services */ +import { LoansService } from 'app/loans/loans.service'; +import { DatePipe } from '@angular/common'; + +/** + * Withdrawn By Applicant Loan Form + */ +@Component({ + selector: 'mifosx-withdrawn-by-client', + templateUrl: './withdrawn-by-client.component.html', + styleUrls: ['./withdrawn-by-client.component.scss'] +}) +export class WithdrawnByClientComponent implements OnInit { + + @Input() dataObject: any; + /** Loan Id */ + loanId: string; + /** Minimum Date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum Date allowed. */ + maxDate = new Date(); + /** Withdrawn By Applicant Loan Form */ + withdrawnByClientLoanForm: FormGroup; + + /** + * @param {FormBuilder} formBuilder Form Builder. + * @param {LoansService} loanService Loan Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + * @param {DatePipe} datePipe Date Pipe. + */ + 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 withdraw by Applicant loan form + * and initialize with the required values + */ + ngOnInit() { + this.createWithdrawnByClientLoanForm(); + } + + /** + * Creates the create withdraw by applicant form. + */ + createWithdrawnByClientLoanForm() { + this.withdrawnByClientLoanForm = this.formBuilder.group({ + 'withdrawnOnDate': [new Date(), Validators.required], + 'note': '' + }); + } + + /** Submits the withdraw by appplicant form */ + submit() { + const prevTransactionDate: Date = this.withdrawnByClientLoanForm.value.withdrawnOnDate; + // TODO: Update once language and date settings are setup + const dateFormat = 'dd-MM-yyyy'; + this.withdrawnByClientLoanForm.patchValue({ + withdrawnOnDate: this.datePipe.transform(prevTransactionDate, dateFormat) + }); + const WithdrawnByClientLoanData = this.withdrawnByClientLoanForm.value; + WithdrawnByClientLoanData.locale = 'en'; + WithdrawnByClientLoanData.dateFormat = dateFormat; + this.loanService.loanActionButtons(this.loanId, 'withdrawnByApplicant', WithdrawnByClientLoanData) + .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 6468bd19e..eb447b9e5 100644 --- a/src/app/loans/loans.module.ts +++ b/src/app/loans/loans.module.ts @@ -47,6 +47,7 @@ import { CreateGuarantorComponent } from './loans-view/loan-account-actions/crea import { DisburseLoanAccountComponent } from './loans-view/loan-account-actions/disburse-loan-account/disburse-loan-account.component'; 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'; /** Dialog Components */ import { LoansAccountViewGuarantorDetailsDialogComponent } from './custom-dialog/loans-account-view-guarantor-details-dialog/loans-account-view-guarantor-details-dialog.component'; @@ -102,6 +103,7 @@ import { LoansConfirmationDialogBoxComponent } from './custom-dialog/loans-confi DisburseLoanAccountComponent, RejectLoanComponent, DisburseComponent, + WithdrawnByClientComponent, ], entryComponents: [ LoansAccountAddCollateralDialogComponent,