diff --git a/mifosng-db/migrations/core_db/V174__remove_interest_accrual.sql b/mifosng-db/migrations/core_db/V174__remove_interest_accrual.sql new file mode 100644 index 000000000..cd4546329 --- /dev/null +++ b/mifosng-db/migrations/core_db/V174__remove_interest_accrual.sql @@ -0,0 +1,5 @@ +/**Remove all existing apply interest transaction Types**/ +update m_loan_transaction set interest_portion_derived=amount where transaction_type_enum=11; +update m_loan_transaction set transaction_type_enum=10 where transaction_type_enum=11; + + diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java index 5d67a7e8e..cbfda9d08 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java @@ -1744,10 +1744,11 @@ public class Loan extends AbstractPersistable { /** * Add an interest applied transaction of the interest is accrued - * upfront (Up front accrual) + * upfront (Up front accrual), no accounting or cash based accounting is + * selected **/ - if (isUpfrontAccrualAccountingEnabledOnLoanProduct()) { + if (isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied, actualDisbursementDate); this.loanTransactions.add(interestAppliedTransaction); @@ -2007,10 +2008,10 @@ public class Loan extends AbstractPersistable { } } else { /** - * create a Charge applied transaction if Upfront Accrual is - * enabled + * create a Charge applied transaction if Upfront Accrual, + * None or Cash based accounting is enabled **/ - if (isUpfrontAccrualAccountingEnabledOnLoanProduct()) { + if (isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { handleChargeAppliedTransaction(charge, disbursedOn); } } @@ -3283,6 +3284,15 @@ public class Loan extends AbstractPersistable { return this.loanProduct.isUpfrontAccrualAccountingEnabled(); } + public Boolean isAccountingDisabledOnLoanProduct() { + return this.loanProduct.isAccountingDisabled(); + } + + public Boolean isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct() { + return isCashBasedAccountingEnabledOnLoanProduct() || isUpfrontAccrualAccountingEnabledOnLoanProduct() + || isAccountingDisabledOnLoanProduct(); + } + private Boolean isPeriodicAccrualAccountingEnabledOnLoanProduct() { return this.loanProduct.isPeriodicAccrualAccountingEnabled(); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 91506f3f0..5cc353b2e 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -579,7 +579,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf changes.put("transactionAmount", command.stringValueOfParameterNamed("transactionAmount")); changes.put("locale", command.locale()); changes.put("dateFormat", command.dateFormat()); - changes.put("paymentTypeId",command.stringValueOfParameterNamed("paymentTypeId")); + changes.put("paymentTypeId", command.stringValueOfParameterNamed("paymentTypeId")); final String noteText = command.stringValueOfParameterNamed("note"); if (StringUtils.isNotBlank(noteText)) { @@ -656,7 +656,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf changes.put("transactionAmount", command.stringValueOfParameterNamed("transactionAmount")); changes.put("locale", command.locale()); changes.put("dateFormat", command.dateFormat()); - changes.put("paymentTypeId",command.stringValueOfParameterNamed("paymentTypeId")); + changes.put("paymentTypeId", command.stringValueOfParameterNamed("paymentTypeId")); final List existingTransactionIds = new ArrayList(); final List existingReversedTransactionIds = new ArrayList(); @@ -1047,7 +1047,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf * Upfront Accruals **/ if (loan.status().isActive()) { - if (loan.isUpfrontAccrualAccountingEnabledOnLoanProduct()) { + if (loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null); this.loanTransactionRepository.save(applyLoanChargeTransaction); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java index 62c99766c..da35cbde5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java @@ -623,6 +623,10 @@ public class LoanProduct extends AbstractPersistable { return actualChanges; } + public boolean isAccountingDisabled() { + return AccountingRuleType.NONE.getValue().equals(this.accountingRule); + } + public boolean isCashBasedAccountingEnabled() { return AccountingRuleType.CASH_BASED.getValue().equals(this.accountingRule); }