use of org.mifos.customers.api.CustomerLevel in project head by mifos.
the class WebTierAccountServiceFacade method isPaymentPermitted.
@Override
public boolean isPaymentPermitted(Integer accountId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
CustomerLevel customerLevel = null;
if (account.getType().equals(AccountTypes.CUSTOMER_ACCOUNT)) {
customerLevel = account.getCustomer().getLevel();
}
Short personnelId = userContext.getId();
if (account.getPersonnel() != null) {
personnelId = account.getPersonnel().getPersonnelId();
}
return ActivityMapper.getInstance().isPaymentPermittedForAccounts(account.getType(), customerLevel, userContext, account.getOffice().getOfficeId(), personnelId);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.customers.api.CustomerLevel in project head by mifos.
the class CustomerPersistence method setSearchFilters.
private void setSearchFilters(final List<Param> paramList, final SearchFiltersDto filters) throws PersistenceException {
Map<String, Boolean> customerLevelIds = filters.getCustomerLevels();
Map<String, Integer> customerStates = filters.getCustomerStates();
for (CustomerLevel customerLevel : CustomerLevel.values()) {
if (customerLevelIds != null) {
paramList.add(typeNameValue("Boolean", customerLevel.toString() + "_SEARCH", customerLevelIds.get(customerLevel.toString())));
} else {
paramList.add(typeNameValue("Boolean", customerLevel.toString() + "_SEARCH", true));
}
if (customerStates != null) {
paramList.add(typeNameValue("Short", customerLevel.toString() + "_STATUS", customerStates.get(customerLevel.toString())));
} else {
paramList.add(typeNameValue("Short", customerLevel.toString() + "_STATUS", "all"));
}
}
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
if (filters.getCreationDateRangeStart() != null && !filters.getCreationDateRangeStart().equals("")) {
paramList.add(typeNameValue("Boolean", "CREATED_DATE_RANGE_START_SEARCH", true));
paramList.add(typeNameValue("Date", "CREATED_DATE_RANGE_START", simpleDateFormat.parse(filters.getCreationDateRangeStart())));
} else {
paramList.add(typeNameValue("Boolean", "CREATED_DATE_RANGE_START_SEARCH", false));
paramList.add(typeNameValue("Date", "CREATED_DATE_RANGE_START", null));
}
if (filters.getCreationDateRangeEnd() != null && !filters.getCreationDateRangeEnd().equals("")) {
paramList.add(typeNameValue("Boolean", "CREATED_DATE_RANGE_END_SEARCH", true));
paramList.add(typeNameValue("Date", "CREATED_DATE_RANGE_END", simpleDateFormat.parse(filters.getCreationDateRangeEnd())));
} else {
paramList.add(typeNameValue("Boolean", "CREATED_DATE_RANGE_END_SEARCH", false));
paramList.add(typeNameValue("Date", "CREATED_DATE_RANGE_END", null));
}
} catch (ParseException e) {
throw new MifosRuntimeException(e);
}
if (filters.getGender() != null && filters.getGender() != 0) {
paramList.add(typeNameValue("Boolean", "GENDER_SEARCH", true));
paramList.add(typeNameValue("Short", "GENDER_ID", filters.getGender().shortValue()));
} else {
paramList.add(typeNameValue("Boolean", "GENDER_SEARCH", false));
paramList.add(typeNameValue("Short", "GENDER_ID", null));
}
if (filters.getEthnicity() != null && !filters.getEthnicity().equals("")) {
List<Integer> ethnicityIds = getLookupIdsByValue(filters.getEthnicity(), LookUpEntity.ETHNICITY);
if (ethnicityIds.size() == 0) {
ethnicityIds.add(-1);
}
paramList.add(typeNameValue("Boolean", "ETHNICITY_SEARCH", true));
paramList.add(typeNameValue("List", "ETHNICITY_IDS", ethnicityIds));
} else {
paramList.add(typeNameValue("Boolean", "ETHNICITY_SEARCH", false));
paramList.add(typeNameValue("List", "ETHNICITY_IDS", null));
}
if (filters.getBusinessActivity() != null && !filters.getBusinessActivity().equals("")) {
List<Integer> businessActivityIds = getLookupIdsByValue(filters.getBusinessActivity(), LookUpEntity.BUSINESS_ACTIVITY);
if (businessActivityIds.size() == 0) {
businessActivityIds.add(-1);
}
paramList.add(typeNameValue("Boolean", "BUSINESS_ACTIVITY_SEARCH", true));
paramList.add(typeNameValue("List", "BUSINESS_ACTIVITY_IDS", businessActivityIds));
} else {
paramList.add(typeNameValue("Boolean", "BUSINESS_ACTIVITY_SEARCH", false));
paramList.add(typeNameValue("List", "BUSINESS_ACTIVITY_IDS", null));
}
if (filters.getCitizenship() != null && !filters.getCitizenship().equals("")) {
List<Integer> citizenshipIds = getLookupIdsByValue(filters.getCitizenship(), LookUpEntity.CITIZENSHIP);
if (citizenshipIds.size() == 0) {
citizenshipIds.add(-1);
}
paramList.add(typeNameValue("Boolean", "CITIZENSHIP_SEARCH", true));
paramList.add(typeNameValue("List", "CITIZENSHIP_IDS", citizenshipIds));
} else {
paramList.add(typeNameValue("Boolean", "CITIZENSHIP_SEARCH", false));
paramList.add(typeNameValue("List", "CITIZENSHIP_IDS", null));
}
}
Aggregations