Search in sources :

Example 11 with PrdOfferingPersistence

use of org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence in project head by mifos.

the class PrdOfferingBO method update.

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) throws ProductDefinitionException {
    vaildate(prdOfferingName, prdOfferingShortName, prdCategory, prdApplicableMaster, startDate);
    validateStartDateForUpdate(startDate);
    validateEndDateAgainstCurrentDate(startDate, endDate);
    if (!prdOfferingName.equals(this.prdOfferingName)) {
        validateDuplicateProductOfferingName(prdOfferingName);
    }
    if (!prdOfferingShortName.equals(this.prdOfferingShortName)) {
        validateDuplicateProductOfferingShortName(prdOfferingShortName);
    }
    this.prdOfferingName = prdOfferingName;
    this.prdOfferingShortName = prdOfferingShortName;
    this.prdCategory = prdCategory;
    this.prdApplicableMaster = prdApplicableMaster;
    this.startDate = startDate;
    this.endDate = endDate;
    this.description = description;
    try {
        this.prdStatus = new PrdOfferingPersistence().getPrdStatus(status);
    } catch (PersistenceException pe) {
        throw new ProductDefinitionException(pe);
    }
    logger.debug("creating product offering done");
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 12 with PrdOfferingPersistence

use of org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence in project head by mifos.

the class PrdOfferingBO method validateDuplicateProductOfferingName.

private void validateDuplicateProductOfferingName(final String productOfferingName) throws ProductDefinitionException {
    logger.debug("Checking for duplicate product offering name");
    try {
        PrdOfferingPersistence prdOfferingPersistence = new PrdOfferingPersistence();
        Integer count = prdOfferingPersistence.getProductOfferingNameCount(productOfferingName);
        if (!count.equals(0)) {
            throw new ProductDefinitionException(ProductDefinitionConstants.DUPLPRDINSTNAME);
        }
    } catch (PersistenceException e) {
        throw new ProductDefinitionException(e);
    }
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 13 with PrdOfferingPersistence

use of org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence in project head by mifos.

the class PrdOfferingBO method getPrdStatus.

private PrdStatusEntity getPrdStatus(final Date startDate, final ProductTypeEntity prdType) throws ProductDefinitionException {
    logger.debug("getting the Product status for prdouct offering with start date :" + startDate + " and product Type :" + prdType.getProductTypeID());
    PrdStatus prdStatus = null;
    if (!prdType.getProductTypeID().equals(ProductType.LOAN.getValue()) && startDate.compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) == 0) {
        prdStatus = getActivePrdStatus(prdType);
    } else if (prdType.getProductTypeID().equals(ProductType.LOAN.getValue()) && startDate.compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) <= 0) {
        prdStatus = getActivePrdStatus(prdType);
    } else {
        prdStatus = getInActivePrdStatus(prdType);
    }
    try {
        logger.debug("getting the Product status for product status :" + prdStatus);
        return new PrdOfferingPersistence().getPrdStatus(prdStatus);
    } catch (PersistenceException e) {
        throw new ProductDefinitionException(e);
    }
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PrdStatus(org.mifos.accounts.productdefinition.util.helpers.PrdStatus)

Aggregations

PrdOfferingPersistence (org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence)13 PersistenceException (org.mifos.framework.exceptions.PersistenceException)11 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 ArrayList (java.util.ArrayList)4 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)4 DateTime (org.joda.time.DateTime)3 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)3 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)2 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)2 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)2 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)2 ApplicableTo (org.mifos.accounts.productdefinition.util.helpers.ApplicableTo)2 MifosCurrency (org.mifos.application.master.business.MifosCurrency)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 RecurrenceType (org.mifos.application.meeting.util.helpers.RecurrenceType)2 PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)2 ProductDetailsDto (org.mifos.dto.domain.ProductDetailsDto)2 BigDecimal (java.math.BigDecimal)1 Date (java.sql.Date)1 Date (java.util.Date)1