Search in sources :

Example 1 with AccountActionTypes

use of org.mifos.accounts.util.helpers.AccountActionTypes in project head by mifos.

the class LoanBO method applyMifos4948FixPayment.

/*
 * Mifos-4948 specific code
 */
public void applyMifos4948FixPayment(Money totalMissedPayment) throws AccountException {
    String comment = "MIFOS-4948 - Loan: " + this.getGlobalAccountNum() + " - Adding payment: " + totalMissedPayment;
    try {
        PersonnelBO currentUser = legacyPersonnelDao.getPersonnel((short) 1);
        Date transactionDate = new DateTimeService().getCurrentJavaDateTime();
        AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(this, totalMissedPayment, null, null, getPaymentTypeEntity(Short.valueOf("1")), transactionDate);
        addAccountPayment(accountPaymentEntity);
        accountPaymentEntity.setComment(comment);
        AccountActionTypes accountActionTypes;
        String accountConstants;
        if (this.getAccountState().getId().equals(AccountState.LOAN_CLOSED_WRITTEN_OFF.getValue())) {
            accountActionTypes = AccountActionTypes.WRITEOFF;
            accountConstants = AccountConstants.LOAN_WRITTEN_OFF;
        } else {
            accountActionTypes = AccountActionTypes.LOAN_RESCHEDULED;
            accountConstants = AccountConstants.LOAN_RESCHEDULED;
        }
        makeWriteOffOrReschedulePaymentForMifos4948(accountPaymentEntity, accountConstants, accountActionTypes, currentUser);
        addLoanActivity(buildLoanActivity(accountPaymentEntity.getAccountTrxns(), currentUser, accountConstants, transactionDate));
        buildFinancialEntries(accountPaymentEntity.getAccountTrxns());
    } catch (PersistenceException e) {
        throw new AccountException(e);
    }
}
Also used : AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) AccountException(org.mifos.accounts.exceptions.AccountException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) DateTimeService(org.mifos.framework.util.DateTimeService) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 2 with AccountActionTypes

use of org.mifos.accounts.util.helpers.AccountActionTypes in project head by mifos.

the class LoanBOTest method repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoans.

@Test
public void repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoans() throws PersistenceException {
    final LegacyLoanDao legacyLoanDao = mock(LegacyLoanDao.class);
    final CustomerBO customerBO = mock(CustomerBO.class);
    final LoanSummaryEntity loanSummaryEntity = mock(LoanSummaryEntity.class);
    LoanBO loanBO = new LoanBO() {

        @Override
        public boolean isDecliningBalanceInterestRecalculation() {
            return true;
        }

        @Override
        public LegacyLoanDao getlegacyLoanDao() {
            return legacyLoanDao;
        }

        @Override
        public CustomerBO getCustomer() {
            return customerBO;
        }

        @Override
        public LoanSummaryEntity getLoanSummary() {
            return loanSummaryEntity;
        }
    };
    AccountActionTypes accountActionTypes = AccountActionTypes.LOAN_REPAYMENT;
    AccountActionEntity accountActionEntity = mock(AccountActionEntity.class);
    AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntityBuilder().with(loanBO).build();
    PersonnelBO user = new PersonnelBO();
    Money extraInterestDue = new Money(rupee, "0.98");
    Money interest = new Money(rupee, "10");
    Money interestDue = new Money(rupee, "2.07");
    when(legacyLoanDao.getPersistentObject(AccountActionEntity.class, accountActionTypes.getValue())).thenReturn(accountActionEntity);
    when(loanScheduleEntity.getPrincipalDue()).thenReturn(new Money(rupee, "1000"));
    when(loanScheduleEntity.getTotalFeeDueWithMiscFeeDue()).thenReturn(new Money(rupee, "10"));
    when(loanScheduleEntity.getPenaltyDue()).thenReturn(new Money(rupee, "10"));
    when(loanScheduleEntity.getPenalty()).thenReturn(new Money(rupee, "100"));
    when(loanScheduleEntity.getExtraInterestDue()).thenReturn(extraInterestDue);
    when(loanScheduleEntity.getExtraInterestPaid()).thenReturn(extraInterestDue);
    when(loanScheduleEntity.getInterest()).thenReturn(interest);
    when(loanScheduleEntity.getInterestDue()).thenReturn(interestDue);
    loanBO.repayInstallment(loanScheduleEntity, accountPaymentEntity, accountActionTypes, user, "", interestDue);
    Set<AccountTrxnEntity> accountTrxns = accountPaymentEntity.getAccountTrxns();
    AccountTrxnEntity accountTrxnEntity = accountTrxns.toArray(new AccountTrxnEntity[accountTrxns.size()])[0];
    LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity;
    assertThat(loanTrxnDetailEntity.getInterestAmount().getAmount().doubleValue(), is(3.05));
    CalculatedInterestOnPayment calculatedInterestOnPayment = loanTrxnDetailEntity.getCalculatedInterestOnPayment();
    assertNotNull(calculatedInterestOnPayment);
    assertThat(calculatedInterestOnPayment.getExtraInterestPaid(), is(extraInterestDue));
    assertThat(calculatedInterestOnPayment.getInterestDueTillPaid(), is(interestDue));
    assertThat(calculatedInterestOnPayment.getOriginalInterest(), is(interest));
    Mockito.verify(loanScheduleEntity).makeEarlyRepaymentEntries(LoanConstants.PAY_FEES_PENALTY_INTEREST, interestDue, accountPaymentEntity.getPaymentDate());
}
Also used : AccountPaymentEntityBuilder(org.mifos.accounts.business.AccountPaymentEntityBuilder) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) Money(org.mifos.framework.util.helpers.Money) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerBO(org.mifos.customers.business.CustomerBO) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao) Test(org.junit.Test)

