Rev 268 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 259 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 5 | import java.util.Date; |
||
| 6 | import java.util.List; |
||
| 7 | |||
| 8 | import javax.persistence.CascadeType; |
||
| 9 | import javax.persistence.Column; |
||
| 10 | import javax.persistence.Entity; |
||
| 11 | import javax.persistence.FetchType; |
||
| 12 | import javax.persistence.GeneratedValue; |
||
| 13 | import javax.persistence.GenerationType; |
||
| 14 | import javax.persistence.Id; |
||
| 15 | import javax.persistence.JoinColumn; |
||
| 16 | import javax.persistence.ManyToOne; |
||
| 17 | import javax.persistence.OneToMany; |
||
| 18 | import javax.persistence.SequenceGenerator; |
||
| 19 | import javax.persistence.Table; |
||
| 20 | import javax.persistence.Transient; |
||
| 21 | import javax.validation.constraints.NotNull; |
||
| 22 | import javax.validation.constraints.Size; |
||
| 23 | |||
| 24 | import org.hibernate.annotations.ForeignKey; |
||
| 25 | |||
| 26 | import br.com.ec.core.interfaces.Alterar; |
||
| 27 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 28 | import br.com.ec.core.util.DataUtils; |
||
| 29 | import br.com.ec.core.util.StringUtil; |
||
| 30 | import br.com.ec.core.util.VerificadorUtil; |
||
| 31 | |||
| 32 | @Entity |
||
| 33 | @Table(name="sec_venda", schema="sc_sec") |
||
| 34 | public class Venda implements Serializable { |
||
| 35 | |||
| 36 | private static final long serialVersionUID = 1L; |
||
| 37 | |||
| 38 | private Long sequencial; |
||
| 39 | private Loja loja; |
||
| 40 | // private Cliente cliente; |
||
| 41 | private Usuario usuario; |
||
| 268 | espaco | 42 | private Vendedor vendedor; |
| 259 | espaco | 43 | // private Vendedor indicacao; |
| 44 | private Date dataVenda; |
||
| 45 | private String observacao; |
||
| 46 | private String tipoSituacao; |
||
| 47 | private String notaFiscal; |
||
| 48 | private Maquineta maquineta; |
||
| 49 | // private String tipoFrete; |
||
| 50 | // private Double valorFrete; |
||
| 51 | private List<Lancamento> listaLancamentos; |
||
| 52 | private List<VendaFormaPagamento> listaVendaFormaPagamentos; |
||
| 53 | |||
| 54 | private String tipoSituacaoFinanceira; |
||
| 55 | private String justificativaParaExcluir; |
||
| 56 | |||
| 57 | private Boolean permitirEmissaoNotaFiscal = false; |
||
| 58 | private Boolean emitirNotaFiscal = false; |
||
| 59 | private Boolean emitirComanda = false; |
||
| 60 | private Boolean cpfCnpjNaNotaFiscal = false; |
||
| 61 | |||
| 62 | public Venda() { |
||
| 63 | // listaLancamentos = new HashSet<Lancamento>(); |
||
| 64 | // listaVendaFormaPagamentos = new HashSet<VendaFormaPagamento>(); |
||
| 65 | listaLancamentos = new ArrayList<Lancamento>(); |
||
| 66 | listaVendaFormaPagamentos = new ArrayList<VendaFormaPagamento>(); |
||
| 67 | setEmitirNotaFiscal(false); |
||
| 68 | // setTipoFrete(ConstantesSEC.NotaFiscal.Transporte.SEM_OCORRENCIA_TRANSPORTE_9); |
||
| 69 | } |
||
| 413 | espaco | 70 | |
| 71 | public Venda(Long sequencial) { |
||
| 72 | this.sequencial = sequencial; |
||
| 73 | } |
||
| 74 | |||
| 259 | espaco | 75 | /* |
| 76 | public Venda(Loja loja, Usuario usuario) { |
||
| 77 | this.loja = loja; |
||
| 78 | this.usuario = usuario; |
||
| 79 | } |
||
| 80 | |||
| 81 | public Venda(Loja loja, Usuario usuario, Vendedor vendedor, Vendedor indicacao) { |
||
| 82 | this.loja = loja; |
||
| 83 | this.usuario = usuario; |
||
| 84 | this.vendedor = vendedor; |
||
| 85 | this.indicacao = indicacao; |
||
| 86 | } |
||
| 87 | |||
| 88 | public Venda(Loja loja, Usuario usuario, Vendedor vendedor, Vendedor indicacao, String observacao, String notaFiscal) { |
||
| 89 | this.loja = loja; |
||
| 90 | this.usuario = usuario; |
||
| 91 | this.vendedor = vendedor; |
||
| 92 | this.indicacao = indicacao; |
||
| 93 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 94 | this.notaFiscal = notaFiscal; |
||
| 95 | } |
||
| 96 | |||
| 97 | public Venda(Loja loja, Usuario usuario, Set<Lancamento> listaLancamentos, Set<VendaFormaPagamento> listaVendaFormaPagamentos) { |
||
| 98 | this.listaLancamentos = listaLancamentos; |
||
| 99 | this.listaVendaFormaPagamentos = listaVendaFormaPagamentos; |
||
| 100 | this.loja = loja; |
||
| 101 | this.usuario = usuario; |
||
| 102 | } |
||
| 103 | |||
| 104 | public Venda(ParametrosVendaDTO parametrosVenda) { |
||
| 105 | this.loja = parametrosVenda.getLoja(); |
||
| 106 | this.usuario = parametrosVenda.getUsuario(); |
||
| 107 | this.vendedor = parametrosVenda.getVendedor(); |
||
| 108 | this.cliente = parametrosVenda.getCliente(); |
||
| 109 | this.indicacao = parametrosVenda.getIndicacao(); |
||
| 110 | this.observacao = StringUtil.setarUpperCaseComTrim(parametrosVenda.getObservacao()); |
||
| 111 | this.notaFiscal = parametrosVenda.getNotaFiscal(); |
||
| 112 | this.cpfCnpjNaNotaFiscal = parametrosVenda.getCpfCnpjNaNotaFiscal(); |
||
| 113 | } |
||
| 114 | */ |
||
| 115 | @Id |
||
| 116 | @SequenceGenerator(name = "sq_venda") |
||
| 117 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 118 | @Column(name="seq_venda", nullable=false) |
||
| 119 | public Long getSequencial() { |
||
| 120 | return sequencial; |
||
| 121 | } |
||
| 122 | public void setSequencial(Long sequencial) { |
||
| 123 | this.sequencial = sequencial; |
||
| 124 | } |
||
| 125 | |||
| 126 | @ManyToOne |
||
| 127 | @ForeignKey(name="fk_venda_loja") |
||
| 128 | @NotNull(message = "Informe a loja", groups = {Cadastrar.class, Alterar.class}) |
||
| 129 | @JoinColumn(name = "seq_loja", nullable = false) |
||
| 130 | public Loja getLoja() { |
||
| 131 | return loja; |
||
| 132 | } |
||
| 133 | public void setLoja(Loja loja) { |
||
| 134 | this.loja = loja; |
||
| 135 | } |
||
| 136 | /* |
||
| 137 | @ManyToOne |
||
| 138 | @ForeignKey(name="fk_venda_cliente") |
||
| 139 | @JoinColumn(name = "seq_cliente", nullable = true) |
||
| 140 | public Cliente getCliente() { |
||
| 141 | return cliente; |
||
| 142 | } |
||
| 143 | public void setCliente(Cliente cliente) { |
||
| 144 | this.cliente = cliente; |
||
| 145 | } |
||
| 146 | */ |
||
| 147 | @ManyToOne |
||
| 148 | @ForeignKey(name="fk_venda_usuario") |
||
| 149 | @JoinColumn(name = "seq_usuario", nullable = false) |
||
| 150 | public Usuario getUsuario() { |
||
| 151 | return usuario; |
||
| 152 | } |
||
| 153 | public void setUsuario(Usuario usuario) { |
||
| 154 | this.usuario = usuario; |
||
| 155 | } |
||
| 268 | espaco | 156 | |
| 259 | espaco | 157 | @ManyToOne |
| 158 | @ForeignKey(name="fk_venda_vendedor") |
||
| 159 | @NotNull(message = "Informe o vendedor", groups = {Cadastrar.class, Alterar.class}) |
||
| 160 | @JoinColumn(name = "seq_vendedor", nullable = true) |
||
| 161 | public Vendedor getVendedor() { |
||
| 162 | return vendedor; |
||
| 163 | } |
||
| 164 | public void setVendedor(Vendedor vendedor) { |
||
| 165 | this.vendedor = vendedor; |
||
| 166 | } |
||
| 268 | espaco | 167 | /* |
| 259 | espaco | 168 | @ManyToOne |
| 169 | @ForeignKey(name="fk_venda_indicacao") |
||
| 170 | @JoinColumn(name = "seq_indicacao", nullable = true) |
||
| 171 | public Vendedor getIndicacao() { |
||
| 172 | return indicacao; |
||
| 173 | } |
||
| 174 | public void setIndicacao(Vendedor indicacao) { |
||
| 175 | this.indicacao = indicacao; |
||
| 176 | } |
||
| 177 | */ |
||
| 178 | @Column(name="dth_venda") |
||
| 179 | public Date getDataVenda() { |
||
| 180 | return dataVenda; |
||
| 181 | } |
||
| 182 | public void setDataVenda(Date dataVenda) { |
||
| 183 | this.dataVenda = dataVenda; |
||
| 184 | } |
||
| 185 | |||
| 186 | @Column(name="dsc_observacao") |
||
| 187 | @Size(max = 1000, message = "Limite de caracteres ultrapassado: Observação") |
||
| 188 | public String getObservacao() { |
||
| 189 | return observacao; |
||
| 190 | } |
||
| 191 | public void setObservacao(String observacao) { |
||
| 192 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 193 | } |
||
| 194 | |||
| 195 | @Column(name="tip_situacao") |
||
| 196 | public String getTipoSituacao() { |
||
| 197 | return tipoSituacao; |
||
| 198 | } |
||
| 199 | public void setTipoSituacao(String tipoSituacao) { |
||
| 200 | this.tipoSituacao = tipoSituacao; |
||
| 201 | } |
||
| 202 | /* |
||
| 203 | @Transient |
||
| 204 | public String getTipoSituacaoDescricao() { |
||
| 205 | return TipoSituacaoVenda.parse(getTipoSituacao()).getDescricao(); |
||
| 206 | } |
||
| 207 | */ |
||
| 208 | @Column(name="dsc_nota_fiscal") |
||
| 209 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Nota Fiscal") |
||
| 210 | public String getNotaFiscal() { |
||
| 211 | return notaFiscal; |
||
| 212 | } |
||
| 213 | public void setNotaFiscal(String notaFiscal) { |
||
| 214 | this.notaFiscal = notaFiscal; |
||
| 215 | } |
||
| 216 | |||
| 217 | @ManyToOne |
||
| 218 | @ForeignKey(name = "fk_venda_maquineta") |
||
| 219 | @JoinColumn(name="seq_maquineta", referencedColumnName="seq_maquineta", insertable=true, updatable=true) |
||
| 220 | public Maquineta getMaquineta() { |
||
| 221 | return maquineta; |
||
| 222 | } |
||
| 223 | public void setMaquineta(Maquineta maquineta) { |
||
| 224 | this.maquineta = maquineta; |
||
| 225 | } |
||
| 226 | |||
| 227 | /*@Column(name="tip_frete") |
||
| 228 | public String getTipoFrete() { |
||
| 229 | return tipoFrete; |
||
| 230 | } |
||
| 231 | public void setTipoFrete(String tipoFrete) { |
||
| 232 | this.tipoFrete = tipoFrete; |
||
| 233 | } |
||
| 234 | |||
| 235 | @Column(name="val_frete") |
||
| 236 | public Double getValorFrete() { |
||
| 237 | return valorFrete; |
||
| 238 | } |
||
| 239 | public void setValorFrete(Double valorFrete) { |
||
| 240 | this.valorFrete = valorFrete; |
||
| 241 | }*/ |
||
| 242 | |||
| 243 | @OneToMany(mappedBy="venda", cascade=CascadeType.ALL, fetch=FetchType.LAZY, orphanRemoval=true) |
||
| 244 | public List<Lancamento> getListaLancamentos() { |
||
| 245 | return listaLancamentos; |
||
| 246 | } |
||
| 247 | public void setListaLancamentos(List<Lancamento> listaLancamentos) { |
||
| 248 | this.listaLancamentos = listaLancamentos; |
||
| 249 | } |
||
| 250 | |||
| 251 | @OneToMany(mappedBy="venda", cascade=CascadeType.ALL, fetch=FetchType.LAZY, orphanRemoval=true) |
||
| 252 | public List<VendaFormaPagamento> getListaVendaFormaPagamentos() { |
||
| 253 | return listaVendaFormaPagamentos; |
||
| 254 | } |
||
| 255 | public void setListaVendaFormaPagamentos(List<VendaFormaPagamento> listaVendaFormaPagamentos) { |
||
| 256 | this.listaVendaFormaPagamentos = listaVendaFormaPagamentos; |
||
| 257 | } |
||
| 258 | |||
| 259 | @Transient |
||
| 260 | public String getTipoSituacaoFinanceira() { |
||
| 261 | return tipoSituacaoFinanceira; |
||
| 262 | } |
||
| 263 | @Transient |
||
| 264 | public void setTipoSituacaoFinanceira(String tipoSituacaoFinanceira) { |
||
| 265 | this.tipoSituacaoFinanceira = tipoSituacaoFinanceira; |
||
| 266 | } |
||
| 267 | |||
| 268 | @Transient |
||
| 269 | public String getJustificativaParaExcluir() { |
||
| 270 | return justificativaParaExcluir; |
||
| 271 | } |
||
| 272 | public void setJustificativaParaExcluir(String justificativaParaExcluir) { |
||
| 273 | this.justificativaParaExcluir = StringUtil.setarUpperCaseComTrim(justificativaParaExcluir); |
||
| 274 | } |
||
| 275 | |||
| 276 | @Transient |
||
| 277 | public Boolean getPermitirEmissaoNotaFiscal() { |
||
| 278 | return permitirEmissaoNotaFiscal; |
||
| 279 | } |
||
| 280 | public void setPermitirEmissaoNotaFiscal(Boolean permitirEmissaoNotaFiscal) { |
||
| 281 | this.permitirEmissaoNotaFiscal = permitirEmissaoNotaFiscal; |
||
| 282 | } |
||
| 283 | public void verificarSePermiteEmissaoNotaFiscal() { |
||
| 284 | setPermitirEmissaoNotaFiscal(this.getLoja().emissaoNotaFiscalPermitida()); |
||
| 285 | } |
||
| 286 | |||
| 287 | @Transient |
||
| 288 | public Boolean getEmitirNotaFiscal() { |
||
| 289 | return emitirNotaFiscal; |
||
| 290 | } |
||
| 291 | public void setEmitirNotaFiscal(Boolean emitirNotaFiscal) { |
||
| 292 | this.emitirNotaFiscal = emitirNotaFiscal; |
||
| 293 | } |
||
| 294 | |||
| 295 | @Transient |
||
| 296 | public Boolean getEmitirComanda() { |
||
| 297 | return emitirComanda; |
||
| 298 | } |
||
| 299 | public void setEmitirComanda(Boolean emitirComanda) { |
||
| 300 | this.emitirComanda = emitirComanda; |
||
| 301 | } |
||
| 302 | |||
| 303 | @Transient |
||
| 304 | public Boolean getCpfCnpjNaNotaFiscal() { |
||
| 305 | return cpfCnpjNaNotaFiscal; |
||
| 306 | } |
||
| 307 | public void setCpfCnpjNaNotaFiscal(Boolean cpfCnpjNaNotaFiscal) { |
||
| 308 | this.cpfCnpjNaNotaFiscal = cpfCnpjNaNotaFiscal; |
||
| 309 | } |
||
| 310 | |||
| 311 | /****************************************************************/ |
||
| 312 | |||
| 313 | @Transient |
||
| 314 | public List<Lancamento> getLancamentos() { |
||
| 315 | List<Lancamento> lancamentos = new ArrayList<Lancamento>(); |
||
| 316 | lancamentos.addAll(listaLancamentos); |
||
| 317 | return lancamentos; |
||
| 318 | } |
||
| 319 | |||
| 320 | @Transient |
||
| 321 | public List<Lancamento> getLancamentosValidos() { |
||
| 322 | List<Lancamento> lancamentos = new ArrayList<Lancamento>(); |
||
| 323 | for (Lancamento lancamento : listaLancamentos) { |
||
| 324 | if (lancamento.getAtivo()) { |
||
| 325 | lancamentos.add(lancamento); |
||
| 326 | } |
||
| 327 | } |
||
| 328 | return lancamentos; |
||
| 329 | } |
||
| 330 | |||
| 331 | @Transient |
||
| 332 | public List<VendaFormaPagamento> getVendaFormaPagamentos() { |
||
| 333 | List<VendaFormaPagamento> pagamentos = new ArrayList<VendaFormaPagamento>(); |
||
| 334 | pagamentos.addAll(listaVendaFormaPagamentos); |
||
| 335 | return pagamentos; |
||
| 336 | } |
||
| 337 | |||
| 338 | /* |
||
| 339 | @Transient |
||
| 340 | public List<Parcela> getParcelas() { |
||
| 341 | List<Parcela> parcelas = new ArrayList<Parcela>(); |
||
| 342 | parcelas.addAll(listaParcelas); |
||
| 343 | return parcelas; |
||
| 344 | } |
||
| 345 | */ |
||
| 346 | |||
| 347 | @Transient |
||
| 348 | public Double getTotalLancamentos() { |
||
| 349 | Double total = 0.0; |
||
| 350 | for (Lancamento lancamento : getLancamentos()) { |
||
| 351 | total = total + lancamento.getValorVenda(); |
||
| 352 | } |
||
| 353 | return total; |
||
| 354 | } |
||
| 355 | |||
| 356 | @Transient |
||
| 357 | public Double getTotalVenda() { |
||
| 358 | Double total = new Double(0.0); |
||
| 359 | for (Lancamento lancamento : getLancamentos()) { |
||
| 360 | if (lancamento.getAtivo()) { |
||
| 361 | total = total + lancamento.getValorVenda(); |
||
| 362 | } |
||
| 363 | } |
||
| 364 | return total; |
||
| 365 | } |
||
| 366 | |||
| 367 | @Transient |
||
| 368 | public Double getTotalPago() { |
||
| 369 | Double total = new Double(0.0); |
||
| 370 | for (VendaFormaPagamento pagamento : getVendaFormaPagamentos()) { |
||
| 371 | total = total + pagamento.getValorPagamento(); |
||
| 372 | } |
||
| 373 | return total; |
||
| 374 | } |
||
| 375 | |||
| 376 | @Transient |
||
| 377 | public Double getTotalPagoEmDinheiro() { |
||
| 378 | Double total = new Double(0.0); |
||
| 379 | for (VendaFormaPagamento pagamento : getVendaFormaPagamentos()) { |
||
| 380 | if (pagamento.getFormaPagamento().formaPagamentoEhDinheiro()) { |
||
| 381 | total = total + pagamento.getValorPagamento(); |
||
| 382 | } |
||
| 383 | } |
||
| 384 | return total; |
||
| 385 | } |
||
| 386 | |||
| 387 | @Transient |
||
| 388 | public Double getTotalPagoEmCupom() { |
||
| 389 | Double total = new Double(0.0); |
||
| 390 | for (VendaFormaPagamento pagamento : getVendaFormaPagamentos()) { |
||
| 391 | if (pagamento.getFormaPagamento().formaPagamentoEhCupom()) { |
||
| 392 | total = total + pagamento.getValorPagamento(); |
||
| 393 | } |
||
| 394 | } |
||
| 395 | return total; |
||
| 396 | } |
||
| 397 | /* |
||
| 398 | @Transient |
||
| 399 | public String getProdutosVendidos() { |
||
| 400 | StringBuilder produtosVendidos = new StringBuilder(); |
||
| 401 | for (Lancamento lancamento : getLancamentos()) { |
||
| 402 | if (lancamento.getAtivo()) { |
||
| 403 | produtosVendidos.append("["); |
||
| 404 | produtosVendidos.append(lancamento.getProduto().getCodigoProdutoPadrao()); |
||
| 405 | produtosVendidos.append(": "); |
||
| 406 | produtosVendidos.append(lancamento.getProduto().getDescricaoDoModelo()); |
||
| 407 | produtosVendidos.append(", "); |
||
| 408 | produtosVendidos.append(lancamento.getProduto().getDescricao()); |
||
| 409 | produtosVendidos.append(" POR R$ "); |
||
| 410 | produtosVendidos.append(StringUtil.formatarValor(lancamento.getValorVenda())); |
||
| 411 | produtosVendidos.append("] "); |
||
| 412 | } |
||
| 413 | } |
||
| 414 | return produtosVendidos.toString(); |
||
| 415 | } |
||
| 416 | */ |
||
| 417 | @Transient |
||
| 418 | public Long getSequencialDaLoja() { |
||
| 419 | return VerificadorUtil.naoEstaNulo(loja)? loja.getSequencial() : null; |
||
| 420 | } |
||
| 421 | /* |
||
| 422 | @Transient |
||
| 423 | public Long getSequencialDoVendedor() { |
||
| 424 | return VerificadorUtil.naoEstaNulo(vendedor)? vendedor.getSequencial() : null; |
||
| 425 | } |
||
| 426 | |||
| 427 | @Transient |
||
| 428 | public String getLinhaPorSituacao() { |
||
| 429 | if (getTipoSituacao().equals(TipoSituacaoVenda.NOVO.getValor())) return "linha-novo"; |
||
| 430 | if (getTipoSituacao().equals(TipoSituacaoVenda.CONFERIDO.getValor())) return "linha-conferido"; |
||
| 431 | if (getTipoSituacao().equals(TipoSituacaoVenda.FINALIZADO.getValor())) return "linha-finalizado"; |
||
| 432 | if (getTipoSituacao().equals(TipoSituacaoVenda.PENDENCIAS.getValor())) return "linha-pendencias"; |
||
| 433 | return "even-row"; |
||
| 434 | } |
||
| 435 | |||
| 436 | @Transient |
||
| 437 | public String getNomeVendedorDaVenda() { |
||
| 438 | return VerificadorUtil.naoEstaNulo(getVendedor())? getVendedor().getNomeDaPessoa() : null; |
||
| 439 | } |
||
| 440 | */ |
||
| 441 | @Transient |
||
| 442 | public Integer getQuantidadeDiasDaVenda() { |
||
| 443 | return DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), getDataVenda()); |
||
| 444 | } |
||
| 445 | |||
| 446 | @Override |
||
| 447 | public int hashCode() { |
||
| 448 | final int prime = 31; |
||
| 449 | int result = 1; |
||
| 450 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 451 | return result; |
||
| 452 | } |
||
| 453 | |||
| 454 | @Override |
||
| 455 | public boolean equals(Object obj) { |
||
| 456 | if (this == obj) |
||
| 457 | return true; |
||
| 458 | if (obj == null) |
||
| 459 | return false; |
||
| 460 | if (getClass() != obj.getClass()) |
||
| 461 | return false; |
||
| 462 | Venda other = (Venda) obj; |
||
| 463 | if (sequencial == null) { |
||
| 464 | if (other.sequencial != null) |
||
| 465 | return false; |
||
| 466 | } else if (!sequencial.equals(other.sequencial)) |
||
| 467 | return false; |
||
| 468 | return true; |
||
| 469 | } |
||
| 470 | |||
| 471 | @Transient |
||
| 472 | public Pessoa getPessoaJuridicaDaLoja() { |
||
| 473 | return VerificadorUtil.naoEstaNulo(getLoja())? getLoja().getPessoaJuridica() : null; |
||
| 474 | } |
||
| 475 | /* |
||
| 476 | @Transient |
||
| 477 | public String montarDadosDaVenda(List<Lancamento> lancamentos, List<VendaFormaPagamento> pagamentos) { |
||
| 478 | StringBuilder conteudo = new StringBuilder(); |
||
| 479 | //conteudo.append("OPERAÇÃO REALIZADA POR: " + this.getUsuario().getNome() + "\n"); |
||
| 480 | conteudo.append("VENDA ID: " + this.getSequencial() + "\n"); |
||
| 481 | conteudo.append("DATA: " + DataUtils.converterDataComHorarioParaString(this.getDataVenda()) + "\n"); |
||
| 482 | conteudo.append("LOJA: " + this.getLoja().getDescricao() + "\n"); |
||
| 483 | conteudo.append("VENDEDOR: " + this.getVendedor().getNomeDaPessoa() + "\n"); |
||
| 484 | conteudo.append("TOTAL: " + valorTotalVenda(lancamentos) + "\n"); |
||
| 485 | conteudo.append("OBS.: " + this.getObservacao() + "\n"); |
||
| 486 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getJustificativaParaExcluir())) { |
||
| 487 | conteudo.append("JUSTIFICATIVA: " + this.getJustificativaParaExcluir() + "\n"); |
||
| 488 | } else { |
||
| 489 | conteudo.append("SEM JUSTIFICATIVA\n"); |
||
| 490 | } |
||
| 491 | conteudo.append("__________________________________________________\n\n"); |
||
| 492 | for (Lancamento lancamento : lancamentos) { |
||
| 493 | conteudo.append(lancamento.getProduto().getCodigoProdutoPadrao() + " | "); |
||
| 494 | conteudo.append(lancamento.getProduto().getDescricaoComModeloCompleta() + ", "); |
||
| 495 | conteudo.append("R$" + lancamento.getValorVenda()); |
||
| 496 | if (lancamento.comDescontos()) { |
||
| 497 | conteudo.append(" (COM DESCONTO DE R$" + lancamento.valorDescontos() + ")"); |
||
| 498 | } |
||
| 499 | conteudo.append("\n"); |
||
| 500 | } |
||
| 501 | conteudo.append("__________________________________________________\n\n"); |
||
| 502 | for (VendaFormaPagamento pagamento : pagamentos) { |
||
| 503 | if (VerificadorUtil.naoEstaNulo(pagamento.getBandeiraCartao())) { |
||
| 504 | conteudo.append(pagamento.getFormaPagamento().getDescricao() + " - " + pagamento.getBandeiraCartao().getDescricao() + ": R$" + pagamento.getValorPagamento() + "\n"); |
||
| 505 | } else { |
||
| 506 | conteudo.append(pagamento.getFormaPagamento().getDescricao() + ": R$" + pagamento.getValorPagamento() + "\n"); |
||
| 507 | } |
||
| 508 | conteudo.append("\n"); |
||
| 509 | } |
||
| 510 | return conteudo.toString(); |
||
| 511 | } |
||
| 512 | * |
||
| 513 | @Transient |
||
| 514 | private Double valorTotalVenda(List<Lancamento> lancamentos) { |
||
| 515 | Double total = new Double(0.0); |
||
| 516 | for (Lancamento lancamento : lancamentos) { |
||
| 517 | if (lancamento.getAtivo()) { |
||
| 518 | total = total + lancamento.getValorVenda(); |
||
| 519 | } |
||
| 520 | } |
||
| 521 | return total; |
||
| 522 | } |
||
| 523 | |||
| 524 | @Transient |
||
| 525 | public String getEmailDoCliente() { |
||
| 526 | return VerificadorUtil.naoEstaNulo(getCliente())? getCliente().getEmail() : ""; |
||
| 527 | } |
||
| 528 | */ |
||
| 529 | @Transient |
||
| 530 | public String getCertificadoDaLoja() { |
||
| 531 | return VerificadorUtil.naoEstaNulo(getLoja())? getLoja().getDescricaoCertificado() : ""; |
||
| 532 | } |
||
| 533 | |||
| 534 | @Transient |
||
| 535 | public String getDescricaoMaquineta() { |
||
| 536 | return VerificadorUtil.naoEstaNulo(getMaquineta())? getMaquineta().descricaoCompleta() : "NENHUMA"; |
||
| 537 | } |
||
| 538 | |||
| 539 | } |