Search in sources :

Example 1 with MeetingBO

use of org.mifos.application.meeting.business.MeetingBO in project head by mifos.

the class LoanBO method handlePeriodic.

/**
     * Calculate and return the list of {@link FeeInstallment}s to be applied. A fee installment will apply to one of
     * the given loan installmentDates if the installmentIds match. Here's the criteria for matching a fee installment
     * to a loan installment: Calculate the dates in nonAdjustedInstallmentDates that the fee would be due if the fee
     * were to start today. For each unadjusted fee date, build a FeeInstallment object based on the installmentId of
     * the nearest loan installment date in the list installmentDates (this is what causes fees to pile up on a future
     * loan installment that has been pushed out of a holiday), and add it to the list to be returned.
     */
@Override
protected final List<FeeInstallment> handlePeriodic(final AccountFeesEntity accountFees, final List<InstallmentDate> installmentDates, final List<InstallmentDate> nonAdjustedInstallmentDates) throws AccountException {
    Money accountFeeAmount = accountFees.getAccountFeeAmount();
    MeetingBO feeMeetingFrequency = accountFees.getFees().getFeeFrequency().getFeeMeetingFrequency();
    // Generate the dates in nonAdjustedInstallmentDates that the fee would be due if
    // the fee were to start today
    List<Date> feeDates = getFeeDates(feeMeetingFrequency, nonAdjustedInstallmentDates, false);
    // For each unadjusted fee date, build a FeeInstallment object based on the installmentId of the
    // nearest loan installment date adjusted for holidays (this is what causes fees to pile up
    // on a future loan installment that has been pushed out of a holiday), and add it to the list to
    // be returned
    ListIterator<Date> feeDatesIterator = feeDates.listIterator();
    List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
    while (feeDatesIterator.hasNext()) {
        Date feeDate = feeDatesIterator.next();
        logger.debug("Handling periodic fee.." + feeDate);
        Short installmentId = getMatchingInstallmentId(installmentDates, feeDate);
        feeInstallmentList.add(buildFeeInstallment(installmentId, accountFeeAmount, accountFees));
    }
    return feeInstallmentList;
}
Also used : Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) ArrayList(java.util.ArrayList) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 2 with MeetingBO

use of org.mifos.application.meeting.business.MeetingBO in project head by mifos.

the class CenterServiceFacadeWebTier method createNewCenter.

@Override
public CustomerDetailsDto createNewCenter(CenterCreationDetail createCenterDetail, MeetingDto meetingDto) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
    String centerName = createCenterDetail.getDisplayName();
    String externalId = createCenterDetail.getExternalId();
    AddressDto addressDto = createCenterDetail.getAddressDto();
    Address centerAddress = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber());
    PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(createCenterDetail.getLoanOfficerId());
    OfficeBO centerOffice = this.officeDao.findOfficeById(createCenterDetail.getOfficeId());
    List<AccountFeesEntity> feesForCustomerAccount = createAccountFeeEntities(createCenterDetail.getFeesToApply());
    DateTime mfiJoiningDate = null;
    if (createCenterDetail.getMfiJoiningDate() != null) {
        mfiJoiningDate = createCenterDetail.getMfiJoiningDate().toDateMidnight().toDateTime();
    }
    MeetingBO meeting = new MeetingFactory().create(meetingDto);
    meeting.setUserContext(userContext);
    CenterBO center = CenterBO.createNew(userContext, centerName, mfiJoiningDate, meeting, loanOfficer, centerOffice, centerAddress, externalId, new DateMidnight().toDateTime());
    try {
        personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    this.customerService.createCenter(center, meeting, feesForCustomerAccount);
    return new CustomerDetailsDto(center.getCustomerId(), center.getGlobalCustNum());
}
Also used : Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) MeetingFactory(org.mifos.application.meeting.business.MeetingFactory) DateTime(org.joda.time.DateTime) AccountException(org.mifos.accounts.exceptions.AccountException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) DateMidnight(org.joda.time.DateMidnight) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with MeetingBO

use of org.mifos.application.meeting.business.MeetingBO in project head by mifos.

the class CenterPersistence method createCenter.

/**
     * @deprecated use {@link CustomerDao#save(org.mifos.customers.business.CustomerBO)} with {@link CustomerBO} static
     *             factory methods.
     */
