Search in sources :

Example 1 with AcceptedPaymentTypeDto

use of org.mifos.dto.domain.AcceptedPaymentTypeDto in project head by mifos.

the class AcceptedPaymentTypesController method populateAcceptedPaymentTypesBean.

private AcceptedPaymentTypesBean populateAcceptedPaymentTypesBean(AcceptedPaymentTypeDto acceptedPaymentTypeDto) {
    Map<String, String> nonAcceptedFees = new LinkedHashMap<String, String>();
    Map<String, String> acceptedFees = new LinkedHashMap<String, String>();
    List<PaymentTypeDto> outFees = acceptedPaymentTypeDto.getOutFeeList();
    for (PaymentTypeDto paymentType : outFees) {
        acceptedFees.put(paymentType.getId().toString(), paymentType.getName());
    }
    List<PaymentTypeDto> inFees = acceptedPaymentTypeDto.getInFeeList();
    for (PaymentTypeDto paymentType : inFees) {
        nonAcceptedFees.put(paymentType.getId().toString(), paymentType.getName());
    }
    Map<String, String> nonAcceptedLoanDisbursements = new LinkedHashMap<String, String>();
    Map<String, String> acceptedLoanDisbursements = new LinkedHashMap<String, String>();
    List<PaymentTypeDto> outDisbursements = acceptedPaymentTypeDto.getOutDisbursementList();
    for (PaymentTypeDto paymentType : outDisbursements) {
        acceptedLoanDisbursements.put(paymentType.getId().toString(), paymentType.getName());
    }
    List<PaymentTypeDto> inDibursements = acceptedPaymentTypeDto.getInDisbursementList();
    for (PaymentTypeDto paymentType : inDibursements) {
        nonAcceptedLoanDisbursements.put(paymentType.getId().toString(), paymentType.getName());
    }
    Map<String, String> nonAcceptedLoanRepayments = new LinkedHashMap<String, String>();
    Map<String, String> acceptedLoanRepayments = new LinkedHashMap<String, String>();
    List<PaymentTypeDto> outRepayments = acceptedPaymentTypeDto.getOutRepaymentList();
    for (PaymentTypeDto paymentType : outRepayments) {
        acceptedLoanRepayments.put(paymentType.getId().toString(), paymentType.getName());
    }
    List<PaymentTypeDto> inRepayments = acceptedPaymentTypeDto.getInRepaymentList();
    for (PaymentTypeDto paymentType : inRepayments) {
        nonAcceptedLoanRepayments.put(paymentType.getId().toString(), paymentType.getName());
    }
    Map<String, String> nonAcceptedSavingWithdrawals = new LinkedHashMap<String, String>();
    Map<String, String> acceptedSavingWithdrawals = new LinkedHashMap<String, String>();
    List<PaymentTypeDto> outWithdrawals = acceptedPaymentTypeDto.getOutWithdrawalList();
    for (PaymentTypeDto paymentType : outWithdrawals) {
        acceptedSavingWithdrawals.put(paymentType.getId().toString(), paymentType.getName());
    }
    List<PaymentTypeDto> inWithdrawals = acceptedPaymentTypeDto.getInWithdrawalList();
    for (PaymentTypeDto paymentType : inWithdrawals) {
        nonAcceptedSavingWithdrawals.put(paymentType.getId().toString(), paymentType.getName());
    }
    Map<String, String> nonAcceptedSavingDeposits = new LinkedHashMap<String, String>();
    Map<String, String> acceptedSavingDeposits = new LinkedHashMap<String, String>();
    List<PaymentTypeDto> outDeposits = acceptedPaymentTypeDto.getOutDepositList();
    for (PaymentTypeDto paymentType : outDeposits) {
        acceptedSavingDeposits.put(paymentType.getId().toString(), paymentType.getName());
    }
    List<PaymentTypeDto> inDeposits = acceptedPaymentTypeDto.getInDepositList();
    for (PaymentTypeDto paymentType : inDeposits) {
        nonAcceptedSavingDeposits.put(paymentType.getId().toString(), paymentType.getName());
    }
    AcceptedPaymentTypesBean paymentTypes = new AcceptedPaymentTypesBean();
    paymentTypes.setNonAcceptedFeePaymentTypes(nonAcceptedFees);
    paymentTypes.setAcceptedFeePaymentTypes(acceptedFees);
    paymentTypes.setNonAcceptedLoanDisbursementPaymentTypes(nonAcceptedLoanDisbursements);
    paymentTypes.setAcceptedLoanDisbursementPaymentTypes(acceptedLoanDisbursements);
    paymentTypes.setNonAcceptedLoanRepaymentPaymentTypes(nonAcceptedLoanRepayments);
    paymentTypes.setAcceptedLoanRepaymentPaymentTypes(acceptedLoanRepayments);
    paymentTypes.setNonAcceptedSavingWithdrawalPaymentTypes(nonAcceptedSavingWithdrawals);
    paymentTypes.setAcceptedSavingWithdrawalPaymentTypes(acceptedSavingWithdrawals);
    paymentTypes.setNonAcceptedSavingDepositsPaymentTypes(nonAcceptedSavingDeposits);
    paymentTypes.setAcceptedSavingDepositsPaymentTypes(acceptedSavingDeposits);
    return paymentTypes;
}
Also used : PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with AcceptedPaymentTypeDto

