Skip to content

Commit

Permalink
fix: allowPartialPeriodInterestCalculation
Browse files Browse the repository at this point in the history
Due to a typo, the allowPartialPeriodInterestCalculation field was not
processed correctly. Since the typo also occurs in some places in the
Fineract API, the typo is re-introduced where needed.
  • Loading branch information
rhopman committed Dec 19, 2024
1 parent f693318 commit 85d5c1b
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,20 @@ export class EditLoansAccountComponent {
}

if (loansAccountData.interestCalculationPeriodType === 0) {
loansAccountData.allowPartialPeriodInterestCalcualtion = false;
loansAccountData.allowPartialPeriodInterestCalculation = false;
}
if (!loansAccountData.isLoanProductLinkedToFloatingRate || loansAccountData.isLoanProductLinkedToFloatingRate === false) {
delete loansAccountData.isFloatingInterestRate;
}
loansAccountData.principal = loansAccountData.principalAmount;
delete loansAccountData.principalAmount;
delete loansAccountData.multiDisburseLoan;

// In Fineract, the POST and PUT endpoints for /v1/loans have a typo in the field
// allowPartialPeriodInterestCalculation. Until that is fixed, we need to replace the field name in the payload.
loansAccountData.allowPartialPeriodInterestCalcualtion = loansAccountData.allowPartialPeriodInterestCalculation;
delete loansAccountData.allowPartialPeriodInterestCalculation;

this.loansService.updateLoansAccount(this.loanId, loansAccountData).subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ <h3 class="mat-h3" fxFlexFill>{{ 'labels.heading.Terms' | translate }}</h3>
}}</span>
</div>

<div fxFlexFill *ngIf="loansAccount.allowPartialPeriodInterestCalcualtion">
<div fxFlexFill *ngIf="loansAccount.allowPartialPeriodInterestCalculation">
<span fxFlex="40%">{{ 'labels.inputs.Calculate interest for exact days in partial period' | translate }}:</span>
<span fxFlex="60%">{{ loansAccount.allowPartialPeriodInterestCalcualtion }}</span>
<span fxFlex="60%">{{ loansAccount.allowPartialPeriodInterestCalculation }}</span>
</div>

<div fxFlexFill *ngIf="loansAccount.inArrearsTolerance">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ <h3 class="mat-h3" fxFlexFill>{{ 'labels.heading.Terms' | translate }}</h3>
}}</span>
</div>

<div fxFlexFill *ngIf="loansAccount.allowPartialPeriodInterestCalcualtion">
<div fxFlexFill *ngIf="loansAccount.allowPartialPeriodInterestCalculation">
<span fxFlex="40%">{{ 'labels.inputs.Calculate interest for exact days in partial period' | translate }}:</span>
<span fxFlex="60%">{{ loansAccount.allowPartialPeriodInterestCalcualtion }}</span>
<span fxFlex="60%">{{ loansAccount.allowPartialPeriodInterestCalculation }}</span>
</div>

