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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
Aggregations