use of org.mifos.dto.screen.PaymentTypeDto in project head by mifos.
the class AdminServiceFacadeWebTier method getAllPaymentTypes.
private List<PaymentTypeDto> getAllPaymentTypes(Short localeId) {
List<PaymentTypeDto> paymentTypeList = new ArrayList<PaymentTypeDto>();
PaymentTypeDto payment = null;
Short id = 0;
List<PaymentTypeEntity> paymentTypes = getMasterEntities(PaymentTypeEntity.class);
for (PaymentTypeEntity masterDataEntity : paymentTypes) {
PaymentTypeEntity paymentType = masterDataEntity;
id = paymentType.getId();
payment = new PaymentTypeDto(id, paymentType.getName());
paymentTypeList.add(payment);
}
return paymentTypeList;
}
use of org.mifos.dto.screen.PaymentTypeDto 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;
}
use of org.mifos.dto.screen.PaymentTypeDto 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);
}
}
use of org.mifos.dto.screen.PaymentTypeDto 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;
}
use of org.mifos.dto.screen.PaymentTypeDto 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);
}
}
}
Aggregations