<div fxFlexFill *ngIf="loansAccount.inArrearsTolerance">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ <h4 fxFlex="98%" class="mat-h4">{{ 'labels.heading.Interest Calculations' | tran

<mat-checkbox
fxFlex="48%"
formControlName="allowPartialPeriodInterestCalcualtion"
formControlName="allowPartialPeriodInterestCalculation"
matTooltip="{{ 'tooltips.To be used with SAME AS REPAYMENT PERIOD' | translate }}"
>
<p>{{ 'labels.inputs.Calculate interest for exact days in partial period' | translate }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
'interestType': this.loansAccountTermsData.interestType.id,
'isFloatingInterestRate': this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
'interestCalculationPeriodType': this.loansAccountTermsData.interestCalculationPeriodType.id,
'allowPartialPeriodInterestCalcualtion': this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
'allowPartialPeriodInterestCalculation': this.loansAccountTermsData.allowPartialPeriodInterestCalculation,
'inArrearsTolerance': this.loansAccountTermsData.inArrearsTolerance,
'graceOnPrincipalPayment': this.loansAccountTermsData.graceOnPrincipalPayment,
'graceOnInterestPayment': this.loansAccountTermsData.graceOnInterestPayment,
Expand Down Expand Up @@ -186,7 +186,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
}
if (!allowAttributeOverrides.interestCalculationPeriodType) {
this.loansAccountTermsForm.controls.interestCalculationPeriodType.disable();
this.loansAccountTermsForm.controls.allowPartialPeriodInterestCalcualtion.disable();
this.loansAccountTermsForm.controls.allowPartialPeriodInterestCalculation.disable();
}
if (!allowAttributeOverrides.inArrearsTolerance) {
this.loansAccountTermsForm.controls.inArrearsTolerance.disable();
Expand Down Expand Up @@ -232,7 +232,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
'interestType': this.loansAccountTermsData.interestType.id,
'isFloatingInterestRate': this.loansAccountTermsData.isLoanProductLinkedToFloatingRate ? false : '',
'interestCalculationPeriodType': this.loansAccountTermsData.interestCalculationPeriodType.id,
'allowPartialPeriodInterestCalcualtion': this.loansAccountTermsData.allowPartialPeriodInterestCalcualtion,
'allowPartialPeriodInterestCalculation': this.loansAccountTermsData.allowPartialPeriodInterestCalculation,
'inArrearsTolerance': this.loansAccountTermsData.inArrearsTolerance,
'graceOnPrincipalPayment': this.loansAccountTermsData.graceOnPrincipalPayment,
'graceOnInterestPayment': this.loansAccountTermsData.graceOnInterestPayment,
Expand Down Expand Up @@ -351,7 +351,7 @@ export class LoansAccountTermsStepComponent implements OnInit, OnChanges {
'isEqualAmortization': [''],
'amortizationType': ['', Validators.required],
'interestCalculationPeriodType': [''],
'allowPartialPeriodInterestCalcualtion': [''],
'allowPartialPeriodInterestCalculation': [''],
'inArrearsTolerance': [''],
'graceOnInterestCharged': [''],
'graceOnPrincipalPayment': [''],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h3>{{ 'labels.heading.Loan Details' | translate }}</h3>
<span fxFlex="50%">
{{ 'labels.inputs.Allow Partial Interest Calculation with same as repayment' | translate }}</span
>
<span fxFlex="50%"> {{ loanDetails.allowPartialPeriodInterestCalcualtion | yesNo }} </span>
<span fxFlex="50%"> {{ loanDetails.allowPartialPeriodInterestCalculation | yesNo }} </span>
</div>

<div fxFlexFill>
Expand Down
8 changes: 7 additions & 1 deletion src/app/loans/loans.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ export class LoansService {
}

if (loansAccountData.interestCalculationPeriodType === 0) {
loansAccountData.allowPartialPeriodInterestCalcualtion = false;
loansAccountData.allowPartialPeriodInterestCalculation = false;
}
if (!(loansAccountData.isFloatingInterestRate === false)) {
delete loansAccountData.isFloatingInterestRate;
Expand All @@ -612,6 +612,12 @@ export class LoansService {
loansAccountData.principal = loansAccountData.principalAmount;
delete loansAccountData.principalAmount;
delete loansAccountData.multiDisburseLoan; // this was just added so that disbursement data can be send in the backend

// In Fineract, the POST and PUT endpoints for /v1/loans have a typo in the field
// allowPartialPeriodInterestCalculation. Until that is fixed, we need to replace the field name in the payload.
loansAccountData.allowPartialPeriodInterestCalcualtion = loansAccountData.allowPartialPeriodInterestCalculation;
delete loansAccountData.allowPartialPeriodInterestCalculation;

return loansAccountData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
fxFlex="96%"
labelPosition="before"
matTooltip="{{ 'tooltips.To be used with SAME AS REPAYMENT PERIOD' | translate }}"
formControlName="allowPartialPeriodInterestCalcualtion"
formControlName="allowPartialPeriodInterestCalculation"
>
{{ 'labels.inputs.Calculate interest for exact days in partial period' | translate }}
</mat-checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class LoanProductSettingsStepComponent implements OnInit {
.subscribe((isLinkedToFloatingInterestRates: any) => {
if (isLinkedToFloatingInterestRates) {
this.loanProductSettingsForm.get('isInterestRecalculationEnabled').setValue(true);
this.loanProductSettingsForm.get('allowPartialPeriodInterestCalcualtion').setValue(true);
this.loanProductSettingsForm.get('allowPartialPeriodInterestCalculation').setValue(true);
}
});

Expand Down Expand Up @@ -96,7 +96,7 @@ export class LoanProductSettingsStepComponent implements OnInit {
'interestType': this.loanProductsTemplate.interestType.id,
'isEqualAmortization': this.loanProductsTemplate.isEqualAmortization,
'interestCalculationPeriodType': this.loanProductsTemplate.interestCalculationPeriodType.id,
'allowPartialPeriodInterestCalcualtion': this.loanProductsTemplate.allowPartialPeriodInterestCalcualtion,
'allowPartialPeriodInterestCalculation': this.loanProductsTemplate.allowPartialPeriodInterestCalculation,
'transactionProcessingStrategyCode': transactionProcessingStrategyCode,
'graceOnPrincipalPayment': this.loanProductsTemplate.graceOnPrincipalPayment,
'graceOnInterestPayment': this.loanProductsTemplate.graceOnInterestPayment,
Expand Down Expand Up @@ -235,7 +235,7 @@ export class LoanProductSettingsStepComponent implements OnInit {
'holdGuaranteeFunds': [false],
'multiDisburseLoan': [false],
'allowAttributeConfiguration': [true],
'allowPartialPeriodInterestCalcualtion': [false],
'allowPartialPeriodInterestCalculation': [false],
'allowAttributeOverrides': this.formBuilder.group({
'amortizationType': [true],
'interestType': [true],
Expand Down Expand Up @@ -263,7 +263,7 @@ export class LoanProductSettingsStepComponent implements OnInit {
this.loanProductSettingsForm.get('interestCalculationPeriodType').valueChanges
.subscribe((interestCalculationPeriodType: any) => {
if (interestCalculationPeriodType === 0) {
this.loanProductSettingsForm.patchValue({ 'allowPartialPeriodInterestCalcualtion': false });
this.loanProductSettingsForm.patchValue({ 'allowPartialPeriodInterestCalculation': false });
}
});

Expand Down
5 changes: 5 additions & 0 deletions src/app/products/loan-products/loan-products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export class LoanProducts {
delete loanProduct.allowAttributeConfiguration;
delete loanProduct.advancedAccountingRules;

// In Fineract, the POST and PUT endpoints for /v1/loanproducts have a typo in the field
// allowPartialPeriodInterestCalculation. Until that is fixed, we need to replace the field name in the payload.
loanProduct.allowPartialPeriodInterestCalcualtion = loanProduct.allowPartialPeriodInterestCalculation;
delete loanProduct.allowPartialPeriodInterestCalculation;

// Set Default values If they were not set
itemsByDefault.forEach((config: GlobalConfiguration) => {
const propertyName = this.resolvePropertyName(config.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class GeneralTabComponent implements OnInit {
productCopy['currencyCode'] = productCopy['currency'] ? productCopy['currency']['code'] : null;
productCopy['interestRatePerPeriod'] = productCopy['annualInterestRate'];
productCopy['transactionProcessingStrategyCode'] = productCopy['transactionProcessingStrategyName'];
productCopy['allowPartialPeriodInterestCalcualtion'] = productCopy['allowPartialPeriodInterestCalculation'];
productCopy['allowPartialPeriodInterestCalculation'] = productCopy['allowPartialPeriodInterestCalculation'];
productCopy['locale'] = this.settingsService.language.code;

let valueTmp: any = productCopy['daysInMonthType']['value'];
Expand Down
Loading

0 comments on commit 85d5c1b

Please sign in to comment.