Rev 140 | Rev 145 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 140 | Rev 144 | ||
|---|---|---|---|
| Line 18... | Line 18... | ||
| 18 | import javax.persistence.SequenceGenerator; |
18 | import javax.persistence.SequenceGenerator; |
| 19 | import javax.persistence.Table; |
19 | import javax.persistence.Table; |
| 20 | import javax.persistence.Transient; |
20 | import javax.persistence.Transient; |
| 21 | import javax.validation.constraints.NotNull; |
21 | import javax.validation.constraints.NotNull; |
| 22 | import javax.validation.constraints.Size; |
22 | import javax.validation.constraints.Size; |
| - | 23 | import javax.xml.bind.JAXBElement; |
|
| 23 | 24 | ||
| 24 | import org.hibernate.annotations.ForeignKey; |
25 | import org.hibernate.annotations.ForeignKey; |
| 25 | import org.hibernate.annotations.GenericGenerator; |
26 | import org.hibernate.annotations.GenericGenerator; |
| 26 | import org.hibernate.validator.constraints.NotEmpty; |
27 | import org.hibernate.validator.constraints.NotEmpty; |
| 27 | 28 | ||
| 28 | import br.com.ec.controller.util.UtilBean; |
29 | import br.com.ec.controller.util.UtilBean; |
| 29 | import br.com.ec.domain.model.tipos.TipoCorProduto; |
30 | import br.com.ec.domain.model.tipos.TipoCorProduto; |
| 30 | import br.com.ec.domain.model.tipos.TipoEstiloProduto; |
31 | import br.com.ec.domain.model.tipos.TipoEstiloProduto; |
| 31 | import br.com.ec.domain.model.tipos.TipoGenero; |
32 | import br.com.ec.domain.model.tipos.TipoGenero; |
| 32 | import br.com.ec.domain.model.tipos.TipoProduto; |
33 | import br.com.ec.domain.model.tipos.TipoProduto; |
| - | 34 | import br.com.ec.domain.shared.ConstantesSEC; |
|
| 33 | import br.com.ec.domain.util.CodigoBarraEAN; |
35 | import br.com.ec.domain.util.CodigoBarraEAN; |
| 34 | import br.edu.cesmac.core.interfaces.Alterar; |
36 | import br.edu.cesmac.core.interfaces.Alterar; |
| 35 | import br.edu.cesmac.core.interfaces.Cadastrar; |
37 | import br.edu.cesmac.core.interfaces.Cadastrar; |
| 36 | import br.edu.cesmac.core.util.DataUtils; |
38 | import br.edu.cesmac.core.util.DataUtils; |
| 37 | import br.edu.cesmac.core.util.StringUtil; |
39 | import br.edu.cesmac.core.util.StringUtil; |
| 38 | import br.edu.cesmac.core.util.VerificadorUtil; |
40 | import br.edu.cesmac.core.util.VerificadorUtil; |
| - | 41 | import nfce.java.TNFe.InfNFe.Det.Imposto.ICMS.ICMS00; |
|
| 39 | 42 | ||
| 40 | @Entity |
43 | @Entity |
| 41 | @Table(name="sec_produto", schema="sc_sec") |
44 | @Table(name="sec_produto", schema="sc_sec") |
| 42 | public class Produto implements Serializable, Cloneable { |
45 | public class Produto implements Serializable, Cloneable { |
| 43 | 46 | ||
| Line 67... | Line 70... | ||
| 67 | private Date dataOnlineShoplog; |
70 | private Date dataOnlineShoplog; |
| 68 | private Boolean indicadorFavorito; |
71 | private Boolean indicadorFavorito; |
| 69 | private Boolean indicadorComissionado; |
72 | private Boolean indicadorComissionado; |
| 70 | private Boolean indicadorEmissaoNotaFiscal; |
73 | private Boolean indicadorEmissaoNotaFiscal; |
| 71 | 74 | ||
| - | 75 | private Double valorVarejoSimulacao; |
|
| 72 | private Boolean sujeitoST; |
76 | private Boolean sujeitoST; |
| - | 77 | private Double aliquotaIPI; |
|
| - | 78 | private Double aliquotaIcms; |
|
| - | 79 | private Double aliquotaIcmsST; |
|
| - | 80 | private Double aliquotaFecoep; |
|
| 73 | private Boolean ativo; |
81 | private Boolean ativo; |
| 74 | 82 | ||
| 75 | private String codigoNCM; |
83 | private String codigoNCM; |
| 76 | private String codigoEST; |
84 | private String codigoEST; |
| 77 | private Set<ProdutoPedidoCompra> pedidosCompra; |
85 | private Set<ProdutoPedidoCompra> pedidosCompra; |
| Line 325... | Line 333... | ||
| 325 | }
|
333 | }
|
| 326 | return sujeitoST; |
334 | return sujeitoST; |
| 327 | }
|
335 | }
|
| 328 | public void setSujeitoST(Boolean sujeitoST) { |
336 | public void setSujeitoST(Boolean sujeitoST) { |
| 329 | this.sujeitoST = sujeitoST; |
337 | this.sujeitoST = sujeitoST; |
| - | 338 | }
|
|
| - | 339 | ||
| - | 340 | @Transient |
|
| - | 341 | public Double getValorVarejoSimulacao() { |
|
| - | 342 | if (VerificadorUtil.estaNulo(valorVarejoSimulacao)) { |
|
| - | 343 | return getValorVarejo(); |
|
| - | 344 | }
|
|
| - | 345 | return valorVarejoSimulacao; |
|
| - | 346 | }
|
|
| - | 347 | public void setValorVarejoSimulacao(Double valorVarejoSimulacao) { |
|
| - | 348 | this.valorVarejoSimulacao = valorVarejoSimulacao; |
|
| - | 349 | }
|
|
| - | 350 | ||
| - | 351 | @Column(name="val_aliquota_icms") |
|
| - | 352 | public Double getAliquotaIcms() { |
|
| - | 353 | return aliquotaIcms; |
|
| - | 354 | }
|
|
| - | 355 | public void setAliquotaIcms(Double aliquotaIcms) { |
|
| - | 356 | this.aliquotaIcms = aliquotaIcms; |
|
| - | 357 | }
|
|
| - | 358 | ||
| - | 359 | @Column(name="val_aliquota_icms_st") |
|
| - | 360 | public Double getAliquotaIcmsST() { |
|
| - | 361 | return aliquotaIcmsST; |
|
| - | 362 | }
|
|
| - | 363 | public void setAliquotaIcmsST(Double aliquotaIcmsST) { |
|
| - | 364 | this.aliquotaIcmsST = aliquotaIcmsST; |
|
| - | 365 | }
|
|
| - | 366 | ||
| - | 367 | @Column(name="val_aliquota_fecoep") |
|
| - | 368 | public Double getAliquotaFecoep() { |
|
| - | 369 | return aliquotaFecoep; |
|
| - | 370 | }
|
|
| - | 371 | public void setAliquotaFecoep(Double aliquotaFecoep) { |
|
| - | 372 | this.aliquotaFecoep = aliquotaFecoep; |
|
| - | 373 | }
|
|
| - | 374 | ||
| - | 375 | @Column(name="val_aliquota_ipi") |
|
| - | 376 | public Double getAliquotaIPI() { |
|
| - | 377 | return aliquotaIPI; |
|
| - | 378 | }
|
|
| - | 379 | public void setAliquotaIPI(Double aliquotaIPI) { |
|
| - | 380 | this.aliquotaIPI = aliquotaIPI; |
|
| 330 | }
|
381 | }
|
| 331 | 382 | ||
| 332 | @Column(name="ind_ativo") |
383 | @Column(name="ind_ativo") |
| 333 | public Boolean getAtivo() { |
384 | public Boolean getAtivo() { |
| 334 | return ativo; |
385 | return ativo; |
| Line 721... | Line 772... | ||
| 721 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getNCM())) { |
772 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getNCM())) { |
| 722 | this.setCodigoNCM(produtoNota.getProd().getNCM()); |
773 | this.setCodigoNCM(produtoNota.getProd().getNCM()); |
| 723 | }
|
774 | }
|
| 724 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getCEST())) { |
775 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getCEST())) { |
| 725 | this.setCodigoEST(produtoNota.getProd().getCEST()); |
776 | this.setCodigoEST(produtoNota.getProd().getCEST()); |
| - | 777 | }
|
|
| - | 778 | ||
| - | 779 | for (JAXBElement<?> elemento : produtoNota.getImposto().getContent()) { |
|
| - | 780 | if (elemento.getDeclaredType().equals(nfce.java.TNFe.InfNFe.Det.Imposto.ICMS.class)) { |
|
| - | 781 | nfce.java.TNFe.InfNFe.Det.Imposto.ICMS icms = (nfce.java.TNFe.InfNFe.Det.Imposto.ICMS) elemento.getValue(); |
|
| - | 782 | this.setAliquotaIcms(Double.valueOf(icms.getICMS00().getPICMS())); |
|
| - | 783 | }
|
|
| - | 784 | if (elemento.getDeclaredType().equals(nfce.java.TIpi.class)) { |
|
| - | 785 | nfce.java.TIpi ipi = (nfce.java.TIpi) elemento.getValue(); |
|
| - | 786 | this.setAliquotaIPI(Double.valueOf(ipi.getIPITrib().getPIPI())); |
|
| - | 787 | }
|
|
| 726 | }
|
788 | }
|
| 727 | }
|
789 | }
|
| 728 | 790 | ||
| 729 | public Double retornarValorComDesconto(nfce.java.TNFe.InfNFe.Det.Prod produto) { |
791 | public Double retornarValorComDesconto(nfce.java.TNFe.InfNFe.Det.Prod produto) { |
| 730 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getVDesc())) { |
792 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getVDesc())) { |
| Line 772... | Line 834... | ||
| 772 | public String retornarCorMargem() { |
834 | public String retornarCorMargem() { |
| 773 | Double margemBruta = retornarMargemBruta(); |
835 | Double margemBruta = retornarMargemBruta(); |
| 774 | if (margemBruta > 0.50) return "green"; |
836 | if (margemBruta > 0.50) return "green"; |
| 775 | if (margemBruta > 0.34) return "orange"; |
837 | if (margemBruta > 0.34) return "orange"; |
| 776 | if (margemBruta < 0.35) return "red"; |
838 | if (margemBruta < 0.35) return "red"; |
| - | 839 | return "black"; |
|
| - | 840 | }
|
|
| - | 841 | ||
| - | 842 | @Transient |
|
| - | 843 | public String retornarCorMargemLucro() { |
|
| - | 844 | Double margemBruta = calculoMargemAposCustos(); |
|
| - | 845 | if (margemBruta > 29.99) return "green"; |
|
| - | 846 | if (margemBruta > 14.99) return "orange"; |
|
| - | 847 | if (margemBruta < 15.0) return "red"; |
|
| 777 | return "black"; |
848 | return "black"; |
| 778 | }
|
849 | }
|
| 779 | 850 | ||
| 780 | public String retornarMargemBrutaFormatada() { |
851 | public String retornarMargemBrutaFormatada() { |
| 781 | return StringUtil.formatarPercentual(retornarMargemBruta()); |
852 | return StringUtil.formatarPercentual(retornarMargemBruta()); |
| Line 979... | Line 1050... | ||
| 979 | this.codigoEST = produto.getCodigoEST(); |
1050 | this.codigoEST = produto.getCodigoEST(); |
| 980 | this.dataOnline = produto.getDataOnline(); |
1051 | this.dataOnline = produto.getDataOnline(); |
| 981 | this.indicadorOnline = produto.getIndicadorOnline(); |
1052 | this.indicadorOnline = produto.getIndicadorOnline(); |
| 982 | this.indicadorOnlineShoplog = produto.getIndicadorOnlineShoplog(); |
1053 | this.indicadorOnlineShoplog = produto.getIndicadorOnlineShoplog(); |
| 983 | this.setAtivo(true); |
1054 | this.setAtivo(true); |
| - | 1055 | }
|
|
| - | 1056 | ||
| - | 1057 | @Transient |
|
| - | 1058 | public void atualizarAliquotas(Fornecedor fornecedor) { |
|
| - | 1059 | if (VerificadorUtil.naoEstaNulo(getTributacao()) |
|
| - | 1060 | && VerificadorUtil.naoEstaNulo(getAliquotaIcms()) |
|
| - | 1061 | && VerificadorUtil.naoEstaNulo(fornecedor)) { |
|
| - | 1062 | if (getTributacao().getSujeitoST() && fornecedor.getSujeitoST()) { |
|
| - | 1063 | setAliquotaIcmsST(getTributacao().mvaPorIcms(getAliquotaIcms())); |
|
| - | 1064 | setAliquotaFecoep(getTributacao().getAliquotaFecoep()); |
|
| - | 1065 | setSujeitoST(true); |
|
| - | 1066 | } else { |
|
| - | 1067 | setAliquotaFecoep(null); |
|
| - | 1068 | setAliquotaIcmsST(null); |
|
| - | 1069 | setSujeitoST(false); |
|
| - | 1070 | }
|
|
| - | 1071 | } else if (VerificadorUtil.naoEstaNulo(getTributacao()) && VerificadorUtil.naoEstaNulo(getAliquotaIcms())) { |
|
| - | 1072 | if (getTributacao().getSujeitoST()) { |
|
| - | 1073 | setAliquotaIcmsST(getTributacao().mvaPorIcms(getAliquotaIcms())); |
|
| - | 1074 | setAliquotaFecoep(getTributacao().getAliquotaFecoep()); |
|
| - | 1075 | setSujeitoST(true); |
|
| - | 1076 | } else { |
|
| - | 1077 | setAliquotaFecoep(null); |
|
| - | 1078 | setAliquotaIcmsST(null); |
|
| - | 1079 | setSujeitoST(false); |
|
| - | 1080 | }
|
|
| - | 1081 | }
|
|
| - | 1082 | }
|
|
| - | 1083 | ||
| - | 1084 | @Transient |
|
| - | 1085 | public Double calculoIPI() { |
|
| - | 1086 | return VerificadorUtil.naoEstaNulo(getAliquotaIPI())? getAliquotaIPI()/100 * getValorCompra() : 0.0; |
|
| - | 1087 | }
|
|
| - | 1088 | ||
| - | 1089 | @Transient |
|
| - | 1090 | public Double calculoICMS() { |
|
| - | 1091 | return VerificadorUtil.naoEstaNulo(getAliquotaIcms()) && VerificadorUtil.naoEstaNulo(getAliquotaFecoep())? |
|
| - | 1092 | (getAliquotaIcms()/100 + getAliquotaFecoep()/100) * getValorCompra() : 0.0; |
|
| - | 1093 | }
|
|
| - | 1094 | ||
| - | 1095 | @Transient |
|
| - | 1096 | public Double calculoICMSST() { |
|
| - | 1097 | if (getSujeitoST()) { |
|
| - | 1098 | return VerificadorUtil.naoEstaNulo(getAliquotaIcmsST()) |
|
| - | 1099 | && VerificadorUtil.naoEstaNulo(getAliquotaFecoep()) |
|
| - | 1100 | && VerificadorUtil.naoEstaNulo(getTributacao())? |
|
| - | 1101 | ((getTributacao().getAliquotaInterna()/100 + getAliquotaFecoep()/100) * baseCalculoICMSST()) - calculoICMS(): 0.0; |
|
| - | 1102 | }
|
|
| - | 1103 | return 0.0; |
|
| - | 1104 | }
|
|
| - | 1105 | ||
| - | 1106 | @Transient |
|
| - | 1107 | public Double baseCalculoICMSST() { |
|
| - | 1108 | if (getSujeitoST()) { |
|
| - | 1109 | if (VerificadorUtil.naoEstaNulo(getTributacao())) { |
|
| - | 1110 | Double baseCalculoIPI = getValorCompra() + calculoIPI(); |
|
| - | 1111 | return baseCalculoIPI + (baseCalculoIPI * getTributacao().mvaPorIcms(getAliquotaIcms())/100); |
|
| - | 1112 | }
|
|
| - | 1113 | }
|
|
| - | 1114 | return 0.0; |
|
| - | 1115 | }
|
|
| - | 1116 | ||
| - | 1117 | @Transient |
|
| - | 1118 | public Double aliquotaMvaProduto() { |
|
| - | 1119 | return VerificadorUtil.naoEstaNulo(getTributacao())? getTributacao().mvaPorIcms(getAliquotaIcms()) : 0.0; |
|
| - | 1120 | }
|
|
| - | 1121 | ||
| - | 1122 | @Transient |
|
| - | 1123 | public Double calculoTributosCompra() { |
|
| - | 1124 | return VerificadorUtil.naoEstaNulo(getValorCompra())? getValorCompra() + calculoIPI() + calculoICMSST() : 0.0; |
|
| - | 1125 | }
|
|
| - | 1126 | ||
| - | 1127 | @Transient |
|
| - | 1128 | public Double calculoOperacao() { |
|
| - | 1129 | Double aliquota = ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_SIMPLES_NACIONAL_11 + |
|
| - | 1130 | ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_COMISSOES_2 + |
|
| - | 1131 | ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_CARTAO_2; |
|
| - | 1132 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? calculoTributosCompra() + (getValorVarejoSimulacao()*aliquota/100) : 0.0; |
|
| - | 1133 | }
|
|
| - | 1134 | ||
| - | 1135 | @Transient |
|
| - | 1136 | public Double calculoValorAposCustos() { |
|
| - | 1137 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? getValorVarejoSimulacao() - calculoOperacao() : 0.0; |
|
| - | 1138 | }
|
|
| - | 1139 | ||
| - | 1140 | @Transient |
|
| - | 1141 | public Double calculoMargemAposCustos() { |
|
| - | 1142 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? calculoValorAposCustos() * 100 / calculoOperacao() : 0.0; |
|
| 984 | }
|
1143 | }
|
| 985 | 1144 | ||
| 986 | }
|
1145 | }
|