When making loan repayments, guarantor release code is throwing exception: Non-terminating decimal expansion; no exact representable decimal result.
As discussed with Pramod, BigDecimal.divide needs to have a rounding parameter. instead it is done without any rounding,
For Example: amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal); This needs to be changed to: amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, RoundingMode.HALF_EVEN)
There are multiple places that similar fixes may be needed.
Sample stacktrace: 344575476 http-bio-443-exec-57 ERROR c.s.j.s.container.ContainerResponse - The RuntimeException could not be mapped to a response, re-throwing to the HTTP container java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. at java.math.BigDecimal.divide(BigDecimal.java:1616) ~na:1.7.0_51 at org.mifosplatform.portfolio.loanaccount.guarantor.service.GuarantorDomainServiceImpl.releaseGuarantorFunds(GuarantorDomainServiceImpl.java:381) ~GuarantorDomainServiceImpl.class:na at org.mifosplatform.portfolio.loanaccount.guarantor.service.GuarantorDomainServiceImpl.access$1000(GuarantorDomainServiceImpl.java:53) ~GuarantorDomainServiceImpl.class:na at org.mifosplatform.portfolio.loanaccount.guarantor.service.GuarantorDomainServiceImpl$ReleaseFundsOnBusinessEvent.businessEventWasExecuted(GuarantorDomainServiceImpl.java:539) ~GuarantorDomainServiceImpl$ReleaseFundsOnBusinessEvent.class:na at org.mifosplatform.portfolio.common.service.BusinessEventNotifierServiceImpl.notifyBusinessEventWasExecuted(BusinessEventNotifierServiceImpl.java:58) ~BusinessEventNotifierServiceImpl.class:na at org.mifosplatform.portfolio.loanaccount.domain.LoanAccountDomainServiceJpa.makeRepayment(LoanAccountDomainServiceJpa.java:224) ~LoanAccountDomainServiceJpa.class:na at sun.reflect.GeneratedMethodAccessor239.invoke(Unknown Source) ~na:na at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~na:1.7.0_51 at java.lang.reflect.Method.invoke(Method.java:606) ~na:1.7.0_51 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE
|