Search in sources :

Example 1 with ProductDefinitionException

use of org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException in project head by mifos.

the class LoanOfferingBO method update.

// FIXME this update is only used by tests, is not the right logic
public void update(final Short userId, final String prdOfferingName, final String prdOfferingShortName, final ProductCategoryBO prdCategory, final PrdApplicableMasterEntity prdApplicableMaster, final Date startDate, final Date endDate, final String description, final PrdStatus status, final GracePeriodTypeEntity gracePeriodType, final InterestTypesEntity interestTypes, final Short gracePeriodDuration, final Money maxLoanAmount, final Money minLoanAmount, final Money defaultLoanAmount, final Double maxInterestRate, final Double minInterestRate, final Double defInterestRate, final Short maxNoInstallments, final Short minNoInstallments, final Short defNoInstallments, final boolean loanCounter, final boolean intDedDisbursement, final boolean prinDueLastInst, final List<FundBO> funds, final List<FeeBO> fees, final List<PenaltyBO> penalties, final Short recurAfter, final RecurrenceType recurrenceType, boolean waiverInterest) throws ProductDefinitionException {
    logger.debug("Updating loan Offering :" + prdOfferingName);
    super.update(userId, prdOfferingName, prdOfferingShortName, prdCategory, prdApplicableMaster, startDate, endDate, description, status);
    validateForUpdate(gracePeriodType, gracePeriodDuration, interestTypes, minLoanAmount, maxLoanAmount, defaultLoanAmount, maxInterestRate, minInterestRate, defInterestRate, maxNoInstallments, minNoInstallments, defNoInstallments, loanCounter, intDedDisbursement, prinDueLastInst, funds, fees, recurAfter);
    setUpdateDetails(userId);
    setGracePeriodTypeAndDuration(intDedDisbursement, gracePeriodType, gracePeriodDuration);
    this.interestTypes = interestTypes;
    this.maxInterestRate = maxInterestRate;
    this.minInterestRate = minInterestRate;
    this.defInterestRate = defInterestRate;
    setLoanCounter(loanCounter);
    setWaiverInterest(waiverInterest);
    setIntDedDisbursement(intDedDisbursement);
    setPrinDueLastInst(prinDueLastInst);
    setMeetingDetails(startDate, recurAfter, recurrenceType);
    setFunds(funds);
    setFees(fees);
    setPenalties(penalties);
    try {
        getLoanPrdPersistence().createOrUpdate(this);
    } catch (PersistenceException e) {
        throw new ProductDefinitionException(e);
    }
    logger.debug("Loan Offering updated:" + prdOfferingName);
}
Also used : ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 2 with ProductDefinitionException

use of org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException in project head by mifos.

the class PrdOfferingBO method generatePrdOfferingGlobalNum.

private String generatePrdOfferingGlobalNum() throws ProductDefinitionException {
    logger.debug("Generating new product Offering global number");
    StringBuilder globalPrdOfferingNum = new StringBuilder();
    globalPrdOfferingNum.append(userContext.getBranchId());
    globalPrdOfferingNum.append("-");
    Short maxPrdID = null;
    try {
        maxPrdID = new PrdOfferingPersistence().getMaxPrdOffering();
    } catch (PersistenceException e) {
        throw new ProductDefinitionException(e);
    }
    globalPrdOfferingNum.append(StringUtils.leftPad(String.valueOf(maxPrdID != null ? maxPrdID + 1 : ProductDefinitionConstants.DEFAULTMAX + 1), 3, '0'));
    logger.debug("Generation of new product Offering global number done" + globalPrdOfferingNum);
    return globalPrdOfferingNum.toString();
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 3 with ProductDefinitionException

use of org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException in project head by mifos.

the class ProductCategoryBO method generatePrdCategoryNum.

/**
     * @deprecated
     */
@Deprecated
private String generatePrdCategoryNum() throws ProductDefinitionException {
    logger.debug("Generating new product category global number");
    StringBuilder globalPrdOfferingNum = new StringBuilder();
    globalPrdOfferingNum.append(userContext.getBranchId());
    globalPrdOfferingNum.append("-");
    Short maxPrdID;
    try {
        maxPrdID = getLegacyProductCategoryDao().getMaxPrdCategoryId();
    } catch (PersistenceException e) {
        throw new ProductDefinitionException(e);
    }
    globalPrdOfferingNum.append(StringUtils.leftPad(String.valueOf(maxPrdID != null ? maxPrdID + 1 : ProductDefinitionConstants.DEFAULTMAX), 3, '0'));
    logger.debug("Generation of new product category global number done");
    return globalPrdOfferingNum.toString();
}
Also used : ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 4 with ProductDefinitionException

use of org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException in project head by mifos.

the class LoanOfferingBOIntegrationTest method testBuildloanOfferingWithEndDateLessThanStartDate.

@Test
public void testBuildloanOfferingWithEndDateLessThanStartDate() throws SystemException, ApplicationException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(-2);
    try {
        new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, null, null, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), null, 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, null, null, null, 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 5 with ProductDefinitionException

use of org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException in project head by mifos.

the class LoanOfferingBOIntegrationTest method testBuildloanOfferingWithoutGLCode.

@Test
public void testBuildloanOfferingWithoutGLCode() throws SystemException, ApplicationException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    try {
        new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, interestTypes, new Money(getCurrency(), "1000.0"), new Money(getCurrency(), "3000"), 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, frequency, null, null, 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

ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)65 Test (org.junit.Test)51 Date (java.sql.Date)50 Money (org.mifos.framework.util.helpers.Money)49 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)13 PersistenceException (org.mifos.framework.exceptions.PersistenceException)9 ArrayList (java.util.ArrayList)5 InterestTypesEntity (org.mifos.application.master.business.InterestTypesEntity)5 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)4 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)4 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)4 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)4 PrdOfferingPersistence (org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)3 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)2 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)2 FeeBO (org.mifos.accounts.fees.business.FeeBO)2 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)2