use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testSuccessfulMakePayment.
@Test
public void testSuccessfulMakePayment() throws Exception {
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Assert.assertNotNull(customerAccount);
Date transactionDate = new Date(System.currentTimeMillis());
List<AccountActionDateEntity> dueActionDates = TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate);
Assert.assertEquals("The size of the due insallments is ", dueActionDates.size(), 1);
PaymentData accountPaymentDataView = TestObjectFactory.getCustomerAccountPaymentDataView(dueActionDates, TestUtils.createMoney("100.0"), null, center.getPersonnel(), "3424324", Short.valueOf("1"), transactionDate, transactionDate);
center = TestObjectFactory.getCustomer(center.getCustomerId());
customerAccount = center.getCustomerAccount();
IntegrationTestObjectMother.applyAccountPayment(customerAccount, accountPaymentDataView);
Assert.assertEquals(customerAccount.getCustomerActivitDetails().size(), 1);
Assert.assertEquals("The size of the payments done is", customerAccount.getAccountPayments().size(), 1);
Assert.assertEquals("The size of the due insallments after payment is", TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate).size(), 0);
for (CustomerActivityEntity activity : customerAccount.getCustomerActivitDetails()) {
Assert.assertEquals(transactionDate, activity.getCreatedDate());
}
assertThat(customerAccount.getAccountPayments().size(), is(1));
for (AccountPaymentEntity accountPayment : customerAccount.getAccountPayments()) {
assertThat(accountPayment.getAccountTrxns().size(), is(1));
for (AccountTrxnEntity accountTrxnEntity : accountPayment.getAccountTrxns()) {
assertThat(accountTrxnEntity.getFinancialTransactions().size(), is(2));
}
}
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testActivityForMultiplePayments.
@Test
public void testActivityForMultiplePayments() throws Exception {
// setup
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Assert.assertNotNull(customerAccount);
Date transactionDate = incrementCurrentDate(14);
final Money paymentForThisInstallmentAndLastTwoInstallmentsInArrears = TestUtils.createMoney("300.0");
List<AccountActionDateEntity> dueActionDates = TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate);
Assert.assertEquals("The size of the due insallments is ", dueActionDates.size(), 3);
PaymentData accountPaymentDataView = TestObjectFactory.getCustomerAccountPaymentDataView(dueActionDates, paymentForThisInstallmentAndLastTwoInstallmentsInArrears, null, center.getPersonnel(), "3424324", Short.valueOf("1"), transactionDate, transactionDate);
center = TestObjectFactory.getCustomer(center.getCustomerId());
customerAccount = center.getCustomerAccount();
// exercise test
customerAccount.applyPayment(accountPaymentDataView);
// verification
assertThat(customerAccount.getCustomerActivitDetails().size(), is(1));
assertThat("The size of the payments done is", customerAccount.getAccountPayments().size(), is(1));
assertThat("The size of the due insallments after payment is", TestObjectFactory.getDueActionDatesForAccount(customerAccount.getAccountId(), transactionDate).size(), is(0));
assertThat(customerAccount.getAccountPayments().size(), is(1));
for (AccountPaymentEntity accountPayment : customerAccount.getAccountPayments()) {
assertThat(accountPayment.getAccountTrxns().size(), is(3));
for (AccountTrxnEntity accountTrxnEntity : accountPayment.getAccountTrxns()) {
assertThat(accountTrxnEntity.getFinancialTransactions().size(), is(2));
}
}
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method applyPayment.
private void applyPayment() throws Exception {
client = TestObjectFactory.createClient("Client_Active_test", CustomerStatus.CLIENT_ACTIVE, group);
customerAccountBO = client.getCustomerAccount();
Date currentDate = new Date(System.currentTimeMillis());
customerAccountBO.setUserContext(userContext);
CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
accountAction.setMiscFeePaid(TestUtils.createMoney(100));
accountAction.setMiscPenaltyPaid(TestUtils.createMoney(100));
accountAction.setPaymentDate(currentDate);
accountAction.setPaymentStatus(PaymentStatus.PAID);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(customerAccountBO, TestUtils.createMoney(300), "1111", currentDate, new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
CustomerTrxnDetailEntity accountTrxnEntity = new CustomerTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.PAYMENT, Short.valueOf("1"), accountAction.getActionDate(), TestObjectFactory.getPersonnel(userContext.getId()), currentDate, TestUtils.createMoney(300), "payment done", null, TestUtils.createMoney(100), TestUtils.createMoney(100));
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
CustomerAccountBOTestUtils.setFeeAmountPaid((CustomerFeeScheduleEntity) accountFeesActionDetailEntity, TestUtils.createMoney(100));
FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
accountTrxnEntity.addFeesTrxnDetail(feeTrxn);
}
accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
TestObjectFactory.updateObject(customerAccountBO);
StaticHibernateUtil.flushSession();
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class AdminDocumentsServiceImpl method getAdminDocumentsForAccountPayment.
@Override
public List<AdminDocumentDto> getAdminDocumentsForAccountPayment(Integer paymentId) {
try {
List<AdminDocumentDto> adminDocuments = new ArrayList<AdminDocumentDto>();
AccountPaymentEntity accountPaymentEntity = legacyAccountDao.findPaymentById(paymentId);
Set<AccountTrxnEntity> accountTrxnEntities = accountPaymentEntity.getAccountTrxns();
for (AccountTrxnEntity accountTrxnEntity : accountTrxnEntities) {
List<AdminDocumentBO> adminDocumentBOs = legacyAdminDocumentDao.getActiveAdminDocumentsByAccountActionId(accountTrxnEntity.getAccountActionEntity().getId());
if (adminDocumentBOs != null && !adminDocumentBOs.isEmpty()) {
for (AdminDocumentBO adminDocumentBO : adminDocumentBOs) {
AdminDocumentDto adminDocumentDto = new AdminDocumentDto(adminDocumentBO.getAdmindocId().intValue(), adminDocumentBO.getAdminDocumentName(), adminDocumentBO.getAdminDocumentIdentifier(), BooleanUtils.toBoolean(adminDocumentBO.getIsActive().intValue()));
if (!adminDocuments.contains(adminDocumentDto)) {
adminDocuments.add(adminDocumentDto);
}
}
}
}
return adminDocuments;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class LoanBO method isAdjustPossibleOnLastTrxn.
@Override
public boolean isAdjustPossibleOnLastTrxn() {
if (!(getAccountState().isLoanActiveInGoodStanding() || getAccountState().isLoanActiveInBadStanding() || getAccountState().isLoanClosedObligationsMet())) {
logger.debug("State is not active hence adjustment is not possible");
return false;
}
logger.debug("Total payments on this account is " + getAccountPayments().size());
AccountPaymentEntity accountPayment = getLastPmntToBeAdjusted();
if (accountPayment != null) {
for (AccountTrxnEntity accntTrxn : accountPayment.getAccountTrxns()) {
LoanTrxnDetailEntity lntrxn = (LoanTrxnDetailEntity) accntTrxn;
if (lntrxn.getInstallmentId().equals(Short.valueOf("0")) || isAdjustmentForInterestDedAtDisb(lntrxn.getInstallmentId())) {
return false;
}
}
}
if (null != getLastPmntToBeAdjusted() && getLastPmntAmntToBeAdjusted() != 0) {
return true;
}
logger.debug("Adjustment is not possible ");
return false;
}
Aggregations