Rev 353 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 261 | espaco | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 264 | espaco | 3 | import java.util.ArrayList; |
| 4 | import java.util.List; |
||
| 5 | |||
| 261 | espaco | 6 | import br.com.ec.core.util.StringUtil; |
| 7 | |||
| 8 | public class FormaPagamentoDTO { |
||
| 9 | |||
| 10 | private static final long FORMAPAGAMENTO_DINHEIRO = 1; |
||
| 11 | private static final long FORMAPAGAMENTO_DEBITO = 2; |
||
| 12 | private static final long FORMAPAGAMENTO_PAGSEGURO = 6; |
||
| 13 | private static final long FORMAPAGAMENTO_OUTROS = 17; |
||
| 14 | private static final long FORMAPAGAMENTO_1X = 3; |
||
| 15 | private static final long FORMAPAGAMENTO_2X = 4; |
||
| 16 | private static final long FORMAPAGAMENTO_3X = 5; |
||
| 17 | private static final long FORMAPAGAMENTO_4X = 7; |
||
| 18 | private static final long FORMAPAGAMENTO_5X = 8; |
||
| 19 | private static final long FORMAPAGAMENTO_6X = 9; |
||
| 20 | private static final long FORMAPAGAMENTO_7X = 10; |
||
| 21 | private static final long FORMAPAGAMENTO_8X = 11; |
||
| 22 | private static final long FORMAPAGAMENTO_9X = 12; |
||
| 23 | private static final long FORMAPAGAMENTO_10X = 13; |
||
| 24 | private static final long FORMAPAGAMENTO_11X = 14; |
||
| 25 | private static final long FORMAPAGAMENTO_12X = 15; |
||
| 274 | espaco | 26 | private static final long FORMAPAGAMENTO_13X = 19; |
| 27 | private static final long FORMAPAGAMENTO_14X = 20; |
||
| 28 | private static final long FORMAPAGAMENTO_15X = 21; |
||
| 296 | espaco | 29 | private static final long FORMAPAGAMENTO_16X = 22; |
| 30 | private static final long FORMAPAGAMENTO_17X = 23; |
||
| 31 | private static final long FORMAPAGAMENTO_18X = 24; |
||
| 261 | espaco | 32 | private static final long FORMAPAGAMENTO_PIX = 18; |
| 353 | espaco | 33 | private static final long FORMAPAGAMENTO_TRANSFERENCIA = 25; |
| 261 | espaco | 34 | |
| 35 | private static final long FORMAPAGAMENTO_CUPOM = 16; |
||
| 36 | |||
| 37 | private Long codigo; |
||
| 38 | private String descricao; |
||
| 39 | private Integer numeroOrdem; |
||
| 40 | private Boolean ativo; |
||
| 41 | |||
| 42 | public FormaPagamentoDTO() {} |
||
| 43 | |||
| 44 | public FormaPagamentoDTO(Long codigo) { |
||
| 45 | this.codigo = codigo; |
||
| 46 | } |
||
| 47 | |||
| 264 | espaco | 48 | public FormaPagamentoDTO(Long codigo, String descricao) { |
| 49 | this.codigo = codigo; |
||
| 50 | this.descricao = descricao; |
||
| 51 | } |
||
| 52 | |||
| 261 | espaco | 53 | public Long getCodigo() { |
| 54 | return codigo; |
||
| 55 | } |
||
| 56 | public void setCodigo(Long codigo) { |
||
| 57 | this.codigo = codigo; |
||
| 58 | } |
||
| 59 | |||
| 60 | public String getDescricao() { |
||
| 61 | return descricao; |
||
| 62 | } |
||
| 63 | public void setDescricao(String descricao) { |
||
| 64 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 65 | } |
||
| 66 | |||
| 67 | public Integer getNumeroOrdem() { |
||
| 68 | return numeroOrdem; |
||
| 69 | } |
||
| 70 | public void setNumeroOrdem(Integer numeroOrdem) { |
||
| 71 | this.numeroOrdem = numeroOrdem; |
||
| 72 | } |
||
| 73 | |||
| 74 | public Boolean getAtivo() { |
||
| 75 | return ativo; |
||
| 76 | } |
||
| 77 | public void setAtivo(Boolean ativo) { |
||
| 78 | this.ativo = ativo; |
||
| 79 | } |
||
| 80 | |||
| 81 | public boolean formaPagamentoEhDinheiro() { |
||
| 82 | return getCodigo().equals(FORMAPAGAMENTO_DINHEIRO); |
||
| 83 | } |
||
| 84 | |||
| 85 | public boolean formaPagamentoEhCartao() { |
||
| 86 | return !(formaPagamentoEhDinheiro() || formaPagamentoEhCupom() || formaPagamentoEhOutros()); |
||
| 87 | } |
||
| 88 | |||
| 89 | public boolean formaPagamentoEhDebito() { |
||
| 90 | return getCodigo().equals(FORMAPAGAMENTO_DEBITO); |
||
| 91 | } |
||
| 92 | |||
| 93 | public boolean formaPagamentoEhPagseguro() { |
||
| 94 | return getCodigo().equals(FORMAPAGAMENTO_PAGSEGURO); |
||
| 95 | } |
||
| 96 | |||
| 97 | public boolean formaPagamentoEhPix() { |
||
| 98 | return getCodigo().equals(FORMAPAGAMENTO_PIX); |
||
| 99 | } |
||
| 100 | |||
| 353 | espaco | 101 | public boolean formaPagamentoEhTransferencia() { |
| 102 | return getCodigo().equals(FORMAPAGAMENTO_TRANSFERENCIA); |
||
| 103 | } |
||
| 104 | |||
| 261 | espaco | 105 | public boolean formaPagamentoEhCredito() { |
| 106 | return !(formaPagamentoEhDinheiro() || formaPagamentoEhDebito() || formaPagamentoEhPagseguro() || formaPagamentoEhCupom() || formaPagamentoEhOutros() || formaPagamentoEhPix()); |
||
| 107 | } |
||
| 108 | |||
| 109 | public boolean formaPagamentoEhCreditoDividido() { |
||
| 110 | return formaPagamentoEhCredito() && !formaPagamentoEh1x(); |
||
| 111 | } |
||
| 112 | |||
| 113 | public boolean formaPagamentoEh1x() { |
||
| 114 | return getCodigo().equals(FORMAPAGAMENTO_1X); |
||
| 115 | } |
||
| 116 | |||
| 117 | public boolean formaPagamentoEh2x() { |
||
| 118 | return getCodigo().equals(FORMAPAGAMENTO_2X); |
||
| 119 | } |
||
| 120 | |||
| 121 | public boolean formaPagamentoEh3x() { |
||
| 122 | return getCodigo().equals(FORMAPAGAMENTO_3X); |
||
| 123 | } |
||
| 124 | |||
| 125 | public boolean formaPagamentoEh4x() { |
||
| 126 | return getCodigo().equals(FORMAPAGAMENTO_4X); |
||
| 127 | } |
||
| 128 | |||
| 129 | public boolean formaPagamentoEh5x() { |
||
| 130 | return getCodigo().equals(FORMAPAGAMENTO_5X); |
||
| 131 | } |
||
| 132 | |||
| 133 | public boolean formaPagamentoEh6x() { |
||
| 134 | return getCodigo().equals(FORMAPAGAMENTO_6X); |
||
| 135 | } |
||
| 136 | |||
| 137 | public boolean formaPagamentoEh7x() { |
||
| 138 | return getCodigo().equals(FORMAPAGAMENTO_7X); |
||
| 139 | } |
||
| 140 | |||
| 141 | public boolean formaPagamentoEh8x() { |
||
| 142 | return getCodigo().equals(FORMAPAGAMENTO_8X); |
||
| 143 | } |
||
| 144 | |||
| 145 | public boolean formaPagamentoEh9x() { |
||
| 146 | return getCodigo().equals(FORMAPAGAMENTO_9X); |
||
| 147 | } |
||
| 148 | |||
| 149 | public boolean formaPagamentoEh10x() { |
||
| 150 | return getCodigo().equals(FORMAPAGAMENTO_10X); |
||
| 151 | } |
||
| 152 | |||
| 153 | public boolean formaPagamentoEh11x() { |
||
| 154 | return getCodigo().equals(FORMAPAGAMENTO_11X); |
||
| 155 | } |
||
| 156 | |||
| 157 | public boolean formaPagamentoEh12x() { |
||
| 158 | return getCodigo().equals(FORMAPAGAMENTO_12X); |
||
| 159 | } |
||
| 274 | espaco | 160 | |
| 161 | public boolean formaPagamentoEh13x() { |
||
| 162 | return getCodigo().equals(FORMAPAGAMENTO_13X); |
||
| 163 | } |
||
| 164 | |||
| 165 | public boolean formaPagamentoEh14x() { |
||
| 166 | return getCodigo().equals(FORMAPAGAMENTO_14X); |
||
| 167 | } |
||
| 168 | |||
| 169 | public boolean formaPagamentoEh15x() { |
||
| 170 | return getCodigo().equals(FORMAPAGAMENTO_15X); |
||
| 171 | } |
||
| 261 | espaco | 172 | |
| 173 | public boolean formaPagamentoEhCupom() { |
||
| 174 | return getCodigo().equals(FORMAPAGAMENTO_CUPOM); |
||
| 175 | } |
||
| 176 | |||
| 177 | public boolean formaPagamentoEhOutros() { |
||
| 178 | return getCodigo().equals(FORMAPAGAMENTO_OUTROS); |
||
| 179 | } |
||
| 180 | |||
| 181 | public static Long recuperarCodigoDaFormaDePagamento(String parcela) { |
||
| 182 | if (parcela.equals("1")) { |
||
| 183 | return FORMAPAGAMENTO_1X; |
||
| 184 | } else if (parcela.equals("2")) { |
||
| 185 | return FORMAPAGAMENTO_2X; |
||
| 186 | } else if (parcela.equals("3")) { |
||
| 187 | return FORMAPAGAMENTO_3X; |
||
| 188 | } else if (parcela.equals("4")) { |
||
| 189 | return FORMAPAGAMENTO_4X; |
||
| 190 | } else if (parcela.equals("5")) { |
||
| 191 | return FORMAPAGAMENTO_5X; |
||
| 192 | } else if (parcela.equals("6")) { |
||
| 193 | return FORMAPAGAMENTO_6X; |
||
| 194 | } else if (parcela.equals("7")) { |
||
| 195 | return FORMAPAGAMENTO_7X; |
||
| 196 | } else if (parcela.equals("8")) { |
||
| 197 | return FORMAPAGAMENTO_8X; |
||
| 198 | } else if (parcela.equals("9")) { |
||
| 199 | return FORMAPAGAMENTO_9X; |
||
| 200 | } else if (parcela.equals("10")) { |
||
| 201 | return FORMAPAGAMENTO_10X; |
||
| 202 | } else if (parcela.equals("11")) { |
||
| 203 | return FORMAPAGAMENTO_11X; |
||
| 204 | } else if (parcela.equals("12")) { |
||
| 205 | return FORMAPAGAMENTO_12X; |
||
| 274 | espaco | 206 | } else if (parcela.equals("13")) { |
| 207 | return FORMAPAGAMENTO_13X; |
||
| 208 | } else if (parcela.equals("14")) { |
||
| 209 | return FORMAPAGAMENTO_14X; |
||
| 210 | } else if (parcela.equals("15")) { |
||
| 211 | return FORMAPAGAMENTO_15X; |
||
| 261 | espaco | 212 | } |
| 213 | return null; |
||
| 214 | } |
||
| 215 | |||
| 216 | @Override |
||
| 217 | public int hashCode() { |
||
| 218 | final int prime = 31; |
||
| 219 | int result = 1; |
||
| 220 | result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); |
||
| 221 | return result; |
||
| 222 | } |
||
| 223 | |||
| 224 | @Override |
||
| 225 | public boolean equals(Object obj) { |
||
| 226 | if (this == obj) |
||
| 227 | return true; |
||
| 228 | if (obj == null) |
||
| 229 | return false; |
||
| 230 | if (getClass() != obj.getClass()) |
||
| 231 | return false; |
||
| 232 | FormaPagamentoDTO other = (FormaPagamentoDTO) obj; |
||
| 233 | if (codigo == null) { |
||
| 234 | if (other.codigo != null) |
||
| 235 | return false; |
||
| 236 | } else if (!codigo.equals(other.codigo)) |
||
| 237 | return false; |
||
| 238 | return true; |
||
| 239 | } |
||
| 264 | espaco | 240 | |
| 241 | public static List<FormaPagamentoDTO> todasFormasDePagamento() { |
||
| 242 | List<FormaPagamentoDTO> formasPreenchidas = formasDePagamentoSemCupom(); |
||
| 243 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_CUPOM, "CUPOM")); |
||
| 244 | return formasPreenchidas; |
||
| 245 | } |
||
| 261 | espaco | 246 | |
| 296 | espaco | 247 | public static List<FormaPagamentoDTO> formasDePagamentoViaCartaoDebito() { |
| 264 | espaco | 248 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
| 249 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_DEBITO, "DÉBITO")); |
||
| 296 | espaco | 250 | return formasPreenchidas; |
| 251 | } |
||
| 252 | |||
| 253 | public static List<FormaPagamentoDTO> formasDePagamentoViaCartaoCredito() { |
||
| 254 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
||
| 264 | espaco | 255 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_1X, "1X")); |
| 256 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_2X, "2X")); |
||
| 257 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_3X, "3X")); |
||
| 258 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_4X, "4X")); |
||
| 259 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_5X, "5X")); |
||
| 260 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_6X, "6X")); |
||
| 261 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_7X, "7X")); |
||
| 262 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_8X, "8X")); |
||
| 263 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_9X, "9X")); |
||
| 264 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_10X, "10X")); |
||
| 265 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_11X, "11X")); |
||
| 266 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_12X, "12X")); |
||
| 274 | espaco | 267 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_13X, "13X")); |
| 268 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_14X, "14X")); |
||
| 269 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_15X, "15X")); |
||
| 296 | espaco | 270 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_16X, "16X")); |
| 271 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_17X, "17X")); |
||
| 272 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_18X, "18X")); |
||
| 273 | return formasPreenchidas; |
||
| 274 | } |
||
| 275 | |||
| 386 | espaco | 276 | public static List<FormaPagamentoDTO> formasDePagamentoOutros() { |
| 277 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
||
| 278 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_OUTROS, "OUTROS")); |
||
| 279 | return formasPreenchidas; |
||
| 280 | } |
||
| 281 | |||
| 296 | espaco | 282 | public static List<FormaPagamentoDTO> formasDePagamentoViaPix() { |
| 283 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
||
| 264 | espaco | 284 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_PIX, "PIX")); |
| 296 | espaco | 285 | return formasPreenchidas; |
| 286 | } |
||
| 287 | |||
| 353 | espaco | 288 | public static List<FormaPagamentoDTO> formasDePagamentoViaTransferencia() { |
| 289 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
||
| 290 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_TRANSFERENCIA, "TRANSFERÊNCIA")); |
||
| 291 | return formasPreenchidas; |
||
| 292 | } |
||
| 293 | |||
| 296 | espaco | 294 | public static List<FormaPagamentoDTO> formasDePagamentoSemCupom() { |
| 295 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
||
| 296 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_DINHEIRO, "DINHEIRO")); |
||
| 297 | formasPreenchidas.addAll(formasDePagamentoViaCartaoDebito()); |
||
| 298 | formasPreenchidas.addAll(formasDePagamentoViaCartaoCredito()); |
||
| 299 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_PIX, "PIX")); |
||
| 353 | espaco | 300 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_TRANSFERENCIA, "TRANSFERÊNCIA")); |
| 264 | espaco | 301 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_PAGSEGURO, "PAGSEGURO")); |
| 302 | formasPreenchidas.add(new FormaPagamentoDTO(FORMAPAGAMENTO_OUTROS, "OUTROS")); |
||
| 303 | return formasPreenchidas; |
||
| 304 | } |
||
| 305 | |||
| 265 | espaco | 306 | public static List<FormaPagamentoDTO> formasDePagamentoViaCartao() { |
| 307 | List<FormaPagamentoDTO> formasPreenchidas = new ArrayList<FormaPagamentoDTO>(); |
||
| 296 | espaco | 308 | formasPreenchidas.addAll(formasDePagamentoViaCartaoDebito()); |
| 309 | formasPreenchidas.addAll(formasDePagamentoViaCartaoCredito()); |
||
| 265 | espaco | 310 | return formasPreenchidas; |
| 311 | } |
||
| 312 | |||
| 313 | public static List<Long> codigosFormasDePagamentoViaCartao() { |
||
| 314 | List<Long> codigosFormas = new ArrayList<Long>(); |
||
| 315 | for (FormaPagamentoDTO forma : formasDePagamentoViaCartao()) { |
||
| 316 | codigosFormas.add(forma.getCodigo()); |
||
| 317 | } |
||
| 318 | return codigosFormas; |
||
| 319 | } |
||
| 320 | |||
| 261 | espaco | 321 | } |