Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.com.ec.domain.dto.nfce; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 5 | import java.util.List; |
||
| 6 | |||
| 7 | import br.com.ec.domain.model.Loja; |
||
| 8 | import br.com.ec.domain.model.NotaFiscal; |
||
| 9 | import br.com.ec.domain.model.NotaFiscalProduto; |
||
| 10 | import br.com.ec.domain.model.Pessoa; |
||
| 11 | import br.com.ec.domain.model.tipos.TipoNotaFiscal; |
||
| 12 | import br.edu.cesmac.core.util.DataUtils; |
||
| 13 | import br.edu.cesmac.core.util.StringUtil; |
||
| 14 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 15 | import br.edu.cesmac.web.converters.FormatarUtil; |
||
| 16 | import br.edu.cesmac.web.util.DataUtil; |
||
| 17 | |||
| 18 | public class NotaFiscalRemessaDTO implements Serializable { |
||
| 19 | |||
| 20 | private static final long serialVersionUID = 1L; |
||
| 21 | |||
| 22 | private Long sequencialNotaFiscal; |
||
| 23 | |||
| 24 | private Loja lojaEmitente; |
||
| 25 | private Loja lojaDestino; |
||
| 26 | |||
| 27 | private Pessoa pessoaJuridicaEmitente; |
||
| 28 | private Pessoa pessoaJuridicaDestinatario; |
||
| 29 | private List<NotaFiscalProduto> itens = new ArrayList<NotaFiscalProduto>(); |
||
| 30 | |||
| 31 | // private List<NfceItemDTO> itens = new ArrayList<NfceItemDTO>(); |
||
| 32 | |||
| 33 | private String numero = ""; |
||
| 34 | private String serie = ""; |
||
| 35 | private String dataHoraEmissao = ""; |
||
| 36 | private String chave = ""; |
||
| 37 | private String protocoloAutorizacao = ""; |
||
| 38 | private String cpfCnpjConsumidor = ""; |
||
| 39 | private String caminhoQrCode = ""; |
||
| 40 | |||
| 41 | private NotaFiscal notaFiscal; |
||
| 42 | |||
| 43 | public NotaFiscalRemessaDTO() {} |
||
| 44 | |||
| 45 | /* |
||
| 46 | public NotaFiscalRemessaDTO(Venda venda) { |
||
| 47 | this.venda = venda; |
||
| 48 | if (VerificadorUtil.naoEstaNulo(venda.getCliente())) { |
||
| 49 | this.setCpfCnpjConsumidor(venda.getCliente().getCpfCnpj()); |
||
| 50 | } else { |
||
| 51 | this.setCpfCnpjConsumidor("NÃO INFORMADO"); |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | public NotaFiscalRemessaDTO(NotaFiscal notaFiscal) { |
||
| 56 | this.setVenda(notaFiscal.getVenda()); |
||
| 57 | this.setNumero("" + notaFiscal.getNumeroNotaFiscal()); |
||
| 58 | this.setSerie(notaFiscal.getSerie()); |
||
| 59 | this.setChave(notaFiscal.getChave()); |
||
| 60 | this.setCaminhoQrCode(notaFiscal.getCaminhoQrcode()); |
||
| 61 | if (VerificadorUtil.naoEstaNulo(notaFiscal.getVenda().getCliente())) { |
||
| 62 | this.setCpfCnpjConsumidor(notaFiscal.getVenda().getCliente().getCpfCnpj()); |
||
| 63 | } else { |
||
| 64 | this.setCpfCnpjConsumidor("NÃO INFORMADO"); |
||
| 65 | } |
||
| 66 | this.setDataHoraEmissao(DataUtil.retornarDataFormatadaEmFormatoTexto("yyyy-MM-dd HH:mm:ss", notaFiscal.getDataHoraEmissao())); |
||
| 67 | this.setProtocoloAutorizacao(notaFiscal.getProtocoloAutorizacao()); |
||
| 68 | } |
||
| 69 | */ |
||
| 70 | |||
| 71 | public Long getSequencialNotaFiscal() { |
||
| 72 | return sequencialNotaFiscal; |
||
| 73 | } |
||
| 74 | public void setSequencialNotaFiscal(Long sequencialNotaFiscal) { |
||
| 75 | this.sequencialNotaFiscal = sequencialNotaFiscal; |
||
| 76 | } |
||
| 77 | |||
| 78 | public Loja getLojaEmitente() { |
||
| 79 | return lojaEmitente; |
||
| 80 | } |
||
| 81 | public void setLojaEmitente(Loja lojaEmitente) { |
||
| 82 | this.lojaEmitente = lojaEmitente; |
||
| 83 | } |
||
| 84 | |||
| 85 | public Loja getLojaDestino() { |
||
| 86 | return lojaDestino; |
||
| 87 | } |
||
| 88 | public void setLojaDestino(Loja lojaDestino) { |
||
| 89 | this.lojaDestino = lojaDestino; |
||
| 90 | } |
||
| 91 | |||
| 92 | public Pessoa getPessoaJuridicaEmitente() { |
||
| 93 | return pessoaJuridicaEmitente; |
||
| 94 | } |
||
| 95 | public void setPessoaJuridicaEmitente(Pessoa pessoaJuridicaEmitente) { |
||
| 96 | this.pessoaJuridicaEmitente = pessoaJuridicaEmitente; |
||
| 97 | } |
||
| 98 | |||
| 99 | public Pessoa getPessoaJuridicaDestinatario() { |
||
| 100 | return pessoaJuridicaDestinatario; |
||
| 101 | } |
||
| 102 | public void setPessoaJuridicaDestinatario(Pessoa pessoaJuridicaDestinatario) { |
||
| 103 | this.pessoaJuridicaDestinatario = pessoaJuridicaDestinatario; |
||
| 104 | } |
||
| 105 | |||
| 106 | public List<NotaFiscalProduto> getItens() { |
||
| 107 | return itens; |
||
| 108 | } |
||
| 109 | public void setItens(List<NotaFiscalProduto> itens) { |
||
| 110 | this.itens = itens; |
||
| 111 | } |
||
| 112 | |||
| 113 | public String getNumero() { |
||
| 114 | return numero; |
||
| 115 | } |
||
| 116 | public void setNumero(String numero) { |
||
| 117 | this.numero = numero; |
||
| 118 | } |
||
| 119 | |||
| 120 | public String getSerie() { |
||
| 121 | return serie; |
||
| 122 | } |
||
| 123 | public void setSerie(String serie) { |
||
| 124 | this.serie = serie; |
||
| 125 | } |
||
| 126 | |||
| 127 | public String getDataHoraEmissao() { |
||
| 128 | return dataHoraEmissao; |
||
| 129 | } |
||
| 130 | public void setDataHoraEmissao(String dataHoraEmissao) { |
||
| 131 | this.dataHoraEmissao = dataHoraEmissao; |
||
| 132 | } |
||
| 133 | |||
| 134 | public String getChave() { |
||
| 135 | return chave; |
||
| 136 | } |
||
| 137 | public void setChave(String chave) { |
||
| 138 | this.chave = formatarChave(chave); |
||
| 139 | } |
||
| 140 | |||
| 141 | public String getProtocoloAutorizacao() { |
||
| 142 | return protocoloAutorizacao; |
||
| 143 | } |
||
| 144 | public void setProtocoloAutorizacao(String protocoloAutorizacao) { |
||
| 145 | this.protocoloAutorizacao = protocoloAutorizacao; |
||
| 146 | } |
||
| 147 | |||
| 148 | public String getCpfCnpjConsumidor() { |
||
| 149 | if (VerificadorUtil.estaNulo(cpfCnpjConsumidor)) { |
||
| 150 | return "NÃO INFORMADO"; |
||
| 151 | } |
||
| 152 | return cpfCnpjConsumidor; |
||
| 153 | } |
||
| 154 | public void setCpfCnpjConsumidor(String cpfCnpjConsumidor) { |
||
| 155 | this.cpfCnpjConsumidor = cpfCnpjConsumidor; |
||
| 156 | } |
||
| 157 | |||
| 158 | public String getCpfCnpjConsumidorFormatado() { |
||
| 159 | if (VerificadorUtil.estaNulo(cpfCnpjConsumidor)) { |
||
| 160 | return "NÃO INFORMADO"; |
||
| 161 | } |
||
| 162 | return FormatarUtil.retornarCpfCnpjFormatado(cpfCnpjConsumidor); |
||
| 163 | } |
||
| 164 | |||
| 165 | public String getCaminhoQrCode() { |
||
| 166 | return caminhoQrCode; |
||
| 167 | } |
||
| 168 | public void setCaminhoQrCode(String caminhoQrCode) { |
||
| 169 | this.caminhoQrCode = caminhoQrCode; |
||
| 170 | } |
||
| 171 | |||
| 172 | public NotaFiscal getNotaFiscal() { |
||
| 173 | return notaFiscal; |
||
| 174 | } |
||
| 175 | public void setNotaFiscal(NotaFiscal notaFiscal) { |
||
| 176 | this.notaFiscal = notaFiscal; |
||
| 177 | } |
||
| 178 | |||
| 179 | /*******************************************************************/ |
||
| 180 | |||
| 181 | public String getRazaoSocialDaLoja() { |
||
| 182 | return VerificadorUtil.naoEstaNulo(getPessoaJuridicaEmitente())? getPessoaJuridicaEmitente().getRazaoSocial() : ""; |
||
| 183 | } |
||
| 184 | |||
| 185 | public String getCnpjDaLoja() { |
||
| 186 | return VerificadorUtil.naoEstaNulo(getPessoaJuridicaEmitente())? StringUtil.formatarCnpj(getPessoaJuridicaEmitente().getCpfCnpj()) : ""; |
||
| 187 | } |
||
| 188 | /* |
||
| 189 | public String getEnderecoDoEmitente() { |
||
| 190 | return getEnderecoEmitente().getLogradouro() + ", " + getEnderecoEmitente().getNumero() + ", " + getEnderecoEmitente().getComplemento() + ", " + |
||
| 191 | getEnderecoEmitente().getBairro() + ", " + getEnderecoEmitente().getMunicipio() + ", " + getEnderecoEmitente().getUnidadeFederativa(); |
||
| 192 | } |
||
| 193 | */ |
||
| 194 | /* |
||
| 195 | public void preencherItens(List<Lancamento> lancamentos) { |
||
| 196 | Integer sequencial = 1; |
||
| 197 | for (Lancamento lancamento : lancamentos) { |
||
| 198 | NfceItemDTO item = new NfceItemDTO(); |
||
| 199 | item.setSequencial(sequencial); |
||
| 200 | item.setSequencialProduto(lancamento.getProduto().getSequencial()); |
||
| 201 | item.setDescricao(montagemDescricaoDoItem(lancamento)); |
||
| 202 | item.setQuantidade(1); |
||
| 203 | item.setValorUnitario(lancamento.getValorVenda()); |
||
| 204 | getItens().add(item); |
||
| 205 | sequencial++; |
||
| 206 | } |
||
| 207 | } |
||
| 208 | |||
| 209 | public String montagemDescricaoDoItem(Lancamento lancamento) { |
||
| 210 | StringBuilder descricaoCompleta = new StringBuilder(); |
||
| 211 | descricaoCompleta.append(lancamento.getProduto().getCodigo()); |
||
| 212 | descricaoCompleta.append(" - "); |
||
| 213 | descricaoCompleta.append(lancamento.getDescricaoNotaFiscal()); |
||
| 214 | descricaoCompleta.append(" 1 UN X "); |
||
| 215 | descricaoCompleta.append(formatarValor(lancamento.getValorVenda())); |
||
| 216 | descricaoCompleta.append(" "); |
||
| 217 | descricaoCompleta.append(formatarValor(lancamento.getValorVenda() * 1)); |
||
| 218 | return descricaoCompleta.toString(); |
||
| 219 | } |
||
| 220 | |||
| 221 | public void preencherPagamentos(List<VendaFormaPagamento> pagamentos) { |
||
| 222 | for (VendaFormaPagamento vendaFormaPagamento : pagamentos) { |
||
| 223 | NfcePagamentoDTO pagamento = new NfcePagamentoDTO(); |
||
| 224 | String formaDePagamento = vendaFormaPagamento.getFormaPagamento().getDescricao(); |
||
| 225 | if (VerificadorUtil.naoEstaNulo(vendaFormaPagamento.getBandeiraCartao())) { |
||
| 226 | formaDePagamento = formaDePagamento + " (" + vendaFormaPagamento.getBandeiraCartao().getDescricao() + ") "; |
||
| 227 | } |
||
| 228 | pagamento.setFormaDePagamento(formaDePagamento); |
||
| 229 | pagamento.setValor(formatarValor(vendaFormaPagamento.getValorPagamento())); |
||
| 230 | getPagamentos().add(pagamento); |
||
| 231 | } |
||
| 232 | } |
||
| 233 | |||
| 234 | public String getValorTotal() { |
||
| 235 | Double total = 0.0; |
||
| 236 | if (!VerificadorUtil.isListaNulaOuVazia(getItens())) { |
||
| 237 | for (NfceItemDTO item : getItens()) { |
||
| 238 | total = total + item.getValorTotal(); |
||
| 239 | } |
||
| 240 | } |
||
| 241 | return formatarValor(total); |
||
| 242 | } |
||
| 243 | */ |
||
| 244 | public String formatarChave(String chaveAcessoNF) { |
||
| 245 | chaveAcessoNF = chaveAcessoNF.replace("NFe", ""); |
||
| 246 | return chaveAcessoNF.substring(0, 4) + " " + |
||
| 247 | chaveAcessoNF.substring(4, 8) + " " + |
||
| 248 | chaveAcessoNF.substring(8, 12) + " " + |
||
| 249 | chaveAcessoNF.substring(12, 16) + " " + |
||
| 250 | chaveAcessoNF.substring(16, 20) + " " + |
||
| 251 | chaveAcessoNF.substring(20, 24) + " " + |
||
| 252 | chaveAcessoNF.substring(24, 28) + " " + |
||
| 253 | chaveAcessoNF.substring(28, 32) + " " + |
||
| 254 | chaveAcessoNF.substring(32, 36) + " " + |
||
| 255 | chaveAcessoNF.substring(36, 40) + " " + |
||
| 256 | chaveAcessoNF.substring(40, 44); |
||
| 257 | } |
||
| 258 | |||
| 259 | // Número: 1 Série: 1 Emissão: 25/03/2018 16:28:40 |
||
| 260 | // Protocolo de Autorização: 327180000056573 25/03/2018 16:28:42 |
||
| 261 | // http://nfce.sefaz.al.gov.br/QRCode/consultarNFCe.jsp?chNFe=27180321494821000100650010000000011000000011&nVersao=100&tpAmb=2&cDest=06256954459&dhEmi=323031382d30332d32355431363a32383a34302d30333a3030&vNF=11.50&vICMS=0.00&digVal=4e35376b3876386a4d3931483269386843546f4a767443354d41453d&cIdToken=000002&cHashQRCode=A0FC7AB12F30E66649C3FFFB275323FCD2AA0AD7 |
||
| 262 | |||
| 263 | /* |
||
| 264 | public String getNumeroSerieEmissao() { |
||
| 265 | StringBuilder numeroSerieEmissao = new StringBuilder(); |
||
| 266 | numeroSerieEmissao.append("NÚMERO: "); |
||
| 267 | numeroSerieEmissao.append(getNumero()); |
||
| 268 | numeroSerieEmissao.append(" SÉRIE: "); |
||
| 269 | numeroSerieEmissao.append(getSerie()); |
||
| 270 | numeroSerieEmissao.append(" EMISSÃO: "); |
||
| 271 | numeroSerieEmissao.append(getDataHoraEmissao()); |
||
| 272 | return numeroSerieEmissao.toString(); |
||
| 273 | } |
||
| 274 | |||
| 275 | public String getProtocoloAutorizacaoDataHoraEmissao() { |
||
| 276 | return "PROTOCOLO DE AUTORIZAÇÃO: " + getProtocoloAutorizacao(); |
||
| 277 | } |
||
| 278 | */ |
||
| 279 | private String formatarValor(Double valor) { |
||
| 280 | return String.format("%.2f", valor); |
||
| 281 | } |
||
| 282 | |||
| 283 | public void preencherDadosNotaFiscal(NotaFiscal nf) { |
||
| 284 | if (VerificadorUtil.naoEstaNulo(nf.getNumeroNotaFiscal())) { |
||
| 285 | this.setNumero(nf.getNumeroNotaFiscal().toString()); |
||
| 286 | } |
||
| 287 | this.setSerie(nf.getSerie()); |
||
| 288 | this.setDataHoraEmissao(DataUtil.retornarDataFormatadaEmFormatoTexto("yyyy-MM-dd'T'HH:mm:ss'-03:00'", nf.getDataHoraEmissao())); |
||
| 289 | this.setPessoaJuridicaEmitente(nf.getPessoaJuridicaEmitente()); |
||
| 290 | this.setPessoaJuridicaDestinatario(nf.getPessoaJuridicaDestinatario()); |
||
| 291 | if (VerificadorUtil.naoEstaNulo(nf.getListaNFRemessaProdutos())) { |
||
| 292 | this.setItens(nf.getListaNFRemessaProdutos()); |
||
| 293 | } |
||
| 294 | this.setNotaFiscal(nf); |
||
| 295 | } |
||
| 296 | |||
| 297 | /* |
||
| 298 | @Transient |
||
| 299 | public Double getTotalLancamentos() { |
||
| 300 | Double total = 0.0; |
||
| 301 | if (!VerificadorUtil.isListaNulaOuVazia(getListaLancamento())) { |
||
| 302 | for (Lancamento lancamento : getListaLancamento()) { |
||
| 303 | total = total + lancamento.getValorVenda(); |
||
| 304 | } |
||
| 305 | } |
||
| 306 | return total; |
||
| 307 | } |
||
| 308 | |||
| 309 | @Transient |
||
| 310 | public Double getTotalPago() { |
||
| 311 | Double total = 0.0; |
||
| 312 | if (!VerificadorUtil.isListaNulaOuVazia(getListaFormaPagamento())) { |
||
| 313 | for (VendaFormaPagamento vendaFormaPagamento : getListaFormaPagamento()) { |
||
| 314 | total = total + vendaFormaPagamento.getValorPagamento(); |
||
| 315 | } |
||
| 316 | } |
||
| 317 | return total; |
||
| 318 | } |
||
| 319 | */ |
||
| 320 | |||
| 321 | } |