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());
}
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());
}
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());
}
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);
}
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");
}
}
Aggregations