use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class TestObjectFactory method getBulkEntryAccountFeeActionViews.
public static List<CollectionSheetEntryAccountFeeActionDto> getBulkEntryAccountFeeActionViews(final AccountActionDateEntity accountActionDateEntity) {
List<CollectionSheetEntryAccountFeeActionDto> bulkEntryFeeViews = new ArrayList<CollectionSheetEntryAccountFeeActionDto>();
Set<AccountFeesActionDetailEntity> feeActions = null;
if (accountActionDateEntity instanceof LoanScheduleEntity) {
feeActions = ((LoanScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails();
} else if (accountActionDateEntity instanceof CustomerScheduleEntity) {
feeActions = ((CustomerScheduleEntity) accountActionDateEntity).getAccountFeesActionDetails();
}
if (feeActions != null && feeActions.size() > 0) {
for (AccountFeesActionDetailEntity accountFeesActionDetail : feeActions) {
bulkEntryFeeViews.add(getBulkEntryAccountFeeActionView(accountFeesActionDetail));
}
}
return bulkEntryFeeViews;
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class TestObjectFactory method getBulkEntryAccountActionView.
public static CollectionSheetEntryInstallmentDto getBulkEntryAccountActionView(final AccountActionDateEntity accountActionDateEntity) {
CollectionSheetEntryInstallmentDto bulkEntryAccountActionView = null;
if (accountActionDateEntity instanceof LoanScheduleEntity) {
LoanScheduleEntity actionDate = (LoanScheduleEntity) accountActionDateEntity;
CollectionSheetEntryLoanInstallmentDto installmentView = new CollectionSheetEntryLoanInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getPrincipal(), actionDate.getPrincipalPaid(), actionDate.getInterest(), actionDate.getInterestPaid(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getPenalty(), actionDate.getPenaltyPaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
bulkEntryAccountActionView = installmentView;
} else if (accountActionDateEntity instanceof SavingsScheduleEntity) {
SavingsScheduleEntity actionDate = (SavingsScheduleEntity) accountActionDateEntity;
CollectionSheetEntrySavingsInstallmentDto installmentView = new CollectionSheetEntrySavingsInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getDeposit(), actionDate.getDepositPaid());
bulkEntryAccountActionView = installmentView;
} else if (accountActionDateEntity instanceof CustomerScheduleEntity) {
CustomerScheduleEntity actionDate = (CustomerScheduleEntity) accountActionDateEntity;
CollectionSheetEntryCustomerAccountInstallmentDto installmentView = new CollectionSheetEntryCustomerAccountInstallmentDto(actionDate.getAccount().getAccountId(), actionDate.getCustomer().getCustomerId(), actionDate.getInstallmentId(), actionDate.getActionDateId(), actionDate.getActionDate(), actionDate.getMiscFee(), actionDate.getMiscFeePaid(), actionDate.getMiscPenalty(), actionDate.getMiscPenaltyPaid(), TestUtils.RUPEE);
installmentView.setCollectionSheetEntryAccountFeeActions(getBulkEntryAccountFeeActionViews(accountActionDateEntity));
bulkEntryAccountActionView = installmentView;
}
return bulkEntryAccountActionView;
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method validateOnePeriodicFee.
private void validateOnePeriodicFee(String centerSystemId, String expectedPeriodicFeeName, double... expectedFees) {
CenterBO retrievedCenter = customerDao.findCenterBySystemId(centerSystemId);
for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(retrievedCenter.getCustomerAccount())) {
CustomerScheduleEntity scheduleEntity = (CustomerScheduleEntity) accountActionDate;
assertThat(scheduleEntity.getAccountFeesActionDetails().size(), is(1));
assertThat(scheduleEntity.getAccountFeesActionDetailsSortedByFeeId().get(0).getFee().getFeeName(), is(expectedPeriodicFeeName));
assertThat(scheduleEntity.getAccountFeesActionDetailsSortedByFeeId().get(0).getFeeAmount().getAmountDoubleValue(), is(expectedFees[scheduleEntity.getInstallmentId() - 1]));
}
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class AccountFeesActionDetailEntityIntegrationTest method testWaiveCharges.
@Test
public void testWaiveCharges() {
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getGroup(group.getCustomerId());
CustomerScheduleEntity accountActionDate = (CustomerScheduleEntity) group.getCustomerAccount().getAccountActionDates().toArray()[0];
Money chargeWaived = new Money(getCurrency());
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountActionDate.getAccountFeesActionDetails()) {
chargeWaived = accountFeesActionDetailEntity.waiveCharges();
Assert.assertEquals(new Money(getCurrency()), accountFeesActionDetailEntity.getFeeAmount());
}
Assert.assertEquals(new Money(getCurrency(), "100"), chargeWaived);
StaticHibernateUtil.flushSession();
group = TestObjectFactory.getGroup(group.getCustomerId());
center = TestObjectFactory.getCenter(center.getCustomerId());
accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId());
}
use of org.mifos.customers.business.CustomerScheduleEntity in project head by mifos.
the class AccountPaymentEntityIntegrationTest method testReversalAdjustment.
@Test
public void testReversalAdjustment() throws Exception {
userContext = TestObjectFactory.getContext();
createInitialObjects();
accountBO = client.getCustomerAccount();
Date currentDate = new Date(System.currentTimeMillis());
CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
customerAccountBO.setUserContext(userContext);
CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
CustomerAccountBOTestUtils.setMiscFeePaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setMiscPenaltyPaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setPaymentDate(accountAction, currentDate);
accountAction.setPaymentStatus(PaymentStatus.PAID);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(customerAccountBO, TestUtils.createMoney(100), "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(200), "payment done", null, TestUtils.createMoney(100), TestUtils.createMoney(100));
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
accountFeesActionDetailEntity.setFeeAmountPaid(TestUtils.createMoney(100));
FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
CustomerBOTestUtils.addFeesTrxnDetail(accountTrxnEntity, feeTrxn);
// TODO: is there anything to assert on here?
// totalFees = accountFeesActionDetailEntity.getFeeAmountPaid();
}
accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
customerAccountBO.addAccountPayment(accountPaymentEntity);
TestObjectFactory.updateObject(customerAccountBO);
StaticHibernateUtil.flushSession();
customerAccountBO = TestObjectFactory.getObject(CustomerAccountBO.class, customerAccountBO.getAccountId());
client = customerAccountBO.getCustomer();
PersonnelBO loggedInUser = legacyPersonnelDao.getPersonnel(userContext.getId());
List<AccountTrxnEntity> reversedTrxns = customerAccountBO.findMostRecentPaymentByPaymentDate().reversalAdjustment(loggedInUser, "adjustment");
for (AccountTrxnEntity accntTrxn : reversedTrxns) {
CustomerTrxnDetailEntity custTrxn = (CustomerTrxnDetailEntity) accntTrxn;
CustomerScheduleEntity accntActionDate = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(custTrxn.getInstallmentId());
Assert.assertEquals(custTrxn.getMiscFeeAmount(), accntActionDate.getMiscFeePaid().negate());
Assert.assertEquals(custTrxn.getMiscPenaltyAmount(), accntActionDate.getMiscPenaltyPaid().negate());
Assert.assertEquals(loggedInUser.getPersonnelId(), custTrxn.getPersonnel().getPersonnelId());
}
}
Aggregations