Search in sources :

Example 26 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class LoanPrdActionStrutsTest method testManage.

@Test
public void testManage() throws Exception {
    loanOffering = createLoanOfferingBO("Loan Offering", "LOAN");
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    performNoErrors();
    verifyForward(ActionForwards.manage_success.toString());
    List<ProductCategoryBO> productCategories = (List<ProductCategoryBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, request);
    Assert.assertEquals("The size of master data for categories", 1, productCategories.size());
    for (ProductCategoryBO productCategory : productCategories) {
        Assert.assertNotNull(productCategory.getProductType());
    }
    Assert.assertEquals("The size of applicable list", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANAPPLFORLIST, request)).size());
    Assert.assertEquals("The size of grace period types list", 3, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, request)).size());
    Assert.assertEquals("The size of interest types list", 4, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.INTERESTTYPESLIST, request)).size());
    Assert.assertEquals("The size of applicable list", 10, ((List<GLCodeEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRICIPALGLCODELIST, request)).size());
    Assert.assertEquals("The size of applicable list", 3, ((List<GLCodeEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANINTERESTGLCODELIST, request)).size());
    List<FundBO> funds = (List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.SRCFUNDSLIST, request);
    Assert.assertNotNull(funds);
    List<FeeDto> fees = (List<FeeDto>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANFEESLIST, request);
    Assert.assertNull(fees);
    List<FeeBO> productFees = (List<FeeBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEE, request);
    Assert.assertNotNull(productFees);
    List<FeeDto> selectedFees = (List<FeeDto>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEESELECTEDLIST, request);
    Assert.assertNotNull(selectedFees);
    List<FundBO> selectedFunds = (List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFUNDSELECTEDLIST, request);
    Assert.assertNotNull(selectedFunds);
    Assert.assertEquals("The size of applicable status list", 2, ((List<PrdStatusEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDSTATUSLIST, request)).size());
    LoanPrdActionForm loanPrdActionForm = (LoanPrdActionForm) request.getSession().getAttribute(ProductDefinitionConstants.LOANPRODUCTACTIONFORM);
    Assert.assertNotNull(loanPrdActionForm);
    Assert.assertEquals(loanOffering.getPrdOfferingId().toString(), loanPrdActionForm.getPrdOfferingId());
    Assert.assertEquals(loanOffering.getPrdOfferingName(), loanPrdActionForm.getPrdOfferingName());
    Assert.assertEquals(loanOffering.getPrdOfferingShortName(), loanPrdActionForm.getPrdOfferingShortName());
    Assert.assertEquals(loanOffering.getPrdCategory().getProductCategoryID().toString(), loanPrdActionForm.getPrdCategory());
    Assert.assertEquals(loanOffering.getStatus().getValue().toString(), loanPrdActionForm.getPrdStatus());
    Assert.assertEquals(loanOffering.getPrdApplicableMasterEnum(), loanPrdActionForm.getPrdApplicableMasterEnum());
    Assert.assertEquals(DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loanOffering.getStartDate())), loanPrdActionForm.getStartDate());
    if (loanOffering.getEndDate() != null) {
        Assert.assertEquals(DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loanOffering.getEndDate())), loanPrdActionForm.getEndDate());
    } else {
        Assert.assertNull(loanPrdActionForm.getEndDate());
    }
    Assert.assertEquals(loanOffering.getDescription(), loanPrdActionForm.getDescription());
    Assert.assertEquals(loanOffering.getGracePeriodType().getId().toString(), loanPrdActionForm.getGracePeriodType());
    Assert.assertEquals(loanOffering.getGracePeriodDuration().toString(), loanPrdActionForm.getGracePeriodDuration());
    Assert.assertEquals(loanOffering.getInterestTypes().getId().toString(), loanPrdActionForm.getInterestTypes());
    Set<LoanAmountSameForAllLoanBO> loanAmountSameForAllLoan = loanOffering.getLoanAmountSameForAllLoan();
    Assert.assertNotNull(loanAmountSameForAllLoan);
    Set<NoOfInstallSameForAllLoanBO> noOfInstallSameForAllLoan = loanOffering.getNoOfInstallSameForAllLoan();
    Assert.assertNotNull(noOfInstallSameForAllLoan);
    Assert.assertEquals(loanOffering.getMaxInterestRate().toString(), loanPrdActionForm.getMaxInterestRate());
    Assert.assertEquals(loanOffering.getMinInterestRate().toString(), loanPrdActionForm.getMinInterestRate());
    Assert.assertEquals(loanOffering.getDefInterestRate().toString(), loanPrdActionForm.getDefInterestRate());
    Assert.assertEquals(loanOffering.isIntDedDisbursement(), loanPrdActionForm.isIntDedAtDisbValue());
    Assert.assertEquals(loanOffering.isPrinDueLastInst(), loanPrdActionForm.isPrinDueLastInstValue());
    Assert.assertEquals(loanOffering.isIncludeInLoanCounter(), loanPrdActionForm.isLoanCounterValue());
    Assert.assertEquals(loanOffering.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter().toString(), loanPrdActionForm.getRecurAfter());
    Assert.assertEquals(loanOffering.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId().toString(), loanPrdActionForm.getFreqOfInstallments());
    Assert.assertEquals(loanOffering.getPrincipalGLcode().getGlcodeId().toString(), loanPrdActionForm.getPrincipalGLCode());
    Assert.assertEquals(loanOffering.getInterestGLcode().getGlcodeId().toString(), loanPrdActionForm.getInterestGLCode());
    Assert.assertEquals(loanOffering.getLoanOfferingFees().size(), (selectedFees).size());
    Assert.assertEquals(loanOffering.getLoanOfferingFunds().size(), (selectedFunds).size());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) NoOfInstallSameForAllLoanBO(org.mifos.accounts.productdefinition.business.NoOfInstallSameForAllLoanBO) FeeDto(org.mifos.accounts.fees.business.FeeDto) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) List(java.util.List) FeeBO(org.mifos.accounts.fees.business.FeeBO) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) Test(org.junit.Test)

