use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class LoanBO method postPayment.
private void postPayment(PaymentData paymentData, AccountPaymentEntity accountPaymentEntity, LoanPaymentTypes loanPaymentType) throws AccountException {
closeLoanIfRequired(paymentData);
updateLoanStatus(paymentData, loanPaymentType);
handleLoanArrearsAging(loanPaymentType);
AccountPaymentEntity otherTransferPayment = paymentData.getOtherTransferPayment();
if (otherTransferPayment != null) {
otherTransferPayment.setOtherTransferPayment(accountPaymentEntity);
}
addLoanActivity(buildLoanActivity(accountPaymentEntity.getAccountTrxns(), paymentData.getPersonnel(), AccountConstants.PAYMENT_RCVD, paymentData.getTransactionDate()));
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class EditStatusAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditStatusActionForm actionForm = (EditStatusActionForm) form;
actionForm.setSelectedItems(null);
actionForm.setNotes(null);
actionForm.setNewStatusId(null);
actionForm.setFlagId(null);
actionForm.setQuestionGroups(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setAllowBackDatedApprovals(AccountingRules.isBackDatedApprovalAllowed());
request.getSession().removeAttribute(Constants.BUSINESS_KEY);
UserContext userContext = getUserContext(request);
Integer accountId = Integer.valueOf(actionForm.getAccountId());
AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
java.util.Date lastPaymentDate = new java.util.Date(0);
AccountPaymentEntity lastPayment = accountBO.findMostRecentNonzeroPaymentByPaymentDate();
if (lastPayment != null) {
lastPaymentDate = lastPayment.getPaymentDate();
}
actionForm.setLastPaymentDate(lastPaymentDate);
if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.loanAccountServiceFacade.retrieveAccountStatuses(accountId.longValue());
LoanBO loanAccount = this.loanDao.findById(accountId);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(loanAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(loanAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(loanAccount.getLoanOffering().getPrdOfferingName());
if (loanAccount.isGroupLoanAccount() && loanAccount.getParentAccount() == null) {
editStatusActionForm.setInput("grouploan");
} else {
editStatusActionForm.setInput("loan");
}
if (loanAccount.getAccountState().getId().equals(Short.valueOf("2"))) {
List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
List<AdminDocumentBO> loanAdminDocuments = new ArrayList();
for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
if (!loanAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(loanAccount.getType().getValue().shortValue())) {
for (AdminDocAccStateMixBO admindoc : admindoclist) {
if (admindoc.getAccountStateID().getId().shortValue() == loanAccount.getAccountState().getId().shortValue()) {
loanAdminDocuments.add(adminDocumentBO);
}
}
}
}
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", loanAdminDocuments, request);
} else {
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", null, request);
}
}
if (accountBO.isSavingsAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.savingsServiceFacade.retrieveAccountStatuses(accountId.longValue());
SavingsBO savingsAccount = this.savingsDao.findById(accountId.longValue());
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(savingsAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(savingsAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(savingsAccount.getSavingsOffering().getPrdOfferingName());
editStatusActionForm.setInput("savings");
}
List<AccountStateEntity> accountStatuses = new AccountBusinessService().getStatusList(accountBO.getAccountState(), accountBO.getType(), userContext.getLocaleId());
for (AccountStateEntity customerStatusEntity : accountStatuses) {
for (AccountStateFlagEntity flag : customerStatusEntity.getFlagSet()) {
String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
flag.setStatusFlagMessageText(statusMessageText);
}
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, accountStatuses, request);
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class SavingsApplyAdjustmentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
clearActionForm(form);
doCleanUp(request);
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = Long.valueOf(savings.getAccountId());
savings = this.savingsDao.findById(savingsId);
savings.setUserContext(uc);
String paymentIdParam = request.getParameter("paymentId");
Integer paymentId;
if (paymentIdParam == null) {
AccountPaymentEntity payment = savings.getLastPmnt();
paymentId = (payment == null) ? null : payment.getPaymentId();
} else {
paymentId = Integer.valueOf(paymentIdParam);
}
SavingsAdjustmentReferenceDto savingsAdjustmentDto = this.savingsServiceFacade.retrieveAdjustmentReferenceData(savingsId, paymentId);
if (savingsAdjustmentDto.isDepositOrWithdrawal()) {
AccountPaymentEntity payment = (paymentId == null) ? savings.findMostRecentPaymentByPaymentDate() : savings.findPaymentById(paymentId);
AccountActionEntity accountAction = legacyMasterDao.getPersistentObject(AccountActionEntity.class, new SavingsHelper().getPaymentActionType(payment));
Hibernate.initialize(savings.findMostRecentPaymentByPaymentDate().getAccountTrxns());
SessionUtils.setAttribute(SavingsConstants.ACCOUNT_ACTION, accountAction, request);
SessionUtils.setAttribute(SavingsConstants.CLIENT_NAME, savingsAdjustmentDto.getClientName(), request);
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.YES, request);
SessionUtils.setAttribute(SavingsConstants.ADJUSTMENT_AMOUNT, payment.getAmount().getAmount(), request);
SavingsApplyAdjustmentActionForm actionForm = (SavingsApplyAdjustmentActionForm) form;
actionForm.setPaymentId(paymentId);
actionForm.setTrxnDate(new LocalDate(payment.getPaymentDate()));
} else {
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.NO, request);
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
return mapping.findForward("load_success");
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class SavingsClosureAction method close.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward close(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
SavingsClosureActionForm actionForm = (SavingsClosureActionForm) form;
AccountPaymentEntity payment = (AccountPaymentEntity) SessionUtils.getAttribute(SavingsConstants.ACCOUNT_PAYMENT, request);
SavingsBO savingsInSession = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = Long.valueOf(savingsInSession.getAccountId());
SavingsBO savings = this.savingsDao.findById(savingsId);
checkVersionMismatch(savingsInSession.getVersionNo(), savings.getVersionNo());
savings.setUserContext(getUserContext(request));
UserContext userContext = getUserContext(request);
Long customerId = null;
if (actionForm.getCustomerId() != null) {
customerId = Long.valueOf(actionForm.getCustomerId());
}
LocalDate dateOfWithdrawal = new LocalDate(payment.getPaymentDate());
Double amount = payment.getAmount().getAmountDoubleValue();
Integer modeOfPayment = payment.getPaymentType().getId().intValue();
String receiptId = payment.getReceiptNumber();
LocalDate dateOfReceipt = null;
if (payment.getReceiptDate() != null) {
dateOfReceipt = new LocalDate(payment.getReceiptDate());
}
Locale preferredLocale = userContext.getPreferredLocale();
SavingsWithdrawalDto closeAccount = new SavingsWithdrawalDto(savingsId, customerId, dateOfWithdrawal, amount, modeOfPayment, receiptId, dateOfReceipt, preferredLocale);
this.savingsServiceFacade.closeSavingsAccount(savingsId, actionForm.getNotes(), closeAccount);
SessionUtils.removeAttribute(SavingsConstants.ACCOUNT_PAYMENT, request);
closeSavingsQuestionnaire.saveResponses(request, actionForm, savingsInSession.getAccountId());
return mapping.findForward("close_success");
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class SavingsApplyAdjustmentActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = new ActionErrors();
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
try {
if (method != null && method.equals("preview")) {
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
AccountPaymentEntity payment = savings.findPaymentById(this.paymentId);
if (payment == null || savings.getLastPmntAmnt() == 0 || !(new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue()) || new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue()))) {
errors.add(SavingsConstants.INVALID_LAST_PAYMENT, new ActionMessage(SavingsConstants.INVALID_LAST_PAYMENT));
} else {
if (StringUtils.isBlank(getLastPaymentAmount())) {
errors.add(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT, new ActionMessage(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT));
}
if (StringUtils.isNotBlank(getLastPaymentAmount())) {
Locale locale = getUserContext(request).getPreferredLocale();
validateAmount(errors, locale);
}
if (StringUtils.isNotBlank(getNote()) && getNote().length() > CustomerConstants.COMMENT_LENGTH) {
errors.add(AccountConstants.MAX_NOTE_LENGTH, new ActionMessage(AccountConstants.MAX_NOTE_LENGTH, AccountConstants.COMMENT_LENGTH));
}
validateDate(errors);
errors.add(super.validate(mapping, request));
}
}
} catch (ApplicationException ae) {
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
Aggregations