Search in sources :

Example 1 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsBO method createNewAccountPaymentWithAdjustedAmount.

private Set<AccountTrxnEntity> createNewAccountPaymentWithAdjustedAmount(Money amountAdjustedTo, PersonnelBO updatedBy, AccountPaymentEntity payment, AccountActionTypes savingsTransactionType, Date adjustedOn, LocalDate adjustmentDate) {
    AccountPaymentEntity newAccountPayment = new AccountPaymentEntity(this, amountAdjustedTo, payment.getReceiptNumber(), payment.getReceiptDate(), payment.getPaymentType(), adjustmentDate.toDateMidnight().toDate());
    newAccountPayment.setCreatedByUser(updatedBy);
    newAccountPayment.setAmount(amountAdjustedTo);
    Set<AccountTrxnEntity> accountTrxns = new HashSet<AccountTrxnEntity>();
    if (isMandatory() && savingsTransactionType.equals(AccountActionTypes.SAVINGS_DEPOSIT)) {
        accountTrxns = createDepositTrxnsForMandatoryAccountsAfterAdjust(newAccountPayment, payment, amountAdjustedTo, adjustmentDate, updatedBy);
    } else if (isVoluntary() && savingsTransactionType.equals(AccountActionTypes.SAVINGS_DEPOSIT)) {
        accountTrxns = createDepositTrxnsForVolAccountsAfterAdjust(newAccountPayment, payment, amountAdjustedTo, adjustmentDate, updatedBy);
    } else {
        accountTrxns = createWithdrawalTrxnsAfterAdjust(newAccountPayment, payment, amountAdjustedTo, adjustmentDate, updatedBy);
    }
    for (AccountTrxnEntity accountTrxn : accountTrxns) {
        newAccountPayment.addAccountTrxn(accountTrxn);
    }
    this.addAccountPayment(newAccountPayment);
    AccountActionEntity depositOrWithdrawalTransactionType = new AccountActionEntity(savingsTransactionType);
    SavingsActivityEntity depositOrWithdrawalActivity = new SavingsActivityEntity(updatedBy, depositOrWithdrawalTransactionType, amountAdjustedTo, this.savingsBalance, adjustedOn, this);
    this.savingsActivityDetails.add(depositOrWithdrawalActivity);
    return newAccountPayment.getAccountTrxns();
}
Also used : AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsTransactionActivityHelperImpl method createSavingsActivityForWithdrawal.

@Override
public SavingsActivityEntity createSavingsActivityForWithdrawal(final AccountPaymentEntity payment, final Money savingsBalance, final SavingsBO savingsBO) {
    final AccountActionEntity savingsAccountWithdrawalAction = new AccountActionEntity(AccountActionTypes.SAVINGS_WITHDRAWAL);
    final SavingsActivityEntity savingsActivity = new SavingsActivityEntity(payment.getCreatedByUser(), savingsAccountWithdrawalAction, payment.getAmount(), savingsBalance, payment.getPaymentDate(), savingsBO);
    return savingsActivity;
}
Also used : AccountActionEntity(org.mifos.accounts.business.AccountActionEntity)

Example 3 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsTrxnDetailEntity method savingsWithdrawalAdjustment.

public static SavingsTrxnDetailEntity savingsWithdrawalAdjustment(AccountPaymentEntity accountPayment, CustomerBO customer, Money balAfterAdjust, Money negate, PersonnelBO loggedInUser, Date dueDate, Date actionDate, Date transactionCreatedDate, String adjustmentComment, SavingsTrxnDetailEntity relatedTrxn) {
    AccountActionEntity applicationTransactionType = new AccountActionEntity(AccountActionTypes.SAVINGS_ADJUSTMENT);
    AccountActionEntity monetaryTransactionType = new AccountActionEntity(AccountActionTypes.SAVINGS_WITHDRAWAL);
    Short installmentIdNotNeeded = null;
    SavingsTrxnDetailEntity adjustment = new SavingsTrxnDetailEntity(accountPayment, customer, applicationTransactionType, monetaryTransactionType, negate, balAfterAdjust, loggedInUser, dueDate, actionDate, installmentIdNotNeeded, adjustmentComment, transactionCreatedDate, relatedTrxn);
    return adjustment;
}
Also used : AccountActionEntity(org.mifos.accounts.business.AccountActionEntity)

Example 4 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveDepositWithdrawalReferenceData.

@Override
public DepositWithdrawalReferenceDto retrieveDepositWithdrawalReferenceData(Long savingsId, Integer customerId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        SavingsBO savingsAccount = savingsDao.findById(savingsId);
        String depositDue = savingsAccount.getTotalPaymentDue(customerId).toString();
        String withdrawalDue = "0";
        List<ListElement> clients = new ArrayList<ListElement>();
        if (savingsAccount.isGroupModelWithIndividualAccountability()) {
            List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
            for (CustomerBO client : activeAndOnHoldClients) {
                clients.add(new ListElement(client.getCustomerId(), client.getDisplayName()));
            }
        }
        List<AccountActionEntity> trxnTypes = new ArrayList<AccountActionEntity>();
        trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_DEPOSIT.getValue(), userContext.getLocaleId()));
        trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), userContext.getLocaleId()));
        List<ListElement> transactionTypes = new ArrayList<ListElement>();
        for (AccountActionEntity accountActionEntity : trxnTypes) {
            LookUpValueEntity lookupValue = accountActionEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            transactionTypes.add(new ListElement(accountActionEntity.getId().intValue(), messageText));
        }
        List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
        List<ListElement> withdrawalPaymentTypes = new ArrayList<ListElement>();
        List<PaymentTypeEntity> withdrawalPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
        for (PaymentTypeEntity paymentTypeEntity : withdrawalPaymentEntityTypes) {
            LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
            String messageText = lookupValue.getMessageText();
            if (StringUtils.isBlank(messageText)) {
                messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
            }
            withdrawalPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
        }
        boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
        LocalDate defaultTransactionDate = new LocalDate();
        return new DepositWithdrawalReferenceDto(transactionTypes, depositPaymentTypes, withdrawalPaymentTypes, clients, backDatedTransactionsAllowed, defaultTransactionDate, depositDue, withdrawalDue);
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) LocalDate(org.joda.time.LocalDate) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ListElement(org.mifos.dto.screen.ListElement) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) DepositWithdrawalReferenceDto(org.mifos.dto.screen.DepositWithdrawalReferenceDto) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with AccountActionEntity

use of org.mifos.accounts.business.AccountActionEntity in project head by mifos.

the class BirtAdminDocumentUploadAction method upload.

@SuppressWarnings("unchecked")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
    FormFile formFile = uploadForm.getFile();
    uploadFile(formFile);
    AdminDocumentBO admindocBO = createOrUpdateAdminDocument(uploadForm.getAdminiDocumentTitle(), Short.valueOf("1"), formFile.getFileName());
    AdminDocAccStateMixBO admindocaccstatemixBO = new AdminDocAccStateMixBO();
    if (Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
        List<AccountStateEntity> masterList = (List<AccountStateEntity>) SessionUtils.getAttribute("SelectedStatus", request);
        for (AccountStateEntity acc : masterList) {
            admindocaccstatemixBO = new AdminDocAccStateMixBO();
            admindocaccstatemixBO.setAccountStateID(acc);
            admindocaccstatemixBO.setAdminDocumentID(admindocBO);
            legacyAdminDocAccStateMixDao.createOrUpdate(admindocaccstatemixBO);
        }
    } else {
        List<AccountActionEntity> masterList = (List<AccountActionEntity>) SessionUtils.getAttribute("SelectedStatus", request);
        for (AccountActionEntity accountActionEntity : masterList) {
            AdminDocAccActionMixBO adminDocAccActionMixBO = new AdminDocAccActionMixBO();
            adminDocAccActionMixBO.setAccountAction(accountActionEntity);
            adminDocAccActionMixBO.setAdminDocument(admindocBO);
            legacyAdminDocumentDao.createOrUpdate(adminDocAccActionMixBO);
        }
    }
    request.setAttribute("report", admindocBO);
    return getViewBirtAdminDocumentPage(mapping, form, request, response);
}
Also used : AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) ArrayList(java.util.ArrayList) List(java.util.List) AdminDocAccActionMixBO(org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) FormFile(org.apache.struts.upload.FormFile) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)18 ArrayList (java.util.ArrayList)5 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)5 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 Test (org.junit.Test)4 CustomerBO (org.mifos.customers.business.CustomerBO)4 List (java.util.List)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 AccountActionTypes (org.mifos.accounts.util.helpers.AccountActionTypes)3 UserContext (org.mifos.security.util.UserContext)3 FormFile (org.apache.struts.upload.FormFile)2 LocalDate (org.joda.time.LocalDate)2 AccountPaymentEntityBuilder (org.mifos.accounts.business.AccountPaymentEntityBuilder)2 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)2 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)2 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2