use of java.sql.Date in project head by mifos.
the class LoanOfferingBOIntegrationTest method testLoanOfferingWithEqualPrincipalDecliningInterestDeductionAtDisbursement.
@Test
public void testLoanOfferingWithEqualPrincipalDecliningInterestDeductionAtDisbursement() {
try {
createIntitalObjects();
interestTypes = new InterestTypesEntity(InterestType.DECLINING_EPI);
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(2);
new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, null, null, 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, true, false, null, null, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
Assert.fail();
} catch (ProductDefinitionException e) {
Assert.assertEquals("exceptions.declineinterestdisbursementdeduction", e.getKey());
}
}
use of java.sql.Date in project head by mifos.
the class LoanOfferingBOIntegrationTest method testUpdateGracePeriodForIntDedAtDisb.
@Test
public void testUpdateGracePeriodForIntDedAtDisb() throws ProductDefinitionException {
createIntitalObjects();
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(2);
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, null, null, (short) 2, RecurrenceType.WEEKLY, waiverInterest);
StaticHibernateUtil.flushAndClearSession();
product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
Assert.assertNotNull(product.getGracePeriodType());
Assert.assertNotNull(product.getGracePeriodDuration());
Assert.assertEquals(GraceType.NONE.getValue(), product.getGracePeriodType().getId());
Assert.assertEquals(Short.valueOf("0"), product.getGracePeriodDuration());
}
use of java.sql.Date in project head by mifos.
the class LoanOfferingBOIntegrationTest method testNullGracePeriodDurationForNoneGraceType.
@Test
public void testNullGracePeriodDurationForNoneGraceType() throws ProductDefinitionException {
createIntitalObjects();
GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.NONE);
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(2);
LoanOfferingBO loanOffering = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, gracePeriodType, null, 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, null, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
Assert.assertNotNull(loanOffering.getGracePeriodDuration());
Assert.assertEquals(GraceType.NONE.getValue(), loanOffering.getGracePeriodType().getId());
Assert.assertEquals(Short.valueOf("0"), loanOffering.getGracePeriodDuration());
}
use of java.sql.Date 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());
}
use of java.sql.Date in project head by mifos.
the class LoanOfferingBOIntegrationTest method testBuildloanOfferingWithDuplicatePrdOfferingName.
@Test
public void testBuildloanOfferingWithDuplicatePrdOfferingName() throws SystemException, ApplicationException {
product = createLoanOfferingBO("Loan Product", "LOAP");
createIntitalObjects();
Date startDate = offSetCurrentDate(0);
try {
new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
Assert.fail();
} catch (ProductDefinitionException e) {
}
}
Aggregations