Search in sources :

Example 11 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testUpdateFeeNotMatchingFrequencyOfLoanOffering.

@Test
public void testUpdateFeeNotMatchingFrequencyOfLoanOffering() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.NONE);
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    FeeBO fee = new AmountFeeBO(TestObjectFactory.getContext(), "Loan Periodic", new CategoryTypeEntity(FeeCategory.LOAN), new FeeFrequencyTypeEntity(FeeFrequencyType.PERIODIC), intglCodeEntity, new Money(getCurrency(), "100"), false, TestObjectFactory.createMeeting(TestObjectFactory.getNewMeeting(MONTHLY, EVERY_MONTH, CUSTOMER_MEETING, MONDAY)));
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(fee);
    product = createLoanOfferingBO("Loan Product", "LOAP");
    try {
        product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, gracePeriodType, 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.WEEKLY, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) FeeFrequencyTypeEntity(org.mifos.accounts.fees.business.FeeFrequencyTypeEntity) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ArrayList(java.util.ArrayList) CategoryTypeEntity(org.mifos.accounts.fees.business.CategoryTypeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Date(java.sql.Date) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 12 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testUpdateLoanOfferingForLogging.

@Test
public void testUpdateLoanOfferingForLogging() 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");
    ((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(product);
    product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, 12.0, 2.0, 12.0, false, true, true, null, fees, null, (short) 2, RecurrenceType.MONTHLY, populateLoanPrdActionForm("1", "1", new Double("3000"), new Double("1000"), new Double("1000"), "12", "1", "2"), waiverInterest, null);
    StaticHibernateUtil.flushAndClearSession();
    StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOANPRODUCT, new Integer(product.getPrdOfferingId().toString()));
    Assert.assertEquals(1, auditLogList.size());
    Assert.assertEquals(EntityType.LOANPRODUCT.getValue(), auditLogList.get(0).getEntityType());
    Assert.assertEquals(15, auditLogList.get(0).getAuditLogRecords().size());
    for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
        if (auditLogRecord.getFieldName().equalsIgnoreCase("Min Loan Amount")) {
            Assert.assertEquals("300.0", auditLogRecord.getOldValue());
            Assert.assertEquals("1000.0", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Description")) {
            Assert.assertEquals("-", auditLogRecord.getOldValue());
            Assert.assertEquals("Loan Product updated", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Applicable For")) {
            Assert.assertEquals("Groups", auditLogRecord.getOldValue());
            Assert.assertEquals("Clients", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Frequency Of Installments")) {
            Assert.assertEquals("Week(s)", auditLogRecord.getOldValue());
            Assert.assertEquals("Month(s)", auditLogRecord.getNewValue());
        }
    }
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditInterceptor(org.mifos.framework.components.audit.util.helpers.AuditInterceptor) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.sql.Date) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Test(org.junit.Test)

Example 13 with FeeBO

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

the class LoanOfferingBOIntegrationTest method testCreateLoanOffering.

@Test
public void testCreateLoanOffering() 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);
    product = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, "1234", gracePeriodType, (short) 2, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), new Money(getCurrency(), "2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, false, false, null, fees, null, frequency, principalglCodeEntity, intglCodeEntity, ProductDefinitionConstants.LOANAMOUNTSAMEFORALLLOAN.toString(), ProductDefinitionConstants.NOOFINSTALLSAMEFORALLLOAN.toString(), 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());
    LoanAmountOption eligibleLoanAmount = product.eligibleLoanAmount(null, null);
    Assert.assertEquals(1000.0, eligibleLoanAmount.getMinLoanAmount(), DELTA);
    Assert.assertEquals(3000.0, eligibleLoanAmount.getMaxLoanAmount(), DELTA);
    Assert.assertEquals(2000, eligibleLoanAmount.getDefaultLoanAmount(), DELTA);
    Assert.assertEquals(2.0, product.getMinInterestRate(), DELTA);
    Assert.assertEquals(12.0, product.getMaxInterestRate(), DELTA);
    Assert.assertEquals(3.0, product.getDefInterestRate(), DELTA);
    LoanOfferingInstallmentRange eligibleNoOfInstall = product.eligibleNoOfInstall(null, null);
    Assert.assertEquals(Short.valueOf("11"), eligibleNoOfInstall.getMinNoOfInstall());
    Assert.assertEquals(Short.valueOf("20"), eligibleNoOfInstall.getMaxNoOfInstall());
    Assert.assertEquals(Short.valueOf("17"), eligibleNoOfInstall.getDefaultNoOfInstall());
    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 : 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 14 with FeeBO

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

the class FeeInstallmentTest method createWeeklyFeeBO.

private FeeBO createWeeklyFeeBO(int every) {
    MeetingBO feeMeeting = new MeetingBuilder().every(every).weekly().build();
    FeeBO feeBO = new AmountFeeBO(new Money(TestUtils.RUPEE, "10.0"), "Fee", FeeCategory.ALLCUSTOMERS, FeeFrequencyType.PERIODIC, new GLCodeEntity(Short.valueOf("1"), "10000"), feeMeeting, null, new DateTime().minusDays(14).toDate(), TestUtils.makeUserWithLocales().getId());
    return feeBO;
}
Also used : Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) DateTime(org.joda.time.DateTime)

Example 15 with FeeBO

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

the class LoanPrdAction method loadMasterData.

private void loadMasterData(HttpServletRequest request) throws Exception {
    logger.debug("start Load master data method of Loan Product Action ");
    LoanPrdBusinessService service = new LoanPrdBusinessService();
    List<FeeBO> fees = feeDao.getAllAppllicableFeeForLoanCreation();
    List<PenaltyBO> penalties = penaltyDao.getAllAppllicablePenaltyForLoanCreation();
    Short localeId = getUserContext(request).getLocaleId();
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANPRODUCTCATEGORYLIST, service.getActiveLoanProductCategories(), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANAPPLFORLIST, service.getLoanApplicableCustomerTypes(localeId), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANGRACEPERIODTYPELIST, legacyMasterDao.findMasterDataEntitiesWithLocale(GracePeriodTypeEntity.class), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.INTERESTTYPESLIST, legacyMasterDao.findMasterDataEntitiesWithLocale(InterestTypesEntity.class), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.INTCALCTYPESLIST, legacyMasterDao.findMasterDataEntitiesWithLocale(InterestCalcTypeEntity.class), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.SRCFUNDSLIST, this.fundDao.findAllFunds(), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANFEESLIST, getFeeViewList(getUserContext(request), fees), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANPENALTIESLIST, getPenaltyViewList(penalties), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANPRICIPALGLCODELIST, getGLCodes(FinancialActionConstants.PRINCIPALPOSTING, FinancialConstants.CREDIT), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANINTERESTGLCODELIST, getGLCodes(FinancialActionConstants.INTERESTPOSTING, FinancialConstants.CREDIT), request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANPRDFEE, fees, request);
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.LOANPRDPENALTY, penalties, request);
    SessionUtils.setAttribute("GlNamesMode", AccountingRules.getGlNamesMode(), request);
    setQuestionGroupsOnSession(request, getQuestionnaireServiceFacade(request));
    logger.debug("Load master data method of Loan Product Action called");
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) PenaltyBO(org.mifos.accounts.penalties.business.PenaltyBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) LoanPrdBusinessService(org.mifos.accounts.productdefinition.business.service.LoanPrdBusinessService) FeeBO(org.mifos.accounts.fees.business.FeeBO) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)

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