Rev 144 | Rev 152 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 144 | Rev 145 | ||
|---|---|---|---|
| Line 758... | Line 758... | ||
| 758 | if (VerificadorUtil.estaNuloOuVazio(this.getDescricao())) { |
758 | if (VerificadorUtil.estaNuloOuVazio(this.getDescricao())) { |
| 759 | this.setDescricao(produtoNota.getProd().getXProd()); |
759 | this.setDescricao(produtoNota.getProd().getXProd()); |
| 760 | }
|
760 | }
|
| 761 | if (VerificadorUtil.estaNuloOuVazio(this.getGenero())) { |
761 | if (VerificadorUtil.estaNuloOuVazio(this.getGenero())) { |
| 762 | this.setGenero(TipoGenero.UNISSEX.getValor()); |
762 | this.setGenero(TipoGenero.UNISSEX.getValor()); |
| 763 | }
|
- | |
| 764 | if (VerificadorUtil.estaNulo(this.getValorCompra())) { |
- | |
| 765 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getVUnCom())) { |
- | |
| 766 | this.setValorCompra(retornarValorComDesconto(produtoNota.getProd())); |
- | |
| 767 | }
|
- | |
| 768 | }
|
763 | }
|
| 769 | 764 | ||
| 770 | this.setCodigoEAN(StringUtil.retornarApenasNumeros(produtoNota.getProd().getCEAN())); |
765 | this.setCodigoEAN(StringUtil.retornarApenasNumeros(produtoNota.getProd().getCEAN())); |
| 771 | this.setCodigoEANTributado(StringUtil.retornarApenasNumeros(produtoNota.getProd().getCEANTrib())); |
766 | this.setCodigoEANTributado(StringUtil.retornarApenasNumeros(produtoNota.getProd().getCEANTrib())); |
| 772 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getNCM())) { |
767 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getNCM())) { |
| Line 774... | Line 769... | ||
| 774 | }
|
769 | }
|
| 775 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getCEST())) { |
770 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getCEST())) { |
| 776 | this.setCodigoEST(produtoNota.getProd().getCEST()); |
771 | this.setCodigoEST(produtoNota.getProd().getCEST()); |
| 777 | }
|
772 | }
|
| 778 | 773 | ||
| - | 774 | Double aliquotaIPI = null; |
|
| 779 | for (JAXBElement<?> elemento : produtoNota.getImposto().getContent()) { |
775 | for (JAXBElement<?> elemento : produtoNota.getImposto().getContent()) { |
| 780 | if (elemento.getDeclaredType().equals(nfce.java.TNFe.InfNFe.Det.Imposto.ICMS.class)) { |
776 | 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(); |
777 | 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())); |
- | |
| - | 778 | if (VerificadorUtil.naoEstaNulo(icms.getICMS00())) { |
|
| - | 779 | this.setAliquotaIcms(Double.valueOf(icms.getICMS00().getPICMS())); |
|
| - | 780 | }
|
|
| 783 | }
|
781 | }
|
| 784 | if (elemento.getDeclaredType().equals(nfce.java.TIpi.class)) { |
782 | if (elemento.getDeclaredType().equals(nfce.java.TIpi.class)) { |
| 785 | nfce.java.TIpi ipi = (nfce.java.TIpi) elemento.getValue(); |
783 | nfce.java.TIpi ipi = (nfce.java.TIpi) elemento.getValue(); |
| 786 | this.setAliquotaIPI(Double.valueOf(ipi.getIPITrib().getPIPI())); |
- | |
| - | 784 | if (VerificadorUtil.naoEstaNulo(ipi.getIPITrib())) { |
|
| - | 785 | aliquotaIPI = Double.valueOf(ipi.getIPITrib().getPIPI()); |
|
| - | 786 | this.setAliquotaIPI(aliquotaIPI); |
|
| - | 787 | }
|
|
| - | 788 | }
|
|
| - | 789 | }
|
|
| - | 790 | ||
| - | 791 | if (VerificadorUtil.estaNulo(this.getValorCompra())) { |
|
| - | 792 | if (VerificadorUtil.naoEstaNulo(produtoNota.getProd().getVUnCom())) { |
|
| - | 793 | this.setValorCompra(retornarValorComDesconto(produtoNota.getProd())); |
|
| 787 | }
|
794 | }
|
| 788 | }
|
795 | }
|
| 789 | }
|
796 | }
|
| 790 | 797 | ||
| 791 | public Double retornarValorComDesconto(nfce.java.TNFe.InfNFe.Det.Prod produto) { |
798 | public Double retornarValorComDesconto(nfce.java.TNFe.InfNFe.Det.Prod produto) { |
| - | 799 | Double valor = 0.0; |
|
| 792 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getVDesc())) { |
800 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getVDesc())) { |
| 793 | Double valorUnitarioDescontado = (new Double(produto.getVProd()) - new Double(produto.getVDesc())) / new Double(produto.getQCom()).intValue(); |
- | |
| 794 | return valorUnitarioDescontado; |
- | |
| - | 801 | valor = (new Double(produto.getVProd()) - new Double(produto.getVDesc())) / new Double(produto.getQCom()).intValue(); |
|
| - | 802 | } else { |
|
| - | 803 | valor = new Double(produto.getVUnCom()); |
|
| 795 | }
|
804 | }
|
| 796 | return new Double(produto.getVUnCom()); |
- | |
| - | 805 | return valor; |
|
| 797 | }
|
806 | }
|
| 798 | 807 | ||
| 799 | public Double retornarLucroBruto() { |
808 | public Double retornarLucroBruto() { |
| 800 | if (VerificadorUtil.naoEstaNulo(getValorCompra()) && VerificadorUtil.naoEstaNulo(getValorVarejo())) { |
809 | if (VerificadorUtil.naoEstaNulo(getValorCompra()) && VerificadorUtil.naoEstaNulo(getValorVarejo())) { |
| 801 | if (VerificadorUtil.naoEstaNulo(getValorVarejoPromocional())) { |
810 | if (VerificadorUtil.naoEstaNulo(getValorVarejoPromocional())) { |
| Line 844... | Line 853... | ||
| 844 | Double margemBruta = calculoMargemAposCustos(); |
853 | Double margemBruta = calculoMargemAposCustos(); |
| 845 | if (margemBruta > 29.99) return "green"; |
854 | if (margemBruta > 29.99) return "green"; |
| 846 | if (margemBruta > 14.99) return "orange"; |
855 | if (margemBruta > 14.99) return "orange"; |
| 847 | if (margemBruta < 15.0) return "red"; |
856 | if (margemBruta < 15.0) return "red"; |
| 848 | return "black"; |
857 | return "black"; |
| 849 | }
|
- | |
| 850 | - | ||
| 851 | public String retornarMargemBrutaFormatada() { |
- | |
| 852 | return StringUtil.formatarPercentual(retornarMargemBruta()); |
- | |
| 853 | }
|
- | |
| 854 | - | ||
| 855 | public String retornarLucroBrutoFormatado() { |
- | |
| 856 | return StringUtil.formatarPercentual(retornarLucroBruto()); |
- | |
| 857 | }
|
858 | }
|
| 858 | 859 | ||
| 859 | @Transient |
860 | @Transient |
| 860 | public String getFornecedorMenorValorComprado(Fornecedor fornecedorComprar) { |
861 | public String getFornecedorMenorValorComprado(Fornecedor fornecedorComprar) { |
| 861 | FornecedorProduto menorValor = null; |
862 | FornecedorProduto menorValor = null; |
| Line 1049... | Line 1050... | ||
| 1049 | this.codigoNCM = produto.getCodigoNCM(); |
1050 | this.codigoNCM = produto.getCodigoNCM(); |
| 1050 | this.codigoEST = produto.getCodigoEST(); |
1051 | this.codigoEST = produto.getCodigoEST(); |
| 1051 | this.dataOnline = produto.getDataOnline(); |
1052 | this.dataOnline = produto.getDataOnline(); |
| 1052 | this.indicadorOnline = produto.getIndicadorOnline(); |
1053 | this.indicadorOnline = produto.getIndicadorOnline(); |
| 1053 | this.indicadorOnlineShoplog = produto.getIndicadorOnlineShoplog(); |
1054 | this.indicadorOnlineShoplog = produto.getIndicadorOnlineShoplog(); |
| - | 1055 | this.setSujeitoST(produto.getSujeitoST()); |
|
| - | 1056 | this.setAliquotaIcms(produto.getAliquotaIcms()); |
|
| - | 1057 | this.setAliquotaIcmsST(produto.getAliquotaIcmsST()); |
|
| - | 1058 | this.setAliquotaFecoep(produto.getAliquotaFecoep()); |
|
| - | 1059 | this.setAliquotaIPI(produto.getAliquotaIPI()); |
|
| 1054 | this.setAtivo(true); |
1060 | this.setAtivo(true); |
| 1055 | }
|
1061 | }
|
| 1056 | 1062 | ||
| 1057 | @Transient |
1063 | @Transient |
| 1058 | public void atualizarAliquotas(Fornecedor fornecedor) { |
1064 | public void atualizarAliquotas(Fornecedor fornecedor) { |
| Line 1119... | Line 1125... | ||
| 1119 | return VerificadorUtil.naoEstaNulo(getTributacao())? getTributacao().mvaPorIcms(getAliquotaIcms()) : 0.0; |
1125 | return VerificadorUtil.naoEstaNulo(getTributacao())? getTributacao().mvaPorIcms(getAliquotaIcms()) : 0.0; |
| 1120 | }
|
1126 | }
|
| 1121 | 1127 | ||
| 1122 | @Transient |
1128 | @Transient |
| 1123 | public Double calculoTributosCompra() { |
1129 | public Double calculoTributosCompra() { |
| 1124 | return VerificadorUtil.naoEstaNulo(getValorCompra())? getValorCompra() + calculoIPI() + calculoICMSST() : 0.0; |
- | |
| - | 1130 | return VerificadorUtil.naoEstaNulo(getValorCompra())? getValorCompra() + calculoIPI() + calculoICMSST() : 0.0; |
|
| 1125 | }
|
1131 | }
|
| 1126 | 1132 | ||
| 1127 | @Transient |
1133 | @Transient |
| 1128 | public Double calculoOperacao() { |
1134 | public Double calculoOperacao() { |
| 1129 | Double aliquota = ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_SIMPLES_NACIONAL_11 + |
1135 | Double aliquota = ConstantesSEC.NotaFiscal.Imposto.ALIQUOTA_MEDIA_SIMPLES_NACIONAL_11 + |
| Line 1138... | Line 1144... | ||
| 1138 | }
|
1144 | }
|
| 1139 | 1145 | ||
| 1140 | @Transient |
1146 | @Transient |
| 1141 | public Double calculoMargemAposCustos() { |
1147 | public Double calculoMargemAposCustos() { |
| 1142 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? calculoValorAposCustos() * 100 / calculoOperacao() : 0.0; |
1148 | return VerificadorUtil.naoEstaNulo(getValorVarejoSimulacao())? calculoValorAposCustos() * 100 / calculoOperacao() : 0.0; |
| - | 1149 | }
|
|
| - | 1150 | ||
| - | 1151 | @Transient |
|
| - | 1152 | public String retornarLucroBrutoFormatado() { |
|
| - | 1153 | return StringUtil.formatarPercentual(calculoValorAposCustos()); |
|
| - | 1154 | }
|
|
| - | 1155 | ||
| - | 1156 | @Transient |
|
| - | 1157 | public String retornarMargemBrutaFormatada() { |
|
| - | 1158 | try { |
|
| - | 1159 | return StringUtil.formatarValorComDigitos(calculoMargemAposCustos().toString(), 2); |
|
| - | 1160 | } catch (Exception e) { |
|
| - | 1161 | e.printStackTrace(); |
|
| - | 1162 | }
|
|
| - | 1163 | return ""; |
|
| 1143 | }
|
1164 | }
|
| 1144 | 1165 | ||
| 1145 | }
|
1166 | }
|