Search in sources :

Example 66 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class RepayLoanActionStrutsTest method setUp.

@Before
public void setUp() throws Exception {
    DateTime date = new DateTime(2010, 12, 23, 12, 0, 0, 0);
    new DateTimeService().setCurrentDateTime(date);
    ConfigurationPersistence configurationPersistence = new ConfigurationPersistence();
    lsim = configurationPersistence.getConfigurationValueInteger(LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED);
    configurationPersistence.updateConfigurationKeyValueInteger(LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED, 1);
    userContext = TestObjectFactory.getContext();
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    addRequestParameter("recordLoanOfficerId", "1");
    addRequestParameter("recordOfficeId", "1");
    request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
    flowKey = createFlow(request, RepayLoanAction.class);
    accountBO = getLoanAccount();
    ((LoanBO) accountBO).approve(legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER), "approved", date.toLocalDate());
    StaticHibernateUtil.flushSession();
    accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId());
}
Also used : ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) LoanBO(org.mifos.accounts.loan.business.LoanBO) DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 67 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class RepayLoanActionStrutsTest method getLoanAccount.

private AccountBO getLoanAccount() {
    Date startDate = new DateTimeService().getCurrentJavaDateTime();
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) DateTimeService(org.mifos.framework.util.DateTimeService) Date(java.util.Date)

Example 68 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetActiveCustomerAndSavingsAccountIdsForGenerateMeetingTaskShouldReturnThreeCustomerAccounts.

@Test
public void testGetActiveCustomerAndSavingsAccountIdsForGenerateMeetingTaskShouldReturnThreeCustomerAccounts() throws Exception {
    // Superclass creates a center, a group, and a client that start meeting today
    // They should have 10 current or future meeting dates
    // Set time ahead 7 weeks to force regenerating customer schedules.
    new DateTimeService().setCurrentDateTime(new DateTime().plusWeeks(7));
    List<Integer> accountIds = legacyAccountDao.getActiveCustomerAndSavingsAccountIdsForGenerateMeetingTask();
    assertThat(accountIds.size(), is(3));
    assertThat(accountIds.contains(center.getCustomerAccount().getAccountId()), is(true));
    assertThat(accountIds.contains(group.getCustomerAccount().getAccountId()), is(true));
    assertThat(accountIds.contains(client.getCustomerAccount().getAccountId()), is(true));
}
Also used : DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 69 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class LoanAccountServiceFacadeWebTierTest method shouldReturnRepayLoanDtoWithAllDataPopulatedForDecliningBalanceInterestRecalculation.

@Test
public void shouldReturnRepayLoanDtoWithAllDataPopulatedForDecliningBalanceInterestRecalculation() {
    setMifosUserFromContext();
    String accountNumber = "1234";
    LoanBO loanBO = mock(LoanBO.class);
    Money repaymentAmount = TestUtils.createMoney("1234");
    Money interest = TestUtils.createMoney("100");
    DateTime currentDate = new DateTime(2010, 10, 30, 0, 0, 0, 0);
    new DateTimeService().setCurrentDateTime(currentDate);
    RepaymentResultsHolder repaymentResultsHolder = new RepaymentResultsHolder();
    repaymentResultsHolder.setTotalRepaymentAmount(repaymentAmount.getAmount());
    repaymentResultsHolder.setWaiverAmount(interest.getAmount());
    when(loanDao.findByGlobalAccountNum(accountNumber)).thenReturn(loanBO);
    when(scheduleCalculatorAdaptor.computeRepaymentAmount(loanBO, currentDate.toDate())).thenReturn(repaymentResultsHolder);
    when(loanBO.getCurrency()).thenReturn(repaymentAmount.getCurrency());
    when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
    when(loanBO.getOfficeId()).thenReturn((short) 1);
    when(loanBO.getCustomer()).thenReturn(customer);
    when(customer.getLoanOfficerId()).thenReturn((short) 1);
    RepayLoanDto repayLoanDto = this.loanAccountServiceFacade.retrieveLoanRepaymentDetails(accountNumber);
    verify(loanDao).findByGlobalAccountNum(accountNumber);
    verify(scheduleCalculatorAdaptor).computeRepaymentAmount(loanBO, currentDate.toDate());
    verify(loanBO, never()).waiverAmount();
    verify(loanBO, never()).getEarlyRepayAmount();
    verify(loanBO).isDecliningBalanceInterestRecalculation();
    assertEquals(repayLoanDto.getEarlyRepaymentMoney(), repaymentAmount.toString());
    assertEquals(repayLoanDto.getWaivedRepaymentMoney(), repaymentAmount.subtract(interest).toString());
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepayLoanDto(org.mifos.dto.screen.RepayLoanDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) RepaymentResultsHolder(org.mifos.accounts.loan.business.RepaymentResultsHolder) Test(org.junit.Test)

Example 70 with DateTimeService

use of org.mifos.framework.util.DateTimeService in project head by mifos.

the class FlowKeyInterceptor method createToken.

private void createToken(HttpServletRequest request) {
    String flowKey = String.valueOf(new DateTimeService().getCurrentDateTime().getMillis());
    FlowManager flowManager = (FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER);
    if (flowManager == null) {
        flowManager = new FlowManager();
        request.getSession(false).setAttribute(Constants.FLOWMANAGER, flowManager);
    }
    flowManager.addFLow(flowKey, new Flow(), this.getClass().getName());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
}
Also used : FlowManager(org.mifos.framework.util.helpers.FlowManager) DateTimeService(org.mifos.framework.util.DateTimeService) Flow(org.mifos.framework.util.helpers.Flow)

Aggregations

DateTimeService (org.mifos.framework.util.DateTimeService)99 Test (org.junit.Test)24 Date (java.util.Date)21 Money (org.mifos.framework.util.helpers.Money)20 DateTime (org.joda.time.DateTime)19 PersistenceException (org.mifos.framework.exceptions.PersistenceException)19 MeetingBO (org.mifos.application.meeting.business.MeetingBO)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)16 LocalDate (org.joda.time.LocalDate)15 AccountException (org.mifos.accounts.exceptions.AccountException)14 LoanBO (org.mifos.accounts.loan.business.LoanBO)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)14 ArrayList (java.util.ArrayList)13 CustomerBO (org.mifos.customers.business.CustomerBO)10 CustomerException (org.mifos.customers.exceptions.CustomerException)10 UserContext (org.mifos.security.util.UserContext)10 BusinessRuleException (org.mifos.service.BusinessRuleException)9 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)8 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)8 ApplicationException (org.mifos.framework.exceptions.ApplicationException)8