Search in sources :

Example 1 with RecurrenceType

use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.

the class SavingsProductAssembler method fromDto.

public SavingsOfferingBO fromDto(MifosUser user, SavingsProductDto savingsProductRequest) {
    try {
        // FIXME - keithw - this is general assembler common to both savings and loans i.e. all products. so
        // ProductDao and ProductAssembler
        ProductDetailsDto productDetails = savingsProductRequest.getProductDetails();
        String name = productDetails.getName();
        String shortName = productDetails.getShortName();
        String description = productDetails.getDescription();
        Integer category = productDetails.getCategory();
        ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category);
        DateTime startDate = productDetails.getStartDate();
        DateTime endDate = productDetails.getEndDate();
        ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor());
        PrdApplicableMasterEntity applicableToEntity = this.loanProductDao.findApplicableProductType(applicableTo);
        PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_ACTIVE);
        PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_INACTIVE);
        PrdStatusEntity selectedStatus = activeStatus;
        if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) {
            selectedStatus = inActiveStatus;
        }
        String globalNum = generateProductGlobalNum(user);
        // savings specific
        SavingsType savingsType = SavingsType.fromInt(savingsProductRequest.getDepositType());
        SavingsTypeEntity savingsTypeEntity = this.loanProductDao.retrieveSavingsType(savingsType);
        RecommendedAmntUnitEntity recommendedAmntUnitEntity = null;
        if (savingsProductRequest.getGroupMandatorySavingsType() != null) {
            RecommendedAmountUnit recommendedAmountType = RecommendedAmountUnit.fromInt(savingsProductRequest.getGroupMandatorySavingsType());
            recommendedAmntUnitEntity = this.loanProductDao.retrieveRecommendedAmountType(recommendedAmountType);
        }
        Money amountForDeposit = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getAmountForDeposit()));
        Money maxWithdrawal = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getMaxWithdrawal()));
        // interest specific
        BigDecimal interestRate = savingsProductRequest.getInterestRate();
        InterestCalcType interestCalcType = InterestCalcType.fromInt(savingsProductRequest.getInterestCalculationType());
        InterestCalcTypeEntity interestCalcTypeEntity = this.savingsProductDao.retrieveInterestCalcType(interestCalcType);
        RecurrenceType recurrence = RecurrenceType.fromInt(savingsProductRequest.getInterestCalculationFrequencyPeriod().shortValue());
        Integer every = savingsProductRequest.getInterestCalculationFrequency();
        MeetingBO interestCalculationMeeting = new MeetingBO(recurrence, every.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD);
        Integer interestPostingEveryMonthFreq = savingsProductRequest.getInterestPostingFrequency();
        RecurrenceType interestPostingRecurrenceType = null;
        if (savingsProductRequest.isDailyPosting()) {
            interestPostingRecurrenceType = RecurrenceType.DAILY;
        } else {
            interestPostingRecurrenceType = RecurrenceType.MONTHLY;
        }
        MeetingBO interestPostingMeeting = new MeetingBO(interestPostingRecurrenceType, interestPostingEveryMonthFreq.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_POSTING);
        Money minAmountForCalculation = new Money(Money.getDefaultCurrency(), savingsProductRequest.getMinBalanceForInterestCalculation());
        GLCodeEntity depositGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getDepositGlCode().shortValue());
        GLCodeEntity interestGlEntity = this.generalLedgerDao.findGlCodeById(savingsProductRequest.getInterestGlCode().shortValue());
        MifosCurrency currency = Money.getDefaultCurrency();
        return SavingsOfferingBO.createNew(user.getUserId(), globalNum, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, selectedStatus, savingsTypeEntity, recommendedAmntUnitEntity, amountForDeposit, maxWithdrawal, interestRate, interestCalcTypeEntity, interestCalculationMeeting, interestPostingMeeting, minAmountForCalculation, depositGlEntity, interestGlEntity);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } catch (MeetingException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ProductDetailsDto(org.mifos.dto.domain.ProductDetailsDto) DateTime(org.joda.time.DateTime) Money(org.mifos.framework.util.helpers.Money) MifosCurrency(org.mifos.application.master.business.MifosCurrency) RecommendedAmountUnit(org.mifos.accounts.productdefinition.util.helpers.RecommendedAmountUnit) InterestCalcType(org.mifos.accounts.productdefinition.util.helpers.InterestCalcType) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) RecurrenceType(org.mifos.application.meeting.util.helpers.RecurrenceType) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) BigDecimal(java.math.BigDecimal) Date(java.util.Date) ApplicableTo(org.mifos.accounts.productdefinition.util.helpers.ApplicableTo) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity) SavingsType(org.mifos.accounts.productdefinition.util.helpers.SavingsType) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with RecurrenceType

