Search in sources :

Example 81 with DateTimeService

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

the class ClientBoTest method testAddClientAttendance.

@Test
public void testAddClientAttendance() {
    Assert.assertEquals("Expecting no attendance entries on a new object", 0, client.getClientAttendances().size());
    DateTime meetingDate = new DateTimeService().getCurrentDateTime();
    client.addClientAttendance(buildClientAttendance(meetingDate.toDate()));
    Assert.assertEquals("Expecting one attendance entry", 1, client.getClientAttendances().size());
}
Also used : DateTimeService(org.mifos.framework.util.DateTimeService) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 82 with DateTimeService

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

the class ClientBoTest method getDateOffset.

private DateMidnight getDateOffset(final int numberOfDays) {
    DateMidnight currentDate = new DateTimeService().getCurrentDateMidnight();
    currentDate = currentDate.minusDays(numberOfDays);
    return currentDate;
}
Also used : DateMidnight(org.joda.time.DateMidnight) DateTimeService(org.mifos.framework.util.DateTimeService)

Example 83 with DateTimeService

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

the class TestObjectFactory method getNewWeeklyMeeting.

/**
     * Return a new meeting object with a meeting occurring on the day of the week that the test is run. Creating a new
     * method to fix issues with meeting creation without breaking existing tests that may depend on it.
     *
     * @param recurAfter 1 means every day/week/month, 2 means every second day/week/month...
     */
public static MeetingBO getNewWeeklyMeeting(final short recurAfter) {
    Calendar calendar = new GregorianCalendar();
    MeetingBO meeting;
    try {
        meeting = new MeetingBO(WeekDay.getWeekDay((short) calendar.get(Calendar.DAY_OF_WEEK)), recurAfter, new DateTimeService().getCurrentJavaDateTime(), CUSTOMER_MEETING, "meetingPlace");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return meeting;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) DateTimeService(org.mifos.framework.util.DateTimeService) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 84 with DateTimeService

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

the class TestObjectFactory method createClient.

public static ClientBO createClient(final String customerName, final MeetingBO meeting, final CustomerStatus status) {
    ClientBO client;
    try {
        PersonnelBO systemUser = getPersonnel(PersonnelConstants.SYSTEM_USER);
        ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
        clientNameDetailDto.setNames(ClientRules.getNameSequence());
        ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), SAMPLE_SALUTATION, customerName, "middle", customerName, "secondLast");
        ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
        client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), status, null, null, null, null, getFees(), null, systemUser, new OfficePersistence().getOffice(SAMPLE_BRANCH_OFFICE), meeting, systemUser, new DateTimeService().getCurrentJavaDateTime(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
        ApplicationContextProvider.getBean(LegacyClientDao.class).saveClient(client);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return client;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) LegacyClientDao(org.mifos.customers.client.persistence.LegacyClientDao) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) DateTimeService(org.mifos.framework.util.DateTimeService) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 85 with DateTimeService

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

the class LoanBO method applyOneTimeFee.

private void applyOneTimeFee(final FeeBO fee, final Double charge, final AccountActionDateEntity accountActionDateEntity) throws AccountException {
    LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity;
    AccountFeesEntity accountFee = new AccountFeesEntity(this, fee, charge, FeeStatus.ACTIVE.getValue(), new DateTimeService().getCurrentJavaDateTime(), null);
    Set<AccountFeesEntity> accountFeeSet = new HashSet<AccountFeesEntity>();
    accountFeeSet.add(accountFee);
    populateAccountFeeAmount(accountFeeSet, loanSummary.getOriginalInterest());
    List<AccountActionDateEntity> loanScheduleEntityList = new ArrayList<AccountActionDateEntity>();
    loanScheduleEntityList.add(loanScheduleEntity);
    List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
    installmentDates.add(new InstallmentDate(accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate()));
    List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
    feeInstallmentList.add(handleOneTime(accountFee, installmentDates));
    Money totalFeeAmountApplied = applyFeeToInstallments(feeInstallmentList, loanScheduleEntityList);
    filterTimeOfDisbursementFees(loanScheduleEntity, fee);
    updateLoanSummary(fee.getFeeId(), totalFeeAmountApplied);
    updateLoanActivity(fee.getFeeId(), totalFeeAmountApplied, fee.getFeeName() + AccountConstants.APPLIED);
}
Also used : ArrayList(java.util.ArrayList) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Money(org.mifos.framework.util.helpers.Money) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTimeService(org.mifos.framework.util.DateTimeService) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

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