Search in sources :

Example 61 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class ClientIntegrationTest method testGenerateScheduleForClient_OnClientCreate.

@Test
public void testGenerateScheduleForClient_OnClientCreate() throws Exception {
    SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("Offering1", "s1", SavingsType.MANDATORY, ApplicableTo.GROUPS, new Date(System.currentTimeMillis()));
    createParentObjects(CustomerStatus.GROUP_ACTIVE);
    accountBO = TestObjectFactory.createSavingsAccount("globalNum", center, AccountState.SAVINGS_ACTIVE, new java.util.Date(), savingsOffering, TestObjectFactory.getContext());
    Assert.assertEquals(0, accountBO.getAccountActionDates().size());
    client = createClient(CustomerStatus.CLIENT_ACTIVE);
    StaticHibernateUtil.flushSession();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    Assert.assertEquals(1, accountBO.getAccountCustomFields().size());
    Assert.assertEquals(10, accountBO.getAccountActionDates().size());
    for (AccountActionDateEntity actionDate : accountBO.getAccountActionDates()) {
        Assert.assertEquals(client.getCustomerId(), actionDate.getCustomer().getCustomerId());
        Assert.assertTrue(true);
    }
    client = TestObjectFactory.getClient(client.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    center = TestObjectFactory.getCenter(center.getCustomerId());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) Date(java.sql.Date) Test(org.junit.Test)

Example 62 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsAccountBuilder method buildForUnitTests.

public SavingsBO buildForUnitTests() {
    List<AccountActionDateEntity> listOfScheduledPayments = new ArrayList<AccountActionDateEntity>();
    if (scheduledPayments != null) {
        listOfScheduledPayments = new ArrayList<AccountActionDateEntity>(scheduledPayments);
    }
    activationDetails = new SavingsAccountActivationDetail(new LocalDate(activationDate), nextInterestPostingDate, listOfScheduledPayments);
    return buildAccount(activationDetails);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsAccountActivationDetail(org.mifos.accounts.savings.business.SavingsAccountActivationDetail) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate)

Example 63 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsAccountBuilder method buildAccount.

private SavingsBO buildAccount(SavingsAccountActivationDetail derivedActivationDetails) {
    List<AccountActionDateEntity> listOfScheduledPayments = new ArrayList<AccountActionDateEntity>();
    if (scheduledPayments == null) {
        listOfScheduledPayments = derivedActivationDetails.getScheduledPayments();
    } else {
        listOfScheduledPayments = new ArrayList<AccountActionDateEntity>(scheduledPayments);
    }
    activationDetails = new SavingsAccountActivationDetail(new LocalDate(activationDate), nextInterestPostingDate, listOfScheduledPayments);
    CreationDetail creationDetail = new CreationDetail(new DateTime(createdDate), createdByUserId.intValue());
    SavingsBO savingsAccount = new SavingsBO(accountState, customer, activationDetails, creationDetail, savingsProduct, recommendedAmountUnit, recommendedAmount, createdBy, savingsBalanceAmount);
    savingsAccount.setCustomerPersistence(customerDao);
    savingsAccount.setSavingsPaymentStrategy(savingsPaymentStrategy);
    savingsAccount.setSavingsTransactionActivityHelper(savingsTransactionActivityHelper);
    savingsAccount.updateDetails(TestUtils.makeUserWithLocales());
    for (AccountPaymentEntity depositPayment : deposits) {
        try {
            depositPayment.setAccount(savingsAccount);
            savingsAccount.deposit(depositPayment, customer);
        } catch (AccountException e) {
            throw new MifosRuntimeException("builder failed to apply deposits.", e);
        }
    }
    for (AccountPaymentEntity withdrawal : withdrawals) {
        try {
            withdrawal.setAccount(savingsAccount);
            savingsAccount.withdraw(withdrawal, customer);
        } catch (AccountException e) {
            throw new MifosRuntimeException("builder failed to apply withdrawals.", e);
        }
    }
    return savingsAccount;
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsAccountActivationDetail(org.mifos.accounts.savings.business.SavingsAccountActivationDetail) AccountException(org.mifos.accounts.exceptions.AccountException) ArrayList(java.util.ArrayList) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) CreationDetail(org.mifos.clientportfolio.newloan.domain.CreationDetail) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 64 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class LoanArrearsHelperIntegrationTest method setDisbursementDateAsOldDate.

private void setDisbursementDateAsOldDate(AccountBO account) {
    Date startDate = offSetCurrentDate(15);
    LoanBO loan = (LoanBO) account;
    LoanBOTestUtils.modifyDisbursementDate(loan, startDate);
    for (AccountActionDateEntity actionDate : loan.getAccountActionDates()) {
        LoanBOTestUtils.setActionDate(actionDate, offSetGivenDate(actionDate.getActionDate(), 18));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.sql.Date)

Example 65 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class LoanArrearsTaskIntegrationTest method setDisbursementDateAsOldDate.

private void setDisbursementDateAsOldDate(AccountBO account) {
    Date startDate = offSetCurrentDate(15);
    LoanBO loan = (LoanBO) account;
    LoanBOTestUtils.modifyDisbursementDate(loan, startDate);
    for (AccountActionDateEntity actionDate : loan.getAccountActionDates()) {
        LoanBOTestUtils.setActionDate(actionDate, offSetGivenDate(actionDate.getActionDate(), 18));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) Date(java.sql.Date)

Aggregations

AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)211 Money (org.mifos.framework.util.helpers.Money)80 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)58 LocalDate (org.joda.time.LocalDate)42 Date (java.util.Date)39 DateTime (org.joda.time.DateTime)33 MeetingBO (org.mifos.application.meeting.business.MeetingBO)33 AccountException (org.mifos.accounts.exceptions.AccountException)24 PaymentData (org.mifos.accounts.util.helpers.PaymentData)24 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)21 Date (java.sql.Date)19 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)15 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)14 UserContext (org.mifos.security.util.UserContext)14 Calendar (java.util.Calendar)13 GregorianCalendar (java.util.GregorianCalendar)13 CenterBuilder (org.mifos.domain.builders.CenterBuilder)13