You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@fineract.apache.org by Eitan Frailich <ei...@articode.co> on 2021/01/05 12:08:33 UTC

Loan ideal disbursement date and wrong interest issue

Hi All,
My name is Eitan, I Started working on Fineract in the last few months and
I'm happy to join this active community.
Together with David Yahalomi, I'm a part of Articode.

*My issue/bug happens when I am setting "First repayment on" field I get a
repayment schedule with a wrong interest rate for the first installment.*
Example:
When I set "First repayment on" to 01/02/21 and expected disbursement is
27/1/21(*Frist image*) then I get the wrong interest.
The first installment interest is 21,232.88$ (*second Image*) - calculated
for the entire month (31 days) instead of 5 days (the time from the
disbursement to the first repayment), the right interest should be 3424.75$.

*After debugging: *
In AbstractLoanScheduleGenerator there is a function
*calculateInterestStartDateForPeriod
-* it uses the idealDisbursment for setting the interest start date for the
first installment*,*
The *idealDisbursment *is calculated by
*idealDisbursementDateBasedOnFirstRepaymentDate *which does [
*firstRepaymentDate *- 1 repayment Period Frequency] aka, for 01/02/21 with
months as repyment frequency it will return 01/01/21.
So when we dont set the "First repayment on" the *idealDisbursment *will be
the expected disbursement date because the first repayment is always
expectedDisbursment+1.
But if we set the  "First repayment on" we get the wrong value for the
*idealDisbursment - *in my example we got 01/0/21 and this is why the first
installment interest was calculated for an entire month instead of  5 days.

*Is it a bug or not?*
I am not sure why *idealDisbursementDateBasedOnFirstRepaymentDate* exists,
the simple solution is to do  *idealDisbursment*=*expectedDisbursmentDate.*
I tried it locally and looks like it works, I will be happy to make a PR
<https://github.com/apache/fineract/pull/1562>, but want to make sure
indeed that the *idealDisbursementDateBasedOnFirstRepaymentDate *is
redundant.


Thx,
Eitan

[image: image.png]
[image: image.png]

ᐧ

Re: Loan ideal disbursement date and wrong interest issue

Posted by Bharath Gowda <bg...@mifos.org>.
Hi  Eitan,

Welcome to the community and very pleased with the level of understanding
and analysis you have done on this issue in such a short time.

While I allow our Fineract Dev experts to comment on the
*idealDisbursementDateBasedOnFirstRepaymentDate*  and code related queries,

I would like to highlight one configuration point which could fix the
problem

There is a config "interest-charged-from-date-same-as-disbursal-date" under
"admin->system->configurations
If you enable the configuration, the system will calculate the
interest rate for the period between 'Disbursement date' and 'First
Repayment date' properly.
Provided the loan product has 'interest calculation period' set to daily
(which I assume you have done right by referring to your screenshot)


Regards,
Bharath
Lead Implementation Analyst | Mifos Initiative
Skype: live:cbharath4| Mobile: +91.7019635592
http://mifos.org  <http://facebook.com/mifos>
<http://www.twitter.com/mifos>


On Tue, Jan 5, 2021 at 5:39 PM Eitan Frailich <ei...@articode.co> wrote:

> Hi All,
> My name is Eitan, I Started working on Fineract in the last few months and
> I'm happy to join this active community.
> Together with David Yahalomi, I'm a part of Articode.
>
> *My issue/bug happens when I am setting "First repayment on" field I get a
> repayment schedule with a wrong interest rate for the first installment.*
> Example:
> When I set "First repayment on" to 01/02/21 and expected disbursement is
> 27/1/21(*Frist image*) then I get the wrong interest.
> The first installment interest is 21,232.88$ (*second Image*) -
> calculated for the entire month (31 days) instead of 5 days (the time from
> the disbursement to the first repayment), the right interest should be
> 3424.75$.
>
> *After debugging: *
> In AbstractLoanScheduleGenerator there is a function *calculateInterestStartDateForPeriod
> -* it uses the idealDisbursment for setting the interest start date for
> the first installment*,*
> The *idealDisbursment *is calculated by
> *idealDisbursementDateBasedOnFirstRepaymentDate *which does [
> *firstRepaymentDate *- 1 repayment Period Frequency] aka, for 01/02/21
> with months as repyment frequency it will return 01/01/21.
> So when we dont set the "First repayment on" the *idealDisbursment *will
> be the expected disbursement date because the first repayment is always
> expectedDisbursment+1.
> But if we set the  "First repayment on" we get the wrong value for the
> *idealDisbursment - *in my example we got 01/0/21 and this is why the
> first installment interest was calculated for an entire month instead of  5
> days.
>
> *Is it a bug or not?*
> I am not sure why *idealDisbursementDateBasedOnFirstRepaymentDate* exists,
> the simple solution is to do  *idealDisbursment*=
> *expectedDisbursmentDate.*
> I tried it locally and looks like it works, I will be happy to make a PR
> <https://github.com/apache/fineract/pull/1562>, but want to make sure
> indeed that the *idealDisbursementDateBasedOnFirstRepaymentDate *is
> redundant.
>
>
> Thx,
> Eitan
>
> [image: image.png]
> [image: image.png]
>
> ᐧ
>