use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.
the class CustomerAccountAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
String globalCustNum = ((CustomerAccountActionForm) form).getGlobalCustNum();
if (StringUtils.isBlank(globalCustNum)) {
// NOTE: see CustomerAction.getAllActivity for explanation of this craziness
globalCustNum = (String) SessionUtils.getAttribute("customerGlobalNum", request.getSession());
}
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
CustomerAccountBO customerAccount = customerBO.getCustomerAccount();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerAccount, request);
List<CustomerRecentActivityDto> recentActivities = this.centerServiceFacade.retrieveRecentActivities(customerBO.getCustomerId(), 3);
SessionUtils.setCollectionAttribute(CustomerConstants.RECENT_ACTIVITIES, recentActivities, request);
ActionForwards forward = getForward(customerBO);
return mapping.findForward(forward.toString());
}
use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.
the class CloseLoanActionStrutsTest method testRescheduleLoan.
@Test
public void testRescheduleLoan() throws Exception {
loanBO = getLoanAccount();
loanBO.approve(legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER), "approved", currentDate.toLocalDate());
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("accountId", loanBO.getAccountId().toString());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loanBO, request);
request.getSession().setAttribute(Constants.USER_CONTEXT_KEY, userContext);
addRequestParameter("notes", "reschedule");
addRequestParameter("newStatusId", "8");
addRequestParameter("input", "loan");
addRequestParameter("method", "update");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.loan_detail_page.toString());
CustomerAccountBO closedAccount = group.getCustomerAccount();
Assert.assertEquals(AccountState.CUSTOMER_ACCOUNT_ACTIVE, closedAccount.getState());
Session session = StaticHibernateUtil.getSessionTL();
// session.beginTransaction();
loanBO = (LoanBO) session.get(LoanBO.class, loanBO.getAccountId());
List<TransactionHistoryDto> history = loanBO.getTransactionHistoryView();
for (TransactionHistoryDto entry : history) {
Assert.assertEquals(AccountConstants.LOAN_RESCHEDULED, entry.getType());
}
}
use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.
the class CustomerApplyAdjustmentActionStrutsTest method applyPayment.
private void applyPayment() throws Exception {
createInitialObjects();
accountBO = client.getCustomerAccount();
Date currentDate = new Date(System.currentTimeMillis());
CustomerAccountBO customerAccountBO = (CustomerAccountBO) accountBO;
customerAccountBO.setUserContext(userContext);
CustomerScheduleEntity accountAction = (CustomerScheduleEntity) customerAccountBO.getAccountActionDate(Short.valueOf("1"));
CustomerAccountBOTestUtils.setMiscFeePaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setMiscPenaltyPaid(accountAction, TestUtils.createMoney(100));
CustomerAccountBOTestUtils.setPaymentDate(accountAction, currentDate);
accountAction.setPaymentStatus(PaymentStatus.PAID);
AccountPaymentEntity accountPaymentEntity = new AccountPaymentEntity(accountBO, TestUtils.createMoney(100), "1111", currentDate, new PaymentTypeEntity(Short.valueOf("1")), new Date(System.currentTimeMillis()));
CustomerTrxnDetailEntity accountTrxnEntity = new CustomerTrxnDetailEntity(accountPaymentEntity, AccountActionTypes.PAYMENT, Short.valueOf("1"), accountAction.getActionDate(), TestObjectFactory.getPersonnel(userContext.getId()), currentDate, TestUtils.createMoney(200), "payment done", null, TestUtils.createMoney(100), TestUtils.createMoney(100));
for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : accountAction.getAccountFeesActionDetails()) {
CustomerAccountBOTestUtils.setFeeAmountPaid((CustomerFeeScheduleEntity) accountFeesActionDetailEntity, TestUtils.createMoney(100));
FeesTrxnDetailEntity feeTrxn = new FeesTrxnDetailEntity(accountTrxnEntity, accountFeesActionDetailEntity.getAccountFee(), accountFeesActionDetailEntity.getFeeAmount());
CustomerBOTestUtils.addFeesTrxnDetail(accountTrxnEntity, feeTrxn);
// totalFees = accountFeesActionDetailEntity.getFeeAmountPaid();
}
accountPaymentEntity.addAccountTrxn(accountTrxnEntity);
AccountTestUtils.addAccountPayment(accountPaymentEntity, customerAccountBO);
TestObjectFactory.updateObject(customerAccountBO);
StaticHibernateUtil.flushSession();
customerAccountBO = TestObjectFactory.getObject(CustomerAccountBO.class, customerAccountBO.getAccountId());
client = customerAccountBO.getCustomer();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.
the class CustomerAccountCreationTest method firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency.
@Test
public void firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency() throws Exception {
// setup
applicableCalendarEvents = new CalendarEventBuilder().build();
DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
accountFees = new ArrayList<AccountFeesEntity>();
MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
// exercise test
CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
// verification
List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
LocalDate mon18thOfMay = new DateTime().withDate(2011, 5, 18).toLocalDate();
assertThat(firstCenterDate, is(mon18thOfMay));
}
use of org.mifos.customers.business.CustomerAccountBO in project head by mifos.
the class SaveCollectionSheetStructureValidator method validateAccount.
private void validateAccount(Integer customerId, Integer accountId, Short currencyId, ValidationAccountTypes accountType) {
AccountBO account;
try {
account = legacyAccountDao.getAccount(accountId);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
if (account == null) {
addValidationError(InvalidSaveCollectionSheetReason.ACCOUNT_NOT_FOUND, "Customer Id: " + customerId + " Account Id: " + accountId);
return;
}
if (!validAccountOwnership(account, customerId, accountType)) {
addValidationError(InvalidSaveCollectionSheetReason.ACCOUNT_DOESNT_BELONG_TO_CUSTOMER, "Customer Id: " + customerId + " Account Id: " + accountId);
return;
}
validateCurrency(currencyId);
if (accountType.compareTo(ValidationAccountTypes.CUSTOMER) == 0) {
if (!(account instanceof CustomerAccountBO)) {
addValidationError(InvalidSaveCollectionSheetReason.ACCOUNT_NOT_A_CUSTOMER_ACCOUNT, "Customer Id: " + customerId + " Account Id: " + accountId);
}
return;
}
if (accountType.compareTo(ValidationAccountTypes.LOAN) == 0) {
if (!(account instanceof LoanBO)) {
addValidationError(InvalidSaveCollectionSheetReason.ACCOUNT_NOT_A_LOAN_ACCOUNT, "Customer Id: " + customerId + " Account Id: " + accountId);
} else {
if (!(validLoanAccountStates.contains(account.getState()))) {
addValidationError(InvalidSaveCollectionSheetReason.INVALID_LOAN_ACCOUNT_STATUS, "Customer Id: " + customerId + " Account Id: " + accountId + " Account Status: " + account.getState().toString());
}
}
return;
}
if ((accountType.compareTo(ValidationAccountTypes.SAVINGS) == 0) || (accountType.compareTo(ValidationAccountTypes.INDIVIDUAL_SAVINGS) == 0)) {
if (!(account instanceof SavingsBO)) {
addValidationError(InvalidSaveCollectionSheetReason.ACCOUNT_NOT_A_SAVINGS_ACCOUNT, "Customer Id: " + customerId + " Account Id: " + accountId);
} else {
if (!(validSavingsAccountStates.contains(account.getState()))) {
addValidationError(InvalidSaveCollectionSheetReason.INVALID_SAVINGS_ACCOUNT_STATUS, "Customer Id: " + customerId + " Account Id: " + accountId + " Account Status: " + account.getState().toString());
}
}
return;
}
throw new MifosRuntimeException("Account Type: " + accountType.toString() + " not recognised");
}
Aggregations