Search in sources :

Example 6 with AccountingConfigurationDto

use of org.mifos.config.servicefacade.dto.AccountingConfigurationDto in project head by mifos.

the class ViewLoanAccountDetailsController method showLoanAccountTransactionHistory.

@RequestMapping(value = "/viewLoanAccountTransactionHistory", method = RequestMethod.GET)
public ModelAndView showLoanAccountTransactionHistory(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewLoanAccountTransactionHistory", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    LoanInformationDto loanInformationDto = loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
    modelAndView.addObject("loanInformationDto", loanInformationDto);
    AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    List<TransactionHistoryDto> transactionHistoryDto = this.centerServiceFacade.retrieveAccountTransactionHistory(globalAccountNum);
    request.setAttribute("trxnHistoryList", transactionHistoryDto);
    return modelAndView;
}
Also used : AccountingConfigurationDto(org.mifos.config.servicefacade.dto.AccountingConfigurationDto) ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with AccountingConfigurationDto

use of org.mifos.config.servicefacade.dto.AccountingConfigurationDto in project head by mifos.

the class MandatorySavings method validateMandatoryDepositAmountDigits.

private void validateMandatoryDepositAmountDigits(ValidationContext context) {
    if (mandatoryDepositAmount == null) {
        return;
    }
    AccountingConfigurationDto accountingConfiguration = configurationServiceFacade.getAccountingConfiguration();
    BigDecimal decimalAmount;
    try {
        decimalAmount = new BigDecimal(mandatoryDepositAmount);
    } catch (NumberFormatException e) {
        return;
    }
    if ((decimalAmount.precision() - decimalAmount.scale()) > accountingConfiguration.getDigitsBeforeDecimal()) {
        context.getMessageContext().addMessage(new MessageBuilder().error().source("mandatoryDepositAmount").code("DigitsBefore.CreateSavingsAccountFormBean.mandatoryDepositAmount").arg(accountingConfiguration.getDigitsBeforeDecimal()).build());
    }
    if (decimalAmount.scale() > accountingConfiguration.getDigitsAfterDecimal()) {
        context.getMessageContext().addMessage(new MessageBuilder().error().source("mandatoryDepositAmount").code("DigitsAfter.CreateSavingsAccountFormBean.mandatoryDepositAmount").arg(accountingConfiguration.getDigitsAfterDecimal()).build());
    }
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder) AccountingConfigurationDto(org.mifos.config.servicefacade.dto.AccountingConfigurationDto) BigDecimal(java.math.BigDecimal)

Example 8 with AccountingConfigurationDto

use of org.mifos.config.servicefacade.dto.AccountingConfigurationDto in project head by mifos.

the class EditPenaltyPreviewController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, PenaltyFormBean formBean, BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView();
    AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    if (StringUtils.isNotBlank(edit)) {
        modelAndView.setViewName("editPenalty");
        modelAndView.addObject("formBean", formBean);
        modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("penaltyPreview");
    } else {
        modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());
        Short id = Short.valueOf(formBean.getId());
        Short categoryType = Short.valueOf(formBean.getCategoryTypeId());
        Short penaltyStatus = Short.valueOf(formBean.getStatusId());
        Short penaltyFrequency = Short.valueOf(formBean.getFrequencyId());
        Short glCode = Short.valueOf(formBean.getGlCodeId());
        boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
        Short currencyId = null;
        Double rate = null;
        Short penaltyFormula = null;
        Integer duration = null;
        Short penaltyPeriod = 3;
        if (ratePenalty) {
            rate = Double.valueOf(formBean.getRate());
            penaltyFormula = Short.valueOf(formBean.getFormulaId());
        }
        if (StringUtils.isNotBlank(formBean.getDuration())) {
            duration = Integer.valueOf(formBean.getDuration());
        }
        if (StringUtils.isNotBlank(formBean.getCurrencyId())) {
            currencyId = Short.valueOf(formBean.getCurrencyId());
        }
        if (StringUtils.isNotBlank(formBean.getPeriodTypeId())) {
            penaltyPeriod = Short.valueOf(formBean.getPeriodTypeId());
        }
        Double min = Double.valueOf(formBean.getMin());
        Double max = Double.valueOf(formBean.getMax());
        PenaltyFormDto dto = new PenaltyFormDto();
        dto.setId(id);
        dto.setCategoryType(categoryType);
        dto.setPenaltyStatus(penaltyStatus);
        dto.setPenaltyPeriod(penaltyPeriod);
        dto.setPenaltyFrequency(penaltyFrequency);
        dto.setGlCode(glCode);
        dto.setPenaltyFormula(penaltyFormula);
        dto.setPenaltyName(formBean.getName());
        dto.setRatePenalty(ratePenalty);
        dto.setCurrencyId(currencyId);
        dto.setRate(rate);
        dto.setAmount(formBean.getAmount());
        dto.setDuration(duration);
        dto.setMin(min);
        dto.setMax(max);
        this.penaltyServiceFacade.updatePenalty(dto);
        status.setComplete();
    }
    return modelAndView;
}
Also used : PenaltyFormDto(org.mifos.dto.domain.PenaltyFormDto) AccountingConfigurationDto(org.mifos.config.servicefacade.dto.AccountingConfigurationDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AccountingConfigurationDto (org.mifos.config.servicefacade.dto.AccountingConfigurationDto)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 PenaltyFormDto (org.mifos.dto.domain.PenaltyFormDto)2 IncludePage (freemarker.ext.servlet.IncludePage)1 BigDecimal (java.math.BigDecimal)1 Before (org.junit.Before)1 ConfigurationServiceFacade (org.mifos.config.servicefacade.ConfigurationServiceFacade)1 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)1 TransactionHistoryDto (org.mifos.dto.screen.TransactionHistoryDto)1 QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)1 MifosBeanValidator (org.mifos.platform.validation.MifosBeanValidator)1 ValidationException (org.mifos.platform.validations.ValidationException)1 StubValidationContext (org.mifos.ui.validation.StubValidationContext)1 MessageBuilder (org.springframework.binding.message.MessageBuilder)1 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)1