Search in sources :

Example 6 with WeekDay

use of org.mifos.application.meeting.util.helpers.WeekDay 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 7 with WeekDay

use of org.mifos.application.meeting.util.helpers.WeekDay 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 8 with WeekDay

use of org.mifos.application.meeting.util.helpers.WeekDay 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)

Example 9 with WeekDay

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

the class MeetingAction method getLocalizedWorkingDays.

private List<WeekDay> getLocalizedWorkingDays() {
    List<WeekDay> workingDays = new FiscalCalendarRules().getWorkingDays();
    for (WeekDay workDay : workingDays) {
        String weekdayName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(workDay.getPropertiesKey());
        workDay.setWeekdayName(weekdayName);
    }
    return workingDays;
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) MessageLookup(org.mifos.application.master.MessageLookup) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

Example 10 with WeekDay

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

the class MeetingAction method edit.

@TransactionDemarcate(conditionToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    MeetingActionForm actionForm = (MeetingActionForm) form;
    clearActionForm(actionForm);
    CustomerBO customerInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerBO customer = this.customerDao.findCustomerById(customerInSession.getCustomerId());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
    List<WeekDay> workingDays = getLocalizedWorkingDays();
    SessionUtils.setCollectionAttribute(MeetingConstants.WEEKDAYSLIST, workingDays, request);
    SessionUtils.setCollectionAttribute(MeetingConstants.WEEKRANKLIST, RankOfDay.getRankOfDayList(), request);
    ActionForward forward = null;
    if (customer.getCustomerMeeting() != null) {
        MeetingBO meeting = customer.getCustomerMeeting().getMeeting();
        setValuesInActionForm(actionForm, meeting);
        forward = mapping.findForward(ActionForwards.edit_success.toString());
        actionForm.setInput(MeetingConstants.INPUT_EDIT);
    } else {
        actionForm.setInput(MeetingConstants.INPUT_CREATE);
        forward = mapping.findForward(ActionForwards.createMeeting_success.toString());
    }
    return forward;
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerBO(org.mifos.customers.business.CustomerBO) MeetingActionForm(org.mifos.application.meeting.struts.actionforms.MeetingActionForm) ActionForward(org.apache.struts.action.ActionForward) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

WeekDay (org.mifos.application.meeting.util.helpers.WeekDay)17 ArrayList (java.util.ArrayList)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 MessageLookup (org.mifos.application.master.MessageLookup)5 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)5 RankOfDay (org.mifos.application.meeting.util.helpers.RankOfDay)5 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)5 LocalDate (org.joda.time.LocalDate)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 CustomerBO (org.mifos.customers.business.CustomerBO)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 ConfigurationBusinessService (org.mifos.config.business.service.ConfigurationBusinessService)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)2 CreateAccountPenaltyDto (org.mifos.dto.domain.CreateAccountPenaltyDto)2 FeeDto (org.mifos.dto.domain.FeeDto)2