Search in sources :

Example 31 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class LoanPrdAction method update.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) form;
    logger.debug("start update method of Loan Product Action" + loanPrdActionForm.getPrdOfferingId());
    UserContext userContext = getUserContext(request);
    Locale locale = getLocale(userContext);
    LoanOfferingBO loanOffering = getLoanOffering(loanPrdActionForm.getPrdOfferingIdValue());
    loanOffering.setUserContext(userContext);
    setInitialObjectForAuditLogging(loanOffering);
    mapVariableInstallmentDetails(loanOffering, loanPrdActionForm);
    loanOffering.setFixedRepaymentSchedule(loanPrdActionForm.isFixedRepaymentSchedule());
    loanOffering.setRoundingDifferenceInFirstPayment(loanPrdActionForm.isRoundingDifferenceInFirstPayment());
    mapCashFlowDetail(loanPrdActionForm, loanOffering);
    loanOffering.update(userContext.getId(), loanPrdActionForm.getPrdOfferingName(), loanPrdActionForm.getPrdOfferingShortName(), getProductCategory(((List<ProductCategoryBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, request)), loanPrdActionForm.getPrdCategoryValue()), (PrdApplicableMasterEntity) findMasterEntity(request, ProductDefinitionConstants.LOANAPPLFORLIST, loanPrdActionForm.getPrdApplicableMasterEnum().getValue()), loanPrdActionForm.getStartDateValue(locale), loanPrdActionForm.getEndDateValue(locale), loanPrdActionForm.getDescription(), PrdStatus.fromInt(loanPrdActionForm.getPrdStatusValue()), (GracePeriodTypeEntity) findMasterEntity(request, ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, loanPrdActionForm.getGracePeriodTypeValue()), (InterestTypesEntity) findMasterEntity(request, ProductDefinitionConstants.INTERESTTYPESLIST, loanPrdActionForm.getInterestTypesValue()), loanPrdActionForm.getGracePeriodDurationValue(), loanPrdActionForm.getMaxInterestRateValue(), loanPrdActionForm.getMinInterestRateValue(), loanPrdActionForm.getDefInterestRateValue(), loanPrdActionForm.isLoanCounterValue(), loanPrdActionForm.isIntDedAtDisbValue(), loanPrdActionForm.isPrinDueLastInstValue(), getFundsFromList((List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.SRCFUNDSLIST, request), loanPrdActionForm.getLoanOfferingFunds()), getFeeList((List<FeeBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEE, request), loanPrdActionForm.getPrdOfferinFees()), getPenaltyList((List<PenaltyBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDPENALTY, request), loanPrdActionForm.getPrdOfferinPenalties()), loanPrdActionForm.getRecurAfterValue(), RecurrenceType.fromInt(loanPrdActionForm.getFreqOfInstallmentsValue()), loanPrdActionForm, loanPrdActionForm.shouldWaiverInterest(), getQuestionGroups(request));
    logger.debug("update method of Loan Product Action called" + loanPrdActionForm.getPrdOfferingId());
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : Locale(java.util.Locale) LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) UserContext(org.mifos.security.util.UserContext) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) List(java.util.List) ArrayList(java.util.ArrayList) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 32 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class LoanBusinessServiceIntegrationTest method getLoanAccount.

private AccountBO getLoanAccount() {
    Date startDate = new Date(System.currentTimeMillis());
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + "_Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + "_Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date)

Example 33 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class LoanAccountActionStrutsTest method getLoanAccount.

private AccountBO getLoanAccount() {
    Date startDate = new Date(System.currentTimeMillis());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, center.getCustomerMeeting().getMeeting());
    return TestObjectFactory.createLoanAccount("42423142341", client, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date)

Example 34 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class LoanAccountActionStrutsTest method getLoanAccountFromLastLoanAmount.

private AccountBO getLoanAccountFromLastLoanAmount() {
    Date startDate = new Date(System.currentTimeMillis());
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date)

Example 35 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO 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())));
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date) Test(org.junit.Test)

Aggregations

LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)135 MeetingBO (org.mifos.application.meeting.business.MeetingBO)44 Date (java.util.Date)37 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)26 Date (java.sql.Date)21 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 LocalDate (org.joda.time.LocalDate)17 CustomerBO (org.mifos.customers.business.CustomerBO)12 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)11 UserContext (org.mifos.security.util.UserContext)9 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 Money (org.mifos.framework.util.helpers.Money)8 MifosUser (org.mifos.security.MifosUser)8 BusinessRuleException (org.mifos.service.BusinessRuleException)8 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 BigDecimal (java.math.BigDecimal)6 AccountException (org.mifos.accounts.exceptions.AccountException)6 FeeBO (org.mifos.accounts.fees.business.FeeBO)6