Search in sources :

Example 1 with NotesActionForm

use of org.mifos.accounts.struts.actionforms.NotesActionForm in project head by mifos.

the class NotesAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    clearActionForm(form);
    NotesActionForm notesActionForm = (NotesActionForm) form;
    Integer accountId = Integer.valueOf(notesActionForm.getAccountId());
    AccountBO account = new AccountBusinessService().getAccount(accountId);
    if (account.isLoanAccount() || account.isGroupLoanAccount()) {
        LoanAccountDetailDto loanAccountDto = this.loanAccountServiceFacade.retrieveLoanAccountNotes(accountId.longValue());
        if (account.isLoanAccount()) {
            notesActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
        } else {
            notesActionForm.setAccountTypeId(AccountTypes.GROUP_LOAN_ACCOUNT.getValue().toString());
        }
        notesActionForm.setGlobalAccountNum(loanAccountDto.getGlobalAccountNum());
        notesActionForm.setPrdOfferingName(loanAccountDto.getProductDetails().getPrdOfferingName());
    } else if (account.isSavingsAccount()) {
        SavingsAccountDetailDto savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountNotes(accountId.longValue());
        notesActionForm.setPrdOfferingName(savingsAccountDto.getProductDetails().getProductDetails().getName());
        notesActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
        notesActionForm.setGlobalAccountNum(savingsAccountDto.getGlobalAccountNum());
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) NotesActionForm(org.mifos.accounts.struts.actionforms.NotesActionForm) LoanAccountDetailDto(org.mifos.dto.screen.LoanAccountDetailDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with NotesActionForm

use of org.mifos.accounts.struts.actionforms.NotesActionForm in project head by mifos.

the class NotesAction method create.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    NotesActionForm notesActionForm = (NotesActionForm) form;
    UserContext uc = getUserContext(request);
    CreateAccountNote accountNote = (CreateAccountNote) SessionUtils.getAttribute("model.accountNote", request);
    AccountBO accountBO = new AccountBusinessService().getAccount(accountNote.getAccountId());
    if (accountBO.getPersonnel() != null) {
        checkPermissionForAddingNotes(accountBO.getType(), null, uc, accountBO.getOffice().getOfficeId(), accountBO.getPersonnel().getPersonnelId());
    } else {
        checkPermissionForAddingNotes(accountBO.getType(), null, uc, accountBO.getOffice().getOfficeId(), uc.getId());
    }
    if (accountBO.isSavingsAccount()) {
        this.savingsServiceFacade.addNote(accountNote);
    } else {
        this.loanAccountServiceFacade.addNote(accountNote);
    }
    return mapping.findForward(chooseForward(Short.valueOf(notesActionForm.getAccountTypeId())));
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CreateAccountNote(org.mifos.dto.domain.CreateAccountNote) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) UserContext(org.mifos.security.util.UserContext) NotesActionForm(org.mifos.accounts.struts.actionforms.NotesActionForm) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with NotesActionForm

use of org.mifos.accounts.struts.actionforms.NotesActionForm in project head by mifos.

the class NotesAction method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    NotesActionForm notesActionForm = (NotesActionForm) form;
    UserContext uc = getUserContext(request);
    LocalDate commentDate = new LocalDate();
    String comment = notesActionForm.getComment();
    Integer createdById = uc.getId().intValue();
    Integer accountId = Integer.valueOf(notesActionForm.getAccountId());
    CreateAccountNote accountNote = new CreateAccountNote(commentDate, comment, createdById, accountId);
    SessionUtils.setAttribute("model.accountNote", accountNote, request);
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : CreateAccountNote(org.mifos.dto.domain.CreateAccountNote) UserContext(org.mifos.security.util.UserContext) NotesActionForm(org.mifos.accounts.struts.actionforms.NotesActionForm) LocalDate(org.joda.time.LocalDate) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

NotesActionForm (org.mifos.accounts.struts.actionforms.NotesActionForm)3 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 AccountBO (org.mifos.accounts.business.AccountBO)2 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 CreateAccountNote (org.mifos.dto.domain.CreateAccountNote)2 UserContext (org.mifos.security.util.UserContext)2 LocalDate (org.joda.time.LocalDate)1 SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)1 LoanAccountDetailDto (org.mifos.dto.screen.LoanAccountDetailDto)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1