use of org.mifos.dto.domain.AcceptedPaymentTypeDto in project head by mifos.

the class AcceptedPaymentTypesController method showPopulatedForm.

@RequestMapping(method = RequestMethod.GET)
@ModelAttribute("acceptedPaymentTypesBean")
public AcceptedPaymentTypesBean showPopulatedForm() {
    AcceptedPaymentTypeDto acceptedPaymentTypeDto = adminServiceFacade.retrieveAcceptedPaymentTypes();
    AcceptedPaymentTypesBean paymentTypes = populateAcceptedPaymentTypesBean(acceptedPaymentTypeDto);
    return paymentTypes;
}
Also used : AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with AcceptedPaymentTypeDto

use of org.mifos.dto.domain.AcceptedPaymentTypeDto in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveAcceptedPaymentTypes.

@Override
public AcceptedPaymentTypeDto retrieveAcceptedPaymentTypes() {
    List<PaymentTypeDto> payments = getAllPaymentTypes(null);
    AcceptedPaymentTypeDto dto = new AcceptedPaymentTypeDto();
    for (int i = 0; i < TrxnTypes.values().length; i++) {
        setPaymentTypesForATransaction(payments, TrxnTypes.values()[i], legacyAcceptedPaymentTypeDao, dto);
    }
    return dto;
}
Also used : AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto)

Example 4 with AcceptedPaymentTypeDto

use of org.mifos.dto.domain.AcceptedPaymentTypeDto in project head by mifos.

the class AdminServiceFacadeWebTier method updateAcceptedPaymentTypes.