@Deprecated
public CenterBO createCenter(UserContext userContext, CenterTemplate template) throws Exception {
    OfficeBO centerOffice = officePersistence.getOffice(template.getOfficeId());
    PersonnelBO loanOfficer = legacyPersonnelDao.getPersonnel(template.getLoanOfficerId());
    MeetingBO meeting = template.getMeeting();
    CenterBO center = CenterBO.createNew(userContext, template.getDisplayName(), new DateTime(template.getMfiJoiningDate()), meeting, loanOfficer, centerOffice, template.getAddress(), template.getExternalId(), new DateMidnight().toDateTime());
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    try {
        StaticHibernateUtil.startTransaction();
        customerDao.save(center);
        center.generateGlobalCustomerNumber();
        customerDao.save(center);
        StaticHibernateUtil.commitTransaction();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
    } finally {
        StaticHibernateUtil.closeSession();
    }
    return center;
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) DateMidnight(org.joda.time.DateMidnight) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CustomerDao(org.mifos.customers.persistence.CustomerDao) DateTime(org.joda.time.DateTime) CustomerException(org.mifos.customers.exceptions.CustomerException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 4 with MeetingBO

use of org.mifos.application.meeting.business.MeetingBO in project head by mifos.

the class CustomerAccountBO method handlePeriodic.

@Override
protected final List<FeeInstallment> handlePeriodic(final AccountFeesEntity accountFees, final List<InstallmentDate> installmentDates, final List<InstallmentDate> nonAdjustedInstallmentDates) throws AccountException {
    Money accountFeeAmount = accountFees.getAccountFeeAmount();
    MeetingBO feeMeetingFrequency = accountFees.getFees().getFeeFrequency().getFeeMeetingFrequency();
    List<Date> feeDates = getFeeDates(feeMeetingFrequency, nonAdjustedInstallmentDates);
    ListIterator<Date> feeDatesIterator = feeDates.listIterator();
    List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
    while (feeDatesIterator.hasNext()) {
        Date feeDate = feeDatesIterator.next();
        logger.debug("Handling periodic fee.." + feeDate);
        Short installmentId = getMatchingInstallmentId(installmentDates, feeDate);
        feeInstallmentList.add(buildFeeInstallment(installmentId, accountFeeAmount, accountFees));
    }
    return feeInstallmentList;
}
Also used : Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) ArrayList(java.util.ArrayList) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 5 with MeetingBO

use of org.mifos.application.meeting.business.MeetingBO in project head by mifos.

the class InterceptHelper method readFurtherMetaForCollectionType.

