From c279b96db7e13426332e27de34ea2d0606c50c5e Mon Sep 17 00:00:00 2001 From: Ramveer Date: Sat, 4 Jun 2022 23:59:05 +0530 Subject: [PATCH] Loan Tranche Section Added --- .../create-loans-account.component.html | 2 +- .../create-loans-account.component.ts | 15 ++++++ .../loans-account-terms-step.component.html | 47 +++++++++++++++++++ .../loans-account-terms-step.component.ts | 41 +++++++++++++++- 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/src/app/loans/create-loans-account/create-loans-account.component.html b/src/app/loans/create-loans-account/create-loans-account.component.html index 9ddaeab16..843b7151e 100644 --- a/src/app/loans/create-loans-account/create-loans-account.component.html +++ b/src/app/loans/create-loans-account/create-loans-account.component.html @@ -36,7 +36,7 @@ TERMS + [loansAccountTemplate] = "loansAccountTemplate" [multiDisburseLoan] = "multiDisburseLoan"> diff --git a/src/app/loans/create-loans-account/create-loans-account.component.ts b/src/app/loans/create-loans-account/create-loans-account.component.ts index c5c34d1c0..1a8cb0b8f 100644 --- a/src/app/loans/create-loans-account/create-loans-account.component.ts +++ b/src/app/loans/create-loans-account/create-loans-account.component.ts @@ -33,6 +33,8 @@ export class CreateLoansAccountComponent implements OnInit { loansAccountProductTemplate: any; /** Collateral Options */ collateralOptions: any; + /** Multi Disburse Loan */ + multiDisburseLoan: any; /** * Sets loans account create form. @@ -65,6 +67,12 @@ export class CreateLoansAccountComponent implements OnInit { this.loansService.getLoansCollateralTemplateResource(this.loansAccountProductTemplate.loanProductId).subscribe((response: any) => { this.collateralOptions = response.loanCollateralOptions; }); + const clientId = this.loansAccountTemplate.clientId; + const productId= this.loansAccountProductTemplate.loanProductId + this.loansService.getLoansAccountTemplateResource(clientId, productId).subscribe((response: any) => { + this.multiDisburseLoan = response.multiDisburseLoan; + }); + } /** Get Loans Account Details Form Data */ @@ -113,6 +121,10 @@ export class CreateLoansAccountComponent implements OnInit { type: collateralEle.type, value: collateralEle.value, description: collateralEle.description + })), + disbursementData:this.loansAccount.disbursementData.map((item: any) => ({ + expectedDisbursementDate: this.dateUtils.formatDate(item.expectedDisbursementDate, dateFormat), + principal: item.principal })), interestChargedFromDate: this.dateUtils.formatDate(this.loansAccount.interestChargedFromDate, dateFormat), repaymentsStartingFromDate: this.dateUtils.formatDate(this.loansAccount.repaymentsStartingFromDate, dateFormat), @@ -146,6 +158,9 @@ export class CreateLoansAccountComponent implements OnInit { if (!(loansAccountData.isFloatingInterestRate === false)) { delete loansAccountData.isFloatingInterestRate; } + if (!(this.multiDisburseLoan)) { + delete loansAccountData.disbursementData; + } this.loansService.createLoansAccount(loansAccountData).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html index d8e99d9a0..1eadc91bb 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html @@ -325,6 +325,53 @@ {{ loansAccountProductTemplate?.interestRecalculationData.recalculationRestFrequencyInterval}} + + +

Loan Tranche Details

+ + Maximum allowed outstanding balance + + +
+ +
+ + + Expected disbursement on + + + + + Expected disbursement on is required + + + + + Principal + + + Principal is required + + + + + + + + +
+ +
+ + +
+ diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts index 74b2153f5..e94a1c631 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts @@ -1,6 +1,6 @@ /** Angular Imports */ import { Component, OnInit, Input, OnChanges } from '@angular/core'; -import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; +import { FormGroup, FormBuilder, Validators, FormControl, FormArray } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; /** @@ -17,6 +17,8 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges { @Input() loansAccountProductTemplate: any; /** Loans Account Template */ @Input() loansAccountTemplate: any; + /**Is Multi Disburse Loan */ + @Input() multiDisburseLoan: any; /** Minimum date allowed. */ minDate = new Date(2000, 0, 1); @@ -132,6 +134,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges { 'numberOfRepayments': ['', Validators.required], 'repaymentEvery': ['', Validators.required], 'repaymentFrequencyType': ['', Validators.required], + 'disbursementData': this.formBuilder.array([this.createDisbursementDataForm()]), 'repaymentFrequencyNthDayType': [''], 'repaymentFrequencyDayOfWeekType': [''], 'repaymentsStartingFromDate': [''], @@ -157,6 +160,42 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges { }); } + /** + * Creates the Disbursement Data form. + * @returns {FormGroup} Disbursement Data form. + */ + createDisbursementDataForm(): FormGroup { + return this.formBuilder.group({ + 'expectedDisbursementDate': [new Date()], + 'principal': [''] + }); + } + + /** + * Gets the Disbursement Data form array. + * @returns {FormArray} Disbursement Data form array. + */ + get disbursementData(): FormArray { + return this.loansAccountTermsForm.get('disbursementData') as FormArray; + } + + /** + * Adds the Disbursement Data entry form to given Disbursement Data entry form array. + * @param {FormArray} disbursementDataFormArray Given affected gl entry form array (debit/credit). + */ + addDisbursementDataEntry(disbursementDataFormArray: FormArray) { + disbursementDataFormArray.push(this.createDisbursementDataForm()); + } + + /** + * Removes the Disbursement Data entry form from given Disbursement Data entry form array at given index. + * @param {FormArray} disbursementDataFormArray Given Disbursement Data entry form array. + * @param {number} index Array index from where Disbursement Data entry form needs to be removed. + */ + removeDisbursementDataEntry(disbursementDataFormArray: FormArray, index: number) { + disbursementDataFormArray.removeAt(index); + } + /** * Sets all select dropdown options. */