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