private void readFurtherMetaForCollectionType(Object obj, String firstName, String state) {
    Class l = getClazz(obj);
    ClassMetadata customMeta = StaticHibernateUtil.getSessionFactory().getClassMetadata(l);
    Object[] propertyValues = customMeta.getPropertyValues(obj, EntityMode.POJO);
    String[] propertyNames = customMeta.getPropertyNames();
    Type[] propertyTypes = customMeta.getPropertyTypes();
    setPrimaryKeyValueForCollectionType(customMeta, obj, firstName.concat(customMeta.getIdentifierPropertyName()), state);
    for (int i = 0; i < propertyNames.length; i++) {
        if (!propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !propertyTypes[i].isCollectionType()) {
            if (state.equalsIgnoreCase(AuditConstants.TRANSACTIONBEGIN)) {
                String name = firstName.concat(propertyNames[i]);
                logger.debug("i readFurtherMetaForCollectionType : " + name + " : " + propertyValues[i]);
                String oldValue = getOldValueToKey(initialValues, name);
                if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) {
                    String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId);
                    if (!oldValue.equals("")) {
                        initialValues.put(name, value.concat(",").concat(oldValue));
                    } else {
                        initialValues.put(name, value);
                    }
                } else {
                    if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) {
                        if (!oldValue.equals("")) {
                            initialValues.put(name, ((Calendar) propertyValues[i]).getTime().toString().concat(",").concat(oldValue));
                        } else {
                            initialValues.put(name, ((Calendar) propertyValues[i]).getTime());
                        }
                    } else if (!(propertyValues[i] instanceof Calendar) && !(propertyValues[i] instanceof Date) && propertyValues[i] != null) {
                        if (!oldValue.equals("")) {
                            initialValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue));
                        } else {
                            initialValues.put(name, propertyValues[i]);
                        }
                    } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) {
                        if (!oldValue.equals("")) {
                            try {
                                Date date = (Date) propertyValues[i];
                                initialValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()).toString().concat(",").concat(oldValue));
                            } catch (Exception e) {
                                initialValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue));
                            }
                        } else {
                            try {
                                Date date = (Date) propertyValues[i];
                                initialValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()));
                            } catch (Exception e) {
                                initialValues.put(name, propertyValues[i].toString());
                            }
                        }
                    } else {
                        if (!oldValue.equals("")) {
                            initialValues.put(name, oldValue);
                        } else {
                            initialValues.put(name, propertyValues[i]);
                        }
                    }
                }
                String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name);
                if (columnName != null && !columnName.equals("")) {
                    columnNames.put(name, columnName);
                } else {
                    columnNames.put(name, propertyNames[i]);
                }
            } else {
                String name = firstName.concat(propertyNames[i].toString());
                logger.debug("c readFurtherMetaForCollectionType : " + name + " : " + propertyValues[i]);
                String oldValue = getOldValueToKey(changedValues, name);
                if (AuditConfiguration.checkForPropertyName(entityName, name, localeId)) {
                    String value = AuditConfiguration.getValueOfCorrespondingId(entityName, name, propertyValues[i], localeId);
                    if (!value.equals("")) {
                        changedValues.put(name, value.concat(",").concat(oldValue));
                    } else {
                        changedValues.put(name, oldValue);
                    }
                } else {
                    if (propertyValues[i] instanceof Calendar && propertyValues[i] != null) {
                        if (!oldValue.equals("")) {
                            changedValues.put(name, ((Calendar) propertyValues[i]).getTime().toString().concat(",").concat(oldValue));
                        } else {
                            changedValues.put(name, ((Calendar) propertyValues[i]).getTime());
                        }
                    } else if (!(propertyValues[i] instanceof Calendar) && !(propertyValues[i] instanceof Date) && propertyValues[i] != null) {
                        if (!oldValue.equals("")) {
                            changedValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue));
                        } else {
                            changedValues.put(name, propertyValues[i]);
                        }
                    } else if (propertyValues[i] instanceof Date && propertyValues[i] != null) {
                        if (!oldValue.equals("")) {
                            try {
                                Date date = (Date) propertyValues[i];
                                changedValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()).toString().concat(",").concat(oldValue));
                            } catch (Exception e) {
                                changedValues.put(name, propertyValues[i].toString().concat(",").concat(oldValue));
                            }
                        } else {
                            try {
                                Date date = (Date) propertyValues[i];
                                changedValues.put(name, DateUtils.getUserLocaleDate(locale, new java.sql.Date(date.getTime()).toString()));
                            } catch (Exception e) {
                                changedValues.put(name, propertyValues[i].toString());
                            }
                        }
                    } else {
                        if (!oldValue.equals("")) {
                            changedValues.put(name, oldValue);
                        } else {
                            changedValues.put(name, propertyValues[i]);
                        }
                    }
                }
                String columnName = AuditConfiguration.getColumnNameForPropertyName(entityName, name);
                if (columnName != null && !columnName.equals("")) {
                    columnNames.put(name, columnName);
                } else {
                    columnNames.put(name, propertyNames[i]);
                }
            }
        }
        if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && propertyValues[i] instanceof MasterDataEntity && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
            populateValueForObjectsOfTypeMasterDataEntityInCollections(propertyValues[i], state, firstName.concat(propertyNames[i]));
        }
        if (propertyTypes[i].isEntityType() && !propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
            Object object = propertyValues[i];
            if (object != null) {
                if (object instanceof MeetingBO) {
                    MeetingBO meeting = (MeetingBO) object;
                    if (propertyNames[i].equalsIgnoreCase("meeting") && meeting.getMeetingId() != null) {
                        readMeetingCollection(meeting, propertyNames[i], state);
                    } else {
                        readFurtherMetaForCollectionType(object, propertyNames[i], state);
                    }
                } else {
                    readFurtherMetaForCollectionType(object, propertyNames[i], state);
                }
            }
        }
        // Reading further component type
        if (!propertyTypes[i].isEntityType() && propertyTypes[i].isComponentType() && !(propertyValues[i] instanceof MasterDataEntity) && AuditConfiguration.isObjectToBeLogged(entityName, propertyNames[i], firstName)) {
            Object obj1 = propertyValues[i];
            if (obj1 != null) {
                readComponenetTypeInCollectionTypeWithoutMerge(obj1, propertyNames[i], state, propertyTypes[i]);
            }
        }
    }
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Calendar(java.util.Calendar) Date(java.util.Date) ComponentType(org.hibernate.type.ComponentType) Type(org.hibernate.type.Type) AbstractBusinessObject(org.mifos.framework.business.AbstractBusinessObject)

Aggregations

MeetingBO (org.mifos.application.meeting.business.MeetingBO)355 Test (org.junit.Test)176 Date (java.util.Date)91 ArrayList (java.util.ArrayList)84 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)74 DateTime (org.joda.time.DateTime)68 LocalDate (org.joda.time.LocalDate)56 Money (org.mifos.framework.util.helpers.Money)56 CenterBuilder (org.mifos.domain.builders.CenterBuilder)54 CenterBO (org.mifos.customers.center.business.CenterBO)46 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)44 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)42 Date (java.sql.Date)40 UserContext (org.mifos.security.util.UserContext)34 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)33 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)27 CustomerBO (org.mifos.customers.business.CustomerBO)23 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)22 MifosUser (org.mifos.security.MifosUser)20