@Override
public void updateAcceptedPaymentTypes(String[] chosenAcceptedFees, String[] chosenAcceptedLoanDisbursements, String[] chosenAcceptedLoanRepayments, String[] chosenAcceptedSavingDeposits, String[] chosenAcceptedSavingWithdrawals) {
    LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
    List<AcceptedPaymentType> deletedPaymentTypeList = new ArrayList<AcceptedPaymentType>();
    List<AcceptedPaymentType> addedPaymentTypeList = new ArrayList<AcceptedPaymentType>();
    List<PaymentTypeDto> allPayments = getAllPaymentTypes(null);
    AcceptedPaymentTypeDto oldAcceptedPaymentTypeDto = retrieveAcceptedPaymentTypes();
    for (int i = 0; i < TrxnTypes.values().length; i++) {
        TrxnTypes transactionType = TrxnTypes.values()[i];
        List<PaymentTypeDto> selectedPaymentTypes = new ArrayList<PaymentTypeDto>();
        List<PaymentTypeDto> outList = null;
        if (transactionType == TrxnTypes.fee) {
            selectedPaymentTypes = populateSelectedPayments(chosenAcceptedFees, allPayments);
            outList = oldAcceptedPaymentTypeDto.getOutFeeList();
        } else if (transactionType == TrxnTypes.loan_disbursement) {
            selectedPaymentTypes = populateSelectedPayments(chosenAcceptedLoanDisbursements, allPayments);
            outList = oldAcceptedPaymentTypeDto.getOutDisbursementList();
        } else if (transactionType == TrxnTypes.loan_repayment) {
            selectedPaymentTypes = populateSelectedPayments(chosenAcceptedLoanRepayments, allPayments);
            outList = oldAcceptedPaymentTypeDto.getOutRepaymentList();
        } else if (transactionType == TrxnTypes.savings_deposit) {
            selectedPaymentTypes = populateSelectedPayments(chosenAcceptedSavingDeposits, allPayments);
            outList = oldAcceptedPaymentTypeDto.getOutDepositList();
        } else if (transactionType == TrxnTypes.savings_withdrawal) {
            selectedPaymentTypes = populateSelectedPayments(chosenAcceptedSavingWithdrawals, allPayments);
            outList = oldAcceptedPaymentTypeDto.getOutWithdrawalList();
        } else {
            throw new MifosRuntimeException("Unknown account action for accepted payment type " + transactionType.toString());
        }
        process(selectedPaymentTypes, outList, deletedPaymentTypeList, addedPaymentTypeList, persistence, transactionType);
    }
    try {
        if (addedPaymentTypeList.size() > 0) {
            persistence.addAcceptedPaymentTypes(addedPaymentTypeList);
            StaticHibernateUtil.commitTransaction();
        }
        if (deletedPaymentTypeList.size() > 0) {
            persistence.deleteAcceptedPaymentTypes(deletedPaymentTypeList);
            StaticHibernateUtil.commitTransaction();
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) TrxnTypes(org.mifos.application.util.helpers.TrxnTypes) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto) LegacyAcceptedPaymentTypeDao(org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with AcceptedPaymentTypeDto

use of org.mifos.dto.domain.AcceptedPaymentTypeDto in project head by mifos.

the class AdminServiceFacadeWebTier method setPaymentTypesForATransaction.

private void setPaymentTypesForATransaction(List<PaymentTypeDto> payments, TrxnTypes transactionType, LegacyAcceptedPaymentTypeDao paymentTypePersistence, AcceptedPaymentTypeDto dto) {
    try {
        Short transactionId = transactionType.getValue();
        List<AcceptedPaymentType> paymentTypeList = paymentTypePersistence.getAcceptedPaymentTypesForATransaction(transactionId, TrxnTypes.loan_repayment);
        List<PaymentTypeDto> inList = new ArrayList<PaymentTypeDto>(payments);
        List<PaymentTypeDto> outList = new ArrayList<PaymentTypeDto>();
        if (transactionType != TrxnTypes.fee && transactionType != TrxnTypes.loan_repayment) {
            RemoveFromInList(inList, legacyAcceptedPaymentTypeDao.getSavingsTransferId());
        }
        PaymentTypeDto data = null;
        for (AcceptedPaymentType paymentType : paymentTypeList) {
            Short paymentTypeId = paymentType.getPaymentTypeEntity().getId();
            data = new PaymentTypeDto(paymentTypeId, paymentType.getPaymentTypeEntity().getName(), paymentType.getAcceptedPaymentTypeId());
            outList.add(data);
            RemoveFromInList(inList, paymentTypeId);
        }
        if (transactionType == TrxnTypes.loan_repayment) {
            dto.setInRepaymentList(inList);
            dto.setOutRepaymentList(outList);
        } else if (transactionType == TrxnTypes.fee) {
            dto.setInFeeList(inList);
            dto.setOutFeeList(outList);
        } else if (transactionType == TrxnTypes.loan_disbursement) {
            dto.setInDisbursementList(inList);
            dto.setOutDisbursementList(outList);
        } else if (transactionType == TrxnTypes.savings_deposit) {
            dto.setInDepositList(inList);
            dto.setOutDepositList(outList);
        } else if (transactionType == TrxnTypes.savings_withdrawal) {
            dto.setInWithdrawalList(inList);
            dto.setOutWithdrawalList(outList);
        } else {
            throw new MifosRuntimeException("Unknown account action for accepted payment type " + transactionType.toString());
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

AcceptedPaymentTypeDto (org.mifos.dto.domain.AcceptedPaymentTypeDto)5 PaymentTypeDto (org.mifos.dto.screen.PaymentTypeDto)4 ArrayList (java.util.ArrayList)2 AcceptedPaymentType (org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 LinkedHashMap (java.util.LinkedHashMap)1 LegacyAcceptedPaymentTypeDao (org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao)1 TrxnTypes (org.mifos.application.util.helpers.TrxnTypes)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1