Search in sources :

Example 6 with FeeBO

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

the class GroupServiceFacadeWebTier method retrieveGroupFormCreationData.

@Override
public GroupFormCreationDto retrieveGroupFormCreationData(GroupCreation groupCreation) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO parentCustomer = null;
    Short parentOfficeId = groupCreation.getOfficeId();
    CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.empty();
    List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
    CenterCreation centerCreation;
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (isCenterHierarchyExists) {
        parentCustomer = this.customerDao.findCenterBySystemId(groupCreation.getParentSystemId());
        parentOfficeId = parentCustomer.getOffice().getOfficeId();
        centerCreation = new CenterCreation(parentOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        MeetingBO customerMeeting = parentCustomer.getCustomerMeetingValue();
        List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroupsRefinedBy(customerMeeting);
        applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    } else {
        centerCreation = new CenterCreation(groupCreation.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
        List<FeeBO> fees = customerDao.retrieveFeesApplicableToGroups();
        applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    }
    List<ApplicableAccountFeeDto> applicableDefaultAccountFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getDefaultFees()) {
        applicableDefaultAccountFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<ApplicableAccountFeeDto> applicableDefaultAdditionalFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getAdditionalFees()) {
        applicableDefaultAdditionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<PersonnelDto> formedByPersonnel = customerDao.findLoanOfficerThatFormedOffice(centerCreation.getOfficeId());
    return new GroupFormCreationDto(isCenterHierarchyExists, personnelList, formedByPersonnel, applicableDefaultAccountFees, applicableDefaultAdditionalFees);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) GroupFormCreationDto(org.mifos.dto.domain.GroupFormCreationDto) CenterCreation(org.mifos.dto.domain.CenterCreation) CustomerBO(org.mifos.customers.business.CustomerBO) FeeBO(org.mifos.accounts.fees.business.FeeBO)

Example 7 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testCreateLoanOfferingSameForAllLoan.

@Test
public void testCreateLoanOfferingSameForAllLoan() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.GRACEONALLREPAYMENTS);
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, (short) 1);
    oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(periodicFee);
    fees.add(oneTimeFee);
    LoanPrdActionForm loanPrdActionForm = new LoanPrdActionForm();
    product = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, "1234", gracePeriodType, (short) 2, interestTypes, 12.0, 2.0, 3.0, false, false, false, null, fees, null, frequency, principalglCodeEntity, intglCodeEntity, populateNoOfInstallSameForAllLoan("1", "12", "1", "2", populateLoanAmountSameForAllLoan("1", new Double("3000"), new Double("1000"), new Double("2000"), loanPrdActionForm)), waiverInterest);
    product.save();
    StaticHibernateUtil.flushAndClearSession();
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals("Loan Offering", product.getPrdOfferingName());
    Assert.assertEquals("LOAP", product.getPrdOfferingShortName());
    Assert.assertEquals(Short.valueOf("1"), product.getPrdCategory().getProductCategoryID());
    Assert.assertEquals(ApplicableTo.CLIENTS, product.getPrdApplicableMasterEnum());
    Assert.assertEquals(startDate, product.getStartDate());
    Assert.assertEquals(endDate, product.getEndDate());
    Assert.assertEquals("1234", product.getDescription());
    Assert.assertEquals(GraceType.GRACEONALLREPAYMENTS.getValue(), product.getGracePeriodType().getId());
    Assert.assertEquals(Short.valueOf("2"), product.getGracePeriodDuration());
    Assert.assertEquals(InterestType.FLAT.getValue(), product.getInterestTypes().getId());
    for (LoanAmountSameForAllLoanBO loanAmountSameForAllLoanBO : product.getLoanAmountSameForAllLoan()) {
        Assert.assertEquals(new Double("3000"), loanAmountSameForAllLoanBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("1000"), loanAmountSameForAllLoanBO.getMinLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountSameForAllLoanBO.getDefaultLoanAmount());
    }
    for (NoOfInstallSameForAllLoanBO noofInstallSameForAllLoanBO : product.getNoOfInstallSameForAllLoan()) {
        Assert.assertEquals(new Short("12"), noofInstallSameForAllLoanBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("1"), noofInstallSameForAllLoanBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("2"), noofInstallSameForAllLoanBO.getDefaultNoOfInstall());
    }
    Assert.assertEquals(2.0, product.getMinInterestRate(), DELTA);
    Assert.assertEquals(12.0, product.getMaxInterestRate(), DELTA);
    Assert.assertEquals(3.0, product.getDefInterestRate(), DELTA);
    Assert.assertFalse(product.isIncludeInLoanCounter());
    Assert.assertFalse(product.isIntDedDisbursement());
    Assert.assertFalse(product.isPrinDueLastInst());
    Assert.assertEquals(2, product.getLoanOfferingFees().size());
    Assert.assertNotNull(product.getLoanOfferingMeeting());
    Assert.assertEquals(RecurrenceType.WEEKLY, product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceTypeEnum());
    Assert.assertNotNull(product.getPrincipalGLcode());
    Assert.assertNotNull(product.getInterestGLcode());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Date(java.sql.Date) Test(org.junit.Test)

