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