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.forEach(function (filter: any) {
|
||||
if (filter.value) {
|
||||
console.log(filter.value);
|
||||
httpParams = httpParams.set(filter.type, filter.value);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -62,7 +62,6 @@ export class AddressTabComponent {
|
||||
const addAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||
addAddressDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
console.log(response.data);
|
||||
this.clientService.createClientAddress(this.clientId, response.data.value.addressType, response.data.value).subscribe((res: any) => {
|
||||
const addressData = response.data.value;
|
||||
addressData.addressId = res.resourceId;
|
||||
@@ -89,7 +88,6 @@ export class AddressTabComponent {
|
||||
const editAddressDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||
editAddressDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
console.log(response.data.value);
|
||||
const addressData = response.data.value;
|
||||
addressData.addressId = address.addressId;
|
||||
addressData.isActive = address.isActive;
|
||||
|
||||
-2
@@ -43,7 +43,6 @@ export class AddClientCollateralComponent implements OnInit {
|
||||
) {
|
||||
this.route.data.subscribe((data: { clientActionData: any }) => {
|
||||
this.clientCollateralOptions = data.clientActionData;
|
||||
console.log(this.clientCollateralOptions);
|
||||
});
|
||||
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.productsService.getCollateral(collateralId).subscribe((data: any) => {
|
||||
this.collateralDetails = data;
|
||||
console.log(data);
|
||||
this.clientCollateralForm.patchValue({
|
||||
'name': data.name,
|
||||
'quality': data.quality,
|
||||
|
||||
@@ -23,7 +23,6 @@ export class PopoverComponent extends BasePortalOutlet {
|
||||
@ViewChild(CdkPortalOutlet, { static: true }) portalOutlet: CdkPortalOutlet;
|
||||
|
||||
attachComponentPortal<T>(componentPortal: ComponentPortal<any>): ComponentRef<T> {
|
||||
console.log(this.portalOutlet.attachComponentPortal(componentPortal));
|
||||
return this.portalOutlet.attachComponentPortal(componentPortal);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,6 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
|
||||
}
|
||||
|
||||
navigateMenu(routePath: string): void {
|
||||
console.log(routePath);
|
||||
this.router.navigate([routePath]);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export class CreateLoansAccountComponent implements OnInit {
|
||||
/** Loans Account Template */
|
||||
loansAccountTemplate: any;
|
||||
/** Loans Account Product Template */
|
||||
loansAccountProductTemplate: any;
|
||||
loansAccountProductTemplate: any | null = null;
|
||||
/** Collateral Options */
|
||||
collateralOptions: any;
|
||||
/** Multi Disburse Loan */
|
||||
@@ -63,8 +63,7 @@ export class CreateLoansAccountComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
ngOnInit() { }
|
||||
|
||||
/**
|
||||
* Sets loans account product template and collateral template
|
||||
|
||||
+8
-4
@@ -10,11 +10,12 @@
|
||||
</mat-error>
|
||||
</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-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')">
|
||||
Loan Term is <strong>required</strong>
|
||||
</mat-error>
|
||||
@@ -32,6 +33,9 @@
|
||||
</mat-error>
|
||||
</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-label>Number of repayments</mat-label>
|
||||
<input type="number" matInput formControlName="numberOfRepayments">
|
||||
@@ -52,7 +56,7 @@
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<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')">
|
||||
Repaid every is <strong>required</strong>
|
||||
</mat-error>
|
||||
@@ -60,7 +64,7 @@
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<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">
|
||||
{{ repaymentFrequencyType.value }}
|
||||
</mat-option>
|
||||
|
||||
+32
-4
@@ -2,7 +2,7 @@
|
||||
import { Component, OnInit, Input, OnChanges } from '@angular/core';
|
||||
import { UntypedFormGroup, UntypedFormBuilder, Validators, FormArray } from '@angular/forms';
|
||||
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 { SettingsService } from 'app/settings/settings.service';
|
||||
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 { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
||||
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
||||
import { TooltipPosition } from '@angular/material/tooltip';
|
||||
|
||||
/**
|
||||
* Create Loans Account Terms Step
|
||||
@@ -22,6 +21,8 @@ import { TooltipPosition } from '@angular/material/tooltip';
|
||||
})
|
||||
export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
|
||||
/** Loans Product Options */
|
||||
@Input() loansProductOptions: any;
|
||||
/** Loans Account Product Template */
|
||||
@Input() loansAccountProductTemplate: any;
|
||||
/** Loans Account Template */
|
||||
@@ -217,6 +218,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
|
||||
}
|
||||
this.createloansAccountTermsForm();
|
||||
// this.setCustomValidators();
|
||||
this.setLoanTermListener();
|
||||
}
|
||||
|
||||
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 */
|
||||
createloansAccountTermsForm() {
|
||||
this.loansAccountTermsForm = this.formBuilder.group({
|
||||
'principalAmount': ['', Validators.required],
|
||||
'loanTermFrequency': ['', Validators.required],
|
||||
'loanTermFrequency': [{ value: '', disabled: true }, Validators.required],
|
||||
'loanTermFrequencyType': ['', Validators.required],
|
||||
'numberOfRepayments': ['', Validators.required],
|
||||
'repaymentEvery': ['', Validators.required],
|
||||
'repaymentFrequencyType': ['', Validators.required],
|
||||
'repaymentFrequencyType': [{ value: '', disabled: true }, Validators.required],
|
||||
'repaymentFrequencyNthDayType': [''],
|
||||
'repaymentFrequencyDayOfWeekType': [''],
|
||||
'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.
|
||||
* @returns {Array} Disbursement Data array.
|
||||
|
||||
@@ -179,7 +179,6 @@ export class InvestorsComponent implements OnInit {
|
||||
|
||||
reload() {
|
||||
const url: string = this.router.url;
|
||||
console.log(url);
|
||||
this.router.navigateByUrl(`/`, {skipLocationChange: true})
|
||||
.then(() => this.router.navigate([url]));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { ConfigurationWizardService } from '../configuration-wizard/configuratio
|
||||
})
|
||||
export class OrganizationComponent implements OnInit, AfterViewInit {
|
||||
|
||||
shouldShowFundMapping: boolean = false;
|
||||
shouldShowFundMapping = false;
|
||||
/* Reference of manage offices */
|
||||
@ViewChild('office') office: ElementRef<any>;
|
||||
/* Template for popover on manage offices */
|
||||
|
||||
+2
-2
@@ -65,8 +65,8 @@
|
||||
|
||||
<mifosx-loan-product-payment-strategy-step
|
||||
[advancedPaymentAllocations]="advancedPaymentAllocations"
|
||||
[advancedPaymentAllocationTransactionTypes]="loanProductAndTemplate.advancedPaymentAllocationTransactionTypes"
|
||||
[paymentAllocationOrderDefault]="loanProductAndTemplate.advancedPaymentAllocationTypes"
|
||||
[advancedPaymentAllocationTransactionTypes]="loanProductsTemplate.advancedPaymentAllocationTransactionTypes"
|
||||
[paymentAllocationOrderDefault]="loanProductsTemplate.advancedPaymentAllocationTypes"
|
||||
(setPaymentAllocation)="setPaymentAllocation($event)"
|
||||
>
|
||||
</mifosx-loan-product-payment-strategy-step>
|
||||
|
||||
@@ -60,7 +60,9 @@ export class CreateLoanProductComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() { }
|
||||
ngOnInit() {
|
||||
this.buildAdvancedPaymentAllocation();
|
||||
}
|
||||
|
||||
get loanProductDetailsForm() {
|
||||
return this.loanProductDetailsStep.loanProductDetailsForm;
|
||||
@@ -85,7 +87,6 @@ export class CreateLoanProductComponent implements OnInit {
|
||||
}
|
||||
|
||||
setPaymentAllocation(paymentAllocation: PaymentAllocation[]): void {
|
||||
console.log(paymentAllocation);
|
||||
this.paymentAllocation = paymentAllocation;
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -53,16 +53,18 @@ export class AdvancedPaymentStrategy {
|
||||
const advancedPaymentAllocationTypes: PaymentAllocationOrder[] = loanProduct.advancedPaymentAllocationTypes;
|
||||
const advancedPaymentAllocationFutureInstallmentAllocationRules: FutureInstallmentAllocationRule[] =
|
||||
loanProduct.advancedPaymentAllocationFutureInstallmentAllocationRules;
|
||||
loanProduct.paymentAllocation.forEach((item: PaymentAllocation) => {
|
||||
advancedPaymentAllocation.push({
|
||||
transaction: this.getItemByCode(item.transactionType, advancedPaymentAllocationTransactionTypes),
|
||||
paymentAllocationOrder: this.buildCurrentPaymentAllocationOrder(item.paymentAllocationOrder,
|
||||
advancedPaymentAllocationTypes),
|
||||
futureInstallmentAllocationRule: this.getItemByCode(item.futureInstallmentAllocationRule,
|
||||
advancedPaymentAllocationFutureInstallmentAllocationRules),
|
||||
futureInstallmentAllocationRules: advancedPaymentAllocationFutureInstallmentAllocationRules,
|
||||
if (loanProduct.paymentAllocation) {
|
||||
loanProduct.paymentAllocation.forEach((item: PaymentAllocation) => {
|
||||
advancedPaymentAllocation.push({
|
||||
transaction: this.getItemByCode(item.transactionType, advancedPaymentAllocationTransactionTypes),
|
||||
paymentAllocationOrder: this.buildCurrentPaymentAllocationOrder(item.paymentAllocationOrder,
|
||||
advancedPaymentAllocationTypes),
|
||||
futureInstallmentAllocationRule: this.getItemByCode(item.futureInstallmentAllocationRule,
|
||||
advancedPaymentAllocationFutureInstallmentAllocationRules),
|
||||
futureInstallmentAllocationRules: advancedPaymentAllocationFutureInstallmentAllocationRules,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// If this is Empty, add the Default
|
||||
if (advancedPaymentAllocation.length === 0) {
|
||||
advancedPaymentAllocation.push({
|
||||
|
||||
Reference in New Issue
Block a user