Search in sources :

Example 11 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity 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 12 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class LoanBOTest method repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoansWithWaiverInterest.

@Test
public void repayInstallmentsShouldPopulateCalculatedInterestsForDIPBLoansWithWaiverInterest() 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;
        }

        @Override
        public MifosCurrency getCurrency() {
            return rupee;
        }
    };
    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, "0");
    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);
    loanBO.repayInstallmentWithInterestWaiver(loanScheduleEntity, accountPaymentEntity, "", accountActionTypes, user);
    Set<AccountTrxnEntity> accountTrxns = accountPaymentEntity.getAccountTrxns();
    AccountTrxnEntity accountTrxnEntity = accountTrxns.toArray(new AccountTrxnEntity[accountTrxns.size()])[0];
    LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity;
    assertThat(loanTrxnDetailEntity.getInterestAmount().getAmount().doubleValue(), is(0.98));
    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, 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 13 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsTrxnDetailEntity method savingsDepositAdjustment.

public static SavingsTrxnDetailEntity savingsDepositAdjustment(AccountPaymentEntity accountPayment, CustomerBO customer, Money balAfterAdjust, Money negate, PersonnelBO loggedInUser, Date dueDate, Date actionDate, Date transactionCreatedDate, String adjustmentComment, SavingsTrxnDetailEntity relatedTrxn) {
    AccountActionEntity applicationTransactionType = new AccountActionEntity(AccountActionTypes.SAVINGS_ADJUSTMENT);
    AccountActionEntity monetaryTransactionType = new AccountActionEntity(AccountActionTypes.SAVINGS_DEPOSIT);
    Short installmentIdNotNeeded = null;
    SavingsTrxnDetailEntity adjustment = new SavingsTrxnDetailEntity(accountPayment, customer, applicationTransactionType, monetaryTransactionType, negate, balAfterAdjust, loggedInUser, dueDate, actionDate, installmentIdNotNeeded, adjustmentComment, transactionCreatedDate, relatedTrxn);
    return adjustment;
}
Also used : AccountActionEntity(org.mifos.accounts.business.AccountActionEntity)

Example 14 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsTrxnDetailEntity method savingsWithdrawal.

public static SavingsTrxnDetailEntity savingsWithdrawal(AccountPaymentEntity newAccountPayment, CustomerBO customer, Money savingsBalance, Money withdrawalAmount, PersonnelBO createdBy, Date dueDate, Date oldTrxnDate, Date transactionCreatedDate) {
    AccountActionEntity accountAction = new AccountActionEntity(AccountActionTypes.SAVINGS_WITHDRAWAL);
    Short installmentIdNotNeeded = null;
    SavingsTrxnDetailEntity relatedTrxnNotApplicable = null;
    return new SavingsTrxnDetailEntity(newAccountPayment, customer, accountAction, accountAction, withdrawalAmount, savingsBalance, createdBy, dueDate, oldTrxnDate, installmentIdNotNeeded, "", transactionCreatedDate, relatedTrxnNotApplicable);
}
Also used : AccountActionEntity(org.mifos.accounts.business.AccountActionEntity)

Example 15 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsTrxnDetailEntity method savingsInterestPosting.

public static SavingsTrxnDetailEntity savingsInterestPosting(AccountPaymentEntity interestPayment, CustomerBO customer, Money savingsBalance, Date nextIntPostDate, DateTime dueDate, PersonnelBO createdBy) {
    AccountActionEntity accountAction = new AccountActionEntity(AccountActionTypes.SAVINGS_INTEREST_POSTING);
    SavingsTrxnDetailEntity relatedTrxnNotApplicable = null;
    return new SavingsTrxnDetailEntity(interestPayment, customer, accountAction, accountAction, interestPayment.getAmount(), savingsBalance, createdBy, null, nextIntPostDate, null, "", dueDate.toDate(), relatedTrxnNotApplicable);
}
Also used : AccountActionEntity(org.mifos.accounts.business.AccountActionEntity)

Aggregations

AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)18 ArrayList (java.util.ArrayList)5 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)5 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 Test (org.junit.Test)4 CustomerBO (org.mifos.customers.business.CustomerBO)4 List (java.util.List)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 AccountActionTypes (org.mifos.accounts.util.helpers.AccountActionTypes)3 UserContext (org.mifos.security.util.UserContext)3 FormFile (org.apache.struts.upload.FormFile)2 LocalDate (org.joda.time.LocalDate)2 AccountPaymentEntityBuilder (org.mifos.accounts.business.AccountPaymentEntityBuilder)2 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2