use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveDepositWithdrawalReferenceData.
@Override
public DepositWithdrawalReferenceDto retrieveDepositWithdrawalReferenceData(Long savingsId, Integer customerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
SavingsBO savingsAccount = savingsDao.findById(savingsId);
String depositDue = savingsAccount.getTotalPaymentDue(customerId).toString();
String withdrawalDue = "0";
List<ListElement> clients = new ArrayList<ListElement>();
if (savingsAccount.isGroupModelWithIndividualAccountability()) {
List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
for (CustomerBO client : activeAndOnHoldClients) {
clients.add(new ListElement(client.getCustomerId(), client.getDisplayName()));
}
}
List<AccountActionEntity> trxnTypes = new ArrayList<AccountActionEntity>();
trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_DEPOSIT.getValue(), userContext.getLocaleId()));
trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), userContext.getLocaleId()));
List<ListElement> transactionTypes = new ArrayList<ListElement>();
for (AccountActionEntity accountActionEntity : trxnTypes) {
LookUpValueEntity lookupValue = accountActionEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
transactionTypes.add(new ListElement(accountActionEntity.getId().intValue(), messageText));
}
List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
List<ListElement> withdrawalPaymentTypes = new ArrayList<ListElement>();
List<PaymentTypeEntity> withdrawalPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
for (PaymentTypeEntity paymentTypeEntity : withdrawalPaymentEntityTypes) {
LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
withdrawalPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
}
boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
LocalDate defaultTransactionDate = new LocalDate();
return new DepositWithdrawalReferenceDto(transactionTypes, depositPaymentTypes, withdrawalPaymentTypes, clients, backDatedTransactionsAllowed, defaultTransactionDate, depositDue, withdrawalDue);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveDepositPaymentTypes.
private List<ListElement> retrieveDepositPaymentTypes(UserContext userContext) {
try {
List<ListElement> depositPaymentTypes = new ArrayList<ListElement>();
List<PaymentTypeEntity> acceptedPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_deposit.getValue());
for (PaymentTypeEntity paymentTypeEntity : acceptedPaymentEntityTypes) {
LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
depositPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
}
return depositPaymentTypes;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class LegacyRolesPermissionsDao method retrieveOneActivityEntity.
public ActivityEntity retrieveOneActivityEntity(int lookUpId) throws PersistenceException {
Map<String, Object> queryParameters = new HashMap<String, Object>();
LookUpValueEntity aLookUpValueEntity = getPersistentObject(LookUpValueEntity.class, lookUpId);
queryParameters.put("aLookUpValueEntity", aLookUpValueEntity);
Object obj = execUniqueResultNamedQuery(NamedQueryConstants.GETACTIVITYENTITY, queryParameters);
if (null != obj) {
return (ActivityEntity) obj;
}
return null;
}
use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class LegacyRolesPermissionsDao method createLookUpValue.
private int createLookUpValue(DynamicLookUpValueCreationTypes type, String lookUpDescription) throws PersistenceException {
LookUpValueEntity anLookUp = new LookUpValueEntity();
LookUpEntity lookUpEntity = getPersistentObject(LookUpEntity.class, Short.valueOf((short) LookUpEntity.ACTIVITY));
String lookupName = SearchUtils.generateLookupName(type.name(), lookUpDescription);
anLookUp.setLookUpName(lookupName);
anLookUp.setLookUpEntity(lookUpEntity);
createOrUpdate(anLookUp);
ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(lookupName, lookUpDescription);
int lookUpId = anLookUp.getLookUpId().intValue();
return lookUpId;
}
use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class LookupOptionsAction method update.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("Inside update method");
// setHiddenFields(request);
LookupOptionsActionForm lookupOptionsActionForm = (LookupOptionsActionForm) form;
LookupOptionData data = (LookupOptionData) SessionUtils.getAttribute(ConfigurationConstants.LOOKUP_OPTION_DATA, request);
data.setLookupValue(lookupOptionsActionForm.getLookupValue());
String entity = request.getParameter(ConfigurationConstants.ENTITY);
if (data.getLookupId() > 0) {
legacyMasterDao.updateValueListElementForLocale(data.getLookupId(), data.getLookupValue());
} else {
LookUpValueEntity newLookupValue = legacyMasterDao.addValueListElementForLocale(DynamicLookUpValueCreationTypes.LookUpOption, data.getValueListId(), data.getLookupValue());
/*
* Add a special case for payment types since we not only need to create a new
* lookup value but also a new PaymentTypeEntity when adding an entry
*/
if (entity.equals(ConfigurationConstants.CONFIG_PAYMENT_TYPE)) {
PaymentTypeEntity newPaymentType = new PaymentTypeEntity(newLookupValue);
legacyMasterDao.createOrUpdate(newPaymentType);
StaticHibernateUtil.commitTransaction();
}
}
return mapping.findForward(ActionForwards.update_success.toString());
}
Aggregations