fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [fineract] branch develop updated: FINERACT-822 enable BigDecimalEquals error
Date Sat, 13 Jun 2020 10:35:00 GMT
This is an automated email from the ASF dual-hosted git repository.

kaze pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 17cb620  FINERACT-822 enable BigDecimalEquals error
17cb620 is described below

commit 17cb620ec0b062c537cb507acf6127c659173ad2
Author: percyashu <percyayukashu@gmail.com>
AuthorDate: Fri Jun 12 02:31:39 2020 +0100

    FINERACT-822 enable BigDecimalEquals error
---
 fineract-provider/build.gradle                                        | 2 +-
 .../account/service/AccountTransfersWritePlatformServiceImpl.java     | 4 ++--
 .../interestratechart/domain/InterestRateChartSlabFields.java         | 3 ++-
 .../java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java   | 2 +-
 .../service/LoanWritePlatformServiceJpaRepositoryImpl.java            | 4 ++--
 .../apache/fineract/portfolio/savings/domain/FixedDepositAccount.java | 2 +-
 .../fineract/portfolio/savings/domain/RecurringDepositAccount.java    | 2 +-
 .../apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java  | 2 +-
 .../apache/fineract/portfolio/shareproducts/domain/ShareProduct.java  | 4 ++--
 9 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle
