Rev 497 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 497 | Rev 499 | ||
|---|---|---|---|
| Line 16... | Line 16... | ||
| 16 | 16 | ||
| 17 | import com.mchange.lang.DoubleUtils; |
17 | import com.mchange.lang.DoubleUtils; |
| 18 | 18 | ||
| 19 | import br.com.ec.core.exception.NegocioException; |
19 | import br.com.ec.core.exception.NegocioException; |
| 20 | import br.com.ec.core.generic.identidade.Identidade; |
20 | import br.com.ec.core.generic.identidade.Identidade; |
| - | 21 | import br.com.ec.core.util.StringUtil; |
|
| 21 | import br.com.ec.core.util.VerificadorUtil; |
22 | import br.com.ec.core.util.VerificadorUtil; |
| 22 | import br.com.ec.domain.model.nfe.TipoNotaFiscalImpostoIcms; |
23 | import br.com.ec.domain.model.nfe.TipoNotaFiscalImpostoIcms; |
| 23 | import br.com.swconsultoria.nfe.schema_4.enviNFe.TNFe; |
24 | import br.com.swconsultoria.nfe.schema_4.enviNFe.TNFe; |
| 24 | import br.com.swconsultoria.nfe.schema_4.enviNFe.TNFe.InfNFe.Det.Imposto.ICMS; |
25 | import br.com.swconsultoria.nfe.schema_4.enviNFe.TNFe.InfNFe.Det.Imposto.ICMS; |
| 25 | 26 | ||
| Line 49... | Line 50... | ||
| 49 | private Double percentualMagemValorAdicionadoST; //pmvast |
50 | private Double percentualMagemValorAdicionadoST; //pmvast |
| 50 | private Double baseCalculoST; //vBCST |
51 | private Double baseCalculoST; //vBCST |
| 51 | private Double aliquotaIcmsST; //picmsst |
52 | private Double aliquotaIcmsST; //picmsst |
| 52 | private Double valorIcmsST; //icmsst |
53 | private Double valorIcmsST; //icmsst |
| 53 | 54 | ||
| 54 | private Double baseCalculoFCP; //vBCFCPST |
- | |
| - | 55 | private Double baseCalculoFCPST; //vBCFCPST |
|
| 55 | private Double aliquotaFCPST; //pFCPST |
56 | private Double aliquotaFCPST; //pFCPST |
| 56 | private Double valorFCPST; //vFCPST |
57 | private Double valorFCPST; //vFCPST |
| 57 | private Double aliquotaCreditoSimplesNacional; //pCredSN |
58 | private Double aliquotaCreditoSimplesNacional; //pCredSN |
| 58 | private Double valorCreditoIcmsSimplesNacional; //vCredICMSSN |
59 | private Double valorCreditoIcmsSimplesNacional; //vCredICMSSN |
| - | 60 | private Double percentualReducaoBCST; //predBCST |
|
| 59 | 61 | ||
| 60 | private String xmlImposto; |
62 | private String xmlImposto; |
| 61 | 63 | ||
| 62 | public ImpostoIcms() { |
64 | public ImpostoIcms() { |
| 63 | this.impostoIcmsId = new ImpostoIcmsId(); |
65 | this.impostoIcmsId = new ImpostoIcmsId(); |
| Line 186... | Line 188... | ||
| 186 | public Double getPercentualReducaoBC() { |
188 | public Double getPercentualReducaoBC() { |
| 187 | return percentualReducaoBC; |
189 | return percentualReducaoBC; |
| 188 | }
|
190 | }
|
| 189 | public void setPercentualReducaoBC(Double percentualReducaoBC) { |
191 | public void setPercentualReducaoBC(Double percentualReducaoBC) { |
| 190 | this.percentualReducaoBC = percentualReducaoBC; |
192 | this.percentualReducaoBC = percentualReducaoBC; |
| - | 193 | }
|
|
| - | 194 | ||
| - | 195 | @Column(name="val_predbcst") |
|
| - | 196 | public Double getPercentualReducaoBCST() { |
|
| - | 197 | return percentualReducaoBCST; |
|
| - | 198 | }
|
|
| - | 199 | public void setPercentualReducaoBCST(Double percentualReducaoBCST) { |
|
| - | 200 | this.percentualReducaoBCST = percentualReducaoBCST; |
|
| 191 | }
|
201 | }
|
| 192 | 202 | ||
| 193 | @Column(name="cod_modbcst") |
203 | @Column(name="cod_modbcst") |
| 194 | public String getModalidadeDeterminacaoBCST() { |
204 | public String getModalidadeDeterminacaoBCST() { |
| 195 | return modalidadeDeterminacaoBCST; |
205 | return modalidadeDeterminacaoBCST; |
| Line 229... | Line 239... | ||
| 229 | public void setValorIcmsST(Double valorIcmsST) { |
239 | public void setValorIcmsST(Double valorIcmsST) { |
| 230 | this.valorIcmsST = valorIcmsST; |
240 | this.valorIcmsST = valorIcmsST; |
| 231 | }
|
241 | }
|
| 232 | 242 | ||
| 233 | @Column(name="val_bcfcpst") |
243 | @Column(name="val_bcfcpst") |
| 234 | public Double getBaseCalculoFCP() { |
- | |
| 235 | return baseCalculoFCP; |
- | |
| - | 244 | public Double getBaseCalculoFCPST() { |
|
| - | 245 | return baseCalculoFCPST; |
|
| 236 | }
|
246 | }
|
| 237 | public void setBaseCalculoFCP(Double baseCalculoFCP) { |
- | |
| 238 | this.baseCalculoFCP = baseCalculoFCP; |
- | |
| - | 247 | public void setBaseCalculoFCPST(Double baseCalculoFCPST) { |
|
| - | 248 | this.baseCalculoFCPST = baseCalculoFCPST; |
|
| 239 | }
|
249 | }
|
| 240 | 250 | ||
| 241 | @Column(name="val_pfcpst") |
251 | @Column(name="val_pfcpst") |
| 242 | public Double getAliquotaFCPST() { |
252 | public Double getAliquotaFCPST() { |
| 243 | return aliquotaFCPST; |
253 | return aliquotaFCPST; |
| Line 271... | Line 281... | ||
| 271 | }
|
281 | }
|
| 272 | 282 | ||
| 273 | @Column(name="xml_imposto") |
283 | @Column(name="xml_imposto") |
| 274 | public String getXmlImposto() { |
284 | public String getXmlImposto() { |
| 275 | return xmlImposto; |
285 | return xmlImposto; |
| 276 | }
|
- | |
| - | 286 | }
|
|
| 277 | public void setXmlImposto(String xmlImposto) { |
287 | public void setXmlImposto(String xmlImposto) { |
| 278 | this.xmlImposto = xmlImposto; |
288 | this.xmlImposto = xmlImposto; |
| 279 | }
|
289 | }
|
| 280 | 290 | ||
| 281 | // TODO: ALTERAR OS VALORES, BASEANDO-SE NA QUANTIDADE INFORMADA
|
291 | // TODO: ALTERAR OS VALORES, BASEANDO-SE NA QUANTIDADE INFORMADA
|
| 282 | public void preencherDados(ICMS icms, Integer quantidade) { |
- | |
| - | 292 | public void preencherDados(ICMS icms, Double diferencaQuantitativa) { |
|
| 283 | if (VerificadorUtil.naoEstaNulo(icms.getICMS00())) { |
293 | if (VerificadorUtil.naoEstaNulo(icms.getICMS00())) { |
| 284 | this.setTipoImposto(TipoNotaFiscalImpostoIcms.ICMS00_CST00.getValor()); |
294 | this.setTipoImposto(TipoNotaFiscalImpostoIcms.ICMS00_CST00.getValor()); |
| 285 | this.setCodigoOrigem(icms.getICMS00().getOrig()); |
295 | this.setCodigoOrigem(icms.getICMS00().getOrig()); |
| 286 | this.setModalidadeDeterminacaoBC(icms.getICMS00().getModBC()); |
296 | this.setModalidadeDeterminacaoBC(icms.getICMS00().getModBC()); |
| 287 | this.setCodigoSituacaoTributaria(icms.getICMS00().getCST()); |
297 | this.setCodigoSituacaoTributaria(icms.getICMS00().getCST()); |
| 288 | if (VerificadorUtil.naoEstaNulo(icms.getICMS00().getPFCP())) { |
- | |
| 289 | this.setAliquotaFCP(new Double(icms.getICMS00().getPFCP())); |
- | |
| 290 | this.setValorFCP(new Double(icms.getICMS00().getVFCP())); |
- | |
| 291 | }
|
- | |
| 292 | this.setAliquotaIcms(new Double(icms.getICMS00().getPICMS())); |
- | |
| 293 | this.setBaseCalculo(new Double(icms.getICMS00().getVBC())); |
- | |
| 294 | this.setValorIcms(new Double(icms.getICMS00().getVICMS())); |
- | |
| - | 298 | this.setAliquotaFCP(retornarValoresSeExistir(icms.getICMS00().getPFCP())); |
|
| - | 299 | ||
| - | 300 | icms.getICMS00().setVFCP(retornarValoresCorrigidosSeExistir(icms.getICMS00().getVFCP(), diferencaQuantitativa)); |
|
| - | 301 | this.setValorFCP(retornarValoresSeExistir(icms.getICMS00().getVFCP())); |
|
| - | 302 | ||
| - | 303 | this.setAliquotaIcms(retornarValoresSeExistir(icms.getICMS00().getPICMS())); |
|
| - | 304 | ||
| - | 305 | icms.getICMS00().setVBC(retornarValoresCorrigidosSeExistir(icms.getICMS00().getVBC(), diferencaQuantitativa)); |
|
| - | 306 | this.setBaseCalculo(retornarValoresSeExistir(icms.getICMS00().getVBC())); |
|
| - | 307 | ||
| - | 308 | icms.getICMS00().setVICMS(retornarValoresCorrigidosSeExistir(icms.getICMS00().getVICMS(), diferencaQuantitativa)); |
|
| - | 309 | this.setValorIcms(retornarValoresSeExistir(icms.getICMS00().getVICMS())); |
|
| 295 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN101())) { |
310 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN101())) { |
| 296 | this.setTipoImposto(TipoNotaFiscalImpostoIcms.ICMSSN101_CSOSN101.getValor()); |
311 | this.setTipoImposto(TipoNotaFiscalImpostoIcms.ICMSSN101_CSOSN101.getValor()); |
| 297 | this.setCodigoSituacaoOperacaoSimplesNacional(icms.getICMSSN101().getCSOSN()); |
312 | this.setCodigoSituacaoOperacaoSimplesNacional(icms.getICMSSN101().getCSOSN()); |
| 298 | this.setCodigoOrigem(icms.getICMSSN101().getOrig()); |
313 | this.setCodigoOrigem(icms.getICMSSN101().getOrig()); |
| 299 | this.setAliquotaCreditoSimplesNacional(new Double(icms.getICMSSN101().getPCredSN())); |
- | |
| 300 | this.setValorCreditoIcmsSimplesNacional(new Double(icms.getICMSSN101().getVCredICMSSN())); |
- | |
| - | 314 | this.setAliquotaCreditoSimplesNacional(retornarValoresSeExistir(icms.getICMSSN101().getPCredSN())); |
|
| - | 315 | ||
| - | 316 | icms.getICMSSN101().setVCredICMSSN(retornarValoresCorrigidosSeExistir(icms.getICMSSN101().getVCredICMSSN(), diferencaQuantitativa)); |
|
| - | 317 | this.setValorCreditoIcmsSimplesNacional(retornarValoresSeExistir(icms.getICMSSN101().getVCredICMSSN())); |
|
| 301 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN201())) { |
318 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN201())) { |
| 302 | this.setTipoImposto(TipoNotaFiscalImpostoIcms.ICMSSN201_CSOSN201.getValor()); |
319 | this.setTipoImposto(TipoNotaFiscalImpostoIcms.ICMSSN201_CSOSN201.getValor()); |
| 303 | icms.getICMSSN201().getCSOSN(); |
- | |
| 304 | icms.getICMSSN201().getModBCST(); |
- | |
| 305 | icms.getICMSSN201().getOrig(); |
- | |
| 306 | icms.getICMSSN201().getPCredSN(); |
- | |
| 307 | icms.getICMSSN201().getPFCPST(); |
- | |
| 308 | icms.getICMSSN201().getPICMSST(); |
- | |
| 309 | icms.getICMSSN201().getPMVAST(); |
- | |
| 310 | icms.getICMSSN201().getPRedBCST(); |
- | |
| 311 | icms.getICMSSN201().getVBCFCPST(); |
- | |
| 312 | icms.getICMSSN201().getVBCST(); |
- | |
| 313 | icms.getICMSSN201().getVCredICMSSN(); |
- | |
| 314 | icms.getICMSSN201().getVFCPST(); |
- | |
| 315 | icms.getICMSSN201().getVICMSST(); |
- | |
| 316 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN500())) { |
- | |
| - | 320 | this.setCodigoSituacaoOperacaoSimplesNacional(icms.getICMSSN201().getCSOSN()); |
|
| - | 321 | this.setCodigoOrigem(icms.getICMSSN201().getOrig()); |
|
| - | 322 | this.setModalidadeDeterminacaoBCST(icms.getICMSSN201().getModBCST()); |
|
| - | 323 | this.setPercentualMagemValorAdicionadoST(retornarValoresSeExistir(icms.getICMSSN201().getPMVAST())); |
|
| - | 324 | this.setAliquotaCreditoSimplesNacional(retornarValoresSeExistir(icms.getICMSSN201().getPCredSN())); |
|
| 317 | 325 | ||
| 318 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN900())) { |
- | |
| - | 326 | icms.getICMSSN201().setVCredICMSSN(retornarValoresCorrigidosSeExistir(icms.getICMSSN201().getVCredICMSSN(), diferencaQuantitativa)); |
|
| - | 327 | this.setValorCreditoIcmsSimplesNacional(retornarValoresSeExistir(icms.getICMSSN201().getVCredICMSSN())); |
|
| 319 | 328 | ||
| - | 329 | this.setAliquotaFCPST(retornarValoresSeExistir(icms.getICMSSN201().getPFCPST())); |
|
| - | 330 | ||
| - | 331 | icms.getICMSSN201().setVBCFCPST(retornarValoresCorrigidosSeExistir(icms.getICMSSN201().getVBCFCPST(), diferencaQuantitativa)); |
|
| - | 332 | this.setBaseCalculoFCPST(retornarValoresSeExistir(icms.getICMSSN201().getVBCFCPST())); |
|
| - | 333 | ||
| - | 334 | icms.getICMSSN201().setVFCPST(retornarValoresCorrigidosSeExistir(icms.getICMSSN201().getVFCPST(), diferencaQuantitativa)); |
|
| - | 335 | this.setValorFCPST(retornarValoresSeExistir(icms.getICMSSN201().getVFCPST())); |
|
| - | 336 | ||
| - | 337 | this.setAliquotaIcmsST(retornarValoresSeExistir(icms.getICMSSN201().getPICMSST())); |
|
| - | 338 | ||
| - | 339 | icms.getICMSSN201().setVICMSST(retornarValoresCorrigidosSeExistir(icms.getICMSSN201().getVICMSST(), diferencaQuantitativa)); |
|
| - | 340 | this.setValorIcmsST(retornarValoresSeExistir(icms.getICMSSN201().getVICMSST())); |
|
| - | 341 | ||
| - | 342 | this.setPercentualReducaoBCST(retornarValoresSeExistir(icms.getICMSSN201().getPRedBCST())); |
|
| - | 343 | ||
| - | 344 | icms.getICMSSN201().setVBCST(retornarValoresCorrigidosSeExistir(icms.getICMSSN201().getVBCST(), diferencaQuantitativa)); |
|
| - | 345 | this.setBaseCalculoST(retornarValoresSeExistir(icms.getICMSSN201().getVBCST())); |
|
| - | 346 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN500())) { |
|
| - | 347 | throw new NegocioException("TIPO 500 DE ICMS NÃO IMPLEMENTADO: " + icms.toString()); |
|
| - | 348 | } else if (VerificadorUtil.naoEstaNulo(icms.getICMSSN900())) { |
|
| - | 349 | throw new NegocioException("TIPO 900 DE ICMS NÃO IMPLEMENTADO: " + icms.toString()); |
|
| 320 | } else { |
350 | } else { |
| 321 | throw new NegocioException("TIPO DE ICMS NÃO IMPLEMENTADO: " + icms.toString()); |
351 | throw new NegocioException("TIPO DE ICMS NÃO IMPLEMENTADO: " + icms.toString()); |
| 322 | }
|
352 | }
|
| 323 | }
|
353 | }
|
| - | 354 | ||
| - | 355 | private String formatarValor(String valor) { |
|
| - | 356 | try { |
|
| - | 357 | return StringUtil.formatarValor(new Double(valor)); |
|
| - | 358 | } catch (Exception e) { |
|
| - | 359 | return ""; |
|
| - | 360 | }
|
|
| - | 361 | }
|
|
| - | 362 | ||
| - | 363 | private Double retornarValoresSeExistir(String valor) { |
|
| - | 364 | try { |
|
| - | 365 | return VerificadorUtil.naoEstaNuloOuVazio(valor)? new Double(StringUtil.formatarValorComDoisDigitos(valor)) : null; |
|
| - | 366 | } catch (Exception e) { |
|
| - | 367 | e.printStackTrace(); |
|
| - | 368 | }
|
|
| - | 369 | return null; |
|
| - | 370 | }
|
|
| - | 371 | ||
| - | 372 | private String retornarValoresCorrigidosSeExistir(String valor, Double diferencaQuantitativa) { |
|
| - | 373 | if (VerificadorUtil.naoEstaNulo(valor)) { |
|
| - | 374 | Double valorCorrigido = new Double(valor); |
|
| - | 375 | valorCorrigido = valorCorrigido/diferencaQuantitativa;
|
|
| - | 376 | try { |
|
| - | 377 | return StringUtil.formatarValorComDoisDigitos(valorCorrigido.toString()); |
|
| - | 378 | } catch (Exception e) { |
|
| - | 379 | e.printStackTrace(); |
|
| - | 380 | }
|
|
| - | 381 | // return valorCorrigido.toString();
|
|
| - | 382 | }
|
|
| - | 383 | return null; |
|
| - | 384 | }
|
|
| - | 385 | ||
| - | 386 | private Double retornarValoresDoubleCorrigidosSeExistir(String valor, Double diferencaQuantitativa) { |
|
| - | 387 | if (VerificadorUtil.naoEstaNulo(valor)) { |
|
| - | 388 | Double valorCorrigido = new Double(valor); |
|
| - | 389 | valorCorrigido = valorCorrigido/diferencaQuantitativa;
|
|
| - | 390 | return valorCorrigido; |
|
| - | 391 | }
|
|
| - | 392 | return null; |
|
| - | 393 | }
|
|
| - | 394 | ||
| 324 | 395 | ||
| 325 | }
|
396 | }
|