Fix loan product allow partial period interest calculation (#1739)

* Fix charge payment method edition

* Fix Loan Product edition to use correctly allowPartialPeriodInterestCalculation

---------

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-04-18 21:41:19 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 30c1085b45
commit 7306781db8
6 changed files with 45 additions and 30 deletions
@@ -44,7 +44,7 @@
</mat-form-field>
<mat-form-field *ngIf="editClientForm.contains('fullname')" fxFlex="48%">
<mat-label>{{ editClientForm.value.legalFormId === 1 ? 'Name' : 'Entity Name' }}</mat-label>
<mat-label>{{ legalFormId === 1 ? 'Name' : 'Entity Name' }}</mat-label>
<input matInput required formControlName="fullname">
<mat-error *ngIf="editClientForm.controls.fullname.hasError('required')">
Client name is <strong>required</strong>
@@ -72,8 +72,17 @@
</mat-error>
</mat-form-field>
<mat-form-field *ngIf="legalFormId === 1" fxFlex="48%">
<mat-label>Gender</mat-label>
<mat-select formControlName="genderId">
<mat-option *ngFor="let gender of genderOptions" [value]="gender.id">
{{ gender.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="48%" (click)="dateOfBirthDatePicker.open()">
<mat-label>{{ editClientForm.value.legalFormId === 1 ? 'Date of Birth' : 'Incorporation Date' }}</mat-label>
<mat-label>{{ legalFormId === 1 ? 'Date of Birth' : 'Incorporation Date' }}</mat-label>
<input matInput [max]="maxDate" [matDatepicker]="dateOfBirthDatePicker" formControlName="dateOfBirth">
<mat-datepicker-toggle matSuffix [for]="dateOfBirthDatePicker"></mat-datepicker-toggle>
<mat-datepicker #dateOfBirthDatePicker></mat-datepicker>
@@ -123,7 +132,7 @@
<input matInput formControlName="externalId">
</mat-form-field>
<mat-checkbox *ngIf="editClientForm.value.legalFormId === 1" fxFlex="48%" labelPosition="before" formControlName="isStaff" class="margin-v">
<mat-checkbox *ngIf="legalFormId === 1" fxFlex="48%" labelPosition="before" formControlName="isStaff" class="margin-v">
Is staff?
</mat-checkbox>
@@ -176,15 +185,6 @@
<mat-datepicker #activatedOnDatePicker></mat-datepicker>
</mat-form-field>
<mat-form-field *ngIf="editClientForm.value.legalFormId === 1" fxFlex="48%">
<mat-label>Gender</mat-label>
<mat-select formControlName="genderId">
<mat-option *ngFor="let gender of genderOptions" [value]="gender.id">
{{ gender.name }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</mat-card-content>
@@ -44,6 +44,7 @@ export class EditClientComponent implements OnInit {
constitutionOptions: any;
/** Gender Options */
genderOptions: any;
legalFormId = 1;
/**
* Fetches client template data from `resolve`
@@ -70,6 +71,7 @@ export class EditClientComponent implements OnInit {
this.createEditClientForm();
this.setOptions();
this.buildDependencies();
this.legalFormId = 1;
this.editClientForm.patchValue({
'officeId': this.clientDataAndTemplate.officeId,
'staffId': this.clientDataAndTemplate.staffId,
@@ -87,6 +89,9 @@ export class EditClientComponent implements OnInit {
'submittedOnDate': this.clientDataAndTemplate.timeline.submittedOnDate && new Date(this.clientDataAndTemplate.timeline.submittedOnDate),
'activationDate': this.clientDataAndTemplate.timeline.activatedOnDate && new Date(this.clientDataAndTemplate.timeline.activatedOnDate)
});
if (this.clientDataAndTemplate.legalForm) {
this.legalFormId = this.clientDataAndTemplate.legalForm.id;
}
}
/**
@@ -291,7 +291,7 @@
<span fxFlex="60%">{{ loanProduct.interestCalculationPeriodType | find:loanProductsTemplate.interestCalculationPeriodTypeOptions:'id':'value' }}</span>
</div>
<div fxFlexFill *ngIf="loanProduct.interestCalculationPeriodType === 1">
<div fxFlexFill>
<span fxFlex="40%">Allow Partial Interest Calculation with same as repayment:</span>
<span fxFlex="60%">{{ loanProduct.allowPartialPeriodInterestCalcualtion ? 'Yes' : 'No' }}</span>
</div>
@@ -32,7 +32,8 @@
<mat-form-field fxFlex="48%">
<mat-label>Interest calculation period</mat-label>
<mat-select formControlName="interestCalculationPeriodType" matTooltip="Daily - Will Calculate the interest on DAILY basis ex: Month of February has 28days and it will calculate interest for 28days, SAME AS REPAYMENT PERIOD- it calculates for the month,that is, 30days." required>
<mat-select formControlName="interestCalculationPeriodType" matTooltip="Daily - Will Calculate the interest on DAILY basis ex: Month of February has 28days
and it will calculate interest for 28days, SAME AS REPAYMENT PERIOD- it calculates for the month,that is, 30days." required>
<mat-option *ngFor="let interestCalculationPeriodType of interestCalculationPeriodTypeData" [value]="interestCalculationPeriodType.id">
{{ interestCalculationPeriodType.value }}
</mat-option>
@@ -42,7 +43,10 @@
</mat-error>
</mat-form-field>
<mat-checkbox *ngIf="loanProductSettingsForm.value.interestCalculationPeriodType === 1" fxFlex="48%" labelPosition="before" matTooltip=" To be used with SAME AS REPAYMENT PERIOD- for calculating exact interest with partial period ex: Interest charged from is 5th of April , Principal is 10000 and interest is 1% per month then the interest will be (10000 * 1%)* (25/30) , it calculates for the month first then calculates exact periods between start date and end date(can be a decimal)" formControlName="allowPartialPeriodInterestCalcualtion">
<mat-checkbox *ngIf="loanProductSettingsForm.value.interestCalculationPeriodType === 1" fxFlex="48%" labelPosition="before"
matTooltip=" To be used with SAME AS REPAYMENT PERIOD- for calculating exact interest with partial period ex: Interest charged from is 5th of April ,
Principal is 10000 and interest is 1% per month then the interest will be (10000 * 1%)* (25/30) , it calculates for the month first then calculates exact periods between start date and end date(can be a decimal)"
formControlName="allowPartialPeriodInterestCalcualtion">
Calculate interest for exact days in partial period
</mat-checkbox>
@@ -85,12 +89,14 @@
<mat-form-field fxFlex="48%">
<mat-label>Interest free period</mat-label>
<input type="number" matInput matTooltip="If the Interest Free Period is '4' and the client's Repayment Frequency is every week, then for the first four weeks the client need not to pay interest, he has to pay principle due for that week only." formControlName="graceOnInterestCharged">
<input type="number" matInput matTooltip="If the Interest Free Period is '4' and the client's Repayment Frequency is every week,
then for the first four weeks the client need not to pay interest, he has to pay principle due for that week only." formControlName="graceOnInterestCharged">
</mat-form-field>
<mat-form-field fxFlex="48%">
<mat-label>Arrears tolerance</mat-label>
<input type="number" matInput matTooltip="With 'Arrears tolerance' you can specify a tolerance amount and if the loan is behind (in arrears), but within the tolerance, it won't be classified as 'in arrears' and part of the portfolio at risk." formControlName="inArrearsTolerance">
<input type="number" matInput matTooltip="With 'Arrears tolerance' you can specify a tolerance amount and if the loan is behind (in arrears),
but within the tolerance, it won't be classified as 'in arrears' and part of the portfolio at risk." formControlName="inArrearsTolerance">
</mat-form-field>
<mat-form-field fxFlex="48%">
@@ -121,14 +127,16 @@
Allow fixing of the installment amount
</mat-checkbox>
<h4 fxFlex="48%" class="mat-h4">Number of days a loan may be overdue before moving into arrears <i class="fas fa-question" matTooltip="A loan is in arrears once the number of days entered into this field is exceeded. If this field is blank, the loan will be in arrears the day after a scheduled payment is missed. "></i></h4>
<h4 fxFlex="48%" class="mat-h4">Number of days a loan may be overdue before moving into arrears <i class="fas fa-question"
matTooltip="A loan is in arrears once the number of days entered into this field is exceeded. If this field is blank, the loan will be in arrears the day after a scheduled payment is missed. "></i></h4>
<mat-form-field fxFlex="48%">
<mat-label>On arrears ageing</mat-label>
<input type="number" matInput formControlName="graceOnArrearsAgeing">
</mat-form-field>
<h4 fxFlex="48%" class="mat-h4">Maximum number of days a loan may be overdue before becoming a NPA (non-performing asset) <i class="fas fa-question" matTooltip="A loan is a NPA (non performing asset) once the number of days entered into this field is exceeded. If this field is blank, the loan will be an NPA the day after a scheduled payment is missed."></i></h4>
<h4 fxFlex="48%" class="mat-h4">Maximum number of days a loan may be overdue before becoming a NPA (non-performing asset) <i class="fas fa-question"
matTooltip="A loan is a NPA (non performing asset) once the number of days entered into this field is exceeded. If this field is blank, the loan will be an NPA the day after a scheduled payment is missed."></i></h4>
<mat-form-field fxFlex="48%">
<mat-label>Overdue days for NPA</mat-label>
@@ -265,7 +273,8 @@
</div>
<div *ngIf="(loanProductSettingsForm.value.recalculationCompoundingFrequencyType === 4 && loanProductSettingsForm.value.recalculationCompoundingFrequencyNthDayType !== -2) || loanProductSettingsForm.value.recalculationCompoundingFrequencyType === 3" fxFlex="31%" fxLayout="row" fxLayout.lt-md="column">
<div *ngIf="(loanProductSettingsForm.value.recalculationCompoundingFrequencyType === 4 && loanProductSettingsForm.value.recalculationCompoundingFrequencyNthDayType !== -2) ||
loanProductSettingsForm.value.recalculationCompoundingFrequencyType === 3" fxFlex="31%" fxLayout="row" fxLayout.lt-md="column">
<mat-form-field fxFlexFill>
<mat-select formControlName="recalculationCompoundingFrequencyDayOfWeekType">
@@ -277,7 +286,8 @@
</div>
<div *ngIf="loanProductSettingsForm.value.recalculationCompoundingFrequencyType === 4 && loanProductSettingsForm.value.recalculationCompoundingFrequencyNthDayType === -2" fxFlex="31%" fxLayout="row" fxLayout.lt-md="column">
<div *ngIf="loanProductSettingsForm.value.recalculationCompoundingFrequencyType === 4 && loanProductSettingsForm.value.recalculationCompoundingFrequencyNthDayType === -2"
fxFlex="31%" fxLayout="row" fxLayout.lt-md="column">
<mat-form-field fxFlexFill>
<mat-select formControlName="recalculationCompoundingFrequencyOnDayType">
@@ -315,7 +325,8 @@
</div>
<div *ngIf="(loanProductSettingsForm.value.recalculationRestFrequencyType === 4 && loanProductSettingsForm.value.recalculationRestFrequencyNthDayType !== -2) || loanProductSettingsForm.value.recalculationRestFrequencyType === 3" fxFlex="31%" fxLayout="row" fxLayout.lt-md="column">
<div *ngIf="(loanProductSettingsForm.value.recalculationRestFrequencyType === 4 && loanProductSettingsForm.value.recalculationRestFrequencyNthDayType !== -2) ||
loanProductSettingsForm.value.recalculationRestFrequencyType === 3" fxFlex="31%" fxLayout="row" fxLayout.lt-md="column">
<mat-form-field fxFlexFill>
<mat-select formControlName="recalculationRestFrequencyDayOfWeekType">
@@ -379,7 +390,8 @@
<h3 fxFlex="23%" class="mat-h3">Loan Tranche Details</h3>
<mat-checkbox fxFlex="73%" labelPosition="before" formControlName="multiDisburseLoan" matTooltip="Leave this checkbox unchecked if the loan is a single disburse loan. Check this checkbox if the loan is a multi disburse loan. See additional fields for additional information required for this type of loan." class="margin-b">
<mat-checkbox fxFlex="73%" labelPosition="before" formControlName="multiDisburseLoan" matTooltip="Leave this checkbox unchecked if the loan is a single disburse loan. Check this
checkbox if the loan is a multi disburse loan. See additional fields for additional information required for this type of loan." class="margin-b">
Enable Multiple Disbursals
</mat-checkbox>
@@ -1,6 +1,5 @@
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { TooltipPosition } from '@angular/material/tooltip';
@Component({
selector: 'mifosx-loan-product-settings-step',
@@ -170,6 +169,7 @@ export class LoanProductSettingsStepComponent implements OnInit {
'holdGuaranteeFunds': [false],
'multiDisburseLoan': [false],
'allowAttributeConfiguration': [true],
'allowPartialPeriodInterestCalcualtion': [false],
'allowAttributeOverrides': this.formBuilder.group({
'amortizationType': [true],
'interestType': [true],
@@ -189,10 +189,8 @@ export class LoanProductSettingsStepComponent implements OnInit {
this.loanProductSettingsForm.get('interestCalculationPeriodType').valueChanges
.subscribe((interestCalculationPeriodType: any) => {
if (interestCalculationPeriodType === 1) {
this.loanProductSettingsForm.addControl('allowPartialPeriodInterestCalcualtion', new FormControl(false));
} else {
this.loanProductSettingsForm.removeControl('allowPartialPeriodInterestCalcualtion');
if (interestCalculationPeriodType === 0) {
this.loanProductSettingsForm.patchValue({'allowPartialPeriodInterestCalcualtion': false});
}
});
@@ -314,9 +314,9 @@
<span fxFlex="60%">{{ loanProduct.interestCalculationPeriodType.value }}</span>
</div>
<div fxFlexFill *ngIf="loanProduct.interestCalculationPeriodType.id === 1">
<div fxFlexFill>
<span fxFlex="40%">Allow Partial Interest Calculation with same as repayment:</span>
<span fxFlex="60%">{{ loanProduct.allowPartialPeriodInterestCalcualtion ? 'Yes' : 'No' }}</span>
<span fxFlex="60%">{{ loanProduct.allowPartialPeriodInterestCalculation ? 'Yes' : 'No' }}</span>
</div>
<div fxFlexFill>