Search in sources :

Example 61 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class TestObjectFactory method createLoanOffering.

public static LoanOfferingBO createLoanOffering(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus offeringStatus, final Double defLnAmnt, final Double defIntRate, final Short defInstallments, final InterestType interestType, final boolean interestDeductedAtDisbursement, final boolean principalDueInLastInstallment, final MeetingBO meeting, final GraceType graceType, final short gracePeriodDuration, final String loanAmountCalcType, final String noOfInstallCalcType, final MifosCurrency currency, VariableInstallmentDetailsBO variableInstallmentDetails) {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    ProductCategoryBO productCategory = TestObjectFactory.getLoanPrdCategory();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(graceType);
    InterestTypesEntity interestTypes = new InterestTypesEntity(interestType);
    GLCodeEntity glCodePrincipal = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.LOANS_TO_CLIENTS);
    GLCodeEntity glCodeInterest = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.INTEREST_ON_LOANS);
    LoanOfferingBO loanOffering;
    boolean loanCounter = true;
    boolean waiverInterest = true;
    try {
        loanOffering = new LoanOfferingBO(getContext(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, gracePeriodType, gracePeriodDuration, interestTypes, new Money(currency, defLnAmnt.toString()), new Money(currency, defLnAmnt.toString()), new Money(currency, defLnAmnt.toString()), defIntRate, defIntRate, defIntRate, defInstallments, defInstallments, defInstallments, loanCounter, interestDeductedAtDisbursement, principalDueInLastInstallment, new ArrayList<FundBO>(), new ArrayList<FeeBO>(), new ArrayList<PenaltyBO>(), meeting, glCodePrincipal, glCodeInterest, loanAmountCalcType, noOfInstallCalcType, waiverInterest);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    }
    loanOffering.setCurrency(currency);
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(offeringStatus);
    LoanOfferingTestUtils.setStatus(loanOffering, prdStatus);
    LoanOfferingTestUtils.setGracePeriodType(loanOffering, gracePeriodType, gracePeriodDuration);
    if (variableInstallmentDetails != null) {
        loanOffering.setVariableInstallmentsAllowed(true);
        loanOffering.setVariableInstallmentDetails(variableInstallmentDetails);
    }
    IntegrationTestObjectMother.saveLoanProducts(loanOffering);
    return IntegrationTestObjectMother.findLoanProductBySystemId(loanOffering.getGlobalPrdOfferingNum());
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 62 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class TestObjectFactory method createLoanOffering.

/**
     * @param defLnAmnt       - Loan Amount same would be set as min and max amounts
     * @param defIntRate      - Interest Rate same would be set as min and max amounts
     * @param defInstallments Number of installments set as min and max amounts
     */
public static LoanOfferingBO createLoanOffering(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus offeringStatus, final Double defLnAmnt, final Double defIntRate, final Short defInstallments, final InterestType interestType, final boolean interestDeductedAtDisbursement, final boolean principalDueInLastInstallment, final MeetingBO meeting, final GraceType graceType) {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    ProductCategoryBO productCategory = TestObjectFactory.getLoanPrdCategory();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(graceType);
    InterestTypesEntity interestTypes = new InterestTypesEntity(interestType);
    GLCodeEntity glCodePrincipal = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("11"));
    GLCodeEntity glCodeInterest = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("21"));
    LoanOfferingBO loanOffering;
    short gracePeriodDuration = (short) 0;
    boolean loanCounter = true;
    boolean waiverInterest = true;
    try {
        loanOffering = new LoanOfferingBO(getContext(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, gracePeriodType, gracePeriodDuration, interestTypes, TestUtils.createMoney(defLnAmnt), TestUtils.createMoney(defLnAmnt), TestUtils.createMoney(defLnAmnt), defIntRate, defIntRate, defIntRate, defInstallments, defInstallments, defInstallments, loanCounter, interestDeductedAtDisbursement, principalDueInLastInstallment, new ArrayList<FundBO>(), new ArrayList<FeeBO>(), new ArrayList<PenaltyBO>(), meeting, glCodePrincipal, glCodeInterest, waiverInterest);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    }
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(offeringStatus);
    LoanOfferingTestUtils.setStatus(loanOffering, prdStatus);
    LoanOfferingTestUtils.setGracePeriodType(loanOffering, gracePeriodType, gracePeriodDuration);
    return (LoanOfferingBO) testObjectPersistence.persist(loanOffering);
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 63 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class TestObjectFactory method createCompleteLoanOfferingObject.

public static LoanOfferingBO createCompleteLoanOfferingObject() throws Exception {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.GROUPS);
    MeetingBO frequency = TestObjectFactory.createMeeting(getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    GLCodeEntity principalglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.BANK_ACCOUNT_ONE);
    GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, TestGeneralLedgerCode.BANK_ACCOUNT_ONE);
    ProductCategoryBO productCategory = getLoanPrdCategory();
    InterestTypesEntity interestTypes = new InterestTypesEntity(InterestType.FLAT);
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(GraceType.GRACEONALLREPAYMENTS);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    List<FundBO> funds = new ArrayList<FundBO>();
    FundBO fundBO = (FundBO) StaticHibernateUtil.getSessionTL().get(FundBO.class, Short.valueOf("2"));
    funds.add(fundBO);
    LoanOfferingBO loanOfferingBO = new LoanOfferingBO(getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, DateUtils.getCurrentDateWithoutTimeStamp(), null, null, gracePeriodType, (short) 2, interestTypes, TestUtils.createMoney("1000"), TestUtils.createMoney("3000"), TestUtils.createMoney("2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, false, false, funds, fees, null, frequency, principalglCodeEntity, intglCodeEntity, true);
    loanOfferingBO.save();
    return loanOfferingBO;
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) FundBO(org.mifos.accounts.fund.business.FundBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 64 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class ReportProductOfferingServiceIntegrationTest method testGetLoanOffering1ReturnsLoanOffering.

@Test
public void testGetLoanOffering1ReturnsLoanOffering() throws Exception {
    LoanOfferingBO loanOffering1 = LoanOfferingBO.createInstanceForTest(LOAN_OFFERING_1_ID);
    expect(loanPrdBusinessServiceMock.getLoanOffering(LOAN_OFFERING_1_ID)).andReturn(loanOffering1);
    replay(loanPrdBusinessServiceMock);
    LoanOfferingBO retrievedLoanOffering = reportProductOfferingService.getLoanOffering1();
    verify(loanPrdBusinessServiceMock);
    Assert.assertEquals(loanOffering1, retrievedLoanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 65 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class CustomerBOIntegrationTest method getLoanAccount.

private AccountBO getLoanAccount(CustomerBO customer, MeetingBO meeting) {
    Date startDate = new Date(System.currentTimeMillis());
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    return TestObjectFactory.createLoanAccount("42423142341", customer, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.sql.Date)

Aggregations

LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)135 MeetingBO (org.mifos.application.meeting.business.MeetingBO)44 Date (java.util.Date)37 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)26 Date (java.sql.Date)21 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 LocalDate (org.joda.time.LocalDate)17 CustomerBO (org.mifos.customers.business.CustomerBO)12 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)11 UserContext (org.mifos.security.util.UserContext)9 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 Money (org.mifos.framework.util.helpers.Money)8 MifosUser (org.mifos.security.MifosUser)8 BusinessRuleException (org.mifos.service.BusinessRuleException)8 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 BigDecimal (java.math.BigDecimal)6 AccountException (org.mifos.accounts.exceptions.AccountException)6 FeeBO (org.mifos.accounts.fees.business.FeeBO)6