Rev 106 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 3 | import java.util.ArrayList; |
||
| 4 | import java.util.Date; |
||
| 5 | import java.util.List; |
||
| 6 | |||
| 7 | import javax.persistence.Transient; |
||
| 8 | |||
| 195 | espaco | 9 | import br.com.ec.core.util.VerificadorUtil; |
| 106 | espaco | 10 | import br.com.ec.domain.model.FormaPagamento; |
| 11 | |||
| 12 | public class CartaoResumoDTO { |
||
| 13 | |||
| 14 | private Date dataResumo; |
||
| 15 | private List<CartaoBandeiraDTO> cartoesPorBandeira; |
||
| 16 | private Boolean indicadorConciliado; |
||
| 17 | |||
| 18 | private Double valorTotalBrutoCartoes; |
||
| 19 | private Double valorTotalBrutoCartoesDebito; |
||
| 20 | private Double valorTotalBrutoCartoesCredito1x; |
||
| 21 | private Double valorTotalBrutoCartoesCreditoParcelado; |
||
| 22 | |||
| 23 | private Double valorTotalBrutoImportadoCartoes; |
||
| 24 | private Double valorTotalBrutoImportadoCartoesDebito; |
||
| 25 | private Double valorTotalBrutoImportadoCartoesCredito1x; |
||
| 26 | private Double valorTotalBrutoImportadoCartoesCreditoParcelado; |
||
| 27 | |||
| 28 | private Double valorTotalLiquidoCartoesGerados; |
||
| 29 | private Double valorTotalLiquidoCartoesGeradosDebito; |
||
| 30 | private Double valorTotalLiquidoCartoesGeradosCredito1x; |
||
| 31 | private Double valorTotalLiquidoCartoesGeradosCreditoParcelado; |
||
| 32 | |||
| 33 | public CartaoResumoDTO() { |
||
| 34 | setCartoesPorBandeira(new ArrayList<CartaoBandeiraDTO>()); |
||
| 35 | setIndicadorConciliado(false); |
||
| 36 | setValorTotalBrutoCartoes(new Double(0.0)); |
||
| 37 | setValorTotalBrutoCartoesDebito(new Double(0.0)); |
||
| 38 | setValorTotalBrutoCartoesCredito1x(new Double(0.0)); |
||
| 39 | setValorTotalBrutoCartoesCreditoParcelado(new Double(0.0)); |
||
| 40 | setValorTotalBrutoImportadoCartoes(new Double(0.0)); |
||
| 41 | setValorTotalBrutoImportadoCartoesDebito(new Double(0.0)); |
||
| 42 | setValorTotalBrutoImportadoCartoesCredito1x(new Double(0.0)); |
||
| 43 | setValorTotalBrutoImportadoCartoesCreditoParcelado(new Double(0.0)); |
||
| 44 | setValorTotalLiquidoCartoesGerados(new Double(0.0)); |
||
| 45 | setValorTotalLiquidoCartoesGeradosDebito(new Double(0.0)); |
||
| 46 | setValorTotalLiquidoCartoesGeradosCredito1x(new Double(0.0)); |
||
| 47 | setValorTotalLiquidoCartoesGeradosCreditoParcelado(new Double(0.0)); |
||
| 48 | |||
| 49 | } |
||
| 50 | |||
| 51 | public Date getDataResumo() { |
||
| 52 | return dataResumo; |
||
| 53 | } |
||
| 54 | public void setDataResumo(Date dataResumo) { |
||
| 55 | this.dataResumo = dataResumo; |
||
| 56 | } |
||
| 57 | |||
| 58 | public void setCartoesPorBandeira(List<CartaoBandeiraDTO> cartoesPorBandeira) { |
||
| 59 | this.cartoesPorBandeira = cartoesPorBandeira; |
||
| 60 | } |
||
| 61 | public List<CartaoBandeiraDTO> getCartoesPorBandeira() { |
||
| 62 | return cartoesPorBandeira; |
||
| 63 | } |
||
| 64 | |||
| 65 | public Boolean getIndicadorConciliado() { |
||
| 66 | return indicadorConciliado; |
||
| 67 | } |
||
| 68 | public void setIndicadorConciliado(Boolean indicadorConciliado) { |
||
| 69 | this.indicadorConciliado = indicadorConciliado; |
||
| 70 | } |
||
| 71 | |||
| 72 | public Double getValorTotalBrutoCartoes() { |
||
| 73 | return valorTotalBrutoCartoes; |
||
| 74 | } |
||
| 75 | public void setValorTotalBrutoCartoes(Double valorTotalBrutoCartoes) { |
||
| 76 | this.valorTotalBrutoCartoes = valorTotalBrutoCartoes; |
||
| 77 | } |
||
| 78 | |||
| 79 | public Double getValorTotalBrutoCartoesDebito() { |
||
| 80 | return valorTotalBrutoCartoesDebito; |
||
| 81 | } |
||
| 82 | public void setValorTotalBrutoCartoesDebito(Double valorTotalBrutoCartoesDebito) { |
||
| 83 | this.valorTotalBrutoCartoesDebito = valorTotalBrutoCartoesDebito; |
||
| 84 | } |
||
| 85 | |||
| 86 | public Double getValorTotalBrutoCartoesCredito() { |
||
| 87 | return getValorTotalBrutoCartoesCredito1x() + getValorTotalBrutoCartoesCreditoParcelado(); |
||
| 88 | } |
||
| 89 | |||
| 90 | public Double getValorTotalBrutoImportadoCartoesCredito() { |
||
| 91 | return getValorTotalBrutoImportadoCartoesCredito1x() + getValorTotalBrutoImportadoCartoesCreditoParcelado(); |
||
| 92 | } |
||
| 93 | |||
| 94 | public String getCorValoresConciliadosCartoesCredito() { |
||
| 95 | return getValorTotalBrutoCartoesCredito().equals(getValorTotalBrutoImportadoCartoesCredito())? "green" : "red"; |
||
| 96 | } |
||
| 97 | |||
| 98 | public Double getValorTotalBrutoCartoesCredito1x() { |
||
| 99 | return valorTotalBrutoCartoesCredito1x; |
||
| 100 | } |
||
| 101 | public void setValorTotalBrutoCartoesCredito1x(Double valorTotalBrutoCartoesCredito1x) { |
||
| 102 | this.valorTotalBrutoCartoesCredito1x = valorTotalBrutoCartoesCredito1x; |
||
| 103 | } |
||
| 104 | |||
| 105 | public Double getValorTotalBrutoCartoesCreditoParcelado() { |
||
| 106 | return valorTotalBrutoCartoesCreditoParcelado; |
||
| 107 | } |
||
| 108 | public void setValorTotalBrutoCartoesCreditoParcelado(Double valorTotalBrutoCartoesCreditoParcelado) { |
||
| 109 | this.valorTotalBrutoCartoesCreditoParcelado = valorTotalBrutoCartoesCreditoParcelado; |
||
| 110 | } |
||
| 111 | |||
| 112 | public Double getValorTotalBrutoImportadoCartoes() { |
||
| 113 | return valorTotalBrutoImportadoCartoes; |
||
| 114 | } |
||
| 115 | public void setValorTotalBrutoImportadoCartoes(Double valorTotalBrutoImportadoCartoes) { |
||
| 116 | this.valorTotalBrutoImportadoCartoes = valorTotalBrutoImportadoCartoes; |
||
| 117 | } |
||
| 118 | |||
| 119 | public Double getValorTotalBrutoImportadoCartoesDebito() { |
||
| 120 | return valorTotalBrutoImportadoCartoesDebito; |
||
| 121 | } |
||
| 122 | public void setValorTotalBrutoImportadoCartoesDebito(Double valorTotalBrutoImportadoCartoesDebito) { |
||
| 123 | this.valorTotalBrutoImportadoCartoesDebito = valorTotalBrutoImportadoCartoesDebito; |
||
| 124 | } |
||
| 125 | |||
| 126 | public String getCorValoresConciliadosCartoesDebito() { |
||
| 127 | return getValorTotalBrutoCartoesDebito().equals(getValorTotalBrutoImportadoCartoesDebito())? "green" : "red"; |
||
| 128 | } |
||
| 129 | |||
| 130 | public Double getValorTotalBrutoImportadoCartoesCredito1x() { |
||
| 131 | return valorTotalBrutoImportadoCartoesCredito1x; |
||
| 132 | } |
||
| 133 | public void setValorTotalBrutoImportadoCartoesCredito1x(Double valorTotalBrutoImportadoCartoesCredito1x) { |
||
| 134 | this.valorTotalBrutoImportadoCartoesCredito1x = valorTotalBrutoImportadoCartoesCredito1x; |
||
| 135 | } |
||
| 136 | |||
| 137 | public String getCorValoresConciliadosCartoesCredito1x() { |
||
| 138 | return getValorTotalBrutoCartoesCredito1x().equals(getValorTotalBrutoImportadoCartoesCredito1x())? "green" : "red"; |
||
| 139 | } |
||
| 140 | |||
| 141 | public Double getValorTotalBrutoImportadoCartoesCreditoParcelado() { |
||
| 142 | return valorTotalBrutoImportadoCartoesCreditoParcelado; |
||
| 143 | } |
||
| 144 | public void setValorTotalBrutoImportadoCartoesCreditoParcelado(Double valorTotalBrutoImportadoCartoesCreditoParcelado) { |
||
| 145 | this.valorTotalBrutoImportadoCartoesCreditoParcelado = valorTotalBrutoImportadoCartoesCreditoParcelado; |
||
| 146 | } |
||
| 147 | |||
| 148 | public String getCorValoresConciliadosCartoesCreditoParcelado() { |
||
| 149 | return getValorTotalBrutoCartoesCreditoParcelado().equals(getValorTotalBrutoImportadoCartoesCreditoParcelado())? "green" : "red"; |
||
| 150 | } |
||
| 151 | |||
| 152 | public Double getValorTotalLiquidoCartoesGerados() { |
||
| 153 | return valorTotalLiquidoCartoesGerados; |
||
| 154 | } |
||
| 155 | public void setValorTotalLiquidoCartoesGerados(Double valorTotalLiquidoCartoesGerados) { |
||
| 156 | this.valorTotalLiquidoCartoesGerados = valorTotalLiquidoCartoesGerados; |
||
| 157 | } |
||
| 158 | |||
| 159 | public Double getValorTotalLiquidoCartoesGeradosDebito() { |
||
| 160 | return valorTotalLiquidoCartoesGeradosDebito; |
||
| 161 | } |
||
| 162 | public void setValorTotalLiquidoCartoesGeradosDebito(Double valorTotalLiquidoCartoesGeradosDebito) { |
||
| 163 | this.valorTotalLiquidoCartoesGeradosDebito = valorTotalLiquidoCartoesGeradosDebito; |
||
| 164 | } |
||
| 165 | |||
| 166 | public Double getValorTotalLiquidoCartoesGeradosCredito() { |
||
| 167 | return getValorTotalLiquidoCartoesGeradosCredito1x() + getValorTotalLiquidoCartoesGeradosCreditoParcelado(); |
||
| 168 | } |
||
| 169 | |||
| 170 | public Double getValorTotalLiquidoCartoesGeradosCredito1x() { |
||
| 171 | return valorTotalLiquidoCartoesGeradosCredito1x; |
||
| 172 | } |
||
| 173 | public void setValorTotalLiquidoCartoesGeradosCredito1x(Double valorTotalLiquidoCartoesGeradosCredito1x) { |
||
| 174 | this.valorTotalLiquidoCartoesGeradosCredito1x = valorTotalLiquidoCartoesGeradosCredito1x; |
||
| 175 | } |
||
| 176 | |||
| 177 | public Double getValorTotalLiquidoCartoesGeradosCreditoParcelado() { |
||
| 178 | return valorTotalLiquidoCartoesGeradosCreditoParcelado; |
||
| 179 | } |
||
| 180 | public void setValorTotalLiquidoCartoesGeradosCreditoParcelado(Double valorTotalLiquidoCartoesGeradosCreditoParcelado) { |
||
| 181 | this.valorTotalLiquidoCartoesGeradosCreditoParcelado = valorTotalLiquidoCartoesGeradosCreditoParcelado; |
||
| 182 | } |
||
| 183 | |||
| 184 | @Transient |
||
| 185 | public String getCorValoresConciliados() { |
||
| 186 | return getIndicadorConciliado()? "green" : "red"; |
||
| 187 | } |
||
| 188 | |||
| 189 | /*************************************************************************/ |
||
| 190 | |||
| 191 | public void adicionarPagamento(CartaoBandeiraDTO cartaoBandeira) { |
||
| 192 | int index = getCartoesPorBandeira().indexOf(cartaoBandeira); |
||
| 193 | if (index >= 0) { |
||
| 194 | CartaoBandeiraDTO cartaoAdicionado = getCartoesPorBandeira().get(index); |
||
| 195 | cartaoAdicionado.setBruto(cartaoAdicionado.getBruto() + cartaoBandeira.getBruto()); |
||
| 196 | cartaoAdicionado.setQuantidade(cartaoAdicionado.getQuantidade() + 1); |
||
| 197 | cartaoAdicionado.setFormaPagamento(cartaoBandeira.getFormaPagamento()); |
||
| 198 | } else { |
||
| 199 | cartaoBandeira.setQuantidade(1); |
||
| 200 | getCartoesPorBandeira().add(cartaoBandeira); |
||
| 201 | } |
||
| 202 | somarValoresBruto(cartaoBandeira.getBruto(), cartaoBandeira.getFormaPagamento()); |
||
| 203 | } |
||
| 204 | |||
| 205 | public void adicionarPagamentoImportado(CartaoBandeiraDTO cartaoBandeira) { |
||
| 206 | int index = getCartoesPorBandeira().indexOf(cartaoBandeira); |
||
| 207 | if (index >= 0) { |
||
| 208 | CartaoBandeiraDTO cartaoAdicionado = getCartoesPorBandeira().get(index); |
||
| 209 | cartaoAdicionado.setBrutoImportado(cartaoAdicionado.getBrutoImportado() + cartaoBandeira.getBrutoImportado()); |
||
| 210 | cartaoAdicionado.setQuantidadeImportado(cartaoAdicionado.getQuantidadeImportado() + 1); |
||
| 211 | cartaoAdicionado.setFormaPagamento(cartaoBandeira.getFormaPagamento()); |
||
| 212 | } else { |
||
| 213 | cartaoBandeira.setQuantidadeImportado(1); |
||
| 214 | getCartoesPorBandeira().add(cartaoBandeira); |
||
| 215 | } |
||
| 216 | somarValoresBrutoImportado(cartaoBandeira.getBrutoImportado(), cartaoBandeira.getFormaPagamento()); |
||
| 217 | } |
||
| 218 | |||
| 219 | public List<CartaoBandeiraDTO> getCartoesPorBandeiraDebito() { |
||
| 220 | List<CartaoBandeiraDTO> cartoesDebito = new ArrayList<CartaoBandeiraDTO>(); |
||
| 221 | for (CartaoBandeiraDTO cartaoBandeira : getCartoesPorBandeira()) { |
||
| 222 | if (cartaoBandeira.getFormaPagamento().formaPagamentoEhDebito()) { |
||
| 223 | cartoesDebito.add(cartaoBandeira); |
||
| 224 | } |
||
| 225 | } |
||
| 226 | return cartoesDebito; |
||
| 227 | } |
||
| 228 | |||
| 229 | public List<CartaoBandeiraDTO> getCartoesPorBandeiraCredito() throws CloneNotSupportedException { |
||
| 230 | List<CartaoBandeiraDTO> cartoesCredito = new ArrayList<CartaoBandeiraDTO>(); |
||
| 231 | for (CartaoBandeiraDTO cartaoBandeira : getCartoesPorBandeira()) { |
||
| 232 | if (cartaoBandeira.getFormaPagamento().formaPagamentoEhCredito()) { |
||
| 233 | CartaoBandeiraDTO cartao = cartaoBandeira.clone(); |
||
| 234 | cartao.setFormaPagamento(null); |
||
| 235 | int index = cartoesCredito.indexOf(cartao); |
||
| 236 | if (index >= 0) { |
||
| 237 | CartaoBandeiraDTO cartaoAdicionado = cartoesCredito.get(index); |
||
| 238 | cartaoAdicionado.setBrutoImportado(cartaoAdicionado.getBrutoImportado() + cartao.getBrutoImportado()); |
||
| 239 | cartaoAdicionado.setBruto(cartaoAdicionado.getBruto() + cartao.getBruto()); |
||
| 240 | cartaoAdicionado.setQuantidadeImportado(cartaoAdicionado.getQuantidadeImportado() + cartao.getQuantidadeImportado()); |
||
| 241 | cartaoAdicionado.setQuantidade(cartaoAdicionado.getQuantidade() + cartao.getQuantidade()); |
||
| 242 | cartaoAdicionado.setFormaPagamento(cartao.getFormaPagamento()); |
||
| 243 | } else { |
||
| 244 | cartoesCredito.add(cartao); |
||
| 245 | } |
||
| 246 | } |
||
| 247 | } |
||
| 248 | return cartoesCredito; |
||
| 249 | } |
||
| 250 | |||
| 251 | public List<CartaoBandeiraDTO> getCartoesPorBandeiraCredito1x() { |
||
| 252 | List<CartaoBandeiraDTO> cartoesCredito = new ArrayList<CartaoBandeiraDTO>(); |
||
| 253 | for (CartaoBandeiraDTO cartaoBandeira : getCartoesPorBandeira()) { |
||
| 254 | if (cartaoBandeira.getFormaPagamento().formaPagamentoEhCredito() && cartaoBandeira.getFormaPagamento().formaPagamentoEh1x()) { |
||
| 255 | cartoesCredito.add(cartaoBandeira); |
||
| 256 | } |
||
| 257 | } |
||
| 258 | return cartoesCredito; |
||
| 259 | } |
||
| 260 | |||
| 261 | public List<CartaoBandeiraDTO> getCartoesPorBandeiraCreditoParcelado() { |
||
| 262 | List<CartaoBandeiraDTO> cartoesCredito = new ArrayList<CartaoBandeiraDTO>(); |
||
| 263 | for (CartaoBandeiraDTO cartaoBandeira : getCartoesPorBandeira()) { |
||
| 264 | if (cartaoBandeira.getFormaPagamento().formaPagamentoEhCredito() && !cartaoBandeira.getFormaPagamento().formaPagamentoEh1x()) { |
||
| 265 | cartoesCredito.add(cartaoBandeira); |
||
| 266 | } |
||
| 267 | } |
||
| 268 | return cartoesCredito; |
||
| 269 | } |
||
| 270 | |||
| 271 | public List<CartaoBandeiraDTO> getCartoesPorBandeiraCreditoParceladoAgrupado() { |
||
| 272 | List<CartaoBandeiraDTO> cartoesCredito = new ArrayList<CartaoBandeiraDTO>(); |
||
| 273 | for (CartaoBandeiraDTO cartaoBandeira : getCartoesPorBandeiraCreditoParcelado()) { |
||
| 274 | CartaoBandeiraDTO cartao = cartaoBandeira.clone(); |
||
| 275 | cartao.setFormaPagamento(null); |
||
| 276 | int index = cartoesCredito.indexOf(cartao); |
||
| 277 | if (index >= 0) { |
||
| 278 | CartaoBandeiraDTO cartaoAdicionado = cartoesCredito.get(index); |
||
| 279 | cartaoAdicionado.setBrutoImportado(cartaoAdicionado.getBrutoImportado() + cartao.getBrutoImportado()); |
||
| 280 | cartaoAdicionado.setBruto(cartaoAdicionado.getBruto() + cartao.getBruto()); |
||
| 281 | cartaoAdicionado.setQuantidadeImportado(cartaoAdicionado.getQuantidadeImportado() + cartao.getQuantidadeImportado()); |
||
| 282 | cartaoAdicionado.setQuantidade(cartaoAdicionado.getQuantidade() + cartao.getQuantidade()); |
||
| 283 | } else { |
||
| 284 | cartoesCredito.add(cartao); |
||
| 285 | } |
||
| 286 | } |
||
| 287 | return cartoesCredito; |
||
| 288 | } |
||
| 289 | |||
| 290 | public void somarValoresBruto(Double valor, FormaPagamento formaDePagamento) { |
||
| 291 | valorTotalBrutoCartoes = valorTotalBrutoCartoes + valor; |
||
| 292 | if (formaDePagamento.formaPagamentoEhDebito()) { |
||
| 293 | valorTotalBrutoCartoesDebito = valorTotalBrutoCartoesDebito + valor; |
||
| 294 | } |
||
| 295 | if (formaDePagamento.formaPagamentoEhCredito()) { |
||
| 296 | if (formaDePagamento.formaPagamentoEh1x()) { |
||
| 297 | valorTotalBrutoCartoesCredito1x = valorTotalBrutoCartoesCredito1x + valor; |
||
| 298 | } else { |
||
| 299 | valorTotalBrutoCartoesCreditoParcelado = valorTotalBrutoCartoesCreditoParcelado + valor; |
||
| 300 | } |
||
| 301 | } |
||
| 302 | } |
||
| 303 | |||
| 304 | public void somarValoresBrutoImportado(Double valor, FormaPagamento formaDePagamento) { |
||
| 305 | valorTotalBrutoImportadoCartoes = valorTotalBrutoImportadoCartoes + valor; |
||
| 306 | if (formaDePagamento.formaPagamentoEhDebito()) { |
||
| 307 | valorTotalBrutoImportadoCartoesDebito = valorTotalBrutoImportadoCartoesDebito + valor; |
||
| 308 | } |
||
| 309 | if (formaDePagamento.formaPagamentoEhCredito()) { |
||
| 310 | if (formaDePagamento.formaPagamentoEh1x()) { |
||
| 311 | valorTotalBrutoImportadoCartoesCredito1x = valorTotalBrutoImportadoCartoesCredito1x + valor; |
||
| 312 | } else { |
||
| 313 | valorTotalBrutoImportadoCartoesCreditoParcelado = valorTotalBrutoImportadoCartoesCreditoParcelado + valor; |
||
| 314 | } |
||
| 315 | } |
||
| 316 | } |
||
| 317 | |||
| 318 | public void somarValoresLiquido(List<CartaoDTO> cartoesGerados) { |
||
| 319 | for (CartaoDTO cartaoGerado : cartoesGerados) { |
||
| 320 | valorTotalLiquidoCartoesGerados = valorTotalLiquidoCartoesGerados + cartaoGerado.getParcela().getValor(); |
||
| 321 | if (VerificadorUtil.naoEstaNulo(cartaoGerado.getFormaDePagamento())) { |
||
| 322 | if (cartaoGerado.getFormaDePagamento().formaPagamentoEhDebito()) { |
||
| 323 | valorTotalLiquidoCartoesGeradosDebito = valorTotalLiquidoCartoesGeradosDebito + cartaoGerado.getParcela().getValor(); |
||
| 324 | } |
||
| 325 | if (cartaoGerado.getFormaDePagamento().formaPagamentoEhCredito()) { |
||
| 326 | if (cartaoGerado.getFormaDePagamento().formaPagamentoEh1x()) { |
||
| 327 | valorTotalLiquidoCartoesGeradosCredito1x = valorTotalLiquidoCartoesGeradosCredito1x + cartaoGerado.getParcela().getValor(); |
||
| 328 | } else { |
||
| 329 | valorTotalLiquidoCartoesGeradosCreditoParcelado = valorTotalLiquidoCartoesGeradosCreditoParcelado + cartaoGerado.getParcela().getValor(); |
||
| 330 | } |
||
| 331 | } |
||
| 332 | } |
||
| 333 | } |
||
| 334 | } |
||
| 335 | |||
| 336 | public void somarValores() { |
||
| 337 | setIndicadorConciliado(true); |
||
| 338 | for (CartaoBandeiraDTO bandeira : getCartoesPorBandeira()) { |
||
| 339 | if (!bandeira.getBruto().equals(bandeira.getBrutoImportado())) { |
||
| 340 | setIndicadorConciliado(false); |
||
| 341 | } |
||
| 342 | somarValoresBruto(bandeira.getBruto(), bandeira.getFormaPagamento()); |
||
| 343 | somarValoresBrutoImportado(bandeira.getBrutoImportado(), bandeira.getFormaPagamento()); |
||
| 344 | } |
||
| 345 | } |
||
| 346 | |||
| 347 | } |