From b08037698926a3caedb99f06e0e8ce0299de4180 Mon Sep 17 00:00:00 2001 From: julio Date: Thu, 7 Apr 2016 19:03:33 +0000 Subject: [PATCH] bug #6817 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@54736 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/service/impl/FiscalServiceImpl.java | 9 ++++----- .../ventaboletos/utilerias/UtileriasFiscal.java | 12 +++++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java index 312fd5b58..f78215ce1 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/FiscalServiceImpl.java @@ -96,8 +96,8 @@ public class FiscalServiceImpl implements FiscalService { String condicaoPagamento = StringHelper.preencherStringEsquerda(null, 3, "9"); BigDecimal valorTotal = UtileriasFiscal.arredondar(calculaValorTotalECFManual(imf)); - String valorTotalDocumanto = UtileriasFiscal.formataZeroDecimal(valorTotal, 14); - String valorItens = UtileriasFiscal.formataZeroDecimal(valorTotal, 14); + String valorTotalDocumanto = UtileriasFiscal.formataEspacosDecimalDireita(valorTotal, 14); + String valorItens = valorTotalDocumanto; BigDecimal valorICMS = imf.getIcms() == null ? BigDecimal.ZERO : UtileriasFiscal.arredondar(imf.getIcms()); String baseCalICMS = UtileriasFiscal.formataZeroDecimal(valorICMS, 14); @@ -479,9 +479,8 @@ public class FiscalServiceImpl implements FiscalService { String coo = StringHelper.preencherStringEspacoDireita(item.getCoo(), 9); - BigDecimal valorTotal = valorTotalItensECF(item); - valorTotal = UtileriasFiscal.arredondar(valorTotal); - String valorTotalDocumanto = UtileriasFiscal.formataEspacosDecimal(valorTotal, 14); + BigDecimal valorTotal = UtileriasFiscal.arredondar(valorTotalItensECF(item)); + String valorTotalDocumanto = UtileriasFiscal.formataEspacosDecimalDireita(valorTotal, 14); String valorItens = valorTotalDocumanto; HashMap aliquotaBaseCalculo = getAliquotaBaseCalculo(item); diff --git a/src/com/rjconsultores/ventaboletos/utilerias/UtileriasFiscal.java b/src/com/rjconsultores/ventaboletos/utilerias/UtileriasFiscal.java index eb1862b0d..86d9131d6 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/UtileriasFiscal.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/UtileriasFiscal.java @@ -64,7 +64,6 @@ public class UtileriasFiscal { } public static String formataZeroDecimal(final BigDecimal valor, final int tamanho) { - String valorFommat = valor == null ? "" : valor.toString(); valorFommat = valorFommat.toString().replace(".", "").replace(",", ""); valorFommat = formataNumerico(valorFommat, valorFommat.length()); @@ -72,8 +71,7 @@ public class UtileriasFiscal { return valorFommat; } - public static String formataEspacosDecimal(final BigDecimal valor, final int tamanho) { - + public static String formataEspacosDecimalEsquerda(final BigDecimal valor, final int tamanho) { String valorFommat = valor == null ? "" : valor.toString(); valorFommat = valorFommat.toString().replace(".", "").replace(",", ""); valorFommat = UtileriasFiscal.formataNumerico(valorFommat, valorFommat.length()); @@ -81,6 +79,14 @@ public class UtileriasFiscal { return valorFommat; } + public static String formataEspacosDecimalDireita(final BigDecimal valor, final int tamanho) { + String valorFommat = valor == null ? "" : valor.toString(); + valorFommat = valorFommat.toString().replace(".", "").replace(",", ""); + valorFommat = UtileriasFiscal.formataNumerico(valorFommat, valorFommat.length()); + valorFommat = StringUtils.rightPad(valorFommat, (tamanho), " "); + return valorFommat; + } + public static BigDecimal arredondar(BigDecimal aNumber) { return aNumber.setScale(DECIMALS, ROUNDING_MODE); }