Buggy code:
} for ( CreateAccountPenaltyDto createAccountPenaltyDto : loanAccountInfo . getAccountPenalties ( ) ) { Integer penaltyId = createAccountPenaltyDto . getPenaltyId ( ) ; String amount = createAccountPenaltyDto . getAmount ( ) ; PenaltyBO penaltyBO = this . penaltyDao . findPenaltyById ( penaltyId . shortValue ( ) ) ; if ( penaltyBO instanceof AmountPenaltyBO ) { amount = String . valueOf ( ( ( Double . valueOf ( createAccountPenaltyDto . getAmount ( ) ) ) * ( loanAmount . divide ( loanAccountInfo . getLoanAmount ( ) ) . getAmount ( ) . doubleValue ( ) ) ) ) ; } defaultAccountPenalties . add ( new CreateAccountPenaltyDto ( penaltyId , amount ) ) ; } List < AccountFeesEntity > feeEntities = assembleAccountFees ( defaultAccountFees ) ; List < AccountPenaltiesEntity > penaltyEntities = assembleAccountPenalties ( defaultAccountPenalties ) ; LoanProductOverridenDetail memberOverridenDetail = new LoanProductOverridenDetail ( loanAmount , feeEntities , overridenDetail , penaltyEntities ) ; LoanSchedule memberSchedule = assembleLoanSchedule ( member , loanAccountDetail . getLoanProduct ( ) , memberOverridenDetail , configuration , repaymentDayMeeting , userOffice , new ArrayList < DateTime > ( ) , loanAccountInfo . getDisbursementDate ( ) , new ArrayList < Number > ( ) ) ; GroupMemberLoanDetail groupMemberLoanDetail = new GroupMemberLoanDetail ( member , memberOverridenDetail , memberSchedule , groupMemberAccount . getLoanPurposeId ( ) ) ; individualMembersOfGroupLoan . add ( groupMemberLoanDetail ) ; } checkScheduleForMembers ( loanSchedule , loan , individualMembersOfGroupLoan , radio ) ; for ( GroupMemberLoanDetail groupMemberAccount : individualMembersOfGroupLoan ) { LoanBO memberLoan = LoanBO . openGroupMemberLoanAccount ( loan , loanAccountDetail . getLoanProduct ( ) , groupMemberAccount . getMember ( ) , repaymentDayMeeting , groupMemberAccount . getMemberSchedule ( ) , groupMemberAccount . getMemberOverridenDetail ( ) , configuration , installmentRange , amountRange , creationDetail , createdBy ) ; if ( ( groupMemberAccount . getLoanPurposeId ( ) ) > 0 ) { memberLoan . setBusinessActivityId ( groupMemberAccount . getLoanPurposeId ( ) ) ; } if ( ! ( backdatedLoanPayments . isEmpty ( ) ) ) { memberLoan . markAsCreatedWithBackdatedPayments ( ) ; } this . loanDao . save ( memberLoan ) ; transactionHelper . flushSession ( ) ; try { memberLoan . setGlobalAccountNum ( memberLoan . generateId ( userOffice . getGlobalOfficeNum ( ) ) ) ; } catch ( AccountException e ) { throw new BusinessRuleException ( e . getMessage ( ) ) ; } this . loanDao . save ( memberLoan ) ; transactionHelper . flushSession ( ) ; } if ( ! ( questionGroups . isEmpty ( ) ) ) { Integer eventSourceId = questionnaireServiceFacade . getEventSourceId ( "Create" , "Loan" ) ; QuestionGroupDetails questionGroupDetails = new QuestionGroupDetails ( Integer . valueOf ( user . getUserId ( ) ) . shortValue ( ) , loan . getAccountId ( ) , eventSourceId , questionGroups ) ; questionnaireServiceFacade . saveResponses ( questionGroupDetails ) ; transactionHelper . flushSession ( ) ; } if ( ( loanAccountCashFlow != null ) && ( ! ( loanAccountCashFlow . getMonthlyCashFlow ( ) . isEmpty ( ) ) ) ) { List < MonthlyCashFlowDetail > monthlyCashFlowDetails = new ArrayList < MonthlyCashFlowDetail > ( ) ; for ( MonthlyCashFlowDto monthlyCashFlow : loanAccountCashFlow . getMonthlyCashFlow ( ) ) { MonthlyCashFlowDetail monthlyCashFlowDetail = new MonthlyCashFlowDetail ( monthlyCashFlow . getMonthDate ( ) , monthlyCashFlow . getRevenue ( ) , monthlyCashFlow . getExpenses ( ) , monthlyCashFlow . getNotes ( ) ) ; monthlyCashFlowDetails . add ( monthlyCashFlowDetail ) ; } CashFlowDetail cashFlowDetail = new CashFlowDetail ( monthlyCashFlowDetails ) ; cashFlowDetail . setTotalCapital ( loanAccountCashFlow . getTotalCapital ( ) ) ; cashFlowDetail . setTotalLiability ( loanAccountCashFlow . getTotalLiability ( ) ) ; cashFlowService . save ( cashFlowDetail ) ; transactionHelper . flushSession ( ) ; } if ( isBackdatedLoan ) { String comment = "Automatic<seq2seq4repair_space>Status<seq2seq4repair_space>Update<seq2seq4repair_space>(Redo<seq2seq4repair_space>Loan)" ; LocalDate approvalDate = loanAccountInfo . getDisbursementDate ( ) ; loan . approve ( createdBy , comment , approvalDate ) ; String receiptNumber = null ; Date receiptDate = null ; PaymentTypeEntity paymentType = new PaymentTypeEntity ( CASH . getValue ( ) ) ; if ( ( loanAccountInfo . getDisbursalPaymentTypeId ( ) ) != null ) { paymentType = new PaymentTypeEntity ( loanAccountInfo . getDisbursalPaymentTypeId ( ) ) ; } Date paymentDate = loanAccountInfo . getDisbursementDate ( ) . toDateMidnight ( ) . toDate ( ) ; AccountPaymentEntity disbursalPayment = new AccountPaymentEntity ( loan , loan . getLoanAmount ( ) , receiptNumber , receiptDate , paymentType , paymentDate ) ; disbursalPayment . setCreatedByUser ( createdBy ) ; if ( customer . isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct ( loan . getLoanOffering ( ) ) ) { <START_BUG> throw new AccountException ( "errors.cannotDisburseLoan.because.otherLoansAreActive" ) ; <END_BUG> } try { loan . updateCustomer ( customer ) ; new ProductMixValidator ( ) . checkIfProductsOfferingCanCoexist ( loan ) ; } catch ( ServiceException e1 ) { throw new AccountException ( e1 . getMessage ( ) ) ; } loan . disburse ( createdBy , disbursalPayment ) ; customer . updatePerformanceHistoryOnDisbursement ( loan , loan . getLoanAmount ( ) ) ; this . loanDao . save ( loan ) ; transactionHelper . flushSession ( ) ; for ( LoanPaymentDto loanPayment : backdatedLoanPayments ) { Money amountPaidToDate = new Money ( loan . getCurrency ( ) , loanPayment . getAmount ( ) ) ; PaymentData paymentData = new PaymentData ( amountPaidToDate , createdBy , loanPayment . getPaymentTypeId ( ) , loanPayment . getPaymentDate ( ) . toDateMidnight ( ) . toDate ( ) ) ; loan . applyPayment ( paymentData ) ; this . loanDao . save ( loan ) ; } } transactionHelper . commitTransaction ( ) ; return new LoanCreationResultDto ( false , loan . getAccountId ( ) , loan . getGlobalAccountNum ( ) ) ; } catch ( BusinessRuleException e ) { this . transactionHelper . rollbackTransaction ( ) ; throw new BusinessRuleException ( e . getMessageKey ( ) , e ) ; } catch ( Exception e ) { this . transactionHelper . rollbackTransaction ( ) ; throw new MifosRuntimeException ( e ) ; } finally { this . transactionHelper . closeSession ( ) ; } }

Fix:
throw new BusinessRuleException ( "errors.cannotDisburseLoan.because.otherLoansAreActive" ) ;