Search in sources :

Example 36 with PaymentData

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

the class AccountBOIntegrationTest method testGetTransactionHistoryView.

@Test
public void testGetTransactionHistoryView() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    LoanBO loan = groupLoan;
    loan.setUserContext(TestUtils.makeUser());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(loan.getAccountActionDates());
    PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(100), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
    loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
    List<Integer> ids = new ArrayList<Integer>();
    for (AccountPaymentEntity accountPaymentEntity : loan.getAccountPayments()) {
        for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
            for (FinancialTransactionBO financialTransactionBO : accountTrxnEntity.getFinancialTransactions()) {
                ids.add(financialTransactionBO.getTrxnId());
            }
        }
    }
    loan.setUserContext(TestUtils.makeUser());
    List<TransactionHistoryDto> trxnHistlist = loan.getTransactionHistoryView();
    Assert.assertNotNull("Account TrxnHistoryView list object should not be null", trxnHistlist);
    Assert.assertTrue("Account TrxnHistoryView list object Size should be greater than zero", trxnHistlist.size() > 0);
    Assert.assertEquals(ids.size(), trxnHistlist.size());
    int i = 0;
    for (TransactionHistoryDto transactionHistoryDto : trxnHistlist) {
        Assert.assertEquals(ids.get(i), transactionHistoryDto.getAccountTrxnId());
        i++;
    }
    StaticHibernateUtil.flushSession();
    groupLoan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.sql.Date) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) Test(org.junit.Test)

Example 37 with PaymentData

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

the class AccountBOIntegrationTest method testRetrievalOfNullMonetaryValue.

@Test
public void testRetrievalOfNullMonetaryValue() throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    LoanBO loan = groupLoan;
    loan.setUserContext(TestUtils.makeUser());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(loan.getAccountActionDates());
    PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(0), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
    TestObjectFactory.updateObject(loan);
    StaticHibernateUtil.flushSession();
    loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
    List<AccountPaymentEntity> payments = loan.getAccountPayments();
    Assert.assertEquals(1, payments.size());
    AccountPaymentEntity accntPmnt = payments.iterator().next();
    StaticHibernateUtil.flushSession();
    Assert.assertEquals("Account payment retrieved should be zero with currency MFI currency", TestUtils.createMoney(0), accntPmnt.getAmount());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.sql.Date) Test(org.junit.Test)

Example 38 with PaymentData

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

the class AccountBOIntegrationTest method testSuccessGetLastPmntAmntToBeAdjusted.

@Test
public void testSuccessGetLastPmntAmntToBeAdjusted() throws Exception {
    LoanBO loan = groupLoan;
    Date currentDate = new Date(System.currentTimeMillis());
    Date startDate = new Date(System.currentTimeMillis());
    loan.setAccountState(new AccountStateEntity(AccountState.LOAN_APPROVED));
    disburseLoan(loan, startDate);
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.addAll(loan.getAccountActionDates());
    PaymentData firstPaymentData = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(88), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, firstPaymentData);
    TestObjectFactory.updateObject(loan);
    StaticHibernateUtil.flushAndClearSession();
    // the loan has to be reloaded from db so that the payment list will be
    // in desc order and the
    // last payment will be the first in the payment list
    Session session = StaticHibernateUtil.getSessionTL();
    loan = (LoanBO) session.get(LoanBO.class, loan.getAccountId());
    Assert.assertEquals(88.0, loan.getLastPmntAmntToBeAdjusted(), DELTA);
    groupLoan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.sql.Date) Session(org.hibernate.Session) Test(org.junit.Test)

Example 39 with PaymentData

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

the class ApplyAdjustmentActionStrutsTest method applyPayment.

private void applyPayment(LoanBO loan, int amount) throws Exception {
    Date currentDate = new Date(System.currentTimeMillis());
    List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
    accntActionDates.add(loan.getAccountActionDate(Short.valueOf("1")));
    PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(amount), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
    IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
    TestObjectFactory.updateObject(loan);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 40 with PaymentData

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

the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountFeesAreDue.

@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountFeesAreDue() throws Exception {
    createCenter();
    CustomerAccountBO customerAccount = center.getCustomerAccount();
    Date transactionDate = incrementCurrentDate(14);
    PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "300"), center.getPersonnel(), Short.valueOf("1"), transactionDate);
    paymentData.setCustomer(center);
    IntegrationTestObjectMother.applyAccountPayment(customerAccount, paymentData);
    if (customerAccount.getAccountPayments() != null && customerAccount.getAccountPayments().size() == 1) {
        for (AccountPaymentEntity accountPaymentEntity : customerAccount.getAccountPayments()) {
            final Money zeroAmount = new Money(getCurrency(), "0.0");
            final Money OneHundredAmount = new Money(getCurrency(), "100.0");
            if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
                for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
                    CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
                    Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getAmount());
                    Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getTotalAmount());
                    Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscFeeAmount());
                    Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
                    if (customerTrxnDetailEntity.getFeesTrxnDetails() != null && customerTrxnDetailEntity.getFeesTrxnDetails().size() == 1) {
                        for (FeesTrxnDetailEntity feesTrxnDetailEntity : customerTrxnDetailEntity.getFeesTrxnDetails()) {
                            Assert.assertEquals(OneHundredAmount, feesTrxnDetailEntity.getFeeAmount());
                        }
                    } else {
                        throw new Exception("Expected one FeesTrxnDetailEntity, found none or more than one");
                    }
                }
            } else {
                throw new Exception("Expected three CustomerTrxnDetailEntity, found none or not three");
            }
        }
    } else {
        throw new Exception("Expected one AccountPaymentEntity, found none or more than one");
    }
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) Money(org.mifos.framework.util.helpers.Money) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) Date(java.sql.Date) SystemException(org.mifos.framework.exceptions.SystemException) AccountException(org.mifos.accounts.exceptions.AccountException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) FeesTrxnDetailEntity(org.mifos.accounts.business.FeesTrxnDetailEntity) Test(org.junit.Test)

Aggregations

PaymentData (org.mifos.accounts.util.helpers.PaymentData)59 Money (org.mifos.framework.util.helpers.Money)34 Test (org.junit.Test)32 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)24 Date (java.util.Date)22 AccountException (org.mifos.accounts.exceptions.AccountException)22 LoanBO (org.mifos.accounts.loan.business.LoanBO)22 ArrayList (java.util.ArrayList)19 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)18 Date (java.sql.Date)17 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)15 LocalDate (org.joda.time.LocalDate)11 UserContext (org.mifos.security.util.UserContext)11 BigDecimal (java.math.BigDecimal)10 SavingsPaymentData (org.mifos.accounts.util.helpers.SavingsPaymentData)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 MifosUser (org.mifos.security.MifosUser)7 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)6 DateTimeService (org.mifos.framework.util.DateTimeService)6