FINERACT-822 Enable CompareToZero check

This commit is contained in:
percyashu
2020-06-01 12:43:49 +02:00
committed by Michael Vorburger ⛑️
parent e295bef743
commit aed3e41ca4
29 changed files with 153 additions and 155 deletions
+4 -6
View File
@@ -309,7 +309,6 @@ tasks.withType(JavaCompile) {
"UnnecessaryParentheses", "UnnecessaryParentheses",
"ClassCanBeStatic", "ClassCanBeStatic",
"MissingCasesInEnumSwitch", "MissingCasesInEnumSwitch",
"CompareToZero",
"OperatorPrecedence", "OperatorPrecedence",
"MixedMutabilityReturnType", "MixedMutabilityReturnType",
"SameNameButDifferent", "SameNameButDifferent",
@@ -332,11 +331,13 @@ tasks.withType(JavaCompile) {
"UnusedNestedClass", "UnusedNestedClass",
"UndefinedEquals", "UndefinedEquals",
"JdkObsolete", "JdkObsolete",
"OperatorPrecedence", "OperatorPrecedence"
"NarrowingCompoundAssignment"
) )
//TODO gradually enable these checks //TODO gradually enable these checks
error( "DefaultCharset", error( "DefaultCharset",
"RemoveUnusedImports",
"WaitNotInLoop",
"ThreeLetterTimeZoneID",
// "ReturnMissingNullable", // "ReturnMissingNullable",
// "InconsistentOverloads", // "InconsistentOverloads",
// "MethodCanBeStatic", // "MethodCanBeStatic",
@@ -348,7 +349,6 @@ tasks.withType(JavaCompile) {
// "MultiVariableDeclaration", // "MultiVariableDeclaration",
// "PackageLocation", // "PackageLocation",
// "PrivateConstructorForNoninstantiableModule", // "PrivateConstructorForNoninstantiableModule",
// "RemoveUnusedImports",
// "UnnecessaryStaticImport", // "UnnecessaryStaticImport",
// "UseBinds", // "UseBinds",
// "WildcardImport", // "WildcardImport",
@@ -357,11 +357,9 @@ tasks.withType(JavaCompile) {
// "FloatCast", // "FloatCast",
// "ClassNewInstance", // "ClassNewInstance",
// "ConstructorInvokesOverridable", // "ConstructorInvokesOverridable",
// "ThreeLetterTimeZoneID",
// "UnsafeFinalization", // "UnsafeFinalization",
// "MutableMethodReturnType", // "MutableMethodReturnType",
// "SynchronizeOnNonFinalField", // "SynchronizeOnNonFinalField",
// "WaitNotInLoop",
// "SwitchDefault", // "SwitchDefault",
// "ReachabilityFenceUsage", // "ReachabilityFenceUsage",
// "BoxedPrimitiveConstructor", // "BoxedPrimitiveConstructor",
@@ -231,7 +231,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
} }
if (this.status != null) { if (this.status != null) {
if ((Double) this.status.get("id") >= 0) { if ((Double) this.status.get("id") >= 0) {
hash += (Double) this.status.get("id"); hash = (int) (hash + (Double) this.status.get("id"));
} }
if ((String) this.status.get("code") != null) { if ((String) this.status.get("code") != null) {
hash += this.status.get("code").hashCode(); hash += this.status.get("code").hashCode();
@@ -66,7 +66,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
FinancialActivity.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId, FinancialActivity.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
transactionDate, overdraftAmount, isReversal); transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
@@ -77,7 +77,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
@@ -90,7 +90,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
FinancialActivity.LIABILITY_TRANSFER.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
@@ -101,7 +101,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
@@ -154,12 +154,12 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
else if (savingsTransactionDTO.getTransactionType().isInterestPosting() && savingsTransactionDTO.isOverdraftTransaction()) { else if (savingsTransactionDTO.getTransactionType().isInterestPosting() && savingsTransactionDTO.isOverdraftTransaction()) {
// Post journal entry if earned interest amount is greater than // Post journal entry if earned interest amount is greater than
// zero // zero
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) == 1) { if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
@@ -171,7 +171,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) { else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
// Post journal entry if earned interest amount is greater than // Post journal entry if earned interest amount is greater than
// zero // zero
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) == 1) { if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
@@ -193,7 +193,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES,
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
penaltyPayments); penaltyPayments);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES,
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
@@ -204,7 +204,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES,
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
feePayments); feePayments);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal, paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
@@ -76,7 +76,7 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
public void createJournalEntriesForRedeem(final Long shareAccountId, final Long shareProductId, final String currencyCode, public void createJournalEntriesForRedeem(final Long shareAccountId, final Long shareProductId, final String currencyCode,
final Date transactionDate, final String transactionId, final Office office, final Long paymentTypeId, final BigDecimal amount, final Date transactionDate, final String transactionId, final Office office, final Long paymentTypeId, final BigDecimal amount,
final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) { final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) {
if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) != 1) { if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) <= 0) {
this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_EQUITY.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_EQUITY.getValue(),
CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount); transactionDate, amount);
@@ -94,7 +94,7 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
SharesTransactionDTO transactionDTO, final Date transactionDate, final String transactionId, final Office office, SharesTransactionDTO transactionDTO, final Date transactionDate, final String transactionId, final Office office,
final Long paymentTypeId, final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) { final Long paymentTypeId, final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) {
if (transactionDTO.getTransactionStatus().isApplied()) { if (transactionDTO.getTransactionStatus().isApplied()) {
if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) != 1) { if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) <= 0) {
this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE.getValue(),
CashAccountsForShares.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount); transactionDate, amount);
@@ -108,14 +108,14 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
} }
} else if (transactionDTO.getTransactionStatus().isApproved()) { } else if (transactionDTO.getTransactionStatus().isApproved()) {
BigDecimal amountForJE = amount; BigDecimal amountForJE = amount;
if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) == 1) { if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) > 0) {
amountForJE = amount.subtract(chargeAmount); amountForJE = amount.subtract(chargeAmount);
} }
this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(),
CashAccountsForShares.SHARES_EQUITY.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_EQUITY.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amountForJE); transactionDate, amountForJE);
} else if (transactionDTO.getTransactionStatus().isRejected()) { } else if (transactionDTO.getTransactionStatus().isRejected()) {
if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) == 1) { if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) > 0) {
this.helper.revertCashBasedJournalEntryForSharesCharges(office, currencyCode, CashAccountsForShares.INCOME_FROM_FEES, this.helper.revertCashBasedJournalEntryForSharesCharges(office, currencyCode, CashAccountsForShares.INCOME_FROM_FEES,
shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments); shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments);
this.helper.createDebitJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId, this.helper.createDebitJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId,
@@ -708,7 +708,7 @@ public class DataValidatorBuilder {
public DataValidatorBuilder comapareMinimumAndMaximumAmounts(final BigDecimal minimumBalance, final BigDecimal maximumBalance) { public DataValidatorBuilder comapareMinimumAndMaximumAmounts(final BigDecimal minimumBalance, final BigDecimal maximumBalance) {
if (minimumBalance != null && maximumBalance != null) { if (minimumBalance != null && maximumBalance != null) {
if (maximumBalance.compareTo(minimumBalance) == -1) { if (maximumBalance.compareTo(minimumBalance) < 0) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.not.within.expected.range"); .append(this.parameter).append(".is.not.within.expected.range");
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ") final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ")
@@ -725,7 +725,7 @@ public class DataValidatorBuilder {
public DataValidatorBuilder inMinAndMaxAmountRange(final BigDecimal minimumAmount, final BigDecimal maximumAmount) { public DataValidatorBuilder inMinAndMaxAmountRange(final BigDecimal minimumAmount, final BigDecimal maximumAmount) {
if (minimumAmount != null && maximumAmount != null && this.value != null) { if (minimumAmount != null && maximumAmount != null && this.value != null) {
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString())); final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
if (amount.compareTo(minimumAmount) == -1 || amount.compareTo(maximumAmount) == 1) { if (amount.compareTo(minimumAmount) < 0 || amount.compareTo(maximumAmount) > 0) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".amount.is.not.within.min.max.range"); .append(this.parameter).append(".amount.is.not.within.min.max.range");
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" amount ") final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" amount ")
@@ -743,7 +743,7 @@ public class DataValidatorBuilder {
public DataValidatorBuilder notLessThanMin(final BigDecimal min) { public DataValidatorBuilder notLessThanMin(final BigDecimal min) {
if (min != null && this.value != null) { if (min != null && this.value != null) {
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString())); final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
if (amount.compareTo(min) == -1) { if (amount.compareTo(min) < 0) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.less.than.min"); .append(this.parameter).append(".is.less.than.min");
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ") final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ")
@@ -760,7 +760,7 @@ public class DataValidatorBuilder {
public DataValidatorBuilder notGreaterThanMax(final BigDecimal max) { public DataValidatorBuilder notGreaterThanMax(final BigDecimal max) {
if (max != null && this.value != null) { if (max != null && this.value != null) {
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString())); final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
if (amount.compareTo(max) == 1) { if (amount.compareTo(max) > 0) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.greater.than.max"); .append(this.parameter).append(".is.greater.than.max");
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ") final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ")
@@ -776,7 +776,7 @@ public class DataValidatorBuilder {
public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) { public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) {
if (min != null && max != null) { if (min != null && max != null) {
if (max.compareTo(min) == -1) { if (max.compareTo(min) < 0) {
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".") final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
.append(this.parameter).append(".is.not.within.expected.range"); .append(this.parameter).append(".is.not.within.expected.range");
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min) final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min)
@@ -154,7 +154,7 @@ public class InterestRateChartSlabDataValidator {
} }
if (amountRangeFrom != null && amountRangeTo != null) { if (amountRangeFrom != null && amountRangeTo != null) {
if (amountRangeFrom.compareTo(amountRangeTo) > 1) { if (amountRangeFrom.compareTo(amountRangeTo) > 0) {
baseDataValidator.parameter(amountRangeFromParamName).value(fromPeriod).failWithCode("from.amount.greater.than.to.amount"); baseDataValidator.parameter(amountRangeFromParamName).value(fromPeriod).failWithCode("from.amount.greater.than.to.amount");
} }
} }
@@ -239,7 +239,7 @@ public class InterestRateChartSlabDataValidator {
} }
if (amountRangeFrom != null && amountRangeTo != null) { if (amountRangeFrom != null && amountRangeTo != null) {
if (amountRangeFrom.compareTo(amountRangeTo) > 1) { if (amountRangeFrom.compareTo(amountRangeTo) > 0) {
baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod).failWithCode("fromperiod.greater.than.toperiod"); baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod).failWithCode("fromperiod.greater.than.toperiod");
} }
} }
@@ -163,7 +163,7 @@ public class InterestRateChartSlabFields {
public boolean isFromPeriodGreaterThanToPeriod() { public boolean isFromPeriodGreaterThanToPeriod() {
boolean isGreater = false; boolean isGreater = false;
if (this.toPeriod != null && this.fromPeriod.compareTo(this.toPeriod) > 1) { if (this.toPeriod != null && this.fromPeriod.compareTo(this.toPeriod) > 0) {
isGreater = true; isGreater = true;
} }
return isGreater; return isGreater;
@@ -171,7 +171,7 @@ public class InterestRateChartSlabFields {
public boolean isAmountRangeFromGreaterThanTo() { public boolean isAmountRangeFromGreaterThanTo() {
boolean isGreater = false; boolean isGreater = false;
if (this.amountRangeFrom != null && this.amountRangeTo != null && this.amountRangeFrom.compareTo(this.amountRangeTo) > 1) { if (this.amountRangeFrom != null && this.amountRangeTo != null && this.amountRangeFrom.compareTo(this.amountRangeTo) > 0) {
isGreater = true; isGreater = true;
} }
return isGreater; return isGreater;
@@ -281,8 +281,8 @@ public class InterestRateChartSlabFields {
return true; return true;
} else if (this.amountRangeTo == null) { } else if (this.amountRangeTo == null) {
return true; return true;
} else if (that.amountRangeTo == null) { return that.amountRangeFrom.compareTo(this.amountRangeTo) < 1; } } else if (that.amountRangeTo == null) { return that.amountRangeFrom.compareTo(this.amountRangeTo) <= 0; }
return this.amountRangeFrom.compareTo(that.amountRangeTo) < 1 && that.amountRangeFrom.compareTo(this.amountRangeTo) < 1; return this.amountRangeFrom.compareTo(that.amountRangeTo) <= 0 && that.amountRangeFrom.compareTo(this.amountRangeTo) <= 0;
} }
public boolean isAmountSame(final InterestRateChartSlabFields that) { public boolean isAmountSame(final InterestRateChartSlabFields that) {
@@ -2203,7 +2203,7 @@ public class Loan extends AbstractPersistableCustom {
// Approved amount has to be less than or equal to principal // Approved amount has to be less than or equal to principal
// amount demanded // amount demanded
if (approvedLoanAmount.compareTo(this.proposedPrincipal) == -1) { if (approvedLoanAmount.compareTo(this.proposedPrincipal) < 0) {
this.approvedPrincipal = approvedLoanAmount; this.approvedPrincipal = approvedLoanAmount;
@@ -2217,7 +2217,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put(LoanApiConstants.approvedLoanAmountParameterName, approvedLoanAmount); actualChanges.put(LoanApiConstants.approvedLoanAmountParameterName, approvedLoanAmount);
actualChanges.put(LoanApiConstants.disbursementPrincipalParameterName, approvedLoanAmount); actualChanges.put(LoanApiConstants.disbursementPrincipalParameterName, approvedLoanAmount);
} else if (approvedLoanAmount.compareTo(this.proposedPrincipal) == 1) { } else if (approvedLoanAmount.compareTo(this.proposedPrincipal) > 0) {
final String errorMessage = "Loan approved amount can't be greater than loan amount demanded."; final String errorMessage = "Loan approved amount can't be greater than loan amount demanded.";
throw new InvalidLoanStateTransitionException("approval", "amount.can't.be.greater.than.loan.amount.demanded", throw new InvalidLoanStateTransitionException("approval", "amount.can't.be.greater.than.loan.amount.demanded",
errorMessage, this.proposedPrincipal, approvedLoanAmount); errorMessage, this.proposedPrincipal, approvedLoanAmount);
@@ -2511,7 +2511,7 @@ public class Loan extends AbstractPersistableCustom {
totalAmount = totalAmount.add(disbursementDetails.principal()); totalAmount = totalAmount.add(disbursementDetails.principal());
} }
this.loanRepaymentScheduleDetail.setPrincipal(setPrincipalAmount); this.loanRepaymentScheduleDetail.setPrincipal(setPrincipalAmount);
if (totalAmount.compareTo(this.approvedPrincipal) == 1) { if (totalAmount.compareTo(this.approvedPrincipal) > 0) {
final String errorMsg = "Loan can't be disbursed,disburse amount is exceeding approved principal "; final String errorMsg = "Loan can't be disbursed,disburse amount is exceeding approved principal ";
throw new LoanDisbursalException(errorMsg, "disburse.amount.must.be.less.than.approved.principal", principalDisbursed, throw new LoanDisbursalException(errorMsg, "disburse.amount.must.be.less.than.approved.principal", principalDisbursed,
this.approvedPrincipal); this.approvedPrincipal);
@@ -2519,7 +2519,7 @@ public class Loan extends AbstractPersistableCustom {
} else { } else {
this.loanRepaymentScheduleDetail.setPrincipal(this.loanRepaymentScheduleDetail.getPrincipal().minus(diff).getAmount()); this.loanRepaymentScheduleDetail.setPrincipal(this.loanRepaymentScheduleDetail.getPrincipal().minus(diff).getAmount());
} }
if (!(this.loanProduct().isMultiDisburseLoan()) && diff.compareTo(BigDecimal.ZERO) == -1) { if (!(this.loanProduct().isMultiDisburseLoan()) && diff.compareTo(BigDecimal.ZERO) < 0) {
final String errorMsg = "Loan can't be disbursed,disburse amount is exceeding approved amount "; final String errorMsg = "Loan can't be disbursed,disburse amount is exceeding approved amount ";
throw new LoanDisbursalException(errorMsg, "disburse.amount.must.be.less.than.approved.amount", principalDisbursed, throw new LoanDisbursalException(errorMsg, "disburse.amount.must.be.less.than.approved.amount", principalDisbursed,
this.loanRepaymentScheduleDetail.getPrincipal().getAmount()); this.loanRepaymentScheduleDetail.getPrincipal().getAmount());
@@ -3004,7 +3004,7 @@ public class Loan extends AbstractPersistableCustom {
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
if (status().isOverpaid()) { if (status().isOverpaid()) {
if (this.totalOverpaid.compareTo(loanTransaction.getAmount(getCurrency()).getAmount()) == -1) { if (this.totalOverpaid.compareTo(loanTransaction.getAmount(getCurrency()).getAmount()) < 0) {
final String errorMessage = "The refund amount must be less than or equal to overpaid amount "; final String errorMessage = "The refund amount must be less than or equal to overpaid amount ";
throw new InvalidLoanStateTransitionException("transaction", "is.exceeding.overpaid.amount", errorMessage, throw new InvalidLoanStateTransitionException("transaction", "is.exceeding.overpaid.amount", errorMessage,
this.totalOverpaid, loanTransaction.getAmount(getCurrency()).getAmount()); this.totalOverpaid, loanTransaction.getAmount(getCurrency()).getAmount());
@@ -3258,7 +3258,7 @@ public class Loan extends AbstractPersistableCustom {
boolean isAllChargesPaid = true; boolean isAllChargesPaid = true;
for (final LoanCharge loanCharge : this.charges) { for (final LoanCharge loanCharge : this.charges) {
if (loanCharge.isActive() && loanCharge.amount().compareTo(BigDecimal.ZERO) == 1 && !(loanCharge.isPaid() || loanCharge.isWaived())) { if (loanCharge.isActive() && loanCharge.amount().compareTo(BigDecimal.ZERO) > 0 && !(loanCharge.isPaid() || loanCharge.isWaived())) {
isAllChargesPaid = false; isAllChargesPaid = false;
break; break;
} }
@@ -567,7 +567,7 @@ public class LoanCharge extends AbstractPersistableCustom {
} }
private static boolean isGreaterThanZero(final BigDecimal value) { private static boolean isGreaterThanZero(final BigDecimal value) {
return value.compareTo(BigDecimal.ZERO) == 1; return value.compareTo(BigDecimal.ZERO) > 0;
} }
public LoanChargeCommand toCommand() { public LoanChargeCommand toCommand() {
@@ -120,7 +120,7 @@ public class GuarantorFundingDetails extends AbstractPersistableCustom {
public void undoReleaseFunds(final BigDecimal amount) { public void undoReleaseFunds(final BigDecimal amount) {
this.amountReleased = getAmountReleased().subtract(amount); this.amountReleased = getAmountReleased().subtract(amount);
this.amountRemaining = getAmountRemaining().add(amount); this.amountRemaining = getAmountRemaining().add(amount);
if (getStatus().isCompleted() && this.amountRemaining.compareTo(BigDecimal.ZERO) == 1) { if (getStatus().isCompleted() && this.amountRemaining.compareTo(BigDecimal.ZERO) > 0) {
this.updateStatus(GuarantorFundStatusType.ACTIVE); this.updateStatus(GuarantorFundStatusType.ACTIVE);
} }
} }
@@ -141,17 +141,17 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.guarantor"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.guarantor");
if (actualSelfAmount.compareTo(minSelfAmount) == -1) { if (actualSelfAmount.compareTo(minSelfAmount) < 0) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_SELF_GUARANTEE_ERROR, baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_SELF_GUARANTEE_ERROR,
minSelfAmount); minSelfAmount);
} }
if (actualExtGuarantee.compareTo(minExtGuarantee) == -1) { if (actualExtGuarantee.compareTo(minExtGuarantee) < 0) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_EXTERNAL_GUARANTEE_ERROR, baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_EXTERNAL_GUARANTEE_ERROR,
minExtGuarantee); minExtGuarantee);
} }
actualAmount = actualAmount.add(actualExtGuarantee).add(actualSelfAmount); actualAmount = actualAmount.add(actualExtGuarantee).add(actualSelfAmount);
if (actualAmount.compareTo(mandatoryAmount) == -1) { if (actualAmount.compareTo(mandatoryAmount) < 0) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_MANDATORY_GUARANTEE_ERROR, baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_MANDATORY_GUARANTEE_ERROR,
mandatoryAmount); mandatoryAmount);
} }
@@ -171,7 +171,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
if (guarantorFundingDetails.getStatus().isActive()) { if (guarantorFundingDetails.getStatus().isActive()) {
SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount(); SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount();
savingsAccount.holdFunds(guarantorFundingDetails.getAmount()); savingsAccount.holdFunds(guarantorFundingDetails.getAmount());
if (savingsAccount.getWithdrawableBalance().compareTo(BigDecimal.ZERO) == -1) { if (savingsAccount.getWithdrawableBalance().compareTo(BigDecimal.ZERO) < 0) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.guarantor"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.guarantor");
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_INSUFFICIENT_BALANCE_ERROR, baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(GuarantorConstants.GUARANTOR_INSUFFICIENT_BALANCE_ERROR,
@@ -195,7 +195,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
@Override @Override
public void releaseGuarantor(final GuarantorFundingDetails guarantorFundingDetails, final LocalDate transactionDate) { public void releaseGuarantor(final GuarantorFundingDetails guarantorFundingDetails, final LocalDate transactionDate) {
BigDecimal amoutForWithdraw = guarantorFundingDetails.getAmountRemaining(); BigDecimal amoutForWithdraw = guarantorFundingDetails.getAmountRemaining();
if (amoutForWithdraw.compareTo(BigDecimal.ZERO) == 1 && (guarantorFundingDetails.getStatus().isActive())) { if (amoutForWithdraw.compareTo(BigDecimal.ZERO) > 0 && (guarantorFundingDetails.getStatus().isActive())) {
SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount(); SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount();
savingsAccount.releaseFunds(amoutForWithdraw); savingsAccount.releaseFunds(amoutForWithdraw);
DepositAccountOnHoldTransaction onHoldTransaction = DepositAccountOnHoldTransaction.release(savingsAccount, amoutForWithdraw, DepositAccountOnHoldTransaction onHoldTransaction = DepositAccountOnHoldTransaction.release(savingsAccount, amoutForWithdraw,
@@ -218,7 +218,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
*/ */
@Override @Override
public void transaferFundsFromGuarantor(final Loan loan) { public void transaferFundsFromGuarantor(final Loan loan) {
if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) != 1) { return; } if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) <= 0) { return; }
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan); final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
final boolean isRegularTransaction = true; final boolean isRegularTransaction = true;
final boolean isExceptionForBalanceCheck = true; final boolean isExceptionForBalanceCheck = true;
@@ -252,7 +252,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
releaseLoanIds.put(loanId, guarantorFundingDetails.getId()); releaseLoanIds.put(loanId, guarantorFundingDetails.getId());
try { try {
BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining(); BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining();
if (loan.getGuaranteeAmount().compareTo(loan.getPrincpal().getAmount()) == 1) { if (loan.getGuaranteeAmount().compareTo(loan.getPrincpal().getAmount()) > 0) {
remainingAmount = remainingAmount.multiply(loan.getPrincpal().getAmount()).divide(loan.getGuaranteeAmount(), remainingAmount = remainingAmount.multiply(loan.getPrincpal().getAmount()).divide(loan.getGuaranteeAmount(),
MoneyHelper.getRoundingMode()); MoneyHelper.getRoundingMode());
} }
@@ -295,7 +295,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
*/ */
private void reverseAllFundTransaction(final Loan loan) { private void reverseAllFundTransaction(final Loan loan) {
if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) == 1) { if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) > 0) {
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan); final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
List<GuarantorFundingDetails> guarantorFundingDetailList = new ArrayList<>(); List<GuarantorFundingDetails> guarantorFundingDetailList = new ArrayList<>();
for (Guarantor guarantor : existGuarantorList) { for (Guarantor guarantor : existGuarantorList) {
@@ -349,7 +349,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
null, onHoldTransaction); null, onHoldTransaction);
guarantorFundingDetails.addGuarantorFundingTransactions(guarantorFundingTransaction); guarantorFundingDetails.addGuarantorFundingTransactions(guarantorFundingTransaction);
guarantorFundingDetailList.add(guarantorFundingDetails); guarantorFundingDetailList.add(guarantorFundingDetails);
if (savingsAccount.getWithdrawableBalance().compareTo(BigDecimal.ZERO) == -1) { if (savingsAccount.getWithdrawableBalance().compareTo(BigDecimal.ZERO) < 0) {
insufficientBalanceIds.add(savingsAccount.getId()); insufficientBalanceIds.add(savingsAccount.getId());
} }
savingsAccount.updateSavingsAccountSummary(savingsAccount.getTransactions()); savingsAccount.updateSavingsAccountSummary(savingsAccount.getTransactions());
@@ -382,7 +382,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
*/ */
private void releaseGuarantorFunds(final LoanTransaction loanTransaction) { private void releaseGuarantorFunds(final LoanTransaction loanTransaction) {
final Loan loan = loanTransaction.getLoan(); final Loan loan = loanTransaction.getLoan();
if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) == 1) { if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) > 0) {
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan); final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
List<GuarantorFundingDetails> externalGuarantorList = new ArrayList<>(); List<GuarantorFundingDetails> externalGuarantorList = new ArrayList<>();
List<GuarantorFundingDetails> selfGuarantorList = new ArrayList<>(); List<GuarantorFundingDetails> selfGuarantorList = new ArrayList<>();
@@ -413,7 +413,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease, BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease,
loanTransaction, accountOnHoldTransactions); loanTransaction, accountOnHoldTransactions);
if (amountLeft.compareTo(BigDecimal.ZERO) == 1) { if (amountLeft.compareTo(BigDecimal.ZERO) > 0) {
calculateAndRelaseGuarantorFunds(selfGuarantorList, selfGuarantee, amountLeft, loanTransaction, calculateAndRelaseGuarantorFunds(selfGuarantorList, selfGuarantee, amountLeft, loanTransaction,
accountOnHoldTransactions); accountOnHoldTransactions);
externalGuarantorList.addAll(selfGuarantorList); externalGuarantorList.addAll(selfGuarantorList);
@@ -435,7 +435,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
*/ */
private void releaseAllGuarantors(final LoanTransaction loanTransaction) { private void releaseAllGuarantors(final LoanTransaction loanTransaction) {
Loan loan = loanTransaction.getLoan(); Loan loan = loanTransaction.getLoan();
if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) == 1) { if (loan.getGuaranteeAmount().compareTo(BigDecimal.ZERO) > 0) {
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan); final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
List<GuarantorFundingDetails> saveGuarantorFundingDetails = new ArrayList<>(); List<GuarantorFundingDetails> saveGuarantorFundingDetails = new ArrayList<>();
List<DepositAccountOnHoldTransaction> onHoldTransactions = new ArrayList<>(); List<DepositAccountOnHoldTransaction> onHoldTransactions = new ArrayList<>();
@@ -443,7 +443,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
final List<GuarantorFundingDetails> fundingDetails = guarantor.getGuarantorFundDetails(); final List<GuarantorFundingDetails> fundingDetails = guarantor.getGuarantorFundDetails();
for (GuarantorFundingDetails guarantorFundingDetails : fundingDetails) { for (GuarantorFundingDetails guarantorFundingDetails : fundingDetails) {
BigDecimal amoutForRelease = guarantorFundingDetails.getAmountRemaining(); BigDecimal amoutForRelease = guarantorFundingDetails.getAmountRemaining();
if (amoutForRelease.compareTo(BigDecimal.ZERO) == 1 && (guarantorFundingDetails.getStatus().isActive())) { if (amoutForRelease.compareTo(BigDecimal.ZERO) > 0 && (guarantorFundingDetails.getStatus().isActive())) {
SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount(); SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount();
savingsAccount.releaseFunds(amoutForRelease); savingsAccount.releaseFunds(amoutForRelease);
DepositAccountOnHoldTransaction onHoldTransaction = DepositAccountOnHoldTransaction.release(savingsAccount, DepositAccountOnHoldTransaction onHoldTransaction = DepositAccountOnHoldTransaction.release(savingsAccount,
@@ -495,7 +495,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
for (GuarantorFundingDetails fundingDetails : guarantorList) { for (GuarantorFundingDetails fundingDetails : guarantorList) {
BigDecimal guarantorAmount = amountForRelease.multiply(fundingDetails.getAmountRemaining()).divide(totalGuaranteeAmount, BigDecimal guarantorAmount = amountForRelease.multiply(fundingDetails.getAmountRemaining()).divide(totalGuaranteeAmount,
MoneyHelper.getRoundingMode()); MoneyHelper.getRoundingMode());
if (fundingDetails.getAmountRemaining().compareTo(guarantorAmount) < 1) { if (fundingDetails.getAmountRemaining().compareTo(guarantorAmount) <= 0) {
guarantorAmount = fundingDetails.getAmountRemaining(); guarantorAmount = fundingDetails.getAmountRemaining();
} }
fundingDetails.releaseFunds(guarantorAmount); fundingDetails.releaseFunds(guarantorAmount);
@@ -278,7 +278,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
// will check for EMI amount greater than interest calculated // will check for EMI amount greater than interest calculated
if (loanApplicationTerms.getFixedEmiAmount() != null if (loanApplicationTerms.getFixedEmiAmount() != null
&& loanApplicationTerms.getFixedEmiAmount().compareTo(principalInterestForThisPeriod.interest().getAmount()) == -1) { && loanApplicationTerms.getFixedEmiAmount().compareTo(principalInterestForThisPeriod.interest().getAmount()) < 0) {
String errorMsg = "EMI amount must be greater than : " + principalInterestForThisPeriod.interest().getAmount(); String errorMsg = "EMI amount must be greater than : " + principalInterestForThisPeriod.interest().getAmount();
throw new MultiDisbursementEmiAmountException(errorMsg, principalInterestForThisPeriod.interest().getAmount(), throw new MultiDisbursementEmiAmountException(errorMsg, principalInterestForThisPeriod.interest().getAmount(),
loanApplicationTerms.getFixedEmiAmount()); loanApplicationTerms.getFixedEmiAmount());
@@ -154,7 +154,7 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC
BigDecimal disbursedAmount = loan.getDisbursedAmount(); BigDecimal disbursedAmount = loan.getDisbursedAmount();
BigDecimal principalRepaid = loan.getLoanSummary().getTotalPrincipalRepaid(); BigDecimal principalRepaid = loan.getLoanSummary().getTotalPrincipalRepaid();
BigDecimal principalWrittenOff = loan.getLoanSummary().getTotalPrincipalWrittenOff(); BigDecimal principalWrittenOff = loan.getLoanSummary().getTotalPrincipalWrittenOff();
if (disbursedAmount.subtract(principalWrittenOff).subtract(principalRepaid).compareTo(BigDecimal.ZERO) != 1) { return; } if (disbursedAmount.subtract(principalWrittenOff).subtract(principalRepaid).compareTo(BigDecimal.ZERO) <= 0) { return; }
} }
MonetaryCurrency currency = loan.getCurrency(); MonetaryCurrency currency = loan.getCurrency();
Money totalPrincipal = Money.zero(currency); Money totalPrincipal = Money.zero(currency);
@@ -154,7 +154,7 @@ public class LoanScheduleHistoryReadPlatformServiceImpl implements LoanScheduleH
periods.add(periodData); periods.add(periodData);
this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount()); this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
} else if (data.isDueForDisbursement(fromDate, dueDate) } else if (data.isDueForDisbursement(fromDate, dueDate)
&& this.outstandingLoanPrincipalBalance.compareTo(BigDecimal.ZERO) == 1) { && this.outstandingLoanPrincipalBalance.compareTo(BigDecimal.ZERO) > 0) {
principal = principal.add(data.amount()); principal = principal.add(data.amount());
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod( final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
data.disbursementDate(), data.amount(), BigDecimal.ZERO, data.isDisbursed()); data.disbursementDate(), data.amount(), BigDecimal.ZERO, data.isDisbursed());
@@ -1144,7 +1144,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
i++; i++;
} while (i < variationArray.size()); } while (i < variationArray.size());
if (tatalDisbursement.compareTo(totalPrincipal) == 1) { if (tatalDisbursement.compareTo(totalPrincipal) > 0) {
baseDataValidator.reset().parameter(LoanApiConstants.disbursementPrincipalParameterName) baseDataValidator.reset().parameter(LoanApiConstants.disbursementPrincipalParameterName)
.failWithCode(LoanApiConstants.APPROVED_AMOUNT_IS_LESS_THAN_SUM_OF_TRANCHES); .failWithCode(LoanApiConstants.APPROVED_AMOUNT_IS_LESS_THAN_SUM_OF_TRANCHES);
} }
@@ -206,7 +206,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
penaltyportion = null; penaltyportion = null;
} }
} }
if (amount.compareTo(BigDecimal.ZERO) == 1) { if (amount.compareTo(BigDecimal.ZERO) > 0) {
addAccrualAccounting(accrualData, amount, interestportion, totalAccInterest, feeportion, totalAccFee, penaltyportion, addAccrualAccounting(accrualData, amount, interestportion, totalAccInterest, feeportion, totalAccFee, penaltyportion,
totalAccPenalty, tilldate); totalAccPenalty, tilldate);
} }
@@ -257,7 +257,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
penaltyportion = null; penaltyportion = null;
} }
} }
if (amount.compareTo(BigDecimal.ZERO) == 1) { if (amount.compareTo(BigDecimal.ZERO) > 0) {
addAccrualAccounting(scheduleAccrualData, amount, interestportion, totalAccInterest, feeportion, totalAccFee, penaltyportion, addAccrualAccounting(scheduleAccrualData, amount, interestportion, totalAccInterest, feeportion, totalAccFee, penaltyportion,
totalAccPenalty, scheduleAccrualData.getDueDateAsLocaldate()); totalAccPenalty, scheduleAccrualData.getDueDateAsLocaldate());
} }
@@ -374,7 +374,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
accruableForInstallment = accruableForInstallment.subtract(installmentChargeData.getAmountUnrecognized()); accruableForInstallment = accruableForInstallment.subtract(installmentChargeData.getAmountUnrecognized());
} }
chargeAmount = accruableForInstallment; chargeAmount = accruableForInstallment;
boolean canAddCharge = chargeAmount.compareTo(BigDecimal.ZERO) == 1; boolean canAddCharge = chargeAmount.compareTo(BigDecimal.ZERO) > 0;
if (canAddCharge if (canAddCharge
&& (installmentChargeData.getAmountAccrued() == null || chargeAmount.compareTo(installmentChargeData && (installmentChargeData.getAmountAccrued() == null || chargeAmount.compareTo(installmentChargeData
.getAmountAccrued()) != 0)) { .getAmountAccrued()) != 0)) {
@@ -398,7 +398,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
if (loanCharge.getAmountUnrecognized() != null) { if (loanCharge.getAmountUnrecognized() != null) {
chargeAmount = chargeAmount.subtract(loanCharge.getAmountUnrecognized()); chargeAmount = chargeAmount.subtract(loanCharge.getAmountUnrecognized());
} }
boolean canAddCharge = chargeAmount.compareTo(BigDecimal.ZERO) == 1; boolean canAddCharge = chargeAmount.compareTo(BigDecimal.ZERO) > 0;
if (canAddCharge && (loanCharge.getAmountAccrued() == null || chargeAmount.compareTo(loanCharge.getAmountAccrued()) != 0)) { if (canAddCharge && (loanCharge.getAmountAccrued() == null || chargeAmount.compareTo(loanCharge.getAmountAccrued()) != 0)) {
BigDecimal amountForAccrual = chargeAmount; BigDecimal amountForAccrual = chargeAmount;
if (loanCharge.getAmountAccrued() != null) { if (loanCharge.getAmountAccrued() != null) {
@@ -451,14 +451,14 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
Iterator<LoanTransactionData> iterator = loanTransactionDatas.iterator(); Iterator<LoanTransactionData> iterator = loanTransactionDatas.iterator();
for (LoanSchedulePeriodData loanSchedulePeriodData : loanSchedulePeriodDatas) { for (LoanSchedulePeriodData loanSchedulePeriodData : loanSchedulePeriodDatas) {
if (recognized.compareTo(BigDecimal.ZERO) != 1 && unrecognized.compareTo(BigDecimal.ZERO) != 1 && iterator.hasNext()) { if (recognized.compareTo(BigDecimal.ZERO) <= 0 && unrecognized.compareTo(BigDecimal.ZERO) <= 0 && iterator.hasNext()) {
LoanTransactionData loanTransactionData = iterator.next(); LoanTransactionData loanTransactionData = iterator.next();
recognized = recognized.add(loanTransactionData.getInterestPortion()); recognized = recognized.add(loanTransactionData.getInterestPortion());
unrecognized = unrecognized.add(loanTransactionData.getUnrecognizedIncomePortion()); unrecognized = unrecognized.add(loanTransactionData.getUnrecognizedIncomePortion());
} }
if (loanSchedulePeriodData.periodDueDate().isBefore(accrualData.getDueDateAsLocaldate())) { if (loanSchedulePeriodData.periodDueDate().isBefore(accrualData.getDueDateAsLocaldate())) {
remainingAmt = remainingAmt.add(loanSchedulePeriodData.interestWaived()); remainingAmt = remainingAmt.add(loanSchedulePeriodData.interestWaived());
if (recognized.compareTo(remainingAmt) == 1) { if (recognized.compareTo(remainingAmt) > 0) {
recognized = recognized.subtract(remainingAmt); recognized = recognized.subtract(remainingAmt);
remainingAmt = BigDecimal.ZERO; remainingAmt = BigDecimal.ZERO;
} else { } else {
@@ -477,7 +477,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
} }
BigDecimal interestWaived = accrualData.getWaivedInterestIncome(); BigDecimal interestWaived = accrualData.getWaivedInterestIncome();
if (interestWaived.compareTo(recognized) == 1) { if (interestWaived.compareTo(recognized) > 0) {
interestIncome = interestIncome.subtract(interestWaived.subtract(recognized)); interestIncome = interestIncome.subtract(interestWaived.subtract(recognized));
} }
} }
@@ -183,7 +183,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
} }
BigDecimal totalOverDue = principalOverdue.add(interestOverdue).add(feeOverdue).add(penaltyOverdue); BigDecimal totalOverDue = principalOverdue.add(interestOverdue).add(feeOverdue).add(penaltyOverdue);
if (totalOverDue.compareTo(BigDecimal.ZERO) == 1) { if (totalOverDue.compareTo(BigDecimal.ZERO) > 0) {
if (isInsertStatement) { if (isInsertStatement) {
updateSql = constructInsertStatement(loan.getId(), principalOverdue, interestOverdue, feeOverdue, penaltyOverdue, updateSql = constructInsertStatement(loan.getId(), principalOverdue, interestOverdue, feeOverdue, penaltyOverdue,
overDueSince); overDueSince);
@@ -277,12 +277,12 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
loanSchedulePeriodData.penaltyChargesPaid())); loanSchedulePeriodData.penaltyChargesPaid()));
if (overDueSince.isAfter(loanSchedulePeriodData.periodDueDate()) if (overDueSince.isAfter(loanSchedulePeriodData.periodDueDate())
&& loanSchedulePeriodData.principalDue().subtract(loanSchedulePeriodData.principalPaid()) && loanSchedulePeriodData.principalDue().subtract(loanSchedulePeriodData.principalPaid())
.compareTo(BigDecimal.ZERO) == 1) { .compareTo(BigDecimal.ZERO) > 0) {
overDueSince = loanSchedulePeriodData.periodDueDate(); overDueSince = loanSchedulePeriodData.periodDueDate();
} }
} }
} }
if (principalOverdue.compareTo(BigDecimal.ZERO) == 1) { if (principalOverdue.compareTo(BigDecimal.ZERO) > 0) {
String sqlStatement = null; String sqlStatement = null;
if (isInsertStatement) { if (isInsertStatement) {
sqlStatement = constructInsertStatement(loanId, principalOverdue, interestOverdue, feeOverdue, penaltyOverdue, sqlStatement = constructInsertStatement(loanId, principalOverdue, interestOverdue, feeOverdue, penaltyOverdue,
@@ -356,7 +356,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
BigDecimal feeChargesPaid = null; BigDecimal feeChargesPaid = null;
BigDecimal penaltyChargesPaid = null; BigDecimal penaltyChargesPaid = null;
Boolean isComplete = true; Boolean isComplete = true;
if (loanSchedulePeriodData.principalDue().compareTo(principalAmt) == 1) { if (loanSchedulePeriodData.principalDue().compareTo(principalAmt) > 0) {
principalPaid = principalAmt; principalPaid = principalAmt;
principalAmt = BigDecimal.ZERO; principalAmt = BigDecimal.ZERO;
isComplete = false; isComplete = false;
@@ -365,7 +365,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
principalAmt = principalAmt.subtract(loanSchedulePeriodData.principalDue()); principalAmt = principalAmt.subtract(loanSchedulePeriodData.principalDue());
} }
if (loanSchedulePeriodData.interestDue().compareTo(interestAmt) == 1) { if (loanSchedulePeriodData.interestDue().compareTo(interestAmt) > 0) {
interestPaid = interestAmt; interestPaid = interestAmt;
interestAmt = BigDecimal.ZERO; interestAmt = BigDecimal.ZERO;
isComplete = false; isComplete = false;
@@ -373,7 +373,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
interestPaid = loanSchedulePeriodData.interestDue(); interestPaid = loanSchedulePeriodData.interestDue();
interestAmt = interestAmt.subtract(loanSchedulePeriodData.interestDue()); interestAmt = interestAmt.subtract(loanSchedulePeriodData.interestDue());
} }
if (loanSchedulePeriodData.feeChargesDue().compareTo(feeAmt) == 1) { if (loanSchedulePeriodData.feeChargesDue().compareTo(feeAmt) > 0) {
feeChargesPaid = feeAmt; feeChargesPaid = feeAmt;
feeAmt = BigDecimal.ZERO; feeAmt = BigDecimal.ZERO;
isComplete = false; isComplete = false;
@@ -381,7 +381,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
feeChargesPaid = loanSchedulePeriodData.feeChargesDue(); feeChargesPaid = loanSchedulePeriodData.feeChargesDue();
feeAmt = feeAmt.subtract(loanSchedulePeriodData.feeChargesDue()); feeAmt = feeAmt.subtract(loanSchedulePeriodData.feeChargesDue());
} }
if (loanSchedulePeriodData.penaltyChargesDue().compareTo(penaltyAmt) == 1) { if (loanSchedulePeriodData.penaltyChargesDue().compareTo(penaltyAmt) > 0) {
penaltyChargesPaid = penaltyAmt; penaltyChargesPaid = penaltyAmt;
penaltyAmt = BigDecimal.ZERO; penaltyAmt = BigDecimal.ZERO;
isComplete = false; isComplete = false;
@@ -193,9 +193,9 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter(maxPrincipalParameterName).value(maxPrincipalAmount).ignoreIfNull().positiveAmount(); baseDataValidator.reset().parameter(maxPrincipalParameterName).value(maxPrincipalAmount).ignoreIfNull().positiveAmount();
} }
if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) != -1) { if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) >= 0) {
if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) != -1) { if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter(maxPrincipalParameterName).value(maxPrincipalAmount).notLessThanMin(minPrincipalAmount); baseDataValidator.reset().parameter(maxPrincipalParameterName).value(maxPrincipalAmount).notLessThanMin(minPrincipalAmount);
if (minPrincipalAmount.compareTo(maxPrincipalAmount) <= 0 && principal != null) { if (minPrincipalAmount.compareTo(maxPrincipalAmount) <= 0 && principal != null) {
baseDataValidator.reset().parameter("principal").value(principal) baseDataValidator.reset().parameter("principal").value(principal)
@@ -204,7 +204,7 @@ public final class LoanProductDataValidator {
} else if (principal != null) { } else if (principal != null) {
baseDataValidator.reset().parameter("principal").value(principal).notGreaterThanMax(maxPrincipalAmount); baseDataValidator.reset().parameter("principal").value(principal).notGreaterThanMax(maxPrincipalAmount);
} }
} else if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) != -1 && principal != null) { } else if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) >= 0 && principal != null) {
baseDataValidator.reset().parameter("principal").value(principal).notLessThanMin(minPrincipalAmount); baseDataValidator.reset().parameter("principal").value(principal).notLessThanMin(minPrincipalAmount);
} }
@@ -227,8 +227,8 @@ public final class LoanProductDataValidator {
.integerGreaterThanZero(); .integerGreaterThanZero();
} }
if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) == 1) { if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) > 0) {
if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) > 0) {
baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments) baseDataValidator.reset().parameter(maxNumberOfRepaymentsParameterName).value(maxNumberOfRepayments)
.notLessThanMin(minNumberOfRepayments); .notLessThanMin(minNumberOfRepayments);
if (minNumberOfRepayments.compareTo(maxNumberOfRepayments) <= 0) { if (minNumberOfRepayments.compareTo(maxNumberOfRepayments) <= 0) {
@@ -239,7 +239,7 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments) baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments)
.notGreaterThanMax(maxNumberOfRepayments); .notGreaterThanMax(maxNumberOfRepayments);
} }
} else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { } else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) > 0) {
baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments).notLessThanMin(minNumberOfRepayments); baseDataValidator.reset().parameter("numberOfRepayments").value(numberOfRepayments).notLessThanMin(minNumberOfRepayments);
} }
@@ -397,22 +397,22 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter(maxDifferentialLendingRateParameterName).value(maxDifferentialLendingRate).notNull() baseDataValidator.reset().parameter(maxDifferentialLendingRateParameterName).value(maxDifferentialLendingRate).notNull()
.zeroOrPositiveAmount(); .zeroOrPositiveAmount();
if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("defaultDifferentialLendingRate").value(defaultDifferentialLendingRate) baseDataValidator.reset().parameter("defaultDifferentialLendingRate").value(defaultDifferentialLendingRate)
.notLessThanMin(minDifferentialLendingRate); .notLessThanMin(minDifferentialLendingRate);
} }
} }
if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate) baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate)
.notLessThanMin(minDifferentialLendingRate); .notLessThanMin(minDifferentialLendingRate);
} }
} }
if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate) baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate)
.notLessThanMin(defaultDifferentialLendingRate); .notLessThanMin(defaultDifferentialLendingRate);
} }
@@ -493,8 +493,8 @@ public final class LoanProductDataValidator {
.zeroOrPositiveAmount(); .zeroOrPositiveAmount();
} }
if (maxInterestRatePerPeriod != null && maxInterestRatePerPeriod.compareTo(BigDecimal.ZERO) != -1) { if (maxInterestRatePerPeriod != null && maxInterestRatePerPeriod.compareTo(BigDecimal.ZERO) >= 0) {
if (minInterestRatePerPeriod != null && minInterestRatePerPeriod.compareTo(BigDecimal.ZERO) != -1) { if (minInterestRatePerPeriod != null && minInterestRatePerPeriod.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod) baseDataValidator.reset().parameter(maxInterestRatePerPeriodParameterName).value(maxInterestRatePerPeriod)
.notLessThanMin(minInterestRatePerPeriod); .notLessThanMin(minInterestRatePerPeriod);
if (minInterestRatePerPeriod.compareTo(maxInterestRatePerPeriod) <= 0) { if (minInterestRatePerPeriod.compareTo(maxInterestRatePerPeriod) <= 0) {
@@ -505,7 +505,7 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod) baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod)
.notGreaterThanMax(maxInterestRatePerPeriod); .notGreaterThanMax(maxInterestRatePerPeriod);
} }
} else if (minInterestRatePerPeriod != null && minInterestRatePerPeriod.compareTo(BigDecimal.ZERO) != -1) { } else if (minInterestRatePerPeriod != null && minInterestRatePerPeriod.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod) baseDataValidator.reset().parameter("interestRatePerPeriod").value(interestRatePerPeriod)
.notLessThanMin(minInterestRatePerPeriod); .notLessThanMin(minInterestRatePerPeriod);
} }
@@ -1260,22 +1260,22 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter(maxDifferentialLendingRateParameterName).value(maxDifferentialLendingRate).notNull() baseDataValidator.reset().parameter(maxDifferentialLendingRateParameterName).value(maxDifferentialLendingRate).notNull()
.zeroOrPositiveAmount(); .zeroOrPositiveAmount();
if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("defaultDifferentialLendingRate").value(defaultDifferentialLendingRate) baseDataValidator.reset().parameter("defaultDifferentialLendingRate").value(defaultDifferentialLendingRate)
.notLessThanMin(minDifferentialLendingRate); .notLessThanMin(minDifferentialLendingRate);
} }
} }
if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (minDifferentialLendingRate != null && minDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate) baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate)
.notLessThanMin(minDifferentialLendingRate); .notLessThanMin(minDifferentialLendingRate);
} }
} }
if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (maxDifferentialLendingRate != null && maxDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) != -1) { if (defaultDifferentialLendingRate != null && defaultDifferentialLendingRate.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate) baseDataValidator.reset().parameter("maxDifferentialLendingRate").value(maxDifferentialLendingRate)
.notLessThanMin(defaultDifferentialLendingRate); .notLessThanMin(defaultDifferentialLendingRate);
} }
@@ -1594,14 +1594,14 @@ public final class LoanProductDataValidator {
maxPrincipalAmount = minmaxValues.get(LoanProductConstants.maxPrincipal); maxPrincipalAmount = minmaxValues.get(LoanProductConstants.maxPrincipal);
} }
if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) > 0)
&& (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1)) { && (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) > 0)) {
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount) baseDataValidator.reset().parameter(principalParameterName).value(principalAmount)
.inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount); .inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount);
} else { } else {
if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) { if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notLessThanMin(minPrincipalAmount); baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notLessThanMin(minPrincipalAmount);
} else if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) { } else if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notGreaterThanMax(maxPrincipalAmount); baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notGreaterThanMax(maxPrincipalAmount);
} }
} }
@@ -1620,15 +1620,15 @@ public final class LoanProductDataValidator {
} }
} }
if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) == 1) { if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) > 0) {
if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) > 0) {
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
.inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments); .inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments);
} else { } else {
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
.notGreaterThanMax(maxNumberOfRepayments); .notGreaterThanMax(maxNumberOfRepayments);
} }
} else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { } else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) > 0) {
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
.notLessThanMin(minNumberOfRepayments); .notLessThanMin(minNumberOfRepayments);
} }
@@ -1700,14 +1700,14 @@ public final class LoanProductDataValidator {
if ((principalUpdated || minPrincipalUpdated || maxPrincipalUpdated)) { if ((principalUpdated || minPrincipalUpdated || maxPrincipalUpdated)) {
if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) > 0)
&& (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1)) { && (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) > 0)) {
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount) baseDataValidator.reset().parameter(principalParameterName).value(principalAmount)
.inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount); .inMinAndMaxAmountRange(minPrincipalAmount, maxPrincipalAmount);
} else { } else {
if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) { if (minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notLessThanMin(minPrincipalAmount); baseDataValidator.reset().parameter(principalParameterName).value(principalAmount).notLessThanMin(minPrincipalAmount);
} else if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) == 1) { } else if (maxPrincipalAmount != null && maxPrincipalAmount.compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().parameter(principalParameterName).value(principalAmount) baseDataValidator.reset().parameter(principalParameterName).value(principalAmount)
.notGreaterThanMax(maxPrincipalAmount); .notGreaterThanMax(maxPrincipalAmount);
} }
@@ -1759,15 +1759,15 @@ public final class LoanProductDataValidator {
} }
if (numberOfRepaymentsUpdated || minNumberOfRepaymentsUpdated || maxNumberOfRepaymentsUpdated) { if (numberOfRepaymentsUpdated || minNumberOfRepaymentsUpdated || maxNumberOfRepaymentsUpdated) {
if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) == 1) { if (maxNumberOfRepayments != null && maxNumberOfRepayments.compareTo(0) > 0) {
if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) > 0) {
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
.inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments); .inMinMaxRange(minNumberOfRepayments, maxNumberOfRepayments);
} else { } else {
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
.notGreaterThanMax(maxNumberOfRepayments); .notGreaterThanMax(maxNumberOfRepayments);
} }
} else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) == 1) { } else if (minNumberOfRepayments != null && minNumberOfRepayments.compareTo(0) > 0) {
baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments) baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments)
.notLessThanMin(minNumberOfRepayments); .notLessThanMin(minNumberOfRepayments);
} }
@@ -1924,14 +1924,14 @@ public final class LoanProductDataValidator {
if (maxValue != null) { if (maxValue != null) {
baseDataValidator.reset().parameter(maxParameterName).value(maxValue).notLessThanMin(minValue); baseDataValidator.reset().parameter(maxParameterName).value(maxValue).notLessThanMin(minValue);
} }
if ((minValue != null && minValue.compareTo(BigDecimal.ZERO) == 1) if ((minValue != null && minValue.compareTo(BigDecimal.ZERO) > 0)
&& (maxValue != null && maxValue.compareTo(BigDecimal.ZERO) == 1)) { && (maxValue != null && maxValue.compareTo(BigDecimal.ZERO) > 0)) {
baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue) baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue)
.inMinAndMaxAmountRange(minValue, maxValue); .inMinAndMaxAmountRange(minValue, maxValue);
} else { } else {
if (minValue != null && minValue.compareTo(BigDecimal.ZERO) == 1) { if (minValue != null && minValue.compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notLessThanMin(minValue); baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notLessThanMin(minValue);
} else if (maxValue != null && maxValue.compareTo(BigDecimal.ZERO) == 1) { } else if (maxValue != null && maxValue.compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notGreaterThanMax(maxValue); baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notGreaterThanMax(maxValue);
} }
} }
@@ -2019,7 +2019,7 @@ public final class LoanProductDataValidator {
} }
} }
if (mandatoryGuarantee.compareTo(minimumGuaranteeFromOwnFunds.add(minimumGuaranteeFromGuarantor)) == -1) { if (mandatoryGuarantee.compareTo(minimumGuaranteeFromOwnFunds.add(minimumGuaranteeFromGuarantor)) < 0) {
baseDataValidator.parameter(LoanProductConstants.mandatoryGuaranteeParamName).failWithCode( baseDataValidator.parameter(LoanProductConstants.mandatoryGuaranteeParamName).failWithCode(
"must.be.greter.than.sum.of.min.funds"); "must.be.greter.than.sum.of.min.funds");
} }
@@ -730,8 +730,8 @@ public class DepositProductDataValidator {
baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notNull().positiveAmount(); baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notNull().positiveAmount();
} }
if (depositMaxAmount != null && depositMaxAmount.compareTo(BigDecimal.ZERO) != -1) { if (depositMaxAmount != null && depositMaxAmount.compareTo(BigDecimal.ZERO) >= 0) {
if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) != -1) { if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notLessThanMin(depositMinAmount); baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notLessThanMin(depositMinAmount);
if (depositMinAmount.compareTo(depositMaxAmount) <= 0) { if (depositMinAmount.compareTo(depositMaxAmount) <= 0) {
baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount) baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount)
@@ -740,7 +740,7 @@ public class DepositProductDataValidator {
} else { } else {
baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notGreaterThanMax(depositMaxAmount); baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notGreaterThanMax(depositMaxAmount);
} }
} else if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) != -1) { } else if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notLessThanMin(depositMinAmount); baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notLessThanMin(depositMinAmount);
} }
} }
@@ -766,8 +766,8 @@ public class DepositProductDataValidator {
} }
if (depositAmount != null) { if (depositAmount != null) {
if (depositMaxAmount != null && depositMaxAmount.compareTo(BigDecimal.ZERO) != -1) { if (depositMaxAmount != null && depositMaxAmount.compareTo(BigDecimal.ZERO) >= 0) {
if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) != -1) { if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notLessThanMin(depositMinAmount); baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notLessThanMin(depositMinAmount);
if (depositMinAmount.compareTo(depositMaxAmount) <= 0) { if (depositMinAmount.compareTo(depositMaxAmount) <= 0) {
baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount) baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount)
@@ -776,7 +776,7 @@ public class DepositProductDataValidator {
} else { } else {
baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notGreaterThanMax(depositMaxAmount); baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notGreaterThanMax(depositMaxAmount);
} }
} else if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) != -1) { } else if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) >= 0) {
baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notLessThanMin(depositMinAmount); baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notLessThanMin(depositMinAmount);
} }
} }
@@ -144,7 +144,7 @@ public class SavingsAccountTransactionDataValidator {
baseDataValidator.reset().parameter(withdrawBalanceParamName).value(withdrawBalance).isOneOfTheseValues(true, false); baseDataValidator.reset().parameter(withdrawBalanceParamName).value(withdrawBalance).isOneOfTheseValues(true, false);
} }
if (account.getSavingsHoldAmount().compareTo(BigDecimal.ZERO) == 1) { if (account.getSavingsHoldAmount().compareTo(BigDecimal.ZERO) > 0) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
"amount.is.on.hold.release.the.amount.to.continue", account.getId()); "amount.is.on.hold.release.the.amount.to.continue", account.getId());
} }
@@ -198,7 +198,7 @@ public class SavingsAccountTransactionDataValidator {
.failWithCodeNoParameterAddedToErrorCode(SavingsApiConstants.ERROR_MSG_SAVINGS_ACCOUNT_NOT_ACTIVE); .failWithCodeNoParameterAddedToErrorCode(SavingsApiConstants.ERROR_MSG_SAVINGS_ACCOUNT_NOT_ACTIVE);
} }
account.holdAmount(amount); account.holdAmount(amount);
if (account.getWithdrawableBalance().compareTo(BigDecimal.ZERO)==-1){ if (account.getWithdrawableBalance().compareTo(BigDecimal.ZERO) < 0){
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("insufficient balance", account.getId()); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("insufficient balance", account.getId());
} }
LocalDate lastTransactionDate = account.retrieveLastTransactionDate(); LocalDate lastTransactionDate = account.retrieveLastTransactionDate();
@@ -177,7 +177,7 @@ public class FixedDepositAccount extends SavingsAccount {
if (applyPreMaturePenalty) { if (applyPreMaturePenalty) {
applicableInterestRate = applicableInterestRate.subtract(penalInterest); applicableInterestRate = applicableInterestRate.subtract(penalInterest);
applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : applicableInterestRate; applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : applicableInterestRate;
} }
} }
this.nominalAnnualInterestRate = applicableInterestRate; this.nominalAnnualInterestRate = applicableInterestRate;
@@ -230,7 +230,7 @@ public class RecurringDepositAccount extends SavingsAccount {
if (applyPreMaturePenalty) { if (applyPreMaturePenalty) {
applicableInterestRate = applicableInterestRate.subtract(penalInterest); applicableInterestRate = applicableInterestRate.subtract(penalInterest);
applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : applicableInterestRate; applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : applicableInterestRate;
} }
this.nominalAnnualInterestRate = applicableInterestRate; this.nominalAnnualInterestRate = applicableInterestRate;
@@ -610,10 +610,10 @@ public class SavingsAccount extends AbstractPersistableCustom {
protected boolean createWithHoldTransaction(final BigDecimal amount, final LocalDate date) { protected boolean createWithHoldTransaction(final BigDecimal amount, final LocalDate date) {
boolean isTaxAdded = false; boolean isTaxAdded = false;
if (this.taxGroup != null && amount.compareTo(BigDecimal.ZERO) == 1) { if (this.taxGroup != null && amount.compareTo(BigDecimal.ZERO) > 0) {
Map<TaxComponent, BigDecimal> taxSplit = TaxUtils.splitTax(amount, date, this.taxGroup.getTaxGroupMappings(), amount.scale()); Map<TaxComponent, BigDecimal> taxSplit = TaxUtils.splitTax(amount, date, this.taxGroup.getTaxGroupMappings(), amount.scale());
BigDecimal totalTax = TaxUtils.totalTaxAmount(taxSplit); BigDecimal totalTax = TaxUtils.totalTaxAmount(taxSplit);
if (totalTax.compareTo(BigDecimal.ZERO) == 1) { if (totalTax.compareTo(BigDecimal.ZERO) > 0) {
SavingsAccountTransaction withholdTransaction = SavingsAccountTransaction.withHoldTax(this, office(), date, SavingsAccountTransaction withholdTransaction = SavingsAccountTransaction.withHoldTax(this, office(), date,
Money.of(currency, totalTax), taxSplit); Money.of(currency, totalTax), taxSplit);
addTransaction(withholdTransaction); addTransaction(withholdTransaction);
@@ -625,11 +625,11 @@ public class SavingsAccount extends AbstractPersistableCustom {
protected boolean updateWithHoldTransaction(final BigDecimal amount, final SavingsAccountTransaction withholdTransaction) { protected boolean updateWithHoldTransaction(final BigDecimal amount, final SavingsAccountTransaction withholdTransaction) {
boolean isTaxAdded = false; boolean isTaxAdded = false;
if (this.taxGroup != null && amount.compareTo(BigDecimal.ZERO) == 1) { if (this.taxGroup != null && amount.compareTo(BigDecimal.ZERO) > 0) {
Map<TaxComponent, BigDecimal> taxSplit = TaxUtils.splitTax(amount, withholdTransaction.transactionLocalDate(), Map<TaxComponent, BigDecimal> taxSplit = TaxUtils.splitTax(amount, withholdTransaction.transactionLocalDate(),
this.taxGroup.getTaxGroupMappings(), amount.scale()); this.taxGroup.getTaxGroupMappings(), amount.scale());
BigDecimal totalTax = TaxUtils.totalTaxAmount(taxSplit); BigDecimal totalTax = TaxUtils.totalTaxAmount(taxSplit);
if (totalTax.compareTo(BigDecimal.ZERO) == 1) { if (totalTax.compareTo(BigDecimal.ZERO) > 0) {
if (withholdTransaction.getId() == null) { if (withholdTransaction.getId() == null) {
withholdTransaction.updateAmount(Money.of(currency, totalTax)); withholdTransaction.updateAmount(Money.of(currency, totalTax));
withholdTransaction.getTaxDetails().clear(); withholdTransaction.getTaxDetails().clear();
@@ -1143,7 +1143,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
"transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount); } "transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount); }
} }
if (this.getSavingsHoldAmount().compareTo(BigDecimal.ZERO) == 1) { if (this.getSavingsHoldAmount().compareTo(BigDecimal.ZERO) > 0) {
if (runningBalance.minus(this.getSavingsHoldAmount()).isLessThanZero()) { if (runningBalance.minus(this.getSavingsHoldAmount()).isLessThanZero()) {
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), withdrawalFee, throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), withdrawalFee,
transactionAmount); transactionAmount);
@@ -2690,7 +2690,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME);
if (this.overdraftLimit != null && this.product.overdraftLimit() != null if (this.overdraftLimit != null && this.product.overdraftLimit() != null
&& this.overdraftLimit.compareTo(this.product.overdraftLimit()) == 1) { && this.overdraftLimit.compareTo(this.product.overdraftLimit()) > 0) {
baseDataValidator.reset().parameter(SavingsApiConstants.overdraftLimitParamName).value(this.overdraftLimit) baseDataValidator.reset().parameter(SavingsApiConstants.overdraftLimitParamName).value(this.overdraftLimit)
.failWithCode("cannot.exceed.product.value"); .failWithCode("cannot.exceed.product.value");
} }
@@ -501,7 +501,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
} }
private boolean isGreaterThanZero(final BigDecimal value) { private boolean isGreaterThanZero(final BigDecimal value) {
return value.compareTo(BigDecimal.ZERO) == 1; return value.compareTo(BigDecimal.ZERO) > 0;
} }
public LocalDate getDueLocalDate() { public LocalDate getDueLocalDate() {
@@ -840,7 +840,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
public boolean isChargeIsOverPaid(final LocalDate nextDueDate) { public boolean isChargeIsOverPaid(final LocalDate nextDueDate) {
final BigDecimal amountPaid = this.amountPaid == null ? BigDecimal.ZERO : amountPaid(); final BigDecimal amountPaid = this.amountPaid == null ? BigDecimal.ZERO : amountPaid();
return this.getDueLocalDate().isAfter(nextDueDate) && amountPaid.compareTo(BigDecimal.ZERO) == 1; return this.getDueLocalDate().isAfter(nextDueDate) && amountPaid.compareTo(BigDecimal.ZERO) > 0;
} }
private BigDecimal amountPaid() { private BigDecimal amountPaid() {
@@ -111,7 +111,7 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth, postInterestOnDate); isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -262,7 +262,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
financialYearBeginningMonth); financialYearBeginningMonth);
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -379,7 +379,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -645,7 +645,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -748,7 +748,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -1194,7 +1194,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -1329,7 +1329,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -289,7 +289,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
account.processAccountUponActivation(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth, user); account.processAccountUponActivation(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth, user);
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -625,7 +625,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -717,7 +717,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -1122,7 +1122,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -1255,7 +1255,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
financialYearBeginningMonth, postInterestOnDate); financialYearBeginningMonth, postInterestOnDate);
} }
List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null; List<DepositAccountOnHoldTransaction> depositAccountOnHoldTransactions = null;
if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) == 1) { if (account.getOnHoldFunds().compareTo(BigDecimal.ZERO) > 0) {
depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository depositAccountOnHoldTransactions = this.depositAccountOnHoldTransactionRepository
.findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account); .findBySavingsAccountAndReversedFalseOrderByCreatedDateAsc(account);
} }
@@ -205,7 +205,7 @@ public class ShareAccountCharge extends AbstractPersistableCustom {
} }
private boolean isGreaterThanZero(final BigDecimal value) { private boolean isGreaterThanZero(final BigDecimal value) {
return value.compareTo(BigDecimal.ZERO) == 1; return value.compareTo(BigDecimal.ZERO) > 0;
} }
private boolean determineIfFullyPaid() { private boolean determineIfFullyPaid() {
@@ -73,7 +73,7 @@ public class TaxUtils {
public static BigDecimal addTax(final BigDecimal amount, final LocalDate date, final List<TaxGroupMappings> taxGroupMappings, public static BigDecimal addTax(final BigDecimal amount, final LocalDate date, final List<TaxGroupMappings> taxGroupMappings,
final int scale) { final int scale) {
BigDecimal totalAmount = null; BigDecimal totalAmount = null;
if (amount != null && amount.compareTo(BigDecimal.ZERO) == 1) { if (amount != null && amount.compareTo(BigDecimal.ZERO) > 0) {
double percentageVal = 0; double percentageVal = 0;
double amountVal = amount.doubleValue(); double amountVal = amount.doubleValue();
double cent_percentage = Double.valueOf("100.0"); double cent_percentage = Double.valueOf("100.0");