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