Search in sources :

Example 6 with AcceptedPaymentType

use of org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType in project head by mifos.

the class AcceptedPaymentTypePersistenceIntegrationTest method testAddDeleteAcceptedPaymentTypes.

@Test
public void testAddDeleteAcceptedPaymentTypes() throws Exception {
    testGetAcceptedPaymentTypes();
    List<AcceptedPaymentType> addAcceptedPaymentTypes = new ArrayList<AcceptedPaymentType>();
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        addAcceptedPaymentTypeForATransaction(addAcceptedPaymentTypes, transactionType);
    }
    if (addAcceptedPaymentTypes.size() > 0) {
        legacyAcceptedPaymentTypeDao.addAcceptedPaymentTypes(addAcceptedPaymentTypes);
    }
    // verify results
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        List<AcceptedPaymentType> acceptedPaymentTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(transactionType.getValue(), TrxnTypes.loan_repayment);
        List<AcceptedPaymentType> savedAcceptedPaymentTypes = GetSavePaymentTypes(transactionType);
        verify(savedAcceptedPaymentTypes, acceptedPaymentTypes);
    }
    // delete the added records to get back to before tests
    List<AcceptedPaymentType> deleteAcceptedPaymentTypes = new ArrayList<AcceptedPaymentType>();
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        deleteAcceptedPaymentTypeForATransaction(deleteAcceptedPaymentTypes, transactionType);
    }
    if (deleteAcceptedPaymentTypes.size() > 0) {
        legacyAcceptedPaymentTypeDao.deleteAcceptedPaymentTypes(deleteAcceptedPaymentTypes);
    }
    // verify results
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        List<AcceptedPaymentType> acceptedPaymentTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(transactionType.getValue(), TrxnTypes.loan_repayment);
        List<AcceptedPaymentType> savedAcceptedPaymentTypes = GetBeforeTestPaymentTypes(transactionType);
        verify(savedAcceptedPaymentTypes, acceptedPaymentTypes);
    }
}
Also used : AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) TrxnTypes(org.mifos.application.util.helpers.TrxnTypes) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with AcceptedPaymentType

use of org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType in project head by mifos.

the class AcceptedPaymentTypePersistenceIntegrationTest method testRetrieveAcceptedPaymentTypes.

@Test
public void testRetrieveAcceptedPaymentTypes() throws Exception {
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        Short transactionId = transactionType.getValue();
        List<AcceptedPaymentType> acceptedPaymentTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(transactionId, TrxnTypes.loan_repayment);
        List<PaymentTypeEntity> paymentTypeEntities = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(DEFAULT_LOCALE_ID, transactionId);
        compare(paymentTypeEntities, acceptedPaymentTypes);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) TrxnTypes(org.mifos.application.util.helpers.TrxnTypes) Test(org.junit.Test)

Example 8 with AcceptedPaymentType

use of org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType in project head by mifos.

the class AdminServiceFacadeWebTier method process.

private void process(List<PaymentTypeDto> selectedPaymentTypes, List<PaymentTypeDto> outList, List<AcceptedPaymentType> deletedPaymentTypeList, List<AcceptedPaymentType> addedPaymentTypeList, LegacyAcceptedPaymentTypeDao persistence, TrxnTypes transactionType) {
    AcceptedPaymentType acceptedPaymentType = null;
    if ((outList != null) && (outList.size() > 0)) {
        for (PaymentTypeDto paymentType : outList) {
            if (findDelete(paymentType, selectedPaymentTypes)) {
                acceptedPaymentType = persistence.getAcceptedPaymentType(paymentType.getAcceptedPaymentTypeId());
                deletedPaymentTypeList.add(acceptedPaymentType);
            }
        }
    }
    for (PaymentTypeDto selectedPaymentType : selectedPaymentTypes) {
        Short paymentTypeId = selectedPaymentType.getId();
        if (findNew(paymentTypeId, outList)) {
            acceptedPaymentType = new AcceptedPaymentType();
            PaymentTypeEntity paymentTypeEntity = new PaymentTypeEntity(paymentTypeId);
            acceptedPaymentType.setPaymentTypeEntity(paymentTypeEntity);
            TransactionTypeEntity transactionEntity = new TransactionTypeEntity();
            transactionEntity.setTransactionId(transactionType.getValue());
            acceptedPaymentType.setTransactionTypeEntity(transactionEntity);
            addedPaymentTypeList.add(acceptedPaymentType);
        }
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto) TransactionTypeEntity(org.mifos.accounts.acceptedpaymenttype.business.TransactionTypeEntity)

Example 9 with AcceptedPaymentType

use of org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType 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

AcceptedPaymentType (org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType)9 ArrayList (java.util.ArrayList)5 TrxnTypes (org.mifos.application.util.helpers.TrxnTypes)5 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)4 Test (org.junit.Test)3 AcceptedPaymentTypeDto (org.mifos.dto.domain.AcceptedPaymentTypeDto)3 PaymentTypeDto (org.mifos.dto.screen.PaymentTypeDto)3 TransactionTypeEntity (org.mifos.accounts.acceptedpaymenttype.business.TransactionTypeEntity)2 TransactionAcceptedPaymentTypes (org.mifos.accounts.acceptedpaymenttype.persistence.helper.TransactionAcceptedPaymentTypes)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 HashMap (java.util.HashMap)1 LegacyAcceptedPaymentTypeDao (org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao)1 PaymentTypes (org.mifos.application.master.util.helpers.PaymentTypes)1