use of org.mifos.security.util.UserContext in project head by mifos.
the class GroupServiceFacadeWebTier method retrieveGroupFormCreationData.
@Override
public GroupFormCreationDto retrieveGroupFormCreationData(GroupCreation groupCreation) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CustomerBO parentCustomer = null;
Short parentOfficeId = groupCreation.getOfficeId();
CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.empty();
List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
CenterCreation centerCreation;
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (isCenterHierarchyExists) {
parentCustomer = this.customerDao.findCenterBySystemId(groupCreation.getParentSystemId());
parentOfficeId = parentCustomer.getOffice().getOfficeId();
centerCreation = new CenterCreation(parentOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
MeetingBO customerMeeting = parentCustomer.getCustomerMeetingValue();
List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroupsRefinedBy(customerMeeting);
applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
} else {
centerCreation = new CenterCreation(groupCreation.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroups();
applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
}
List<ApplicableAccountFeeDto> applicableDefaultAccountFees = new ArrayList<ApplicableAccountFeeDto>();
for (FeeDto fee : applicableFees.getDefaultFees()) {
applicableDefaultAccountFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
}
List<ApplicableAccountFeeDto> applicableDefaultAdditionalFees = new ArrayList<ApplicableAccountFeeDto>();
for (FeeDto fee : applicableFees.getAdditionalFees()) {
applicableDefaultAdditionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
}
List<PersonnelDto> formedByPersonnel = customerDao.findLoanOfficerThatFormedOffice(centerCreation.getOfficeId());
return new GroupFormCreationDto(isCenterHierarchyExists, personnelList, formedByPersonnel, applicableDefaultAccountFees, applicableDefaultAdditionalFees);
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class GroupServiceFacadeWebTier method updateGroup.
@Override
public void updateGroup(GroupUpdate groupUpdate) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
customerService.updateGroup(userContext, groupUpdate);
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class CustomerServiceFacadeWebTier method retrieveBranchOnlyOfficeHierarchy.
@Override
public OnlyBranchOfficeHierarchyDto retrieveBranchOnlyOfficeHierarchy() {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
OfficeDto office = officeDao.findOfficeDtoById(userContext.getBranchId());
List<OfficeBO> branchParents = officeDao.findBranchsOnlyWithParentsMatching(office.getSearchId());
List<OfficeDetailsDto> levels = officeDao.findActiveOfficeLevels();
List<OfficeHierarchyDto> branchOnlyOfficeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
return new OnlyBranchOfficeHierarchyDto(userContext.getPreferredLocale(), levels, office.getSearchId(), branchOnlyOfficeHierarchy);
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveStatusChangeHistory.
@Override
public List<SavingsStatusChangeHistoryDto> retrieveStatusChangeHistory(String globalAccountNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
SavingsBO savingsAccount = this.savingsDao.findBySystemId(globalAccountNum);
savingsAccount.updateDetails(userContext);
List<SavingsStatusChangeHistoryDto> dtoList = new ArrayList<SavingsStatusChangeHistoryDto>();
List<AccountStatusChangeHistoryEntity> statusChangeHistory = savingsAccount.getAccountStatusChangeHistory();
for (AccountStatusChangeHistoryEntity accountStatusChangeHistory : statusChangeHistory) {
dtoList.add(accountStatusChangeHistory.toDto());
}
return dtoList;
}
use of org.mifos.security.util.UserContext 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);
}
}
Aggregations