diff --git a/pom.xml b/pom.xml index 35d46a135..56c75af2a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 1.5.1 - 1.3.6 + 1.3.7 UTF-8 UTF-8 diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/StringDecimalToDecimalConverterScale5.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/StringDecimalToDecimalConverterScale5.java new file mode 100644 index 000000000..467149417 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/StringDecimalToDecimalConverterScale5.java @@ -0,0 +1,44 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.utilerias; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.Locale; + +import org.zkoss.zk.ui.Component; +import org.zkoss.zkplus.databind.TypeConverter; + +/** + * + * @author Administrador + */ +public class StringDecimalToDecimalConverterScale5 implements TypeConverter { + + private static final String FORMAT = "#####0.00000"; + + public Object coerceToUi(Object val, Component comp) { + if (val != null) { + String format = (String) comp.getAttribute("format"); + if (format == null) { + format = FORMAT; + } + DecimalFormat df = new DecimalFormat(format, new java.text.DecimalFormatSymbols(new Locale("pt", "BR"))); + return df.format(val); + } + return null; + } + + public Object coerceToBean(Object val, Component cmpnt) { + if (val == null) { + return null; + } + + if (val instanceof String) { + return (val.toString().trim().isEmpty()) ? (BigDecimal) null : new BigDecimal(val.toString().replace(".", "").replace(",", ".")); + } + return null; + } +} diff --git a/web/gui/tarifas/editarCotacao.zul b/web/gui/tarifas/editarCotacao.zul index 6050d584b..d68f7c7f7 100644 --- a/web/gui/tarifas/editarCotacao.zul +++ b/web/gui/tarifas/editarCotacao.zul @@ -54,10 +54,10 @@ value="${c:l('busquedaCotacaoController.valor.label')}" /> + value="@{winEditarCotacao$composer.cotacao.valor,converter=com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverterScale5}" + precision="10" scale="5" />