Search in sources :

Example 6 with ListItem

use of org.mifos.application.servicefacade.ListItem in project head by mifos.

the class ApplyAdjustment method loadAdjustment.

@TransactionDemarcate(joinToken = true)
public ActionForward loadAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    AccountBO accnt = getBizService().findBySystemId(appAdjustActionForm.getGlobalAccountNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, accnt, request);
    request.setAttribute("method", "loadAdjustment");
    UserContext userContext = getUserContext(request);
    SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, this.accountServiceFacade.constructPaymentTypeListForLoanRepayment(userContext.getLocaleId()), request);
    AccountPaymentEntity payment = null;
    if (request.getParameter(Constants.ADJ_TYPE_KEY) != null && request.getParameter(Constants.ADJ_TYPE_KEY).equals(Constants.ADJ_SPECIFIC)) {
        Integer paymentId = appAdjustActionForm.getPaymentId();
        payment = accnt.findPaymentById(paymentId);
        AccountPaymentEntity previous = null;
        AccountPaymentEntity next = null;
        boolean getPrevious = false;
        for (AccountPaymentEntity p : accnt.getAccountPayments()) {
            if (!p.getAmount().equals(Money.zero())) {
                if (getPrevious) {
                    previous = p;
                    break;
                } else if (p.getPaymentId().equals(payment.getPaymentId())) {
                    getPrevious = true;
                } else {
                    next = p;
                }
            }
        }
        Date previousPaymentDate = (previous == null) ? null : previous.getPaymentDate();
        Date nextPaymentDate = (next == null) ? null : next.getPaymentDate();
        appAdjustActionForm.setPreviousPaymentDate(previousPaymentDate);
        appAdjustActionForm.setNextPaymentDate(nextPaymentDate);
        SessionUtils.setAttribute(Constants.ADJUSTED_AMOUNT, payment.getAmount().getAmount(), request);
        Short transferPaymentTypeId = legacyAcceptedPaymentTypeDao.getSavingsTransferId();
        if (payment.getPaymentType().getId().equals(transferPaymentTypeId)) {
            List<ListItem<Short>> paymentTypeList = this.accountServiceFacade.constructPaymentTypeListForLoanRepayment(userContext.getLocaleId());
            for (Iterator<ListItem<Short>> it = paymentTypeList.iterator(); it.hasNext(); ) {
                ListItem<Short> listItem = it.next();
                if (!listItem.getId().equals(transferPaymentTypeId)) {
                    it.remove();
                }
            }
            SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, paymentTypeList, request);
        } else {
            SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, this.accountServiceFacade.constructPaymentTypeListForLoanRepayment(userContext.getLocaleId()), request);
        }
    } else {
        SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, this.accountServiceFacade.constructPaymentTypeListForLoanRepayment(userContext.getLocaleId()), request);
        payment = accnt.getLastPmntToBeAdjusted();
        appAdjustActionForm.setPaymentId(null);
        SessionUtils.setAttribute(Constants.ADJUSTED_AMOUNT, accnt.getLastPmntAmntToBeAdjusted(), request);
    }
    if (accnt.isParentGroupLoanAccount()) {
        SessionUtils.setAttribute(Constants.TYPE_OF_GROUP_LOAN, "parentAcc", request);
    } else if (accnt.isGroupLoanAccountMember()) {
        appAdjustActionForm.setGroupLoanMember(Boolean.TRUE);
    }
    populateForm(appAdjustActionForm, payment);
    return mapping.findForward("loadadjustment_success");
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) UserContext(org.mifos.security.util.UserContext) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ListItem(org.mifos.application.servicefacade.ListItem) Date(java.util.Date) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with ListItem

use of org.mifos.application.servicefacade.ListItem in project head by mifos.

the class WebTierAccountServiceFacade method constructPaymentTypeListForLoanRepayment.

@Override
public List<ListItem<Short>> constructPaymentTypeListForLoanRepayment(Short localeId) {
    try {
        List<PaymentTypeEntity> paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.loan_repayment.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);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ListItem(org.mifos.application.servicefacade.ListItem) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 8 with ListItem

use of org.mifos.application.servicefacade.ListItem in project head by mifos.

the class BulkEntryActionStrutsTest method createDefaultCollectionSheetDto.

private CollectionSheetEntryFormDto createDefaultCollectionSheetDto() {
    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>();
    final Short reloadFormAutomatically = Constants.YES;
    final Short backDatedTransactionAllowed = Constants.NO;
    final Short centerHierarchyExists = Constants.YES;
    final Date meetingDate = new Date();
    return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed, meetingDate);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) ListItem(org.mifos.application.servicefacade.ListItem) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Date(java.util.Date) CollectionSheetEntryFormDto(org.mifos.application.servicefacade.CollectionSheetEntryFormDto)

Example 9 with ListItem

use of org.mifos.application.servicefacade.ListItem in project head by mifos.

the class LoanRepaymentController method retrievePaymentTypes.

//called by spring webflow
public Map<String, String> retrievePaymentTypes() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    List<ListItem<Short>> paymentTypes = this.accountServiceFacade.constructPaymentTypeListForLoanRepayment(user.getPreferredLocaleId());
    Map<String, String> result = new HashMap<String, String>();
    for (ListItem<Short> listItem : paymentTypes) {
        result.put(String.valueOf(listItem.getId()), listItem.getDisplayValue());
    }
    return result;
}
Also used : HashMap(java.util.HashMap) MifosUser(org.mifos.security.MifosUser) ListItem(org.mifos.application.servicefacade.ListItem)

Aggregations

ListItem (org.mifos.application.servicefacade.ListItem)9 ArrayList (java.util.ArrayList)6 Date (java.util.Date)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 CustomerDto (org.mifos.dto.domain.CustomerDto)3 AccountBO (org.mifos.accounts.business.AccountBO)2 ApplyAdjustmentActionForm (org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 CollectionSheetEntryFormDto (org.mifos.application.servicefacade.CollectionSheetEntryFormDto)2 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)2 PersonnelDto (org.mifos.dto.domain.PersonnelDto)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 ImportTransactionsActionForm (org.mifos.application.importexport.struts.actionforms.ImportTransactionsActionForm)1 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)1