index 2e8dd41..b5b064f 100644
--- a/fineract-provider/build.gradle
+++ b/fineract-provider/build.gradle
@@ -316,7 +316,6 @@ tasks.withType(JavaCompile) {
                 "SameNameButDifferent",
                 "StringSplitter",
                 "MissingOverride",
-                "BigDecimalEquals",
                 "ImmutableEnumChecker",
                 "EqualsUnsafeCast",
                 "BoxedPrimitiveEquality",
@@ -341,6 +340,7 @@ tasks.withType(JavaCompile) {
                 "MultiVariableDeclaration",
                 "AssertEqualsArgumentOrderChecker",
                 "EmptySetMultibindingContributions",
+                "BigDecimalEquals",
                 "MixedArrayDimensions",
                 "PackageLocation",
                 "UseBinds",
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
index 96b4ab4..61b5980 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java
@@ -506,7 +506,7 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer
 
         BigDecimal overpaid = this.loanReadPlatformService.retrieveTotalPaidInAdvance(fromLoanAccountId).getPaidInAdvance();
 
-        if (overpaid == null || overpaid.equals(BigDecimal.ZERO) || transactionAmount.floatValue()
> overpaid.floatValue()) {
+        if (overpaid == null || overpaid.compareTo(BigDecimal.ZERO) == 0 ? Boolean.TRUE:Boolean.FALSE
 || transactionAmount.floatValue() > overpaid.floatValue()) {
             if(overpaid == null) {
                 overpaid = BigDecimal.ZERO;
             }
@@ -536,4 +536,4 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer
 
         return builder.build();
     }
-}
\ No newline at end of file
+}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
index 7c21794..16b8a9f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java
@@ -27,6 +27,7 @@ import static org.apache.fineract.portfolio.interestratechart.InterestRateChartS
 import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName;
 
 import java.math.BigDecimal;
+import java.util.Comparator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Objects;
@@ -304,7 +305,7 @@ public class InterestRateChartSlabFields {
 
     public boolean isBigDecimalSame(final BigDecimal obj1, final BigDecimal obj2) {
         if (obj1 == null || obj2 == null) {
-            if (Objects.equals(obj1, obj2)) { return true; }
+            if (Objects.compare(obj1,obj2, Comparator.nullsFirst(Comparator.naturalOrder()))
== 0 ? Boolean.TRUE:Boolean.FALSE){ return true; }
             return false;
         }
         return obj1.compareTo(obj2) == 0;
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
index af09fe9..3a15001 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
@@ -2834,7 +2834,7 @@ public class Loan extends AbstractPersistableCustom {
             this.actualDisbursementDate = null;
             this.disbursedBy = null;
             boolean isDisbursedAmountChanged =
-                    !this.approvedPrincipal.equals(this.loanRepaymentScheduleDetail.getPrincipal().getAmount());
+                    approvedPrincipal.compareTo(this.loanRepaymentScheduleDetail.getPrincipal().getAmount())
== 0 ? Boolean.FALSE:Boolean.TRUE;
             this.loanRepaymentScheduleDetail.setPrincipal(this.approvedPrincipal);
             if (this.loanProduct.isMultiDisburseLoan()) {
                 for (final LoanDisbursementDetails details : this.disbursementDetails) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
index 75a3f91..584882a 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
@@ -2959,7 +2959,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
     private void checkIfLoanIsPaidInAdvance(final Long loanId, final BigDecimal transactionAmount)
{
         BigDecimal overpaid = this.loanReadPlatformService.retrieveTotalPaidInAdvance(loanId).getPaidInAdvance();
 
-        if (overpaid == null || overpaid.equals(new BigDecimal(0)) || transactionAmount.floatValue()
> overpaid.floatValue()) {
+        if (overpaid == null || overpaid.compareTo(BigDecimal.ZERO) == 0 ? Boolean.TRUE:Boolean.FALSE
|| transactionAmount.floatValue() > overpaid.floatValue()) {
             if (overpaid == null) {
                 overpaid = BigDecimal.ZERO;
             }
@@ -3105,4 +3105,4 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
         }
 
     }
-}
\ No newline at end of file
+}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
index a527a17..298040e 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/FixedDepositAccount.java
@@ -746,7 +746,7 @@ public class FixedDepositAccount extends SavingsAccount {
             BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount,
depositStartDate(),
                     calculateMaturityDate(), this.client);
 
-            if (applicableInterestRate.equals(BigDecimal.ZERO)) {
+            if (applicableInterestRate.compareTo(BigDecimal.ZERO) == 0 ? Boolean.TRUE:Boolean.FALSE)
{
                 baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                         "no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
             }
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
index 8cfa864..62499f2 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/RecurringDepositAccount.java
@@ -1042,7 +1042,7 @@ public class RecurringDepositAccount extends SavingsAccount {
             BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(maturityAmount,
depositStartDate(), maturityDate,
                     this.client);
 
-            if (applicableInterestRate.equals(BigDecimal.ZERO)) {
+            if (applicableInterestRate.compareTo(BigDecimal.ZERO) == 0 ? Boolean.TRUE:Boolean.FALSE)
{
                 baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                         "no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
             }
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java
index b4f0220..5d358a3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/domain/ShareAccount.java
@@ -518,7 +518,7 @@ public class ShareAccount extends AbstractPersistableCustom {
         for (ShareAccountTransaction tran : this.shareAccountTransactions) {
             if (tran.getPurchasedDate().equals(transaction.getPurchasedDate())
                     && tran.getTotalShares().equals(transaction.getTotalShares())
-                    && tran.getPurchasePrice().equals(transaction.getPurchasePrice())
+                    && tran.getPurchasePrice().compareTo(transaction.getPurchasePrice())
== 0 ? Boolean.TRUE:Boolean.FALSE
                     && tran.getTransactionStatus().equals(transaction.getTransactionStatus())
                     && tran.getTransactionType().equals(transaction.getTransactionType()))
{
                 returnTrans = tran;
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java
index 5f1ba65..dd86246 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java
@@ -248,7 +248,7 @@ public class ShareProduct extends AbstractAuditableCustom {
 
     public boolean setUnitPrice(BigDecimal unitPrice) {
         boolean returnValue = false;
-        if (!this.unitPrice.equals(unitPrice)) {
+        if (this.unitPrice.compareTo(unitPrice) == 0 ? Boolean.FALSE:Boolean.TRUE) {
             this.unitPrice = unitPrice;
             returnValue = true;
         }
@@ -363,7 +363,7 @@ public class ShareProduct extends AbstractAuditableCustom {
 
     public boolean setshareCapitalValue(BigDecimal shareCapitalValue) {
         boolean updated = false;
-        if (this.shareCapital == null || !this.shareCapital.equals(shareCapitalValue)) {
+        if (this.shareCapital == null || this.shareCapital.compareTo(shareCapitalValue) ==
0 ? Boolean.FALSE:Boolean.TRUE) {
             this.shareCapital = shareCapitalValue;
             updated = true;
         }


Mime
View raw message