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());
}
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);
}
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);
}
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);
}
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())));
}
Aggregations