Search in sources :

Example 11 with PrdOfferingDto

use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.

the class CreateSavingsAccountController method getProductOfferings.

public void getProductOfferings(CreateSavingsAccountFormBean formBean) {
    List<PrdOfferingDto> savingsProducts = savingsServiceFacade.retrieveApplicableSavingsProductsForCustomer(formBean.getCustomer().getCustomerId());
    Map<String, String> offerings = new HashMap<String, String>(savingsProducts.size());
    for (PrdOfferingDto offering : savingsProducts) {
        offerings.put(offering.getPrdOfferingId().toString(), offering.getPrdOfferingName());
    }
    formBean.setProductOfferings(savingsProducts);
    formBean.setProductOfferingOptions(offerings);
}
Also used : HashMap(java.util.HashMap) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto)

Example 12 with PrdOfferingDto

use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.

the class DefineProductMixController method populateAllowedNotAllowedOptions.

private void populateAllowedNotAllowedOptions(ProductMixFormBean formBean) {
    Map<String, String> allowedProductOptions = new LinkedHashMap<String, String>();
    Map<String, String> notAllowedProductOptions = new LinkedHashMap<String, String>();
    List<PrdOfferingDto> allowedProductsInMix = this.adminServiceFacade.retrieveAllowedProductsForMix(Integer.parseInt(formBean.getProductTypeId()), Integer.parseInt(formBean.getProductId()));
    for (PrdOfferingDto allowedProduct : allowedProductsInMix) {
        allowedProductOptions.put(allowedProduct.getPrdOfferingId().toString(), allowedProduct.getPrdOfferingName());
    }
    List<PrdOfferingDto> notAllowedProductsInMix = this.adminServiceFacade.retrieveNotAllowedProductsForMix(Integer.parseInt(formBean.getProductTypeId()), Integer.parseInt(formBean.getProductId()));
    for (PrdOfferingDto notAllowedProduct : notAllowedProductsInMix) {
        notAllowedProductOptions.put(notAllowedProduct.getPrdOfferingId().toString(), notAllowedProduct.getPrdOfferingName());
    }
    formBean.setAllowedProductOptions(allowedProductOptions);
    formBean.setNotAllowedProductOptions(notAllowedProductOptions);
}
Also used : PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with PrdOfferingDto

use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.

the class CreateSavingsAccountControllerTest method setUp.

@Before
public void setUp() {
    controller = new CreateSavingsAccountController();
    QuestionnaireServiceFacade questionnaireServiceFacade = mock(QuestionnaireServiceFacade.class);
    controller.setQuestionnaireServiceFacade(questionnaireServiceFacade);
    savingsServiceFacade = mock(SavingsServiceFacade.class);
    controller.setSavingsServiceFacade(savingsServiceFacade);
    formBean = mock(CreateSavingsAccountFormBean.class);
    offering = new PrdOfferingDto((short) 1, "Offering 1", "10001");
    offerings = new ArrayList<PrdOfferingDto>(1);
    offerings.add(offering);
    customer = new CustomerDto();
    customer.setCustomerId(1);
    when(formBean.getCustomer()).thenReturn(customer);
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) SavingsServiceFacade(org.mifos.application.servicefacade.SavingsServiceFacade) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) Before(org.junit.Before)

Example 14 with PrdOfferingDto

use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveAllowedProductsForMix.

