Search in sources :

Example 1 with TrxnTypes

use of org.mifos.application.util.helpers.TrxnTypes 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 2 with TrxnTypes

use of org.mifos.application.util.helpers.TrxnTypes in project head by mifos.

the class AcceptedPaymentTypePersistenceIntegrationTest method addAcceptedPaymentTypeForATransaction.

private void addAcceptedPaymentTypeForATransaction(List<AcceptedPaymentType> addAcceptedPaymentTypes, TrxnTypes transactionType) throws Exception {
    for (TransactionAcceptedPaymentTypes transactionAcceptedPaymentTypes : currentAcceptedPaymentTypes) {
        TrxnTypes transType = transactionAcceptedPaymentTypes.getTransactionType();
        if (transType.equals(transactionType)) {
            List<AcceptedPaymentType> paymentTypes = GetSavePaymentTypes(transType);
            List<AcceptedPaymentType> acceptedPaymentTypes = transactionAcceptedPaymentTypes.getAcceptedPaymentTypes();
            if ((acceptedPaymentTypes != null) && (acceptedPaymentTypes.size() > 0)) {
                for (PaymentTypes paymentType : PaymentTypes.values()) {
                    if (Find(paymentType, acceptedPaymentTypes) == false) {
                        AcceptedPaymentType acceptedPaymentType = new AcceptedPaymentType();
                        Short paymentTypeId = paymentType.getValue();
                        PaymentTypeEntity paymentTypeEntity = new PaymentTypeEntity(paymentTypeId);
                        acceptedPaymentType.setPaymentTypeEntity(paymentTypeEntity);
                        TransactionTypeEntity transactionEntity = new TransactionTypeEntity();
                        transactionEntity.setTransactionId(transType.getValue());
                        acceptedPaymentType.setTransactionTypeEntity(transactionEntity);
                        addAcceptedPaymentTypes.add(acceptedPaymentType);
                        paymentTypes.add(acceptedPaymentType);
                    }
                }
            }
        }
    }
}
Also used : PaymentTypes(org.mifos.application.master.util.helpers.PaymentTypes) TransactionAcceptedPaymentTypes(org.mifos.accounts.acceptedpaymenttype.persistence.helper.TransactionAcceptedPaymentTypes) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) TransactionAcceptedPaymentTypes(org.mifos.accounts.acceptedpaymenttype.persistence.helper.TransactionAcceptedPaymentTypes) TrxnTypes(org.mifos.application.util.helpers.TrxnTypes) TransactionTypeEntity(org.mifos.accounts.acceptedpaymenttype.business.TransactionTypeEntity)

Example 3 with TrxnTypes

use of org.mifos.application.util.helpers.TrxnTypes in project head by mifos.

the class AcceptedPaymentTypePersistenceIntegrationTest method testGetAcceptedPaymentTypes.

@Test
public void testGetAcceptedPaymentTypes() throws Exception {
    // get all accepted payment types and store in
    // currentAcceptedPaymentTypes
    currentAcceptedPaymentTypes = new ArrayList<TransactionAcceptedPaymentTypes>();
    allAcceptedPaymentTypes = new ArrayList<TransactionAcceptedPaymentTypes>();
    for (TrxnTypes transactionType : TrxnTypes.values()) {
        List<AcceptedPaymentType> acceptedPaymentTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(transactionType.getValue(), TrxnTypes.loan_repayment);
        TransactionAcceptedPaymentTypes transactionAcceptedPaymentTypes = new TransactionAcceptedPaymentTypes();
        transactionAcceptedPaymentTypes.setAcceptedPaymentTypes(acceptedPaymentTypes);
        transactionAcceptedPaymentTypes.setTransactionType(transactionType);
        currentAcceptedPaymentTypes.add(transactionAcceptedPaymentTypes);
        TransactionAcceptedPaymentTypes transactionAcceptedPaymentTypes2 = new TransactionAcceptedPaymentTypes();
        List<AcceptedPaymentType> acceptedPaymentTypes2 = new ArrayList<AcceptedPaymentType>(acceptedPaymentTypes);
        transactionAcceptedPaymentTypes2.setAcceptedPaymentTypes(acceptedPaymentTypes2);
        transactionAcceptedPaymentTypes2.setTransactionType(transactionType);
        allAcceptedPaymentTypes.add(transactionAcceptedPaymentTypes2);
    }
}
Also used : AcceptedPaymentType(org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType) TransactionAcceptedPaymentTypes(org.mifos.accounts.acceptedpaymenttype.persistence.helper.TransactionAcceptedPaymentTypes) TrxnTypes(org.mifos.application.util.helpers.TrxnTypes) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with TrxnTypes

use of org.mifos.application.util.helpers.TrxnTypes 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 5 with TrxnTypes

use of org.mifos.application.util.helpers.TrxnTypes 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)

Aggregations

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