Example 8 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testCreateLoanOfferingByLastLoanAmount.

@Test
public void testCreateLoanOfferingByLastLoanAmount() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.GRACEONALLREPAYMENTS);
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, (short) 1);
    oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(periodicFee);
    fees.add(oneTimeFee);
    LoanPrdActionForm loanPrdActionForm = new LoanPrdActionForm();
    product = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, "1234", gracePeriodType, (short) 2, interestTypes, 12.0, 2.0, 3.0, false, false, false, null, fees, null, frequency, principalglCodeEntity, intglCodeEntity, LoanOfferingTestUtils.populateNoOfInstallFromLastLoanAmount("2", new Integer("0"), new Integer("1000"), new Integer("1001"), new Integer("2000"), new Integer("2001"), new Integer("3000"), new Integer("3001"), new Integer("4000"), new Integer("4001"), new Integer("5000"), new Integer("5001"), new Integer("6000"), "10", "30", "20", "20", "40", "30", "30", "50", "40", "40", "60", "50", "50", "70", "60", "60", "80", "70", LoanOfferingTestUtils.populateLoanAmountFromLastLoanAmount("2", new Integer("0"), new Integer("1000"), new Integer("1001"), new Integer("2000"), new Integer("2001"), new Integer("3000"), new Integer("3001"), new Integer("4000"), new Integer("4001"), new Integer("5000"), new Integer("5001"), new Integer("6000"), new Double("1000"), new Double("3000"), new Double("2000"), new Double("2000"), new Double("4000"), new Double("3000"), new Double("3000"), new Double("5000"), new Double("4000"), new Double("4000"), new Double("6000"), new Double("5000"), new Double("5000"), new Double("7000"), new Double("6000"), new Double("6000"), new Double("8000"), new Double("7000"), loanPrdActionForm)), waiverInterest);
    product.save();
    StaticHibernateUtil.flushAndClearSession();
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals("Loan Offering", product.getPrdOfferingName());
    Assert.assertEquals("LOAP", product.getPrdOfferingShortName());
    Assert.assertEquals(Short.valueOf("1"), product.getPrdCategory().getProductCategoryID());
    Assert.assertEquals(ApplicableTo.CLIENTS, product.getPrdApplicableMasterEnum());
    Assert.assertEquals(startDate, product.getStartDate());
    Assert.assertEquals(endDate, product.getEndDate());
    Assert.assertEquals("1234", product.getDescription());
    Assert.assertEquals(GraceType.GRACEONALLREPAYMENTS.getValue(), product.getGracePeriodType().getId());
    Assert.assertEquals(Short.valueOf("2"), product.getGracePeriodDuration());
    Assert.assertEquals(InterestType.FLAT.getValue(), product.getInterestTypes().getId());
    for (Iterator<LoanAmountFromLastLoanAmountBO> itr = product.getLoanAmountFromLastLoan().iterator(); itr.hasNext(); ) {
        LoanAmountFromLastLoanAmountBO loanAmountFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("0"), loanAmountFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("1000"), loanAmountFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Double("3000"), loanAmountFromLastLoanAmountBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("1000"), loanAmountFromLastLoanAmountBO.getMinLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountFromLastLoanAmountBO.getDefaultLoanAmount());
        loanAmountFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("1001"), loanAmountFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("2000"), loanAmountFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Double("4000"), loanAmountFromLastLoanAmountBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountFromLastLoanAmountBO.getMinLoanAmount());
        Assert.assertEquals(new Double("3000"), loanAmountFromLastLoanAmountBO.getDefaultLoanAmount());
        loanAmountFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("2001"), loanAmountFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("3000"), loanAmountFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Double("5000"), loanAmountFromLastLoanAmountBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("3000"), loanAmountFromLastLoanAmountBO.getMinLoanAmount());
        Assert.assertEquals(new Double("4000"), loanAmountFromLastLoanAmountBO.getDefaultLoanAmount());
        loanAmountFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("3001"), loanAmountFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("4000"), loanAmountFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Double("6000"), loanAmountFromLastLoanAmountBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("4000"), loanAmountFromLastLoanAmountBO.getMinLoanAmount());
        Assert.assertEquals(new Double("5000"), loanAmountFromLastLoanAmountBO.getDefaultLoanAmount());
        loanAmountFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("4001"), loanAmountFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("5000"), loanAmountFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Double("7000"), loanAmountFromLastLoanAmountBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("5000"), loanAmountFromLastLoanAmountBO.getMinLoanAmount());
        Assert.assertEquals(new Double("6000"), loanAmountFromLastLoanAmountBO.getDefaultLoanAmount());
        loanAmountFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("5001"), loanAmountFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("6000"), loanAmountFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Double("8000"), loanAmountFromLastLoanAmountBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("6000"), loanAmountFromLastLoanAmountBO.getMinLoanAmount());
        Assert.assertEquals(new Double("7000"), loanAmountFromLastLoanAmountBO.getDefaultLoanAmount());
    }
    for (Iterator<NoOfInstallFromLastLoanAmountBO> itr = product.getNoOfInstallFromLastLoan().iterator(); itr.hasNext(); ) {
        NoOfInstallFromLastLoanAmountBO noOfInstallFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("0"), noOfInstallFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("1000"), noOfInstallFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Short("30"), noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("10"), noOfInstallFromLastLoanAmountBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("20"), noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall());
        noOfInstallFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("1001"), noOfInstallFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("2000"), noOfInstallFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Short("40"), noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("20"), noOfInstallFromLastLoanAmountBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("30"), noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall());
        noOfInstallFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("2001"), noOfInstallFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("3000"), noOfInstallFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Short("50"), noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("30"), noOfInstallFromLastLoanAmountBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("40"), noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall());
        noOfInstallFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("3001"), noOfInstallFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("4000"), noOfInstallFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Short("60"), noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("40"), noOfInstallFromLastLoanAmountBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("50"), noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall());
        noOfInstallFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("4001"), noOfInstallFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("5000"), noOfInstallFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Short("70"), noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("50"), noOfInstallFromLastLoanAmountBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("60"), noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall());
        noOfInstallFromLastLoanAmountBO = itr.next();
        Assert.assertEquals(new Double("5001"), noOfInstallFromLastLoanAmountBO.getStartRange());
        Assert.assertEquals(new Double("6000"), noOfInstallFromLastLoanAmountBO.getEndRange());
        Assert.assertEquals(new Short("80"), noOfInstallFromLastLoanAmountBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("60"), noOfInstallFromLastLoanAmountBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("70"), noOfInstallFromLastLoanAmountBO.getDefaultNoOfInstall());
    }
    Assert.assertEquals(2.0, product.getMinInterestRate(), DELTA);
    Assert.assertEquals(12.0, product.getMaxInterestRate(), DELTA);
    Assert.assertEquals(3.0, product.getDefInterestRate(), DELTA);
    Assert.assertFalse(product.isIncludeInLoanCounter());
    Assert.assertFalse(product.isIntDedDisbursement());
    Assert.assertFalse(product.isPrinDueLastInst());
    Assert.assertEquals(2, product.getLoanOfferingFees().size());
    Assert.assertNotNull(product.getLoanOfferingMeeting());
    Assert.assertEquals(RecurrenceType.WEEKLY, product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceTypeEnum());
    Assert.assertNotNull(product.getPrincipalGLcode());
    Assert.assertNotNull(product.getInterestGLcode());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ArrayList(java.util.ArrayList) Date(java.sql.Date) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 9 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testUpdateLoanOffering.