@Override
public List<PrdOfferingDto> retrieveAllowedProductsForMix(Integer productTypeId, Integer productId) {
    try {
        List<PrdOfferingDto> allowedProductDtos = new ArrayList<PrdOfferingDto>();
        List<PrdOfferingBO> allowedProducts = new PrdOfferingPersistence().getAllowedPrdOfferingsForMixProduct(productId.toString(), productTypeId.toString());
        for (PrdOfferingBO product : allowedProducts) {
            allowedProductDtos.add(product.toDto());
        }
        return allowedProductDtos;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 15 with PrdOfferingDto

use of org.mifos.dto.domain.PrdOfferingDto in project head by mifos.

the class XlsSavingsAccountImporter method parse.

public ParsedSavingsDto parse(InputStream is) {
    ParsedSavingsDto result = null;
    List<String> errors = new ArrayList<String>();
    // temporary list for new accounts numbers, currently
    List<String> newAccountsNumbers = new ArrayList<String>();
    // not used
    List<ImportedSavingDetail> parsedSavingDetails = new ArrayList<ImportedSavingDetail>();
    try {
        HSSFWorkbook workbook = new HSSFWorkbook(is);
        HSSFSheet sheet = workbook.getSheetAt(0);
        HSSFRow row = sheet.getRow(XlsSavingsImportTemplateConstants.FIRST_ROW_WITH_DATA.getValue());
        if (row == null) {
            throw new XlsParsingException(getMessage(XlsMessageConstants.NOT_ENOUGH_INPUT_ROW, null));
        }
        Iterator<Row> iterator = sheet.rowIterator();
        while (iterator.hasNext() && (iterator.next().getRowNum() < XlsSavingsImportTemplateConstants.FIRST_ROW_WITH_DATA.getValue() - 1)) ;
        while (iterator.hasNext()) {
            row = (HSSFRow) iterator.next();
            List<Object> params = new ArrayList<Object>();
            XlsSavingsImportTemplateConstants currentCell = XlsSavingsImportTemplateConstants.ACCOUNT_NUMBER;
            try {
                String accountNumber = getCellStringValue(row, currentCell);
                if (StringUtils.isBlank(accountNumber)) {
                    accountNumber = null;
                } else if (!StringUtils.isBlank(accountNumber)) {
                    // ...but it's duplicate
                    if (!validateAccountNumber(accountNumber, newAccountsNumbers)) {
                        params.clear();
                        params.add(accountNumber);
                        throw new XlsParsingException(getCellError(XlsMessageConstants.DUPLICATE_GLOBAL_NUM_ERROR, row, currentCell.getValue(), params));
                    }
                }
                currentCell = XlsSavingsImportTemplateConstants.CUSTOMER_GLOBAL_ID;
                String customerGlobalId = getCellStringValue(row, currentCell);
                if (customerGlobalId.isEmpty()) {
                    params.clear();
                    params.add(customerGlobalId);
                    throw new XlsParsingException(getCellError(XlsMessageConstants.CUSTOMER_NOT_BLANK, row, currentCell.getValue(), params));
                }
                CustomerBO customerBO = null;
                customerBO = validateCustomerGlobalId(customerGlobalId);
                if (customerBO == null) {
                    params.clear();
                    params.add(customerGlobalId);
                    throw new XlsParsingException(getCellError(XlsMessageConstants.CUSTOMER_NOT_FOUND, row, currentCell.getValue(), params));
                }
                currentCell = XlsSavingsImportTemplateConstants.PRODUCT_NAME;
                String productName = getCellStringValue(row, currentCell);
                PrdOfferingDto prdOfferingDto = null;
                prdOfferingDto = validateProductName(productName, customerBO, row, currentCell.getValue());
                currentCell = XlsSavingsImportTemplateConstants.STATUS_NAME;
                String statusName = getCellStringValue(row, currentCell);
                XlsLoanSavingsAccountStatesConstants statusConstant = null;
                statusConstant = validateStatusName(statusName, customerBO, row, currentCell.getValue());
                currentCell = XlsSavingsImportTemplateConstants.CANCEL_FlAG_REASON;
                String cancelReason = getCellStringValue(row, currentCell);
                XlsLoanSavingsFlagsConstants flagConstant = null;
                flagConstant = validateStatusFlagReason(cancelReason, statusName, AccountTypes.SAVINGS_ACCOUNT, row, currentCell.getValue());
                currentCell = XlsSavingsImportTemplateConstants.SAVINGS_AMOUNT;
                BigDecimal savingAmount = getCellDecimalValue(row, currentCell);
                if (savingAmount == BigDecimal.valueOf(0) || null == savingAmount) {
                    savingAmount = savingsProductDao.findBySystemId(prdOfferingDto.getGlobalPrdOfferingNum()).getRecommendedAmount().getAmount();
                }
                currentCell = XlsSavingsImportTemplateConstants.SAVINGS_BALANCE;
                BigDecimal savingBalance = getCellDecimalValue(row, currentCell);
                if (savingBalance == null) {
                    savingBalance = BigDecimal.valueOf(0);
                }
                if (accountNumber != null) {
                    newAccountsNumbers.add(accountNumber);
                }
                LocalDate date = new LocalDate();
                Short flagValue = flagConstant == null ? null : flagConstant.getFlag().getValue();
                ImportedSavingDetail detail = new ImportedSavingDetail(accountNumber, customerGlobalId, prdOfferingDto.getGlobalPrdOfferingNum(), statusConstant.getState().getValue(), flagValue, savingAmount, savingBalance, date);
                parsedSavingDetails.add(detail);
            } catch (XlsParsingException xex) {
                if (xex.isMultiple()) {
                    for (String msg : xex.getMessages()) {
                        errors.add(msg);
                    }
                } else {
                    errors.add(xex.getMessage());
                }
            } catch (Exception cex) {
                errors.add(cex.getMessage());
            }
        }
    } catch (Exception ex) {
        errors.add(ex.getMessage());
    }
    result = new ParsedSavingsDto(errors, parsedSavingDetails);
    return result;
}
Also used : ParsedSavingsDto(org.mifos.dto.domain.ParsedSavingsDto) ArrayList(java.util.ArrayList) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) XlsParsingException(org.mifos.application.importexport.xls.XlsLoansAccountImporter.XlsParsingException) HSSFRichTextString(org.apache.poi.hssf.usermodel.HSSFRichTextString) LocalDate(org.joda.time.LocalDate) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) BigDecimal(java.math.BigDecimal) XlsParsingException(org.mifos.application.importexport.xls.XlsLoansAccountImporter.XlsParsingException) ImportedSavingDetail(org.mifos.dto.domain.ImportedSavingDetail) CustomerBO(org.mifos.customers.business.CustomerBO) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) Row(org.apache.poi.ss.usermodel.Row)

Aggregations

PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)19 ArrayList (java.util.ArrayList)10 CustomerBO (org.mifos.customers.business.CustomerBO)6 LinkedHashMap (java.util.LinkedHashMap)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 LocalDate (org.joda.time.LocalDate)3 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Test (org.junit.Test)2 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 PrdOfferingPersistence (org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 ClientBO (org.mifos.customers.client.business.ClientBO)2 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)2 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)2 ValueListElement (org.mifos.dto.domain.ValueListElement)2 LoanCreationProductDetailsDto (org.mifos.dto.screen.LoanCreationProductDetailsDto)2 MultipleLoanAccountDetailsDto (org.mifos.dto.screen.MultipleLoanAccountDetailsDto)2