Search in sources :

Example 6 with CustomerScheduleEntity

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;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) CollectionSheetEntryAccountFeeActionDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryAccountFeeActionDto) AccountFeesActionDetailEntity(org.mifos.accounts.business.AccountFeesActionDetailEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) ArrayList(java.util.ArrayList)

Example 7 with CustomerScheduleEntity

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;
}
Also used : LoanScheduleEntity(org.mifos.accounts.loan.business.LoanScheduleEntity) CollectionSheetEntryLoanInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) CollectionSheetEntrySavingsInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) CollectionSheetEntryCustomerAccountInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto) CollectionSheetEntryInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)

Example 8 with CustomerScheduleEntity

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]));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) CenterBO(org.mifos.customers.center.business.CenterBO)

Example 9 with CustomerScheduleEntity

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());
}
Also used : Money(org.mifos.framework.util.helpers.Money) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Test(org.junit.Test)

Example 10 with CustomerScheduleEntity

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());
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerTrxnDetailEntity(org.mifos.customers.business.CustomerTrxnDetailEntity) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

CustomerScheduleEntity (org.mifos.customers.business.CustomerScheduleEntity)18 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)8 Test (org.junit.Test)5 AccountFeesActionDetailEntity (org.mifos.accounts.business.AccountFeesActionDetailEntity)5 DateTime (org.joda.time.DateTime)4 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)4 Money (org.mifos.framework.util.helpers.Money)4 ArrayList (java.util.ArrayList)3 DateMidnight (org.joda.time.DateMidnight)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)3 Date (java.sql.Date)2 LocalDate (org.joda.time.LocalDate)2 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 CustomerTrxnDetailEntity (org.mifos.customers.business.CustomerTrxnDetailEntity)2 CenterBO (org.mifos.customers.center.business.CenterBO)2 Date (java.util.Date)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1