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());
}
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);
}
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));
}
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());
}
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);
}
Aggregations