Search in sources :

Example 26 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class SavingsAction method update.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In SavingsAction::update()");
    SavingsActionForm actionForm = (SavingsActionForm) form;
    SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Long savingsId = savings.getAccountId().longValue();
    savings = this.savingsDao.findById(savingsId);
    Integer version = savings.getVersionNo();
    checkVersionMismatch(version, savings.getVersionNo());
    this.savingsServiceFacade.updateSavingsAccountDetails(savingsId, actionForm.getRecommendedAmount(), actionForm.getAccountCustomFieldSet());
    request.setAttribute(SavingsConstants.GLOBALACCOUNTNUM, savings.getGlobalAccountNum());
    logger.info("In SavingsAction::update(), Savings object updated successfully");
    doCleanUp(actionForm, request);
    return mapping.findForward("update_success");
}
Also used : SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 27 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class SavingsApplyAdjustmentAction method previous.

@TransactionDemarcate(joinToken = true)
public ActionForward previous(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    if (savings != null) {
        savings = this.savingsDao.findById(savings.getAccountId());
        Hibernate.initialize(savings.findMostRecentPaymentByPaymentDate().getAccountTrxns());
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
    }
    return mapping.findForward("previous_success");
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 28 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class SavingsApplyAdjustmentAction method adjustLastUserAction.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward adjustLastUserAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    request.setAttribute("method", "adjustLastUserAction");
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Integer accountId = savings.getAccountId();
    Integer versionNum = savings.getVersionNo();
    savings = savingsDao.findById(accountId);
    // NOTE: initialise so when error occurs when apply adjustment, savings object is correctly initialised for
    // use within Tag library in jsp.
    new SavingsPersistence().initialize(savings);
    checkVersionMismatch(versionNum, savings.getVersionNo());
    savings.setUserContext(uc);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
    if (savings.getPersonnel() != null) {
        getBizService().checkPermissionForAdjustment(AccountTypes.SAVINGS_ACCOUNT, null, uc, savings.getOffice().getOfficeId(), savings.getPersonnel().getPersonnelId());
    } else {
        getBizService().checkPermissionForAdjustment(AccountTypes.SAVINGS_ACCOUNT, null, uc, savings.getOffice().getOfficeId(), uc.getId());
    }
    SavingsApplyAdjustmentActionForm actionForm = (SavingsApplyAdjustmentActionForm) form;
    if (actionForm.getLastPaymentAmount() == null) {
        throw new MifosRuntimeException("Null payment amount is not allowed");
    }
    // date validation
    Date meetingDate = new CustomerPersistence().getLastMeetingDateForCustomer(savings.getCustomer().getCustomerId());
    boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
    if (!savings.isTrxnDateValid(actionForm.getTrxnDateLocal().toDateMidnight().toDate(), meetingDate, repaymentIndependentOfMeetingEnabled)) {
        throw new AccountException(AccountConstants.ERROR_INVALID_TRXN);
    }
    Long savingsId = Long.valueOf(accountId.toString());
    Double adjustedAmount = Double.valueOf(actionForm.getLastPaymentAmount());
    String note = actionForm.getNote();
    AccountPaymentEntity adjustedPayment = savings.findPaymentById(actionForm.getPaymentId());
    AccountPaymentEntity otherTransferPayment = adjustedPayment.getOtherTransferPayment();
    try {
        if (otherTransferPayment == null || otherTransferPayment.isSavingsDepositOrWithdrawal()) {
            // regular savings payment adjustment or savings-savings transfer adjustment
            SavingsAdjustmentDto savingsAdjustment = new SavingsAdjustmentDto(savingsId, adjustedAmount, note, actionForm.getPaymentId(), actionForm.getTrxnDateLocal());
            this.savingsServiceFacade.adjustTransaction(savingsAdjustment);
        } else {
            // adjust repayment from savings account
            AccountBO account = adjustedPayment.getOtherTransferPayment().getAccount();
            AdjustedPaymentDto adjustedPaymentDto = new AdjustedPaymentDto(actionForm.getLastPaymentAmount(), actionForm.getTrxnDateLocal().toDateMidnight().toDate(), otherTransferPayment.getPaymentType().getId());
            this.accountServiceFacade.applyHistoricalAdjustment(account.getGlobalAccountNum(), otherTransferPayment.getPaymentId(), note, uc.getId(), adjustedPaymentDto);
        }
    } catch (BusinessRuleException e) {
        throw new AccountException(e.getMessageKey(), e);
    } finally {
        doCleanUp(request);
    }
    return mapping.findForward("account_detail_page");
}
Also used : SavingsPersistence(org.mifos.accounts.savings.persistence.SavingsPersistence) UserContext(org.mifos.security.util.UserContext) ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) SavingsAdjustmentDto(org.mifos.dto.domain.SavingsAdjustmentDto) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) AccountBO(org.mifos.accounts.business.AccountBO) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountException(org.mifos.accounts.exceptions.AccountException) AdjustedPaymentDto(org.mifos.dto.domain.AdjustedPaymentDto) SavingsApplyAdjustmentActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsApplyAdjustmentActionForm) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 29 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class SavingsApplyAdjustmentAction method list.

@TransactionDemarcate(joinToken = true)
public ActionForward list(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    List<AdjustableSavingsPaymentDto> adjustablePayments = this.savingsServiceFacade.retrievePaymentsForAdjustment(savings.getAccountId());
    SessionUtils.setCollectionAttribute(SavingsConstants.ADJUSTABLE_PAYMENTS, adjustablePayments, request);
    return mapping.findForward("list_savings_adjustments");
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AdjustableSavingsPaymentDto(org.mifos.dto.screen.AdjustableSavingsPaymentDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 30 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class AccountApplyGroupIndividualAction method previous.

@TransactionDemarcate(joinToken = true)
public ActionForward previous(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    //workaround for checkbox problem
    AccountApplyPaymentActionForm accountApplyPaymentActionForm = (AccountApplyPaymentActionForm) form;
    accountApplyPaymentActionForm.setTruePrintReceipt(accountApplyPaymentActionForm.getPrintReceipt());
    accountApplyPaymentActionForm.setPrintReceipt(false);
    return mapping.findForward(ActionForwards.previous_success.toString());
}
Also used : AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)259 UserContext (org.mifos.security.util.UserContext)72 ArrayList (java.util.ArrayList)41 CloseSession (org.mifos.framework.util.helpers.CloseSession)35 LoanBO (org.mifos.accounts.loan.business.LoanBO)26 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)21 CustomerBO (org.mifos.customers.business.CustomerBO)20 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)19 AccountBO (org.mifos.accounts.business.AccountBO)18 ApplicationException (org.mifos.framework.exceptions.ApplicationException)17 ActionErrors (org.apache.struts.action.ActionErrors)14 LocalDate (org.joda.time.LocalDate)14 AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)13 List (java.util.List)12 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)12 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 ActionForward (org.apache.struts.action.ActionForward)11