use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.
the class AdminServiceFacadeWebTier method getAllPaymentTypes.
private List<PaymentTypeDto> getAllPaymentTypes(Short localeId) {
List<PaymentTypeDto> paymentTypeList = new ArrayList<PaymentTypeDto>();
PaymentTypeDto payment = null;
Short id = 0;
List<PaymentTypeEntity> paymentTypes = getMasterEntities(PaymentTypeEntity.class);
for (PaymentTypeEntity masterDataEntity : paymentTypes) {
PaymentTypeEntity paymentType = masterDataEntity;
id = paymentType.getId();
payment = new PaymentTypeDto(id, paymentType.getName());
paymentTypeList.add(payment);
}
return paymentTypeList;
}
use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.
@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
final Short branchId = userContext.getBranchId();
final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
List<CustomerDto> customerList = new ArrayList<CustomerDto>();
List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
Short reloadFormAutomatically = Constants.YES;
final Short backDatedTransactionAllowed = Constants.NO;
try {
final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
activeBranches = officePersistence.getActiveOffices(branchId);
if (activeBranches.size() == 1) {
loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
if (loanOfficerList.size() == 1) {
Short customerLevel;
if (centerHierarchyExists.equals(Constants.YES)) {
customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
} else {
customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
}
customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
if (customerList.size() == 1) {
reloadFormAutomatically = Constants.YES;
}
reloadFormAutomatically = Constants.NO;
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.
the class SavingsDepositWithdrawalAction method reLoad.
@TransactionDemarcate(joinToken = true)
public ActionForward reLoad(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsDepositWithdrawalActionForm actionForm = (SavingsDepositWithdrawalActionForm) form;
SavingsBO savingsInSession = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
if (actionForm.getTrxnTypeId() != null && actionForm.getTrxnTypeId() != Constants.EMPTY_STRING) {
Long savingsId = savingsInSession.getAccountId().longValue();
SavingsBO savings = this.savingsDao.findById(savingsId);
Integer customerId = savings.getCustomer().getCustomerId();
if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
customerId = Integer.valueOf(actionForm.getCustomerId());
}
DepositWithdrawalReferenceDto depositWithdrawalReferenceDto = this.savingsServiceFacade.retrieveDepositWithdrawalReferenceData(savingsId, customerId);
Short trxnTypeId = Short.valueOf(actionForm.getTrxnTypeId());
// added for defect 1587 [start]
LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
if (trxnTypeId.equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue())) {
if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
actionForm.setAmount(depositWithdrawalReferenceDto.getDepositDue());
}
List<PaymentTypeEntity> depositPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.savings_deposit.getValue());
SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, depositPaymentTypes, request);
} else {
actionForm.setAmount(depositWithdrawalReferenceDto.getWithdrawalDue());
List<PaymentTypeEntity> withdrawalPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, withdrawalPaymentTypes, request);
}
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.
the class WebTierAccountServiceFacade method constructPaymentTypeList.
private List<ListItem<Short>> constructPaymentTypeList(String paymentType, Short localeId) {
try {
List<PaymentTypeEntity> paymentTypeList = null;
if (paymentType != null && !Constants.EMPTY_STRING.equals(paymentType.trim())) {
if (isLoanPayment(paymentType)) {
paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.loan_repayment.getValue());
} else {
paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.fee.getValue());
}
}
List<ListItem<Short>> listItems = new ArrayList<ListItem<Short>>();
for (PaymentTypeEntity paymentTypeEntity : paymentTypeList) {
listItems.add(new ListItem<Short>(paymentTypeEntity.getId(), paymentTypeEntity.getName()));
}
return listItems;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.
the class SavingsServiceFacadeWebTier method closeSavingsAccount.
@Override
public void closeSavingsAccount(Long savingsId, String notes, SavingsWithdrawalDto closeAccountDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
savingsAccount.updateDetails(userContext);
PersonnelBO createdBy = this.personnelDao.findPersonnelById(userContext.getId());
LocalDate closureDate = closeAccountDto.getDateOfWithdrawal();
// Assumption that all previous interest postings occurred correctly
InterestScheduledEvent postingSchedule = savingsInterestScheduledEventFactory.createScheduledEventFrom(savingsAccount.getInterestPostingMeeting());
LocalDate nextPostingDate = new LocalDate(savingsAccount.getNextIntPostDate());
LocalDate startOfPostingPeriod = postingSchedule.findFirstDateOfPeriodForMatchingDate(nextPostingDate);
CalendarPeriod postingPeriodAtClosure;
if (startOfPostingPeriod.isAfter(closureDate)) {
postingPeriodAtClosure = new CalendarPeriod(closureDate, closureDate);
} else {
postingPeriodAtClosure = new CalendarPeriod(startOfPostingPeriod, closureDate);
}
List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor(savingsAccount.getCurrency(), Long.valueOf(savingsId));
InterestPostingPeriodResult postingPeriodAtClosureResult = determinePostingPeriodResult(postingPeriodAtClosure, savingsAccount, allEndOfDayDetailsForAccount);
savingsAccount.postInterest(postingSchedule, postingPeriodAtClosureResult, createdBy);
AccountNotesEntity notesEntity = new AccountNotesEntity(new DateTimeService().getCurrentJavaSqlDate(), notes, createdBy, savingsAccount);
try {
CustomerBO customer = savingsAccount.getCustomer();
if (closeAccountDto.getCustomerId() != null) {
List<CustomerBO> clientList = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
for (CustomerBO client : clientList) {
if (closeAccountDto.getCustomerId().intValue() == client.getCustomerId().intValue()) {
customer = client;
break;
}
}
}
Money amount = new Money(savingsAccount.getCurrency(), closeAccountDto.getAmount().toString());
PaymentTypeEntity paymentType = new PaymentTypeEntity(closeAccountDto.getModeOfPayment().shortValue());
Date receiptDate = null;
if (closeAccountDto.getDateOfReceipt() != null) {
receiptDate = closeAccountDto.getDateOfReceipt().toDateMidnight().toDate();
}
AccountPaymentEntity closeAccount = new AccountPaymentEntity(savingsAccount, amount, closeAccountDto.getReceiptId(), receiptDate, paymentType, closeAccountDto.getDateOfWithdrawal().toDateMidnight().toDate());
this.transactionHelper.startTransaction();
this.transactionHelper.beginAuditLoggingFor(savingsAccount);
savingsAccount.closeAccount(closeAccount, notesEntity, customer, createdBy);
this.savingsDao.save(savingsAccount);
this.transactionHelper.commitTransaction();
} catch (BusinessRuleException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getMessageKey(), e);
} catch (PersistenceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
Aggregations