MIFOSX-1643 : modified charge payment to bypass running balance check
This commit is contained in:
+3
-2
@@ -202,9 +202,10 @@ public class ClientSavingsIntegrationTest {
|
||||
Assert.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = "1500.0";
|
||||
final String openningBalance = "1600";
|
||||
final String enforceMinRequiredBalance = "true";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, openningBalance ,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
@@ -227,7 +228,7 @@ public class ClientSavingsIntegrationTest {
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
Float balance = new Float(MINIMUM_OPENING_BALANCE);
|
||||
Float balance = new Float(openningBalance);
|
||||
Float chargeAmt = 100f;
|
||||
balance -= chargeAmt;
|
||||
assertEquals("Verifying opening Balance", balance, summary.get("accountBalance"));
|
||||
|
||||
+2
-2
@@ -870,7 +870,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
final BigDecimal withdrawalFee = null;
|
||||
// deal with potential minRequiredBalance and
|
||||
// enforceMinRequiredBalance
|
||||
if (!isWithdrawBalance && transaction.isDebit()) {
|
||||
if (!isWithdrawBalance && transaction.canProcessBalanceCheck()) {
|
||||
if (runningBalance.minus(minRequiredBalance).isLessThanZero()) { throw new InsufficientAccountBalanceException(
|
||||
"transactionAmount", getAccountBalance(), withdrawalFee, transactionAmount); }
|
||||
}
|
||||
@@ -891,7 +891,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
// enforceMinRequiredBalance
|
||||
if (transaction.isDebit()) {
|
||||
if (transaction.canProcessBalanceCheck()) {
|
||||
if (runningBalance.minus(minRequiredBalance).isLessThanZero()) {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
|
||||
+16
@@ -40,6 +40,10 @@ import org.mifosplatform.portfolio.charge.domain.ChargeTimeType;
|
||||
import org.mifosplatform.portfolio.charge.exception.SavingsAccountChargeWithoutMandatoryFieldException;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
/**
|
||||
* @author dv6
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "m_savings_account_charge")
|
||||
public class SavingsAccountCharge extends AbstractPersistable<Long> {
|
||||
@@ -823,4 +827,16 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
|
||||
public boolean isNotActive() {
|
||||
return !isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to identify the charges which can override the savings
|
||||
* rules(for example if there is a minimum enforced balance of 1000 on
|
||||
* savings account with account balance of 1000, still these charges can be
|
||||
* collected as these charges are initiated by system and it can bring down
|
||||
* the balance below the enforced minimum balance).
|
||||
*
|
||||
*/
|
||||
public boolean canOverriteSavingAccountRules() {
|
||||
return !(this.isSavingsActivation() || this.isWithdrawalFee());
|
||||
}
|
||||
}
|
||||
+4
@@ -77,4 +77,8 @@ public class SavingsAccountChargePaidBy extends AbstractPersistable<Long> {
|
||||
public boolean isPenaltyCharge() {
|
||||
return (this.savingsAccountCharge == null) ? false : this.savingsAccountCharge.isPenaltyCharge();
|
||||
}
|
||||
|
||||
public boolean canOverriteSavingAccountRules() {
|
||||
return (this.savingsAccountCharge == null) ? false : this.savingsAccountCharge.canOverriteSavingAccountRules();
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -514,6 +514,15 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
||||
return SavingsAccountTransactionType.fromInt(this.typeOf).isWaiveCharge();
|
||||
}
|
||||
|
||||
private boolean canOverriteSavingAccountRules() {
|
||||
final SavingsAccountChargePaidBy chargePaidBy = getSavingsAccountChargePaidBy();
|
||||
return (isChargeTransaction() && chargePaidBy != null) ? chargePaidBy.canOverriteSavingAccountRules() : false;
|
||||
}
|
||||
|
||||
public boolean canProcessBalanceCheck() {
|
||||
return isDebit() && !canOverriteSavingAccountRules();
|
||||
}
|
||||
|
||||
public boolean isFeeCharge() {
|
||||
final SavingsAccountChargePaidBy chargePaidBy = getSavingsAccountChargePaidBy();
|
||||
return (isPayCharge() && chargePaidBy != null) ? chargePaidBy.isFeeCharge() : false;
|
||||
|
||||
Reference in New Issue
Block a user