Search in sources :

Example 31 with DateTimeService

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

the class LoanArrearsAgingHelperIntegrationTest method tearDown.

@After
public void tearDown() throws Exception {
    new DateTimeService().resetToCurrentSystemDateTime();
    loanArrearsAgingHelper = null;
    loanArrearHelper = null;
    MifosConfigurationManager.getInstance().setProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, oldRoundingMode);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : DateTimeService(org.mifos.framework.util.DateTimeService) After(org.junit.After)

Example 32 with DateTimeService

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

the class TestObjectFactory method getNewMeeting.

/**
     * Return a new meeting object.
     *
     * @param frequency   DAILY, WEEKLY, MONTHLY
     * @param recurAfter  1 means every day/week/month, 2 means every second day/week/month...
     * @param meetingType most commonly a CUSTOMER_MEETING
     * @param weekday     MONDAY, TUESDAY...
     */
public static MeetingBO getNewMeeting(final RecurrenceType frequency, final short recurAfter, final MeetingType meetingType, final WeekDay weekday) {
    MeetingBO meeting;
    try {
        meeting = new MeetingBO(frequency, recurAfter, new DateTimeService().getCurrentJavaDateTime(), meetingType);
        meeting.setMeetingPlace("Loan Meeting Place");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    meeting.getMeetingDetails().getMeetingRecurrence().setWeekDay(weekday);
    return meeting;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) 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 33 with DateTimeService

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

the class TestObjectFactory method createPeriodicRateFee.

public static RateFeeBO createPeriodicRateFee(final String feeName, final FeeCategory feeCategory, final Double rate, final FeeFormula feeFormula, final RecurrenceType meetingFrequency, final Short recurAfter, final UserContext userContext, final MeetingBO meeting) {
    try {
        MeetingBO newMeeting = new MeetingBO(meetingFrequency, recurAfter, new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE);
        // GLCodeEntity glCode =
        // ChartOfAccountsCache.get("31301").getAssociatedGlcode();
        GLCodeEntity glCode = new GLCodeEntity((short) 1, "31301");
        RateFeeBO fee = new RateFeeBO(userContext, feeName, new CategoryTypeEntity(feeCategory), new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), glCode, rate, new FeeFormulaEntity(feeFormula), false, newMeeting);
        // [keith] I have no idea why the fee must save itself. Otherwise
        // mySQL errors crop up
        // when you try to attach the fee to a loan.
        fee.save();
        // addObject(fee);
        return fee;
    // return (RateFeeBO) addObject(testObjectPersistence.persist(fee));
    // return (RateFeeBO)
    // addObject(testObjectPersistence.createFee(fee));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) FeeFormulaEntity(org.mifos.accounts.fees.business.FeeFormulaEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) 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 34 with DateTimeService

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

the class TestObjectFactory method createSavingsAccount.

/**
     * Also see {@link SavingsTestHelper#createSavingsAccount(SavingsOfferingBO, CustomerBO, AccountState, UserContext)}
     * which is less elaborate.
     */
public static SavingsBO createSavingsAccount(final String globalNum, final CustomerBO customer, final AccountState state, final Date startDate, final SavingsOfferingBO savingsOffering, UserContext userContext) throws Exception {
    userContext = TestUtils.makeUserWithLocales();
    SavingsBO savings = new SavingsBO(userContext, savingsOffering, customer, state, savingsOffering.getRecommendedAmount(), getCustomFieldView());
    savings.save();
    SavingBOTestUtils.setActivationDate(savings, new DateTimeService().getCurrentJavaDateTime());
    StaticHibernateUtil.flushSession();
    return getObject(SavingsBO.class, savings.getAccountId());
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) DateTimeService(org.mifos.framework.util.DateTimeService)

Example 35 with DateTimeService

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

the class TestObjectFactory method createPeriodicAmountFee.

private static FeeBO createPeriodicAmountFee(final String feeName, final FeeCategory feeCategory, final String feeAmnt, final RecurrenceType meetingFrequency, final Short recurAfter, final UserContext userContext, String categoryLookupValue) {
    try {
        GLCodeEntity glCode = ChartOfAccountsCache.get("31301").getAssociatedGlcode();
        MeetingBO meeting = new MeetingBO(meetingFrequency, recurAfter, new DateTimeService().getCurrentJavaDateTime(), MeetingType.PERIODIC_FEE);
        LookUpValueEntity lookUpValue = new LookUpValueEntity();
        lookUpValue.setLookUpName(categoryLookupValue);
        CategoryTypeEntity categoryType = new CategoryTypeEntity(feeCategory);
        categoryType.setLookUpValue(lookUpValue);
        FeeBO fee = new AmountFeeBO(userContext, feeName, categoryType, new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), glCode, TestUtils.createMoney(feeAmnt), false, meeting);
        return testObjectPersistence.createFee(fee);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) DateTimeService(org.mifos.framework.util.DateTimeService) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) 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) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

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