Search in sources :

Example 6 with PaymentTypeDto

use of org.mifos.dto.screen.PaymentTypeDto 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)6 PaymentTypeDto (org.mifos.dto.screen.PaymentTypeDto)6 ArrayList (java.util.ArrayList)3 AcceptedPaymentType (org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType)3 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 LinkedHashMap (java.util.LinkedHashMap)1 TransactionTypeEntity (org.mifos.accounts.acceptedpaymenttype.business.TransactionTypeEntity)1 LegacyAcceptedPaymentTypeDao (org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao)1 TrxnTypes (org.mifos.application.util.helpers.TrxnTypes)1