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