Search in sources :

Example 1 with ProductMixBusinessService

use of org.mifos.accounts.productsmix.business.service.ProductMixBusinessService in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveProductMixDetails.

@Override
public ProductMixDetailsDto retrieveProductMixDetails(Short prdOfferingId, String productType) {
    try {
        ProductMixBusinessService service = new ProductMixBusinessService();
        PrdOfferingBO product = service.getPrdOfferingByID(prdOfferingId);
        List<PrdOfferingBO> allowedPrdOfferingList = service.getAllowedPrdOfferingsByType(prdOfferingId.toString(), productType);
        List<PrdOfferingBO> notAllowedPrdOfferingList = service.getNotAllowedPrdOfferingsByType(prdOfferingId.toString());
        List<PrdOfferingDto> allowedPrdOfferingNames = new ArrayList<PrdOfferingDto>();
        List<PrdOfferingDto> notAllowedPrdOfferingNames = new ArrayList<PrdOfferingDto>();
        for (PrdOfferingBO prdOffering : allowedPrdOfferingList) {
            allowedPrdOfferingNames.add(prdOffering.toDto());
        }
        for (PrdOfferingBO prdOffering : notAllowedPrdOfferingList) {
            notAllowedPrdOfferingNames.add(prdOffering.toDto());
        }
        ProductMixDetailsDto dto = new ProductMixDetailsDto(prdOfferingId, product.getPrdOfferingName(), product.getPrdType().getProductTypeID(), allowedPrdOfferingNames, notAllowedPrdOfferingNames);
        return dto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) ProductMixBusinessService(org.mifos.accounts.productsmix.business.service.ProductMixBusinessService) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ArrayList(java.util.ArrayList) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) ProductMixDetailsDto(org.mifos.dto.screen.ProductMixDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with ProductMixBusinessService

use of org.mifos.accounts.productsmix.business.service.ProductMixBusinessService in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveAllProductMix.

@Override
public ProductDto retrieveAllProductMix() {
    try {
        List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
        List<PrdOfferingBO> prdOfferingList = new ProductMixBusinessService().getPrdOfferingMix();
        List<ProductCategoryTypeDto> pcList = new ArrayList<ProductCategoryTypeDto>();
        for (ProductCategoryBO pcBO : productCategoryList) {
            ProductCategoryTypeDto pcDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
            pcList.add(pcDto);
        }
        List<ProductMixDto> pmList = new ArrayList<ProductMixDto>();
        for (PrdOfferingBO poBO : prdOfferingList) {
            ProductMixDto pmDto = new ProductMixDto(poBO.getPrdCategory().getProductType().getProductTypeID(), poBO.getPrdOfferingId(), poBO.getPrdType().getProductTypeID(), poBO.getPrdOfferingName());
            pmList.add(pmDto);
        }
        ProductDto productDto = new ProductDto(pcList, pmList);
        return productDto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductMixBusinessService(org.mifos.accounts.productsmix.business.service.ProductMixBusinessService) ArrayList(java.util.ArrayList) ProductMixDto(org.mifos.dto.screen.ProductMixDto) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ProductCategoryTypeDto(org.mifos.dto.screen.ProductCategoryTypeDto) ProductDto(org.mifos.dto.screen.ProductDto) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with ProductMixBusinessService

use of org.mifos.accounts.productsmix.business.service.ProductMixBusinessService in project head by mifos.

the class ProductMixValidatorIntegrationTest method testShouldReturnAllLoansIfNotGlim.

@Test
public void testShouldReturnAllLoansIfNotGlim() throws Exception {
    expect(configServiceMock.isGlimEnabled()).andReturn(false);
    replay(loanMock, customerMock, configServiceMock);
    Assert.assertEquals(Arrays.asList(loanMock), new ProductMixValidator(configServiceMock, new ProductMixBusinessService()).getLoansToCheckAgainstProductMix(customerMock, Arrays.asList(loanMock)));
    verify(loanMock, customerMock, configServiceMock);
}
Also used : ProductMixBusinessService(org.mifos.accounts.productsmix.business.service.ProductMixBusinessService) Test(org.junit.Test)

Aggregations

ProductMixBusinessService (org.mifos.accounts.productsmix.business.service.ProductMixBusinessService)3 ArrayList (java.util.ArrayList)2 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 ServiceException (org.mifos.framework.exceptions.ServiceException)2 Test (org.junit.Test)1 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)1 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)1 PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)1 SavingsProductDto (org.mifos.dto.domain.SavingsProductDto)1 ProductCategoryTypeDto (org.mifos.dto.screen.ProductCategoryTypeDto)1 ProductDto (org.mifos.dto.screen.ProductDto)1 ProductMixDetailsDto (org.mifos.dto.screen.ProductMixDetailsDto)1 ProductMixDto (org.mifos.dto.screen.ProductMixDto)1