use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class ApplyPaymentActionStrutsTest method testApplyPaymentPreviewDateValidation.
@Test
public void testApplyPaymentPreviewDateValidation() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
accountBO = createLoanAccount();
accountBO.setUserContext(TestObjectFactory.getContext());
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
accountBO.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, null, "", loggedInUser);
AccountApplyPaymentActionForm accountApplyPaymentActionForm = new AccountApplyPaymentActionForm();
accountApplyPaymentActionForm.setAmount("212");
request.getSession().setAttribute("applyPaymentActionForm", accountApplyPaymentActionForm);
setRequestPathInfo("/applyPaymentAction");
addRequestParameter("input", "loan");
addRequestParameter("method", "preview");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter("receiptId", "101");
// date fields added individually because we're adding an invalid dat
addRequestParameter("transactionDateDD", "4");
addRequestParameter("transactionDateMM", "20");
addRequestParameter("transactionDateYY", "2007");
addRequestParameter("paymentTypeId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyActionErrors(new String[] { AccountConstants.ERROR_INVALIDDATE });
verifyInputForward();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsClosureActionStrutsTest method testSuccessfullCloseAccount.
@Test
public void testSuccessfullCloseAccount() throws Exception {
createInitialObjects();
createClients();
savingsOffering = helper.createSavingsOffering("asfddsf", "213a");
savings = helper.createSavingsAccount("000X00000000017", savingsOffering, group, AccountStates.SAVINGS_ACC_APPROVED, userContext);
SavingBOTestUtils.setActivationDate(savings, helper.getDate("20/05/2006"));
PersonnelBO createdBy = legacyPersonnelDao.getPersonnel(userContext.getId());
AccountPaymentEntity payment1 = helper.createAccountPaymentToPersist(savings, TestUtils.createMoney("1000.0"), TestUtils.createMoney("1000.0"), helper.getDate("30/05/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
AccountTestUtils.addAccountPayment(payment1, savings);
savings.update();
StaticHibernateUtil.flushSession();
Money balanceAmount = TestUtils.createMoney("1500.0");
AccountPaymentEntity payment2 = helper.createAccountPaymentToPersist(savings, TestUtils.createMoney("500.0"), balanceAmount, helper.getDate("15/06/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
AccountTestUtils.addAccountPayment(payment2, savings);
savings.update();
StaticHibernateUtil.flushSession();
Money interestAmount = TestUtils.createMoney("40");
SavingBOTestUtils.setInterestToBePosted(savings, interestAmount);
SavingBOTestUtils.setBalance(savings, balanceAmount);
savings.update();
StaticHibernateUtil.flushSession();
savings = savingsDao.findById(savings.getAccountId());
savings.setUserContext(userContext);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
setRequestPathInfo("/savingsClosureAction.do");
addRequestParameter("method", "load");
actionPerform();
verifyForward("load_success");
addRequestParameter("receiptId", "101");
addRequestParameter("receiptDate", DateUtils.makeDateAsSentFromBrowser());
addRequestParameter("paymentTypeId", "1");
addRequestParameter("customerId", "1");
addRequestParameter("notes", "closing account");
setRequestPathInfo("/savingsClosureAction.do");
addRequestParameter("method", "preview");
actionPerform();
setRequestPathInfo("/savingsClosureAction.do");
addRequestParameter("method", "close");
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward("close_success");
savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
Assert.assertEquals(new Money(getCurrency()), savings.getSavingsBalance());
Assert.assertEquals(AccountState.SAVINGS_CLOSED.getValue(), savings.getAccountState().getId());
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class LoanAccountActionStrutsTest method testGetForCancelledLoanAccount.
@Test
public void testGetForCancelledLoanAccount() throws Exception {
setMifosUserFromContext();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
Date startDate = new Date(System.currentTimeMillis());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
accountBO.changeStatus(AccountState.LOAN_CANCELLED, AccountStateFlag.LOAN_WITHDRAW.getValue(), "status changed", loggedInUser);
accountBO.update();
StaticHibernateUtil.flushSession();
LoanBO loan = (LoanBO) accountBO;
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter("method", "get");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
actionPerform();
verifyForward("get_success");
Assert.assertEquals(0, loan.getPerformanceHistory().getNoOfPayments().intValue());
// Assert.assertEquals(((LoanBO) accountBO).getTotalAmountDue().getAmountDoubleValue(), 212.0);
modifyActionDateForFirstInstallment();
Assert.assertEquals("Total no. of notes should be 6", 6, accountBO.getAccountNotes().size());
// LoanInformationDto loanInformationDto = retrieveLoanInformationDtoFromSession();
// Assert.assertEquals("Total no. of recent notes should be 3", 3, (loanInformationDto.getRecentAccountNotes().size()));
Assert.assertEquals("Total no. of flags should be 1", 1, accountBO.getAccountFlags().size());
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class LoanAccountActionStrutsTest method testUpdateSuccessWithRegeneratingNewRepaymentSchedule.
@Test
public void testUpdateSuccessWithRegeneratingNewRepaymentSchedule() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
Date startDate = new Date(System.currentTimeMillis());
String newDate = offSetCurrentDate(14, userContext.getPreferredLocale());
// This is a loan with weekly meetings every week. No interest is paid
// at disbursement, so the first payment will be one week after the
// disbursement date of the loan (14 days + 7 days = 21 days)
String firstInstallmentDateWithNoInterestPaidAtDisbursementDate = offSetCurrentDate(21, userContext.getPreferredLocale());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
((LoanBO) accountBO).setBusinessActivityId(1);
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
accountBO.changeStatus(AccountState.LOAN_APPROVED, null, "status changed", loggedInUser);
accountBO.update();
StaticHibernateUtil.flushSession();
LoanBO loan = (LoanBO) accountBO;
LoanOfferingBO loanOffering = loan.getLoanOffering();
// loanOffering.updateLoanOfferingSameForAllLoan(loanOffering);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "manage");
addRequestParameter("customerId", accountBO.getCustomer().getCustomerId().toString());
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
actionPerform();
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "managePreview");
addRequestParameter("loanAmount", loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString());
addRequestParameter("interestRate", loan.getLoanOffering().getDefInterestRate().toString());
addRequestParameter("noOfInstallments", loanOffering.getDefaultNumOfEligibleInstallmentsSameForAllLoan().toString());
addRequestParameter("disbursementDate", newDate);
addRequestParameter("gracePeriodDuration", "0");
addRequestParameter("intDedDisbursement", "0");
addRequestParameter("customerId", group.getCustomerId().toString());
actionPerform();
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "update");
addRequestParameter("collateralNote", "test");
actionPerform();
verifyForward(ActionForwards.update_success.toString());
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
Assert.assertEquals("test", loan.getCollateralNote());
Assert.assertEquals(300.0, loan.getLoanAmount().getAmount().doubleValue(), DELTA);
Assert.assertEquals(0, loan.getGracePeriodDuration().intValue());
Assert.assertEquals(firstInstallmentDateWithNoInterestPaidAtDisbursementDate, DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loan.getAccountActionDate(Short.valueOf("1")).getActionDate())));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsBOIntegrationTest method testChangeStatusPermissionToCancelBlacklistedSucess.
@Test
public void testChangeStatusPermissionToCancelBlacklistedSucess() throws Exception {
createInitialObjects();
savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
savings = helper.createSavingsAccount("000100000000017", savingsOffering, group, AccountStates.SAVINGS_ACC_PENDINGAPPROVAL, userContext);
AccountStateMachines.getInstance().initialize(AccountTypes.SAVINGS_ACCOUNT, null);
// 6 is blacklisted
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
savings.changeStatus(AccountState.SAVINGS_CANCELLED, Short.valueOf("6"), "notes", loggedInUser);
Assert.assertEquals(AccountStates.SAVINGS_ACC_CANCEL, savings.getAccountState().getId().shortValue());
}
Aggregations