Loan Account Term calculation (#1871)
Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
ab55521a5a
commit
adef15df35
@@ -36,7 +36,6 @@ export class CentersService {
|
|||||||
// filterBy: name, externalId
|
// filterBy: name, externalId
|
||||||
filterBy.forEach(function (filter: any) {
|
filterBy.forEach(function (filter: any) {
|
||||||
if (filter.value) {
|
if (filter.value) {
|
||||||
console.log(filter.value);
|
|
||||||
httpParams = httpParams.set(filter.type, filter.value);
|
httpParams = httpParams.set(filter.type, filter.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ export class AddressTabComponent {
|
|||||||
const addAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
const addAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||||
addAddressDialogRef.afterClosed().subscribe((response: any) => {
|
addAddressDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
console.log(response.data);
|
|
||||||
this.clientService.createClientAddress(this.clientId, response.data.value.addressType, response.data.value).subscribe((res: any) => {
|
this.clientService.createClientAddress(this.clientId, response.data.value.addressType, response.data.value).subscribe((res: any) => {
|
||||||
const addressData = response.data.value;
|
const addressData = response.data.value;
|
||||||
addressData.addressId = res.resourceId;
|
addressData.addressId = res.resourceId;
|
||||||
@@ -89,7 +88,6 @@ export class AddressTabComponent {
|
|||||||
const editAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
const editAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||||
editAddressDialogRef.afterClosed().subscribe((response: any) => {
|
editAddressDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
console.log(response.data.value);
|
|
||||||
const addressData = response.data.value;
|
const addressData = response.data.value;
|
||||||
addressData.addressId = address.addressId;
|
addressData.addressId = address.addressId;
|
||||||
addressData.isActive = address.isActive;
|
addressData.isActive = address.isActive;
|
||||||
|
|||||||
-2
@@ -43,7 +43,6 @@ export class AddClientCollateralComponent implements OnInit {
|
|||||||
) {
|
) {
|
||||||
this.route.data.subscribe((data: { clientActionData: any }) => {
|
this.route.data.subscribe((data: { clientActionData: any }) => {
|
||||||
this.clientCollateralOptions = data.clientActionData;
|
this.clientCollateralOptions = data.clientActionData;
|
||||||
console.log(this.clientCollateralOptions);
|
|
||||||
});
|
});
|
||||||
this.clientId = this.route.parent.snapshot.params['clientId'];
|
this.clientId = this.route.parent.snapshot.params['clientId'];
|
||||||
}
|
}
|
||||||
@@ -60,7 +59,6 @@ export class AddClientCollateralComponent implements OnInit {
|
|||||||
this.clientCollateralForm.controls.collateralId.valueChanges.subscribe(collateralId => {
|
this.clientCollateralForm.controls.collateralId.valueChanges.subscribe(collateralId => {
|
||||||
this.productsService.getCollateral(collateralId).subscribe((data: any) => {
|
this.productsService.getCollateral(collateralId).subscribe((data: any) => {
|
||||||
this.collateralDetails = data;
|
this.collateralDetails = data;
|
||||||
console.log(data);
|
|
||||||
this.clientCollateralForm.patchValue({
|
this.clientCollateralForm.patchValue({
|
||||||
'name': data.name,
|
'name': data.name,
|
||||||
'quality': data.quality,
|
'quality': data.quality,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ export class PopoverComponent extends BasePortalOutlet {
|
|||||||
@ViewChild(CdkPortalOutlet, { static: true }) portalOutlet: CdkPortalOutlet;
|
@ViewChild(CdkPortalOutlet, { static: true }) portalOutlet: CdkPortalOutlet;
|
||||||
|
|
||||||
attachComponentPortal<T>(componentPortal: ComponentPortal<any>): ComponentRef<T> {
|
attachComponentPortal<T>(componentPortal: ComponentPortal<any>): ComponentRef<T> {
|
||||||
console.log(this.portalOutlet.attachComponentPortal(componentPortal));
|
|
||||||
return this.portalOutlet.attachComponentPortal(componentPortal);
|
return this.portalOutlet.attachComponentPortal(componentPortal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigateMenu(routePath: string): void {
|
navigateMenu(routePath: string): void {
|
||||||
console.log(routePath);
|
|
||||||
this.router.navigate([routePath]);
|
this.router.navigate([routePath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export class CreateLoansAccountComponent implements OnInit {
|
|||||||
/** Loans Account Template */
|
/** Loans Account Template */
|
||||||
loansAccountTemplate: any;
|
loansAccountTemplate: any;
|
||||||
/** Loans Account Product Template */
|
/** Loans Account Product Template */
|
||||||
loansAccountProductTemplate: any;
|
loansAccountProductTemplate: any | null = null;
|
||||||
/** Collateral Options */
|
/** Collateral Options */
|
||||||
collateralOptions: any;
|
collateralOptions: any;
|
||||||
/** Multi Disburse Loan */
|
/** Multi Disburse Loan */
|
||||||
@@ -63,8 +63,7 @@ export class CreateLoansAccountComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() { }
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets loans account product template and collateral template
|
* Sets loans account product template and collateral template
|
||||||
|
|||||||
+8
-4
@@ -10,11 +10,12 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<h4 fxFlex="98%" class="mat-h4">Term Options</h4>
|
<h4 fxFlex="98%" class="mat-h4">Term Options <i class="fas fa-question" matTooltip="The loan term parameter in loan accounts
|
||||||
|
is the default-calculated field based on the number of repayments and repaid every value entered by the user"></i></h4>
|
||||||
|
|
||||||
<mat-form-field fxFlex="48%">
|
<mat-form-field fxFlex="48%">
|
||||||
<mat-label>Loan Term</mat-label>
|
<mat-label>Loan Term</mat-label>
|
||||||
<input type="number" matInput required formControlName="loanTermFrequency">
|
<input type="number" matInput required disabled formControlName="loanTermFrequency">
|
||||||
<mat-error *ngIf="loansAccountTermsForm.controls.loanTermFrequency.hasError('required')">
|
<mat-error *ngIf="loansAccountTermsForm.controls.loanTermFrequency.hasError('required')">
|
||||||
Loan Term is <strong>required</strong>
|
Loan Term is <strong>required</strong>
|
||||||
</mat-error>
|
</mat-error>
|
||||||
@@ -32,6 +33,9 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<h4 fxFlex="98%" class="mat-h4">Repayments <i class="fas fa-question" matTooltip="Enter the total count of repayments that loan schedule has excluding the down-payment.
|
||||||
|
Example: if the loan account has 4 Installments including down-payment then number of repayments is equal to 3"></i></h4>
|
||||||
|
|
||||||
<mat-form-field fxFlex="48%">
|
<mat-form-field fxFlex="48%">
|
||||||
<mat-label>Number of repayments</mat-label>
|
<mat-label>Number of repayments</mat-label>
|
||||||
<input type="number" matInput formControlName="numberOfRepayments">
|
<input type="number" matInput formControlName="numberOfRepayments">
|
||||||
@@ -52,7 +56,7 @@
|
|||||||
|
|
||||||
<mat-form-field fxFlex="48%">
|
<mat-form-field fxFlex="48%">
|
||||||
<mat-label>Repaid every</mat-label>
|
<mat-label>Repaid every</mat-label>
|
||||||
<input matInput required formControlName="repaymentEvery">
|
<input type="number" matInput required formControlName="repaymentEvery">
|
||||||
<mat-error *ngIf="loansAccountTermsForm.controls.repaymentEvery.hasError('required')">
|
<mat-error *ngIf="loansAccountTermsForm.controls.repaymentEvery.hasError('required')">
|
||||||
Repaid every is <strong>required</strong>
|
Repaid every is <strong>required</strong>
|
||||||
</mat-error>
|
</mat-error>
|
||||||
@@ -60,7 +64,7 @@
|
|||||||
|
|
||||||
<mat-form-field fxFlex="48%">
|
<mat-form-field fxFlex="48%">
|
||||||
<mat-label>Frequency</mat-label>
|
<mat-label>Frequency</mat-label>
|
||||||
<mat-select formControlName="repaymentFrequencyType" required>
|
<mat-select formControlName="repaymentFrequencyType" disabled required>
|
||||||
<mat-option *ngFor="let repaymentFrequencyType of termFrequencyTypeData" [value]="repaymentFrequencyType.id">
|
<mat-option *ngFor="let repaymentFrequencyType of termFrequencyTypeData" [value]="repaymentFrequencyType.id">
|
||||||
{{ repaymentFrequencyType.value }}
|
{{ repaymentFrequencyType.value }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
|||||||
+32
-4
@@ -2,7 +2,7 @@
|
|||||||
import { Component, OnInit, Input, OnChanges } from '@angular/core';
|
import { Component, OnInit, Input, OnChanges } from '@angular/core';
|
||||||
import { UntypedFormGroup, UntypedFormBuilder, Validators, FormArray } from '@angular/forms';
|
import { UntypedFormGroup, UntypedFormBuilder, Validators, FormArray } from '@angular/forms';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { LoansAccountAddCollateralDialogComponent } from 'app/loans/custom-dialog/loans-account-add-collateral-dialog/loans-account-add-collateral-dialog.component';
|
import { LoansAccountAddCollateralDialogComponent } from 'app/loans/custom-dialog/loans-account-add-collateral-dialog/loans-account-add-collateral-dialog.component';
|
||||||
import { SettingsService } from 'app/settings/settings.service';
|
import { SettingsService } from 'app/settings/settings.service';
|
||||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||||
@@ -10,7 +10,6 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
|
|||||||
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
|
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
|
||||||
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
||||||
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
||||||
import { TooltipPosition } from '@angular/material/tooltip';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Loans Account Terms Step
|
* Create Loans Account Terms Step
|
||||||
@@ -22,6 +21,8 @@ import { TooltipPosition } from '@angular/material/tooltip';
|
|||||||
})
|
})
|
||||||
export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
|
/** Loans Product Options */
|
||||||
|
@Input() loansProductOptions: any;
|
||||||
/** Loans Account Product Template */
|
/** Loans Account Product Template */
|
||||||
@Input() loansAccountProductTemplate: any;
|
@Input() loansAccountProductTemplate: any;
|
||||||
/** Loans Account Template */
|
/** Loans Account Template */
|
||||||
@@ -217,6 +218,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
this.createloansAccountTermsForm();
|
this.createloansAccountTermsForm();
|
||||||
// this.setCustomValidators();
|
// this.setCustomValidators();
|
||||||
|
this.setLoanTermListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
allowAddDisbursementDetails() {
|
allowAddDisbursementDetails() {
|
||||||
@@ -244,15 +246,36 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Custom Listeners for the form to calculate Loan Term */
|
||||||
|
setLoanTermListener() {
|
||||||
|
this.loansAccountTermsForm.get('numberOfRepayments').valueChanges
|
||||||
|
.subscribe(numberOfRepayments => {
|
||||||
|
const repaymentEvery: number = this.loansAccountTermsForm.value.repaymentEvery;
|
||||||
|
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.loansAccountTermsForm.get('repaymentEvery').valueChanges
|
||||||
|
.subscribe(repaymentEvery => {
|
||||||
|
const numberOfRepayments: number = this.loansAccountTermsForm.value.numberOfRepayments;
|
||||||
|
this.calculateLoanTerm(numberOfRepayments, repaymentEvery);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.loansAccountTermsForm.get('loanTermFrequencyType').valueChanges
|
||||||
|
.subscribe(loanTermFrequencyType => {
|
||||||
|
this.loansAccountTermsForm.patchValue({'repaymentFrequencyType': loanTermFrequencyType});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/** Create Loans Account Terms Form */
|
/** Create Loans Account Terms Form */
|
||||||
createloansAccountTermsForm() {
|
createloansAccountTermsForm() {
|
||||||
this.loansAccountTermsForm = this.formBuilder.group({
|
this.loansAccountTermsForm = this.formBuilder.group({
|
||||||
'principalAmount': ['', Validators.required],
|
'principalAmount': ['', Validators.required],
|
||||||
'loanTermFrequency': ['', Validators.required],
|
'loanTermFrequency': [{ value: '', disabled: true }, Validators.required],
|
||||||
'loanTermFrequencyType': ['', Validators.required],
|
'loanTermFrequencyType': ['', Validators.required],
|
||||||
'numberOfRepayments': ['', Validators.required],
|
'numberOfRepayments': ['', Validators.required],
|
||||||
'repaymentEvery': ['', Validators.required],
|
'repaymentEvery': ['', Validators.required],
|
||||||
'repaymentFrequencyType': ['', Validators.required],
|
'repaymentFrequencyType': [{ value: '', disabled: true }, Validators.required],
|
||||||
'repaymentFrequencyNthDayType': [''],
|
'repaymentFrequencyNthDayType': [''],
|
||||||
'repaymentFrequencyDayOfWeekType': [''],
|
'repaymentFrequencyDayOfWeekType': [''],
|
||||||
'repaymentsStartingFromDate': [''],
|
'repaymentsStartingFromDate': [''],
|
||||||
@@ -279,6 +302,11 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculateLoanTerm(numberOfRepayments: number, repaymentEvery: number): void {
|
||||||
|
const loanTerm = numberOfRepayments * repaymentEvery;
|
||||||
|
this.loansAccountTermsForm.patchValue({'loanTermFrequency': loanTerm});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Disbursement Data array.
|
* Gets the Disbursement Data array.
|
||||||
* @returns {Array} Disbursement Data array.
|
* @returns {Array} Disbursement Data array.
|
||||||
|
|||||||
@@ -179,7 +179,6 @@ export class InvestorsComponent implements OnInit {
|
|||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
const url: string = this.router.url;
|
const url: string = this.router.url;
|
||||||
console.log(url);
|
|
||||||
this.router.navigateByUrl(`/`, {skipLocationChange: true})
|
this.router.navigateByUrl(`/`, {skipLocationChange: true})
|
||||||
.then(() => this.router.navigate([url]));
|
.then(() => this.router.navigate([url]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { ConfigurationWizardService } from '../configuration-wizard/configuratio
|
|||||||
})
|
})
|
||||||
export class OrganizationComponent implements OnInit, AfterViewInit {
|
export class OrganizationComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
shouldShowFundMapping: boolean = false;
|
shouldShowFundMapping = false;
|
||||||
/* Reference of manage offices */
|
/* Reference of manage offices */
|
||||||
@ViewChild('office') office: ElementRef<any>;
|
@ViewChild('office') office: ElementRef<any>;
|
||||||
/* Template for popover on manage offices */
|
/* Template for popover on manage offices */
|
||||||
|
|||||||
+2
-2
@@ -65,8 +65,8 @@
|
|||||||
|
|
||||||
<mifosx-loan-product-payment-strategy-step
|
<mifosx-loan-product-payment-strategy-step
|
||||||
[advancedPaymentAllocations]="advancedPaymentAllocations"
|
[advancedPaymentAllocations]="advancedPaymentAllocations"
|
||||||
[advancedPaymentAllocationTransactionTypes]="loanProductAndTemplate.advancedPaymentAllocationTransactionTypes"
|
[advancedPaymentAllocationTransactionTypes]="loanProductsTemplate.advancedPaymentAllocationTransactionTypes"
|
||||||
[paymentAllocationOrderDefault]="loanProductAndTemplate.advancedPaymentAllocationTypes"
|
[paymentAllocationOrderDefault]="loanProductsTemplate.advancedPaymentAllocationTypes"
|
||||||
(setPaymentAllocation)="setPaymentAllocation($event)"
|
(setPaymentAllocation)="setPaymentAllocation($event)"
|
||||||
>
|
>
|
||||||
</mifosx-loan-product-payment-strategy-step>
|
</mifosx-loan-product-payment-strategy-step>
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ export class CreateLoanProductComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() {
|
||||||
|
this.buildAdvancedPaymentAllocation();
|
||||||
|
}
|
||||||
|
|
||||||
get loanProductDetailsForm() {
|
get loanProductDetailsForm() {
|
||||||
return this.loanProductDetailsStep.loanProductDetailsForm;
|
return this.loanProductDetailsStep.loanProductDetailsForm;
|
||||||
@@ -85,7 +87,6 @@ export class CreateLoanProductComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void {
|
setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void {
|
||||||
console.log(paymentAllocation);
|
|
||||||
this.paymentAllocation = paymentAllocation;
|
this.paymentAllocation = paymentAllocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-9
@@ -53,16 +53,18 @@ export class AdvancedPaymentStrategy {
|
|||||||
const advancedPaymentAllocationTypes: PaymentAllocationOrder[] = loanProduct.advancedPaymentAllocationTypes;
|
const advancedPaymentAllocationTypes: PaymentAllocationOrder[] = loanProduct.advancedPaymentAllocationTypes;
|
||||||
const advancedPaymentAllocationFutureInstallmentAllocationRules: FutureInstallmentAllocationRule[] =
|
const advancedPaymentAllocationFutureInstallmentAllocationRules: FutureInstallmentAllocationRule[] =
|
||||||
loanProduct.advancedPaymentAllocationFutureInstallmentAllocationRules;
|
loanProduct.advancedPaymentAllocationFutureInstallmentAllocationRules;
|
||||||
loanProduct.paymentAllocation.forEach((item: PaymentAllocation) => {
|
if (loanProduct.paymentAllocation) {
|
||||||
advancedPaymentAllocation.push({
|
loanProduct.paymentAllocation.forEach((item: PaymentAllocation) => {
|
||||||
transaction: this.getItemByCode(item.transactionType, advancedPaymentAllocationTransactionTypes),
|
advancedPaymentAllocation.push({
|
||||||
paymentAllocationOrder: this.buildCurrentPaymentAllocationOrder(item.paymentAllocationOrder,
|
transaction: this.getItemByCode(item.transactionType, advancedPaymentAllocationTransactionTypes),
|
||||||
advancedPaymentAllocationTypes),
|
paymentAllocationOrder: this.buildCurrentPaymentAllocationOrder(item.paymentAllocationOrder,
|
||||||
futureInstallmentAllocationRule: this.getItemByCode(item.futureInstallmentAllocationRule,
|
advancedPaymentAllocationTypes),
|
||||||
advancedPaymentAllocationFutureInstallmentAllocationRules),
|
futureInstallmentAllocationRule: this.getItemByCode(item.futureInstallmentAllocationRule,
|
||||||
futureInstallmentAllocationRules: advancedPaymentAllocationFutureInstallmentAllocationRules,
|
advancedPaymentAllocationFutureInstallmentAllocationRules),
|
||||||
|
futureInstallmentAllocationRules: advancedPaymentAllocationFutureInstallmentAllocationRules,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
// If this is Empty, add the Default
|
// If this is Empty, add the Default
|
||||||
if (advancedPaymentAllocation.length === 0) {
|
if (advancedPaymentAllocation.length === 0) {
|
||||||
advancedPaymentAllocation.push({
|
advancedPaymentAllocation.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user