@Test
public void testUpdateLoanOffering() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.MONTHLY, (short) 1);
    oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(periodicFee);
    fees.add(oneTimeFee);
    product = createLoanOfferingBO("Loan Product", "LOAP");
    product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, new Money(getCurrency(), "3000"), new Money(getCurrency(), "1000"), new Money(getCurrency(), "1000"), 12.0, 2.0, 12.0, (short) 12, (short) 1, (short) 2, false, true, false, null, fees, null, (short) 2, RecurrenceType.MONTHLY, waiverInterest);
    StaticHibernateUtil.flushAndClearSession();
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals("Loan Product", product.getPrdOfferingName());
    Assert.assertEquals("LOAN", product.getPrdOfferingShortName());
    Assert.assertEquals(Short.valueOf("1"), product.getPrdCategory().getProductCategoryID());
    Assert.assertEquals(ApplicableTo.CLIENTS, product.getPrdApplicableMasterEnum());
    Assert.assertEquals(startDate, product.getStartDate());
    Assert.assertEquals(endDate, product.getEndDate());
    Assert.assertEquals("Loan Product updated", product.getDescription());
    Assert.assertEquals(GraceType.NONE, product.getGraceType());
    Assert.assertEquals(Short.valueOf("0"), product.getGracePeriodDuration());
    Assert.assertEquals(InterestType.FLAT, product.getInterestType());
    Assert.assertEquals(2.0, product.getMinInterestRate(), DELTA);
    Assert.assertEquals(12.0, product.getMaxInterestRate(), DELTA);
    Assert.assertEquals(12.0, product.getDefInterestRate(), DELTA);
    Assert.assertFalse(product.isIncludeInLoanCounter());
    Assert.assertTrue(product.isIntDedDisbursement());
    Assert.assertFalse(product.isPrinDueLastInst());
    Assert.assertEquals(2, product.getLoanOfferingFees().size());
    Assert.assertNotNull(product.getLoanOfferingMeeting());
    Assert.assertEquals(RecurrenceType.MONTHLY, product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceTypeEnum());
    Assert.assertNotNull(product.getPrincipalGLcode());
    Assert.assertNotNull(product.getInterestGLcode());
}
Also used : Money(org.mifos.framework.util.helpers.Money) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Date(java.sql.Date) Test(org.junit.Test)

