Search in sources :

Example 41 with Date

use of java.sql.Date 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)

Example 42 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testBuildloanOfferingWithoutName.

@Test
public void testBuildloanOfferingWithoutName() throws SystemException, ApplicationException {
    createIntitalObjects();
    try {
        new LoanOfferingBO(TestObjectFactory.getContext(), null, "S", productCategory, prdApplicableMaster, new Date(System.currentTimeMillis()), 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) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Example 43 with Date

use of java.sql.Date 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 44 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testUpdateloanOfferingWithDuplicatePrdOfferingShortName.

@Test
public void testUpdateloanOfferingWithDuplicatePrdOfferingShortName() throws SystemException, ApplicationException {
    product = createLoanOfferingBO("Loan Product", "LOAP");
    LoanOfferingBO loanOffering1 = createLoanOfferingBO("Loan Product1", "LOA1");
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    try {
        loanOffering1.update((short) 1, "Loan Product1", "LOAP", productCategory, prdApplicableMaster, startDate, null, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, new Money(getCurrency(), "3000"), new Money(getCurrency(), "1000"), new Money(getCurrency(), "2000"), 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, null, null, null, (short) 2, RecurrenceType.WEEKLY, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
    TestObjectFactory.removeObject(loanOffering1);
}
Also used : Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Example 45 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testUpdateDefInterestRateNotBetweenMinMaxRates.

@Test
public void testUpdateDefInterestRateNotBetweenMinMaxRates() {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    product = createLoanOfferingBO("Loan Product", "LOAP");
    try {
        product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, null, "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, 13.0, (short) 20, (short) 1, (short) 12, false, false, false, null, null, null, (short) 2, RecurrenceType.WEEKLY, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

Date (java.sql.Date)689 Test (org.junit.Test)286 PreparedStatement (java.sql.PreparedStatement)127 ResultSet (java.sql.ResultSet)122 Timestamp (java.sql.Timestamp)117 Connection (java.sql.Connection)107 Money (org.mifos.framework.util.helpers.Money)83 ArrayList (java.util.ArrayList)66 SQLException (java.sql.SQLException)60 Properties (java.util.Properties)60 Time (java.sql.Time)55 PDate (org.apache.phoenix.schema.types.PDate)55 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)50 LocalDate (java.time.LocalDate)42 BigDecimal (java.math.BigDecimal)41 MeetingBO (org.mifos.application.meeting.business.MeetingBO)39 Test (org.testng.annotations.Test)39 Calendar (java.util.Calendar)36 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)30 DateWritable (org.apache.hadoop.hive.serde2.io.DateWritable)28