use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.

the class RecurringScheduledEventFactoryImpl method createScheduledEventFrom.

@Override
public ScheduledEvent createScheduledEventFrom(MeetingBO meeting) {
    RecurrenceType period = meeting.getRecurrenceType();
    int every = meeting.getRecurAfter();
    int dayOfWeek = 0;
    if (meeting.getMeetingDetails().getWeekDay() != null) {
        dayOfWeek = WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(meeting.getMeetingDetails().getWeekDay().getValue());
    }
    int dayOfMonth = 0;
    if (meeting.getMeetingDetails().getDayNumber() != null) {
        dayOfMonth = meeting.getMeetingDetails().getDayNumber();
    }
    int weekOfMonth = 0;
    if (meeting.getMeetingDetails().getWeekRank() != null) {
        weekOfMonth = meeting.getMeetingDetails().getWeekRank().getValue();
    }
    return createScheduledEvent(period, every, dayOfWeek, dayOfMonth, weekOfMonth);
}
Also used : RecurrenceType(org.mifos.application.meeting.util.helpers.RecurrenceType)

Example 3 with RecurrenceType

use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.

the class TestObjectFactory method createLoanMeeting.

public static MeetingBO createLoanMeeting(final MeetingBO customerMeeting) {
    MeetingBO meetingToReturn = null;
    try {
        RecurrenceType recurrenceType = RecurrenceType.fromInt(customerMeeting.getMeetingDetails().getRecurrenceType().getRecurrenceId());
        MeetingType meetingType = MeetingType.fromInt(customerMeeting.getMeetingType().getMeetingTypeId());
        Short recurAfter = customerMeeting.getMeetingDetails().getRecurAfter();
        if (recurrenceType.equals(RecurrenceType.MONTHLY)) {
            if (customerMeeting.isMonthlyOnDate()) {
                meetingToReturn = new MeetingBO(customerMeeting.getMeetingDetails().getMeetingRecurrence().getDayNumber(), recurAfter, customerMeeting.getMeetingStartDate(), meetingType, "meetingPlace");
            } else {
                meetingToReturn = new MeetingBO(customerMeeting.getMeetingDetails().getWeekDay(), customerMeeting.getMeetingDetails().getWeekRank(), recurAfter, customerMeeting.getMeetingStartDate(), meetingType, "meetingPlace");
            }
        } else if (recurrenceType.equals(RecurrenceType.WEEKLY)) {
            meetingToReturn = new MeetingBO(WeekDay.getWeekDay(customerMeeting.getMeetingDetails().getMeetingRecurrence().getWeekDayValue().getValue()), recurAfter, customerMeeting.getMeetingStartDate(), meetingType, "meetingPlace");
        } else {
            meetingToReturn = new MeetingBO(recurrenceType, recurAfter, customerMeeting.getMeetingStartDate(), meetingType);
        }
        meetingToReturn.setMeetingPlace(customerMeeting.getMeetingPlace());
    } catch (MeetingException e) {
        throw new RuntimeException(e);
    }
    return meetingToReturn;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) RecurrenceType(org.mifos.application.meeting.util.helpers.RecurrenceType) MeetingType(org.mifos.application.meeting.util.helpers.MeetingType)

Example 4 with RecurrenceType

use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.

the class ScheduledEventFactory method createScheduledEventFrom.