Example 3 with AccountActionTypes

use of org.mifos.accounts.util.helpers.AccountActionTypes in project head by mifos.

the class AccountActionEntityIntegrationTest method testEnum.

@Test
public void testEnum() throws Exception {
    AccountActionTypes myEnum = AccountActionTypes.FEE_REPAYMENT;
    AccountActionEntity entity = new AccountActionEntity(myEnum);
    Assert.assertEquals(myEnum.getValue(), entity.getId());
    AccountActionTypes out = entity.asEnum();
    Assert.assertEquals(myEnum, out);
}
Also used : AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) Test(org.junit.Test)

Example 4 with AccountActionTypes

use of org.mifos.accounts.util.helpers.AccountActionTypes in project head by mifos.

the class SavingsBO method adjustUserAction.

private AccountPaymentEntity adjustUserAction(Money amountAdjustedTo, String adjustmentNote, LocalDate adjustmentDate, PersonnelBO updatedBy, AccountPaymentEntity payment) {
    AccountPaymentEntity newPayment = null;
    try {
        if (!isAdjustPossibleOnTrxn(amountAdjustedTo, payment)) {
            throw new BusinessRuleException(AccountExceptionConstants.CANNOTADJUST);
        }
        AccountActionTypes savingsTransactionType = findFirstDepositOrWithdrawalTransaction(payment);
        Date adjustedOn = new DateTimeService().getCurrentJavaDateTime();
        List<AccountTrxnEntity> reversedTransactions = reverseTransaction(adjustmentNote, updatedBy, payment, savingsTransactionType, adjustedOn);
        buildFinancialEntries(new LinkedHashSet<AccountTrxnEntity>(reversedTransactions));
        if (amountAdjustedTo.isGreaterThanZero()) {
            Set<AccountTrxnEntity> adjustedPaymentTransactions = createNewAccountPaymentWithAdjustedAmount(amountAdjustedTo, updatedBy, payment, savingsTransactionType, adjustedOn, adjustmentDate);
            buildFinancialEntries(adjustedPaymentTransactions);
            newPayment = adjustedPaymentTransactions.toArray(new AccountTrxnEntity[adjustedPaymentTransactions.size()])[0].getAccountPayment();
        }
    } catch (AccountException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
    goActiveDueToDepositOrWithdrawalOnAccount(updatedBy);
    return newPayment;
}
Also used : AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountException(org.mifos.accounts.exceptions.AccountException) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) DateTimeService(org.mifos.framework.util.DateTimeService) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 5 with AccountActionTypes

use of org.mifos.accounts.util.helpers.AccountActionTypes in project head by mifos.

the class BirtAdminDocumentUploadAction method updateSelectedStatus.

@TransactionDemarcate(joinToken = true)
private void updateSelectedStatus(HttpServletRequest request, BirtAdminDocumentUploadActionForm uploadForm) throws PageExpiredException, ServiceException {
    List selectList = null;
    if (uploadForm.getStatusList() != null) {
        Short accountTypeId = Short.valueOf(uploadForm.getAccountTypeId());
        if (accountTypeId.shortValue() <= 2) {
            selectList = new ArrayList<AccountStateEntity>();
            List<AccountStateEntity> masterList = new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(accountTypeId));
            for (AccountStateEntity product : masterList) {
                for (String productStatusId : uploadForm.getStatusList()) {
                    if (productStatusId != null && product.getId().intValue() == Integer.valueOf(productStatusId).intValue()) {
                        selectList.add(product);
                    }
                }
            }
        } else {
            Short currentLocaleId = (Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request);
            selectList = new ArrayList<AccountActionEntity>();
            List<AccountActionEntity> masterList = getAvailableLoanTransactions(currentLocaleId);
            for (String accountActionId : uploadForm.getStatusList()) {
                AccountActionTypes accountActionType = AccountActionTypes.fromInt(Integer.valueOf(accountActionId));
                AccountActionEntity accountAction = new AccountBusinessService().getAccountAction(accountActionType.getValue(), currentLocaleId);
                if (masterList.contains(accountAction)) {
                    selectList.add(accountAction);
                }
            }
        }
    }
    SessionUtils.setCollectionAttribute("SelectedStatus", selectList, request);
}
Also used : AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ArrayList(java.util.ArrayList) List(java.util.List) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

AccountActionTypes (org.mifos.accounts.util.helpers.AccountActionTypes)6 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 Test (org.junit.Test)3 AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)3 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 Date (java.util.Date)2 LocalDate (org.joda.time.LocalDate)2 AccountPaymentEntityBuilder (org.mifos.accounts.business.AccountPaymentEntityBuilder)2 AccountException (org.mifos.accounts.exceptions.AccountException)2 LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 DateTimeService (org.mifos.framework.util.DateTimeService)2 Money (org.mifos.framework.util.helpers.Money)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)1 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1