use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class CustomerServiceImpl method changeStatus.
private void changeStatus(CustomerBO customer, CustomerStatus oldStatus, CustomerStatus newStatus) throws CustomerException {
Short oldStatusId = oldStatus.getValue();
Short newStatusId = newStatus.getValue();
if (customer.isClient()) {
ClientBO client = (ClientBO) customer;
if (client.isActiveForFirstTime(oldStatusId, newStatusId)) {
if (client.getParentCustomer() != null) {
CustomerHierarchyEntity hierarchy = new CustomerHierarchyEntity(client, client.getParentCustomer());
client.addCustomerHierarchy(hierarchy);
}
CalendarEvent applicableCalendarEvents = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>(customer.getCustomerAccount().getAccountFees());
client.getCustomerAccount().createSchedulesAndFeeSchedulesForFirstTimeActiveCustomer(customer, accountFees, customer.getCustomerMeetingValue(), applicableCalendarEvents, new DateMidnight().toDateTime());
client.setCustomerActivationDate(new DateTimeService().getCurrentJavaDateTime());
if (client.getOfferingsAssociatedInCreate() != null) {
for (ClientInitialSavingsOfferingEntity clientOffering : client.getOfferingsAssociatedInCreate()) {
try {
SavingsOfferingBO savingsOffering = savingsProductDao.findById(clientOffering.getSavingsOffering().getPrdOfferingId().intValue());
if (savingsOffering.isActive()) {
List<CustomFieldDto> customerFieldsForSavings = new ArrayList<CustomFieldDto>();
client.addAccount(new SavingsBO(client.getUserContext(), savingsOffering, client, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), customerFieldsForSavings));
}
} catch (AccountException pe) {
throw new CustomerException(pe);
}
}
}
new SavingsPersistence().persistSavingAccounts(client);
try {
if (client.getParentCustomer() != null) {
List<SavingsBO> savingsList = new CustomerPersistence().retrieveSavingsAccountForCustomer(client.getParentCustomer().getCustomerId());
if (client.getParentCustomer().getParentCustomer() != null) {
savingsList.addAll(new CustomerPersistence().retrieveSavingsAccountForCustomer(client.getParentCustomer().getParentCustomer().getCustomerId()));
}
for (SavingsBO savings : savingsList) {
savings.setUserContext(client.getUserContext());
if (client.getCustomerMeeting().getMeeting() != null) {
if (!(savings.getCustomer().getLevel() == CustomerLevel.GROUP && savings.getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue()))) {
DateTime today = new DateTime().toDateMidnight().toDateTime();
savings.generateDepositAccountActions(client, client.getCustomerMeeting().getMeeting(), applicableCalendarEvents.getWorkingDays(), applicableCalendarEvents.getHolidays(), today);
savings.update();
}
}
}
}
} catch (PersistenceException pe) {
throw new CustomerException(pe);
} catch (AccountException ae) {
throw new CustomerException(ae);
}
}
}
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class AccountBO method updateCustomFields.
protected void updateCustomFields(final List<CustomFieldDto> customFields) throws InvalidDateException {
if (customFields == null) {
return;
}
for (CustomFieldDto fieldView : customFields) {
if (fieldView.getFieldType().equals(CustomFieldType.DATE.getValue()) && org.apache.commons.lang.StringUtils.isNotBlank(fieldView.getFieldValue())) {
SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, getUserContext().getPreferredLocale());
String userfmt = DateUtils.convertToCurrentDateFormat(format.toPattern());
fieldView.setFieldValue(DateUtils.convertUserToDbFmt(fieldView.getFieldValue(), userfmt));
}
if (getAccountCustomFields().size() > 0) {
for (AccountCustomFieldEntity fieldEntity : getAccountCustomFields()) {
if (fieldView.getFieldId().equals(fieldEntity.getFieldId())) {
fieldEntity.setFieldValue(fieldView.getFieldValue());
}
}
} else {
for (CustomFieldDto view : customFields) {
this.getAccountCustomFields().add(new AccountCustomFieldEntity(this, view.getFieldId(), view.getFieldValue()));
}
}
}
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class GroupServiceFacadeWebTier method getGroupInformationDto.
// private void checkPermissionForCreate(Short newState, UserContext userContext, Short recordOfficeId,
// Short recordLoanOfficerId) throws ApplicationException {
// if (!isPermissionAllowed(newState, userContext, recordOfficeId, recordLoanOfficerId)) {
// logger.info("permission not allowed: " + userContext.toString() + " officeId: " + recordLoanOfficerId + " loanOfficerId: " + recordLoanOfficerId);
// throw new AccountException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
// }
// }
// private boolean isPermissionAllowed(Short newState, UserContext userContext, Short recordOfficeId,
// Short recordLoanOfficerId) {
// return ActivityMapper.getInstance().isSavePermittedForCustomer(newState.shortValue(), userContext,
// recordOfficeId, recordLoanOfficerId);
// }
@Override
public GroupInformationDto getGroupInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
if (group == null) {
throw new MifosRuntimeException("Group not found for globalCustNum: " + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
GroupDisplayDto groupDisplay = this.customerDao.getGroupDisplayDto(group.getCustomerId(), userContext);
Integer groupId = group.getCustomerId();
String searchId = group.getSearchId();
Short branchId = groupDisplay.getBranchId();
CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(groupId);
GroupPerformanceHistoryDto groupPerformanceHistory = assembleGroupPerformanceHistoryDto(group.getGroupPerformanceHistory(), searchId, branchId, groupId);
CustomerAddressDto groupAddress = this.customerDao.getCustomerAddressDto(group);
List<CustomerDetailDto> clients = this.customerDao.findClientsThatAreNotCancelledOrClosedReturningDetailDto(searchId, branchId);
List<CustomerNoteDto> recentCustomerNotes = this.customerDao.getRecentCustomerNoteDto(groupId);
List<CustomerPositionOtherDto> customerPositions = this.customerDao.getCustomerPositionDto(groupId, userContext);
List<CustomerFlagDto> customerFlags = this.customerDao.getCustomerFlagDto(group.getCustomerFlags());
List<LoanDetailDto> loanDetail = this.customerDao.getLoanDetailDto(group.getOpenLoanAccountsAndGroupLoans());
List<SavingsDetailDto> savingsDetail = this.customerDao.getSavingsDetailDto(groupId, userContext);
CustomerMeetingDto customerMeeting = this.customerDao.getCustomerMeetingDto(group.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(groupId);
List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
} else {
closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
}
}
boolean activeSurveys = false;
// boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.GROUP);
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
return new GroupInformationDto(groupDisplay, customerAccountSummary, groupPerformanceHistory, groupAddress, clients, recentCustomerNotes, customerPositions, customerFlags, loanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedLoanAccounts, closedSavingsAccounts);
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class CustomerServiceImpl method createSavingsAccountsForActiveSavingProducts.
private void createSavingsAccountsForActiveSavingProducts(ClientBO client, List<SavingsOfferingBO> savingProducts) {
UserContext userContext = client.getUserContext();
List<SavingsBO> savingsAccounts = new ArrayList<SavingsBO>();
for (SavingsOfferingBO clientSavingsProduct : savingProducts) {
try {
if (clientSavingsProduct.isActive()) {
List<CustomFieldDto> savingCustomFieldViews = new ArrayList<CustomFieldDto>();
SavingsBO savingsAccount = new SavingsBO(userContext, clientSavingsProduct, client, AccountState.SAVINGS_ACTIVE, clientSavingsProduct.getRecommendedAmount(), savingCustomFieldViews);
savingsAccounts.add(savingsAccount);
}
} catch (AccountException pe) {
throw new MifosRuntimeException(pe);
}
}
client.addSavingsAccounts(savingsAccounts);
}
use of org.mifos.dto.domain.CustomFieldDto in project head by mifos.
the class CustomerCustomFieldEntity method toDto.
public static List<CustomFieldDto> toDto(Set<CustomerCustomFieldEntity> customFieldEntities, List<CustomFieldDefinitionEntity> customFieldDefs, UserContext userContext) {
Locale locale = userContext.getPreferredLocale();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
for (CustomFieldDefinitionEntity customFieldDef : customFieldDefs) {
for (CustomerCustomFieldEntity customFieldEntity : customFieldEntities) {
if (customFieldDef.getFieldId().equals(customFieldEntity.getFieldId())) {
CustomFieldDto customFieldDto;
if (customFieldDef.getFieldType().equals(CustomFieldType.DATE.getValue())) {
customFieldDto = new CustomFieldDto(customFieldEntity.getFieldId(), DateUtils.getUserLocaleDate(locale, customFieldEntity.getFieldValue()), customFieldDef.getFieldType());
} else {
customFieldDto = new CustomFieldDto(customFieldEntity.getFieldId(), customFieldEntity.getFieldValue(), customFieldDef.getFieldType());
}
customFieldDto.setMandatory(customFieldDef.isMandatory());
customFieldDto.setMandatoryString(customFieldDef.getMandatoryStringValue());
customFieldDto.setLookUpEntityType(customFieldDef.getEntityName());
customFields.add(customFieldDto);
}
}
}
return customFields;
}
Aggregations