Search in sources :

Example 1 with CustomerMeetingEntity

use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.

the class AccountBO method getNextMeetingDate.

public Date getNextMeetingDate() {
    AccountActionDateEntity nextAccountAction = getDetailsOfNextInstallment();
    if (nextAccountAction != null) {
        return nextAccountAction.getActionDate();
    }
    // calculate the next date based on the customer's meeting object
    CustomerMeetingEntity customerMeeting = customer.getCustomerMeeting();
    if (customerMeeting != null) {
        ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting.getMeeting());
        DateTime nextMeetingDate = scheduledEvent.nearestMatchingDateBeginningAt(new LocalDate().toDateTimeAtStartOfDay());
        return new java.sql.Date(nextMeetingDate.toDate().getTime());
    }
    return new java.sql.Date(DateUtils.getCurrentDateWithoutTimeStamp().getTime());
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) CustomerMeetingEntity(org.mifos.customers.business.CustomerMeetingEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 2 with CustomerMeetingEntity

use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.

the class CustomerServiceImpl method updateCustomerMeetingSchedule.

@Override
public void updateCustomerMeetingSchedule(MeetingBO updatedMeeting, CustomerBO customer) {
    try {
        customer.validateIsTopOfHierarchy();
        customerDao.checkPermissionForEditMeetingSchedule(updatedMeeting.getUserContext(), customer);
        CalendarEvent calendarEvents = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
        this.hibernateTransactionHelper.startTransaction();
        boolean scheduleUpdateRequired = false;
        CustomerMeetingEntity meetingEntity = customer.getCustomerMeeting();
        if (meetingEntity != null) {
            MeetingBO meeting = customer.getCustomerMeetingValue();
            scheduleUpdateRequired = updateMeeting(meeting, updatedMeeting);
        } else {
            CustomerMeetingEntity newMeetingEntity = customer.createCustomerMeeting(updatedMeeting);
            customer.setCustomerMeeting(newMeetingEntity);
        }
        customerDao.save(customer);
        if (scheduleUpdateRequired) {
            handleChangeInMeetingSchedule(customer, calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
        }
        this.hibernateTransactionHelper.commitTransaction();
    } catch (CustomerException e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (AccountException e) {
        this.hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } finally {
        this.hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerMeetingEntity(org.mifos.customers.business.CustomerMeetingEntity) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CalendarEvent(org.mifos.calendar.CalendarEvent)

Example 3 with CustomerMeetingEntity

use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.

the class ClientBO method transferTo.

public boolean transferTo(GroupBO receivingGroup) {
    boolean regenerateClientSchedules = false;
    this.setParentCustomer(receivingGroup);
    this.setPersonnel(receivingGroup.getPersonnel());
    CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
    if (null != currentHierarchy) {
        currentHierarchy.makeInactive(userContext.getId());
    }
    addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingGroup));
    MeetingBO parentGroupMeeting = receivingGroup.getCustomerMeetingValue();
    MeetingBO clientMeeting = this.getCustomerMeetingValue();
    if (parentGroupMeeting != null) {
        if (clientMeeting != null) {
            regenerateClientSchedules = receivingGroup.hasMeetingDifferentTo(clientMeeting);
            CustomerMeetingEntity clientMeetingEntity = this.getCustomerMeeting();
            clientMeetingEntity.setMeeting(receivingGroup.getCustomerMeetingValue());
        } else {
            CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(parentGroupMeeting);
            this.setCustomerMeeting(customerMeeting);
        }
    } else if (clientMeeting != null) {
        this.setCustomerMeeting(null);
    }
    if (!isSameBranch(receivingGroup.getOffice())) {
        this.makeCustomerMovementEntries(receivingGroup.getOffice());
        regenerateClientSchedules = true;
    }
    this.addGroupMembership();
    this.generateSearchId();
    return regenerateClientSchedules;
}
Also used : CustomerHierarchyEntity(org.mifos.customers.business.CustomerHierarchyEntity) CustomerMeetingEntity(org.mifos.customers.business.CustomerMeetingEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO)

Example 4 with CustomerMeetingEntity

use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.

the class ClientBO method handleGroupTransfer.

public void handleGroupTransfer() {
    if (!isSameBranch(getParentCustomer().getOffice())) {
        makeCustomerMovementEntries(getParentCustomer().getOffice());
        if (isActive()) {
            setCustomerStatus(new CustomerStatusEntity(CustomerStatus.CLIENT_HOLD));
        }
        this.setPersonnel(null);
    }
    setSearchId(getParentCustomer().getSearchId() + getSearchId().substring(getSearchId().lastIndexOf(".")));
    if (getParentCustomer() != null) {
        setPersonnel(getParentCustomer().getPersonnel());
        CustomerMeetingEntity clientMeetingEntity = this.getCustomerMeeting();
        clientMeetingEntity.setMeeting(this.getParentCustomer().getCustomerMeetingValue());
    }
}
Also used : CustomerMeetingEntity(org.mifos.customers.business.CustomerMeetingEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 5 with CustomerMeetingEntity

use of org.mifos.customers.business.CustomerMeetingEntity in project head by mifos.

the class GroupBO method transferTo.

public boolean transferTo(CenterBO receivingCenter) {
    boolean regenerateGroupSchedules = false;
    this.setParentCustomer(receivingCenter);
    this.setPersonnel(receivingCenter.getPersonnel());
    CustomerHierarchyEntity currentHierarchy = this.getActiveCustomerHierarchy();
    if (null != currentHierarchy) {
        currentHierarchy.makeInactive(this.getUserContext().getId());
    }
    this.addCustomerHierarchy(new CustomerHierarchyEntity(this, receivingCenter));
    MeetingBO centerMeeting = receivingCenter.getCustomerMeetingValue();
    MeetingBO groupMeeting = this.getCustomerMeetingValue();
    if (centerMeeting != null) {
        if (groupMeeting != null) {
            regenerateGroupSchedules = receivingCenter.hasMeetingDifferentTo(groupMeeting);
            CustomerMeetingEntity groupMeetingEntity = this.getCustomerMeeting();
            groupMeetingEntity.setMeeting(receivingCenter.getCustomerMeetingValue());
        } else {
            CustomerMeetingEntity customerMeeting = this.createCustomerMeeting(centerMeeting);
            this.setCustomerMeeting(customerMeeting);
        }
    } else if (groupMeeting != null) {
        this.setCustomerMeeting(null);
    }
    OfficeBO centerOffice = receivingCenter.getOffice();
    if (this.isDifferentBranch(centerOffice)) {
        this.makeCustomerMovementEntries(centerOffice);
        if (this.isActive()) {
            this.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
        }
        regenerateGroupSchedules = true;
    }
    this.generateSearchId();
    return regenerateGroupSchedules;
}
Also used : CustomerHierarchyEntity(org.mifos.customers.business.CustomerHierarchyEntity) CustomerMeetingEntity(org.mifos.customers.business.CustomerMeetingEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Aggregations

CustomerMeetingEntity (org.mifos.customers.business.CustomerMeetingEntity)5 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 CustomerHierarchyEntity (org.mifos.customers.business.CustomerHierarchyEntity)2 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)2 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)1 CalendarEvent (org.mifos.calendar.CalendarEvent)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 ScheduledEvent (org.mifos.schedule.ScheduledEvent)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1