Search in sources :

Example 1 with MeetingException

use of org.mifos.application.meeting.exceptions.MeetingException 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 MeetingException

use of org.mifos.application.meeting.exceptions.MeetingException 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 3 with MeetingException

use of org.mifos.application.meeting.exceptions.MeetingException in project head by mifos.

the class MeetingFactory method create.

public MeetingBO create(MeetingDto meetingDto) {
    try {
        MeetingDetailsDto meetingDetailsDto = meetingDto.getMeetingDetailsDto();
        MeetingBO meeting = new MeetingBO(RecurrenceType.fromInt(meetingDetailsDto.getRecurrenceTypeId().shortValue()), meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING);
        RankOfDay rank = null;
        Integer weekOfMonth = meetingDetailsDto.getRecurrenceDetails().getWeekOfMonth();
        if (weekOfMonth != null && weekOfMonth > 0) {
            rank = RankOfDay.getRankOfDay(meetingDetailsDto.getRecurrenceDetails().getWeekOfMonth());
        }
        WeekDay weekDay = null;
        Integer weekDayNum = meetingDetailsDto.getRecurrenceDetails().getDayOfWeek();
        if (weekDayNum != null && weekDayNum > 0) {
            weekDay = WeekDay.getWeekDay(meetingDetailsDto.getRecurrenceDetails().getDayOfWeek());
        }
        if (meetingDetailsDto.getRecurrenceDetails().getDayNumber() > 0) {
            meeting.update(meetingDetailsDto.getRecurrenceDetails().getDayNumber().shortValue(), meetingDto.getMeetingPlace());
        }
        if (rank != null && weekDay != null) {
            meeting = new MeetingBO(weekDay, rank, meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
        } else if (weekDay != null) {
            meeting = new MeetingBO(weekDay, meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateMidnight().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
        }
        if (meetingDetailsDto.getRecurrenceTypeId().equals(new Integer(RecurrenceType.DAILY.getValue().shortValue()))) {
            meeting = new MeetingBO(meetingDetailsDto.getEvery().shortValue(), meetingDto.getMeetingStartDate().toDateTimeAtStartOfDay().toDate(), MeetingType.CUSTOMER_MEETING, meetingDto.getMeetingPlace());
        }
        return meeting;
    } catch (MeetingException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) BusinessRuleException(org.mifos.service.BusinessRuleException) RankOfDay(org.mifos.application.meeting.util.helpers.RankOfDay) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) MeetingDetailsDto(org.mifos.dto.domain.MeetingDetailsDto)

Example 4 with MeetingException

use of org.mifos.application.meeting.exceptions.MeetingException in project head by mifos.

the class GroupLoanAccountServiceFacadeWebTier method createNewMeetingForRepaymentDay.

private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) {
    MeetingBO newMeetingForRepaymentDay = null;
    final int minDaysInterval = configurationPersistence.getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);
    final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime().toDate();
    try {
        if (recurringSchedule.isWeekly()) {
            WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue());
            Short recurEvery = recurringSchedule.getEvery().shortValue();
            newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
        } else if (recurringSchedule.isMonthly()) {
            if (recurringSchedule.isMonthlyOnDayOfMonth()) {
                Short dayOfMonth = recurringSchedule.getDay().shortValue();
                Short dayRecurMonth = recurringSchedule.getEvery().shortValue();
                newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
            } else {
                Short weekOfMonth = recurringSchedule.getDay().shortValue();
                Short monthRank = recurringSchedule.getWeek().shortValue();
                Short everyMonth = recurringSchedule.getEvery().shortValue();
                newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank);
            }
        } else {
            Short recurEvery = recurringSchedule.getEvery().shortValue();
            newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
        }
        return newMeetingForRepaymentDay;
    } catch (NumberFormatException nfe) {
        throw new MifosRuntimeException(nfe);
    } catch (MeetingException me) {
        throw new BusinessRuleException(me.getKey(), me);
    }
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) BusinessRuleException(org.mifos.service.BusinessRuleException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with MeetingException

use of org.mifos.application.meeting.exceptions.MeetingException in project head by mifos.

the class LoanAccountServiceFacadeWebTier method createNewMeetingForRepaymentDay.

private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) {
    MeetingBO newMeetingForRepaymentDay = null;
    final int minDaysInterval = configurationPersistence.getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);
    final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime().toDate();
    try {
        if (recurringSchedule.isWeekly()) {
            WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue());
            Short recurEvery = recurringSchedule.getEvery().shortValue();
            newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
        } else if (recurringSchedule.isMonthly()) {
            if (recurringSchedule.isMonthlyOnDayOfMonth()) {
                Short dayOfMonth = recurringSchedule.getDay().shortValue();
                Short dayRecurMonth = recurringSchedule.getEvery().shortValue();
                newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
            } else {
                Short weekOfMonth = recurringSchedule.getDay().shortValue();
                Short monthRank = recurringSchedule.getWeek().shortValue();
                Short everyMonth = recurringSchedule.getEvery().shortValue();
                newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank);
            }
        } else {
            Short recurEvery = recurringSchedule.getEvery().shortValue();
            newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
        }
        return newMeetingForRepaymentDay;
    } catch (NumberFormatException nfe) {
        throw new MifosRuntimeException(nfe);
    } catch (MeetingException me) {
        throw new BusinessRuleException(me.getKey(), me);
    }
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) BusinessRuleException(org.mifos.service.BusinessRuleException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

MeetingException (org.mifos.application.meeting.exceptions.MeetingException)9 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 WeekDay (org.mifos.application.meeting.util.helpers.WeekDay)4 Date (java.util.Date)3 LocalDate (org.joda.time.LocalDate)3 RecurrenceType (org.mifos.application.meeting.util.helpers.RecurrenceType)3 BusinessRuleException (org.mifos.service.BusinessRuleException)3 MeetingType (org.mifos.application.meeting.util.helpers.MeetingType)2 RankOfDay (org.mifos.application.meeting.util.helpers.RankOfDay)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 BigDecimal (java.math.BigDecimal)1 Locale (java.util.Locale)1 ActionMessage (org.apache.struts.action.ActionMessage)1 DateTime (org.joda.time.DateTime)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)1 FundBO (org.mifos.accounts.fund.business.FundBO)1 PaymentDataHtmlBean (org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean)1