Example 27 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class LoanPrdActionStrutsTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    FeeBO fee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100.0", RecurrenceType.MONTHLY, (short) 1);
    LoanOfferingBO product = createLoanOfferingBO("Loan Offering", "LOAN");
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("prdOfferingId", product.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "editPreview");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("prdOfferingName", "Loan Product");
    addRequestParameter("prdOfferingShortName", "LOAP");
    addRequestParameter("prdCategory", "1");
    addRequestParameter("startDate", offSetCurrentDate(0, userContext.getPreferredLocale()));
    addRequestParameter("endDate", offSetCurrentDate(1, userContext.getPreferredLocale()));
    addRequestParameter("prdApplicableMaster", "1");
    addRequestParameter("minLoanAmount", "2000");
    addRequestParameter("maxLoanAmount", "11000");
    addRequestParameter("defaultLoanAmount", "5000");
    addRequestParameter("interestTypes", "1");
    addRequestParameter("maxInterestRate", "12");
    addRequestParameter("minInterestRate", "1");
    addRequestParameter("defInterestRate", "4");
    addRequestParameter("freqOfInstallments", "2");
    addRequestParameter("prdOfferinFees", new String[] { fee.getFeeId().toString() });
    addRequestParameter("loanOfferingFunds", new String[] { "1" });
    addRequestParameter("recurAfter", "1");
    addRequestParameter("maxNoInstallments", "14");
    addRequestParameter("minNoInstallments", "2");
    addRequestParameter("defNoInstallments", "11");
    addRequestParameter("intDedDisbursementFlag", "1");
    addRequestParameter("prdStatus", "2");
    addRequestParameter("loanAmtCalcType", "1");
    addRequestParameter("calcInstallmentType", "1");
    actionPerform();
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "update");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.update_success.toString());
    StaticHibernateUtil.flushSession();
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals("Loan Product", product.getPrdOfferingName());
    Assert.assertEquals("LOAP", product.getPrdOfferingShortName());
    Assert.assertEquals(PrdStatus.SAVINGS_ACTIVE, product.getStatus());
    for (LoanAmountSameForAllLoanBO loanAmountSameForAllLoanBO : product.getLoanAmountSameForAllLoan()) {
        Assert.assertEquals(new Double("11000"), loanAmountSameForAllLoanBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountSameForAllLoanBO.getMinLoanAmount());
        Assert.assertEquals(new Double("5000"), loanAmountSameForAllLoanBO.getDefaultLoanAmount());
    }
    Assert.assertEquals(Short.valueOf("1"), product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurAfter());
    Assert.assertEquals(Short.valueOf("2"), product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
    Assert.assertEquals(1, product.getLoanOfferingFees().size());
    Assert.assertNull(((FlowManager) request.getSession().getAttribute(Constants.FLOWMANAGER)).getFlow(flowKey));
    TestObjectFactory.removeObject(product);
    fee = null;
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) LoanAmountSameForAllLoanBO(org.mifos.accounts.productdefinition.business.LoanAmountSameForAllLoanBO) Test(org.junit.Test)

Example 28 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class LoanPrdActionStrutsTest method testLoad.

