Search in sources :

Example 1 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity 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;
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) ArrayList(java.util.ArrayList) AcceptedPaymentTypeDto(org.mifos.dto.domain.AcceptedPaymentTypeDto) PaymentTypeDto(org.mifos.dto.screen.PaymentTypeDto)

Example 2 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.

@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
    final Short branchId = userContext.getBranchId();
    final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
    List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
    List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
    List<CustomerDto> customerList = new ArrayList<CustomerDto>();
    List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
    Short reloadFormAutomatically = Constants.YES;
    final Short backDatedTransactionAllowed = Constants.NO;
    try {
        final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
        paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
        activeBranches = officePersistence.getActiveOffices(branchId);
        if (activeBranches.size() == 1) {
            loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
            if (loanOfficerList.size() == 1) {
                Short customerLevel;
                if (centerHierarchyExists.equals(Constants.YES)) {
                    customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
                } else {
                    customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
                }
                customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
                if (customerList.size() == 1) {
                    reloadFormAutomatically = Constants.YES;
                }
                reloadFormAutomatically = Constants.NO;
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class SavingsDepositWithdrawalAction method reLoad.

@TransactionDemarcate(joinToken = true)
public ActionForward reLoad(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    SavingsDepositWithdrawalActionForm actionForm = (SavingsDepositWithdrawalActionForm) form;
    SavingsBO savingsInSession = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    if (actionForm.getTrxnTypeId() != null && actionForm.getTrxnTypeId() != Constants.EMPTY_STRING) {
        Long savingsId = savingsInSession.getAccountId().longValue();
        SavingsBO savings = this.savingsDao.findById(savingsId);
        Integer customerId = savings.getCustomer().getCustomerId();
        if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
            customerId = Integer.valueOf(actionForm.getCustomerId());
        }
        DepositWithdrawalReferenceDto depositWithdrawalReferenceDto = this.savingsServiceFacade.retrieveDepositWithdrawalReferenceData(savingsId, customerId);
        Short trxnTypeId = Short.valueOf(actionForm.getTrxnTypeId());
        // added for defect 1587 [start]
        LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
        if (trxnTypeId.equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue())) {
            if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
                actionForm.setAmount(depositWithdrawalReferenceDto.getDepositDue());
            }
            List<PaymentTypeEntity> depositPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.savings_deposit.getValue());
            SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, depositPaymentTypes, request);
        } else {
            actionForm.setAmount(depositWithdrawalReferenceDto.getWithdrawalDue());
            List<PaymentTypeEntity> withdrawalPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
            SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, withdrawalPaymentTypes, request);
        }
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) UserContext(org.mifos.security.util.UserContext) SavingsDepositWithdrawalActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsDepositWithdrawalActionForm) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LegacyAcceptedPaymentTypeDao(org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao) DepositWithdrawalReferenceDto(org.mifos.dto.screen.DepositWithdrawalReferenceDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class WebTierAccountServiceFacade method constructPaymentTypeList.

private List<ListItem<Short>> constructPaymentTypeList(String paymentType, Short localeId) {
    try {
        List<PaymentTypeEntity> paymentTypeList = null;
        if (paymentType != null && !Constants.EMPTY_STRING.equals(paymentType.trim())) {
            if (isLoanPayment(paymentType)) {
                paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.loan_repayment.getValue());
            } else {
                paymentTypeList = acceptedPaymentTypePersistence.getAcceptedPaymentTypesForATransaction(localeId, TrxnTypes.fee.getValue());
            }
        }
        List<ListItem<Short>> listItems = new ArrayList<ListItem<Short>>();
        for (PaymentTypeEntity paymentTypeEntity : paymentTypeList) {
            listItems.add(new ListItem<Short>(paymentTypeEntity.getId(), paymentTypeEntity.getName()));
        }
        return listItems;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ListItem(org.mifos.application.servicefacade.ListItem) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with PaymentTypeEntity

use of org.mifos.application.master.business.PaymentTypeEntity in project head by mifos.

the class SavingsServiceFacadeWebTier method closeSavingsAccount.

@Override
public void closeSavingsAccount(Long savingsId, String notes, SavingsWithdrawalDto closeAccountDto) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
    savingsAccount.updateDetails(userContext);
    PersonnelBO createdBy = this.personnelDao.findPersonnelById(userContext.getId());
    LocalDate closureDate = closeAccountDto.getDateOfWithdrawal();
    // Assumption that all previous interest postings occurred correctly
    InterestScheduledEvent postingSchedule = savingsInterestScheduledEventFactory.createScheduledEventFrom(savingsAccount.getInterestPostingMeeting());
    LocalDate nextPostingDate = new LocalDate(savingsAccount.getNextIntPostDate());
    LocalDate startOfPostingPeriod = postingSchedule.findFirstDateOfPeriodForMatchingDate(nextPostingDate);
    CalendarPeriod postingPeriodAtClosure;
    if (startOfPostingPeriod.isAfter(closureDate)) {
        postingPeriodAtClosure = new CalendarPeriod(closureDate, closureDate);
    } else {
        postingPeriodAtClosure = new CalendarPeriod(startOfPostingPeriod, closureDate);
    }
    List<EndOfDayDetail> allEndOfDayDetailsForAccount = savingsDao.retrieveAllEndOfDayDetailsFor(savingsAccount.getCurrency(), Long.valueOf(savingsId));
    InterestPostingPeriodResult postingPeriodAtClosureResult = determinePostingPeriodResult(postingPeriodAtClosure, savingsAccount, allEndOfDayDetailsForAccount);
    savingsAccount.postInterest(postingSchedule, postingPeriodAtClosureResult, createdBy);
    AccountNotesEntity notesEntity = new AccountNotesEntity(new DateTimeService().getCurrentJavaSqlDate(), notes, createdBy, savingsAccount);
    try {
        CustomerBO customer = savingsAccount.getCustomer();
        if (closeAccountDto.getCustomerId() != null) {
            List<CustomerBO> clientList = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
            for (CustomerBO client : clientList) {
                if (closeAccountDto.getCustomerId().intValue() == client.getCustomerId().intValue()) {
                    customer = client;
                    break;
                }
            }
        }
        Money amount = new Money(savingsAccount.getCurrency(), closeAccountDto.getAmount().toString());
        PaymentTypeEntity paymentType = new PaymentTypeEntity(closeAccountDto.getModeOfPayment().shortValue());
        Date receiptDate = null;
        if (closeAccountDto.getDateOfReceipt() != null) {
            receiptDate = closeAccountDto.getDateOfReceipt().toDateMidnight().toDate();
        }
        AccountPaymentEntity closeAccount = new AccountPaymentEntity(savingsAccount, amount, closeAccountDto.getReceiptId(), receiptDate, paymentType, closeAccountDto.getDateOfWithdrawal().toDateMidnight().toDate());
        this.transactionHelper.startTransaction();
        this.transactionHelper.beginAuditLoggingFor(savingsAccount);
        savingsAccount.closeAccount(closeAccount, notesEntity, customer, createdBy);
        this.savingsDao.save(savingsAccount);
        this.transactionHelper.commitTransaction();
    } catch (BusinessRuleException e) {
        this.transactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getMessageKey(), e);
    } catch (PersistenceException e) {
        this.transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        this.transactionHelper.closeSession();
    }
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) UserContext(org.mifos.security.util.UserContext) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) Money(org.mifos.framework.util.helpers.Money) BusinessRuleException(org.mifos.service.BusinessRuleException) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) EndOfDayDetail(org.mifos.accounts.savings.interest.EndOfDayDetail) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CalendarPeriod(org.mifos.accounts.savings.interest.CalendarPeriod) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) DateTimeService(org.mifos.framework.util.DateTimeService) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)40 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)24 LocalDate (org.joda.time.LocalDate)16 Money (org.mifos.framework.util.helpers.Money)16 Date (java.util.Date)15 ArrayList (java.util.ArrayList)13 UserContext (org.mifos.security.util.UserContext)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)10 Date (java.sql.Date)9 Test (org.junit.Test)9 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 PersistenceException (org.mifos.framework.exceptions.PersistenceException)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 CustomerBO (org.mifos.customers.business.CustomerBO)6 DateTime (org.joda.time.DateTime)4 AcceptedPaymentType (org.mifos.accounts.acceptedpaymenttype.business.AcceptedPaymentType)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 BigDecimal (java.math.BigDecimal)3 LegacyAcceptedPaymentTypeDao (org.mifos.accounts.acceptedpaymenttype.persistence.LegacyAcceptedPaymentTypeDao)3