use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class EditStatusAction method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
AccountBO accountBO = (AccountBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
// FIXME - ElsieF - KEITHW - is checklist functionality being removed from application?
List<AccountCheckListBO> checklist = new AccountBusinessService().getStatusChecklist(getShortValue(editStatusActionForm.getNewStatusId()), getShortValue(editStatusActionForm.getAccountTypeId()));
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_CHECK_LIST, checklist, request);
String newStatusId = editStatusActionForm.getNewStatusId();
String newStatusName = null;
if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
newStatusName = new AccountBusinessService().getStatusName(AccountState.fromShort(getShortValue(editStatusActionForm.getNewStatusId())), accountBO.getType());
}
SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, newStatusName, request);
initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId);
if (loanApproved(newStatusId) || loanClosed(newStatusId)) {
return loanQuestionnaire.fetchAppliedQuestions(mapping, editStatusActionForm, request, ActionForwards.preview_success);
}
return mapping.findForward(ActionForwards.preview_success.toString());
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class StandardAccountService method createParentLoanPaymentData.
/**
* Create parent payment data with member payment data.
*
*/
private AccountPaymentParametersDto createParentLoanPaymentData(AccountBO memberAccount, AccountPaymentParametersDto memberPaymentParametersDto) {
AccountPaymentParametersDto parentPaymentParametersDto = new AccountPaymentParametersDto(memberPaymentParametersDto.getUserMakingPayment(), new AccountReferenceDto(((LoanBO) memberAccount).getParentAccount().getAccountId()), memberPaymentParametersDto.getPaymentAmount(), memberPaymentParametersDto.getPaymentDate(), memberPaymentParametersDto.getPaymentType(), memberPaymentParametersDto.getComment(), memberPaymentParametersDto.getReceiptDate(), memberPaymentParametersDto.getReceiptId(), memberAccount.getCustomer().toCustomerDto());
Map<Integer, String> membersPaymentsData = new HashMap<Integer, String>();
for (AccountBO member : ((LoanBO) memberAccount).getParentAccount().getMemberAccounts()) {
if (member.isActiveLoanAccount()) {
if (member.getAccountId().equals(memberPaymentParametersDto.getAccountId())) {
membersPaymentsData.put(member.getAccountId(), memberPaymentParametersDto.getPaymentAmount().toString());
} else {
membersPaymentsData.put(member.getAccountId(), BigDecimal.ZERO.toString());
}
}
}
parentPaymentParametersDto.setMemberInfo(membersPaymentsData);
return parentPaymentParametersDto;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class StandardAccountService method validatePayment.
@Override
public List<InvalidPaymentReason> validatePayment(AccountPaymentParametersDto payment) throws PersistenceException, AccountException {
List<InvalidPaymentReason> errors = new ArrayList<InvalidPaymentReason>();
AccountBO accountBo = this.legacyAccountDao.getAccount(payment.getAccountId());
Date meetingDate = new CustomerPersistence().getLastMeetingDateForCustomer(accountBo.getCustomer().getCustomerId());
boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
if (!accountBo.isTrxnDateValid(payment.getPaymentDate().toDateMidnight().toDate(), meetingDate, repaymentIndependentOfMeetingEnabled)) {
errors.add(InvalidPaymentReason.INVALID_DATE);
}
if (accountBo instanceof LoanBO) {
if (((LoanBO) accountBo).paymentsNotAllowed()) {
errors.add(InvalidPaymentReason.INVALID_LOAN_STATE);
}
}
if (accountBo instanceof SavingsBO) {
if (!accountBo.getState().equals(AccountState.SAVINGS_ACTIVE)) {
errors.add(InvalidPaymentReason.INVALID_LOAN_STATE);
}
}
if (AccountTypes.getAccountType(accountBo.getAccountType().getAccountTypeId()) == AccountTypes.LOAN_ACCOUNT) {
if (!getLoanPaymentTypes().contains(payment.getPaymentType())) {
errors.add(InvalidPaymentReason.UNSUPPORTED_PAYMENT_TYPE);
}
} else if (AccountTypes.getAccountType(accountBo.getAccountType().getAccountTypeId()) == AccountTypes.SAVINGS_ACCOUNT) {
if (!getSavingsPaymentTypes().contains(payment.getPaymentType())) {
errors.add(InvalidPaymentReason.UNSUPPORTED_PAYMENT_TYPE);
}
} else if (AccountTypes.getAccountType(accountBo.getAccountType().getAccountTypeId()) == AccountTypes.CUSTOMER_ACCOUNT) {
if (!getFeePaymentTypes().contains(payment.getPaymentType())) {
errors.add(InvalidPaymentReason.UNSUPPORTED_PAYMENT_TYPE);
}
}
if (!accountBo.paymentAmountIsValid(new Money(accountBo.getCurrency(), payment.getPaymentAmount()), payment.getPaymentOptions())) {
errors.add(InvalidPaymentReason.INVALID_PAYMENT_AMOUNT);
}
return errors;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class StandardAccountService method lookupLoanAccountReferencesFromClientPhoneNumberAndWithdrawAmount.
/**
* Warning - this should be only used from MPESA plugin!
*/
@Override
public List<AccountReferenceDto> lookupLoanAccountReferencesFromClientPhoneNumberAndWithdrawAmount(String phoneNumber, BigDecimal withdrawAmount) throws Exception {
List<AccountBO> accounts = this.legacyAccountDao.findApprovedLoansForClientWithPhoneNumber(phoneNumber);
List<AccountReferenceDto> result = new ArrayList<AccountReferenceDto>();
for (AccountBO account : accounts) {
LoanBO loanAccount = (LoanBO) account;
if (loanAccount.getLoanAmount().getAmount().compareTo(computeWithdrawnForMPESA(withdrawAmount, loanAccount)) == 0) {
result.add(new AccountReferenceDto(account.getAccountId()));
}
}
return result;
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class StandardAccountService method lookupPayments.
@Override
public List<AccountPaymentParametersDto> lookupPayments(AccountReferenceDto accountRef) throws PersistenceException {
final int accountId = accountRef.getAccountId();
final AccountBO account = this.legacyAccountDao.getAccount(accountId);
List<AccountPaymentParametersDto> paymentDtos = new ArrayList<AccountPaymentParametersDto>();
for (AccountPaymentEntity paymentEntity : account.getAccountPayments()) {
paymentDtos.add(makePaymentDto(paymentEntity));
}
return paymentDtos;
}
Aggregations