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;
}
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());
}
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;
}
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;
}
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]);
}
}
}
}
Aggregations