@Test
public void testLoad() throws Exception {
    setRequestPathInfo("/loanproductaction.do");
    addRequestParameter("method", "load");
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.load_success.toString());
    List<ProductCategoryBO> productCategories = (List<ProductCategoryBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, request);
    Assert.assertEquals("The size of master data for categories", 1, productCategories.size());
    for (ProductCategoryBO productCategory : productCategories) {
        Assert.assertNotNull(productCategory.getProductType());
    }
    Assert.assertEquals("The size of applicable list", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANAPPLFORLIST, request)).size());
    Assert.assertEquals("The size of grace period types list", 3, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, request)).size());
    Assert.assertEquals("The size of interest types list", 4, ((List<MasterDataEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.INTERESTTYPESLIST, request)).size());
    Assert.assertEquals("The size of applicable list", 10, ((List<GLCodeEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRICIPALGLCODELIST, request)).size());
    Assert.assertEquals("The size of applicable list", 3, ((List<GLCodeEntity>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANINTERESTGLCODELIST, request)).size());
    List<FundBO> funds = (List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.SRCFUNDSLIST, request);
    Assert.assertNotNull(funds);
    List<FeeDto> loanFees = (List<FeeDto>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANFEESLIST, request);
    Assert.assertNull(loanFees);
    List<FeeBO> productFees = (List<FeeBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEE, request);
    Assert.assertNotNull(productFees);
    List<FeeDto> selectedFees = (List<FeeDto>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFEESELECTEDLIST, request);
    Assert.assertNotNull(selectedFees);
    List<FundBO> selectedFunds = (List<FundBO>) SessionUtils.getAttribute(ProductDefinitionConstants.LOANPRDFUNDSELECTEDLIST, request);
    Assert.assertNotNull(selectedFunds);
    Assert.assertEquals(0, (selectedFees).size());
    Assert.assertEquals(0, (selectedFunds).size());
}
Also used : ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) FeeDto(org.mifos.accounts.fees.business.FeeDto) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) List(java.util.List) FeeBO(org.mifos.accounts.fees.business.FeeBO) Test(org.junit.Test)

Example 29 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class FeeInstallmentTest method createMergedFeeInstallmentsForTwoFeesBothAccountAndFeesAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEventPerFee.

/**********************************
     * Tests verify merging fees when two or more fees are attached to the account
     *
     * TODO: KRP: Remove the assumption of order that fee installments appear in the created list.
     **********************************/
@Test
public void createMergedFeeInstallmentsForTwoFeesBothAccountAndFeesAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEventPerFee() {
    ScheduledEvent masterEvent = new ScheduledEventBuilder().every(1).weeks().build();
    FeeBO feeBO1 = createWeeklyFeeBO(1);
    FeeBO feeBO2 = createWeeklyFeeBO(1);
    AccountFeesEntity accountFeesEntity1 = createAccountFeesEntity(feeBO1, 10.0);
    AccountFeesEntity accountFeesEntity2 = createAccountFeesEntity(feeBO2, 13.0);
    List<AccountFeesEntity> accountFees = Arrays.asList(new AccountFeesEntity[] { accountFeesEntity1, accountFeesEntity2 });
    List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallments(masterEvent, accountFees, 3);
    assertThat(feeInstallments.size(), is(6));
    assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(1), 2, 10.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(2), 3, 10.0, feeBO1);
    assertFeeInstallment(feeInstallments.get(3), 1, 13.0, feeBO2);
    assertFeeInstallment(feeInstallments.get(4), 2, 13.0, feeBO2);
    assertFeeInstallment(feeInstallments.get(5), 3, 13.0, feeBO2);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 30 with FeeBO

use of org.mifos.accounts.fees.business.FeeBO in project head by mifos.

the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeAccountScheduledEveryOtherWeekFeeScheduledEveryWeekt.

@Test
public void createMergedFeeInstallmentsForOneFeeAccountScheduledEveryOtherWeekFeeScheduledEveryWeekt() {
    ScheduledEvent masterEvent = new ScheduledEventBuilder().every(2).weeks().build();
    FeeBO feeBO = createWeeklyFeeBO(1);
    AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
    List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(masterEvent, accountFeesEntity, 4);
    assertThat(feeInstallments.size(), is(4));
    assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
    assertFeeInstallment(feeInstallments.get(1), 2, 20.0, feeBO);
    assertFeeInstallment(feeInstallments.get(2), 3, 20.0, feeBO);
    assertFeeInstallment(feeInstallments.get(3), 4, 20.0, feeBO);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ScheduledEventBuilder(org.mifos.domain.builders.ScheduledEventBuilder) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

FeeBO (org.mifos.accounts.fees.business.FeeBO)89 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)50 ArrayList (java.util.ArrayList)40 Test (org.junit.Test)37 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)25 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)21 Money (org.mifos.framework.util.helpers.Money)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)17 Date (java.sql.Date)15 FeeDto (org.mifos.accounts.fees.business.FeeDto)13 MifosRuntimeException (org.mifos.core.MifosRuntimeException)13 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)11 FundBO (org.mifos.accounts.fund.business.FundBO)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 UserContext (org.mifos.security.util.UserContext)10 AccountBO (org.mifos.accounts.business.AccountBO)9 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)9 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)9 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)9 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)8