Example 10 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testCreateLoanOfferingFromLoanCycle.

@Test
public void testCreateLoanOfferingFromLoanCycle() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.GRACEONALLREPAYMENTS);
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, (short) 1);
    oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(periodicFee);
    fees.add(oneTimeFee);
    LoanPrdActionForm loanPrdActionForm = new LoanPrdActionForm();
    product = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, "1234", gracePeriodType, (short) 2, interestTypes, 12.0, 2.0, 3.0, false, false, false, null, fees, null, frequency, principalglCodeEntity, intglCodeEntity, LoanOfferingTestUtils.populateNoOfInstallFromLoanCycle("3", "10", "30", "20", "20", "40", "30", "30", "50", "40", "40", "60", "50", "50", "70", "60", "60", "80", "70", LoanOfferingTestUtils.populateLoanAmountFromLoanCycle("3", new Double("1000"), new Double("3000"), new Double("2000"), new Double("2000"), new Double("4000"), new Double("3000"), new Double("3000"), new Double("5000"), new Double("4000"), new Double("4000"), new Double("6000"), new Double("5000"), new Double("5000"), new Double("7000"), new Double("6000"), new Double("6000"), new Double("8000"), new Double("7000"), loanPrdActionForm)), waiverInterest);
    product.save();
    StaticHibernateUtil.flushAndClearSession();
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals("Loan Offering", product.getPrdOfferingName());
    Assert.assertEquals("LOAP", product.getPrdOfferingShortName());
    Assert.assertEquals(Short.valueOf("1"), product.getPrdCategory().getProductCategoryID());
    Assert.assertEquals(ApplicableTo.CLIENTS, product.getPrdApplicableMasterEnum());
    Assert.assertEquals(startDate, product.getStartDate());
    Assert.assertEquals(endDate, product.getEndDate());
    Assert.assertEquals("1234", product.getDescription());
    Assert.assertEquals(GraceType.GRACEONALLREPAYMENTS.getValue(), product.getGracePeriodType().getId());
    Assert.assertEquals(Short.valueOf("2"), product.getGracePeriodDuration());
    Assert.assertEquals(InterestType.FLAT.getValue(), product.getInterestTypes().getId());
    for (Iterator<LoanAmountFromLoanCycleBO> itr = product.getLoanAmountFromLoanCycle().iterator(); itr.hasNext(); ) {
        LoanAmountFromLoanCycleBO loanAmountFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Double("3000"), loanAmountFromLoanCycleBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("1000"), loanAmountFromLoanCycleBO.getMinLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountFromLoanCycleBO.getDefaultLoanAmount());
        loanAmountFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Double("4000"), loanAmountFromLoanCycleBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("2000"), loanAmountFromLoanCycleBO.getMinLoanAmount());
        Assert.assertEquals(new Double("3000"), loanAmountFromLoanCycleBO.getDefaultLoanAmount());
        loanAmountFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Double("5000"), loanAmountFromLoanCycleBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("3000"), loanAmountFromLoanCycleBO.getMinLoanAmount());
        Assert.assertEquals(new Double("4000"), loanAmountFromLoanCycleBO.getDefaultLoanAmount());
        loanAmountFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Double("6000"), loanAmountFromLoanCycleBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("4000"), loanAmountFromLoanCycleBO.getMinLoanAmount());
        Assert.assertEquals(new Double("5000"), loanAmountFromLoanCycleBO.getDefaultLoanAmount());
        loanAmountFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Double("7000"), loanAmountFromLoanCycleBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("5000"), loanAmountFromLoanCycleBO.getMinLoanAmount());
        Assert.assertEquals(new Double("6000"), loanAmountFromLoanCycleBO.getDefaultLoanAmount());
        loanAmountFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Double("8000"), loanAmountFromLoanCycleBO.getMaxLoanAmount());
        Assert.assertEquals(new Double("6000"), loanAmountFromLoanCycleBO.getMinLoanAmount());
        Assert.assertEquals(new Double("7000"), loanAmountFromLoanCycleBO.getDefaultLoanAmount());
    }
    for (Iterator<NoOfInstallFromLoanCycleBO> itr = product.getNoOfInstallFromLoanCycle().iterator(); itr.hasNext(); ) {
        NoOfInstallFromLoanCycleBO noOfInstallFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Short("30"), noOfInstallFromLoanCycleBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("10"), noOfInstallFromLoanCycleBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("20"), noOfInstallFromLoanCycleBO.getDefaultNoOfInstall());
        noOfInstallFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Short("40"), noOfInstallFromLoanCycleBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("20"), noOfInstallFromLoanCycleBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("30"), noOfInstallFromLoanCycleBO.getDefaultNoOfInstall());
        noOfInstallFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Short("50"), noOfInstallFromLoanCycleBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("30"), noOfInstallFromLoanCycleBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("40"), noOfInstallFromLoanCycleBO.getDefaultNoOfInstall());
        noOfInstallFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Short("60"), noOfInstallFromLoanCycleBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("40"), noOfInstallFromLoanCycleBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("50"), noOfInstallFromLoanCycleBO.getDefaultNoOfInstall());
        noOfInstallFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Short("70"), noOfInstallFromLoanCycleBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("50"), noOfInstallFromLoanCycleBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("60"), noOfInstallFromLoanCycleBO.getDefaultNoOfInstall());
        noOfInstallFromLoanCycleBO = itr.next();
        Assert.assertEquals(new Short("80"), noOfInstallFromLoanCycleBO.getMaxNoOfInstall());
        Assert.assertEquals(new Short("60"), noOfInstallFromLoanCycleBO.getMinNoOfInstall());
        Assert.assertEquals(new Short("70"), noOfInstallFromLoanCycleBO.getDefaultNoOfInstall());
    }
    Assert.assertEquals(2.0, product.getMinInterestRate(), DELTA);
    Assert.assertEquals(12.0, product.getMaxInterestRate(), DELTA);
    Assert.assertEquals(3.0, product.getDefInterestRate(), DELTA);
    Assert.assertFalse(product.isIncludeInLoanCounter());
    Assert.assertFalse(product.isIntDedDisbursement());
    Assert.assertFalse(product.isPrinDueLastInst());
    Assert.assertEquals(2, product.getLoanOfferingFees().size());
    Assert.assertNotNull(product.getLoanOfferingMeeting());
    Assert.assertEquals(RecurrenceType.WEEKLY, product.getLoanOfferingMeeting().getMeeting().getMeetingDetails().getRecurrenceTypeEnum());
    Assert.assertNotNull(product.getPrincipalGLcode());
    Assert.assertNotNull(product.getInterestGLcode());
}
Also used : LoanPrdActionForm(org.mifos.accounts.productdefinition.struts.actionforms.LoanPrdActionForm) ArrayList(java.util.ArrayList) Date(java.sql.Date) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) 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