public static ScheduledEvent createScheduledEventFrom(final MeetingBO meeting) {
    RecurrenceType period = meeting.getRecurrenceType();
    int every = meeting.getRecurAfter();
    int dayOfWeek = 0;
    if (meeting.getMeetingDetails().getWeekDay() != null) {
        dayOfWeek = WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(meeting.getMeetingDetails().getWeekDay().getValue());
    }
    int dayOfMonth = 0;
    if (meeting.getMeetingDetails().getDayNumber() != null) {
        dayOfMonth = meeting.getMeetingDetails().getDayNumber();
    }
    int weekOfMonth = 0;
    if (meeting.getMeetingDetails().getWeekRank() != null) {
        weekOfMonth = meeting.getMeetingDetails().getWeekRank().getValue();
    }
    return createScheduledEvent(period, every, dayOfWeek, dayOfMonth, weekOfMonth);
}
Also used : RecurrenceType(org.mifos.application.meeting.util.helpers.RecurrenceType)

Example 5 with RecurrenceType

use of org.mifos.application.meeting.util.helpers.RecurrenceType in project head by mifos.

the class FeeServiceFacadeWebTier method createFee.

@Override
public String createFee(FeeCreateDto feeCreateDto) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    try {
        FeeCategory feeCategory = (feeCreateDto.getCategoryType() != null) ? FeeCategory.getFeeCategory(feeCreateDto.getCategoryType()) : null;
        FeeFrequencyType feeFrequencyType = (feeCreateDto.getFeeFrequencyType() != null) ? FeeFrequencyType.getFeeFrequencyType(feeCreateDto.getFeeFrequencyType()) : null;
        FeePayment feePayment = (feeCreateDto.getFeePaymentType() != null) ? FeePayment.getFeePayment(feeCreateDto.getFeePaymentType()) : null;
        FeeFormula feeFormula = (feeCreateDto.getFeeFormula() != null) ? FeeFormula.getFeeFormula(feeCreateDto.getFeeFormula()) : null;
        RecurrenceType feeRecurrenceType = (feeCreateDto.getFeeRecurrenceType() != null) ? RecurrenceType.fromInt(feeCreateDto.getFeeRecurrenceType()) : null;
        FeeCreateRequest feeCreateRequest = new FeeCreateRequest(feeCategory, feeFrequencyType, feeCreateDto.getGlCode(), feePayment, feeFormula, feeCreateDto.getFeeName(), feeCreateDto.isRateFee(), feeCreateDto.isCustomerDefaultFee(), feeCreateDto.getRate(), feeCreateDto.getCurrencyId(), feeCreateDto.getAmount(), feeRecurrenceType, feeCreateDto.getMonthRecurAfter(), feeCreateDto.getWeekRecurAfter());
        FeeBO fee = this.feeService.create(feeCreateRequest, userContext);
        return fee.getFeeId().toString();
    } catch (ApplicationException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : FeePayment(org.mifos.accounts.fees.util.helpers.FeePayment) BusinessRuleException(org.mifos.service.BusinessRuleException) FeeFormula(org.mifos.accounts.fees.util.helpers.FeeFormula) ApplicationException(org.mifos.framework.exceptions.ApplicationException) FeeFrequencyType(org.mifos.accounts.fees.util.helpers.FeeFrequencyType) UserContext(org.mifos.security.util.UserContext) RecurrenceType(org.mifos.application.meeting.util.helpers.RecurrenceType) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) FeeBO(org.mifos.accounts.fees.business.FeeBO) FeeCategory(org.mifos.accounts.fees.util.helpers.FeeCategory)

Aggregations

RecurrenceType (org.mifos.application.meeting.util.helpers.RecurrenceType)7 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 DateTime (org.joda.time.DateTime)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)2 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)2 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)2 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)2 PrdOfferingPersistence (org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence)2 ApplicableTo (org.mifos.accounts.productdefinition.util.helpers.ApplicableTo)2 MifosCurrency (org.mifos.application.master.business.MifosCurrency)2 MeetingType (org.mifos.application.meeting.util.helpers.MeetingType)2 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 AccountException (org.mifos.accounts.exceptions.AccountException)1