br_nfe 2.3.2 → 3.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.markdown +1 -1
  4. data/br_nfe.gemspec +0 -0
  5. data/lib/br_nfe/constants.rb +2 -2
  6. data/lib/br_nfe/product/nf_xml_value.rb +6 -11
  7. data/lib/br_nfe/product/nfe/cobranca/pagamento.rb +39 -12
  8. data/lib/br_nfe/product/nfe/item.rb +83 -36
  9. data/lib/br_nfe/product/nfe/item_tax/icms.rb +182 -46
  10. data/lib/br_nfe/product/nfe/item_tax/icms_uf_destino.rb +33 -22
  11. data/lib/br_nfe/product/nfe/item_tax/ipi.rb +18 -18
  12. data/lib/br_nfe/product/nfe/transporte/base.rb +17 -15
  13. data/lib/br_nfe/product/nota_fiscal.rb +72 -6
  14. data/lib/br_nfe/product/operation/base.rb +14 -13
  15. data/lib/br_nfe/product/reader/item.rb +19 -2
  16. data/lib/br_nfe/product/reader/nfe.rb +28 -9
  17. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_prod.xml.slim +2 -2
  18. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ICMSUFDest.xml.slim +1 -1
  19. data/lib/br_nfe/product/xml/v4_00/_tc_infNFe.xml.slim +45 -0
  20. data/lib/br_nfe/product/xml/v4_00/infNFe/_tc_ide.xml.slim +30 -0
  21. data/lib/br_nfe/product/xml/v4_00/infNFe/_tc_total.xml.slim +84 -0
  22. data/lib/br_nfe/product/xml/v4_00/infNFe/det/_tc_prod.xml.slim +62 -0
  23. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS00.xml.slim +11 -0
  24. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS10.xml.slim +28 -0
  25. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +18 -0
  26. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS201.xml.slim +21 -0
  27. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS202.xml.slim +20 -0
  28. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +23 -0
  29. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS500.xml.slim +13 -0
  30. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +25 -0
  31. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS60.xml.slim +12 -0
  32. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +35 -0
  33. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +38 -0
  34. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/ICMS/_tc_ICMS900.xml.slim +31 -0
  35. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/_tc_ICMSUFDest.xml.slim +15 -0
  36. data/lib/br_nfe/product/xml/v4_00/infNFe/det/imposto/_tc_IPI.xml.slim +27 -0
  37. data/lib/br_nfe/product/xml/v4_00/infNFe/pag/_tc_detPag.xml.slim +17 -0
  38. data/lib/br_nfe/version.rb +4 -4
  39. data/lib/config/settings/nfe/reader_xml_paths.yml +40 -9
  40. data/lib/config/settings/nfe/v4_00/operation.yml +843 -0
  41. data/lib/config/settings/nfe/v4_00/soap_client.yml +807 -0
  42. data/lib/config/settings/nfe/v4_00/xml_paths.yml +577 -0
  43. data/test/br_nfe/product/nfe/item_tax/icms_uf_destino_test.rb +9 -8
  44. data/test/br_nfe/product/nota_fiscal_test.rb +28 -36
  45. data/test/br_nfe/product/reader/nfe_test.rb +31 -31
  46. data/test/factories/product/nfe/item_tax/icms_uf_destino.rb +1 -1
  47. data/test/factories/product/operation/nfe_autorizacao.rb +3 -3
  48. metadata +26 -4
@@ -0,0 +1,84 @@
1
+ ICMSTot
2
+ vBC = nf_xml_value_monetary( nfe.total_icms_base_calculo )
3
+ vICMS = nf_xml_value_monetary( nfe.total_icms )
4
+ vICMSDeson = nf_xml_value_monetary( nfe.total_icms_desonerado )
5
+
6
+ - if nfe.total_icms_uf_destino.to_f > 0 || nfe.total_icms_uf_origem.to_f > 0
7
+ vFCPUFDest = nf_xml_value_monetary( nfe.total_icms_fcp_uf_destino )
8
+ vICMSUFDest = nf_xml_value_monetary( nfe.total_icms_uf_destino )
9
+ vICMSUFRemet = nf_xml_value_monetary( nfe.total_icms_uf_origem )
10
+
11
+ vFCP = nf_xml_value_monetary( nfe.total_fcp.to_f )
12
+
13
+ vBCST = nf_xml_value_monetary( nfe.total_icms_base_calculo_st )
14
+ vST = nf_xml_value_monetary( nfe.total_icms_st )
15
+
16
+ vFCPST = nf_xml_value_monetary( nfe.total_fcp_st.to_f )
17
+ vFCPSTRet = nf_xml_value_monetary( nfe.total_fcp_st_retido.to_f )
18
+
19
+ vProd = nf_xml_value_monetary( nfe.total_produtos )
20
+ vFrete = nf_xml_value_monetary( nfe.total_frete )
21
+ vSeg = nf_xml_value_monetary( nfe.total_seguro )
22
+ vDesc = nf_xml_value_monetary( nfe.total_desconto )
23
+ vII = nf_xml_value_monetary( nfe.total_imposto_importacao )
24
+ vIPI = nf_xml_value_monetary( nfe.total_ipi )
25
+ vIPIDevol = nf_xml_value_monetary( nfe.total_ipi_devolvido.to_f )
26
+ vPIS = nf_xml_value_monetary( nfe.total_pis )
27
+ vCOFINS = nf_xml_value_monetary( nfe.total_cofins )
28
+ vOutro = nf_xml_value_monetary( nfe.total_outras_despesas )
29
+ vNF = nf_xml_value_monetary( nfe.total_nf )
30
+
31
+ - if nfe.total_tributos.to_f > 0.0
32
+ vTotTrib = nf_xml_value_monetary( nfe.total_tributos )
33
+
34
+ - if nfe.has_any_service?
35
+ ISSQNtot
36
+ vServ = nf_xml_value_monetary( nfe.total_servicos )
37
+ vBC = nf_xml_value_monetary( nfe.total_servicos_base_calculo )
38
+
39
+ - if nfe.total_servicos_iss.to_f > 0.0
40
+ vISS = nf_xml_value_monetary( nfe.total_servicos_iss )
41
+
42
+ - if nfe.total_servicos_pis.to_f > 0.0
43
+ vPIS = nf_xml_value_monetary( nfe.total_servicos_pis )
44
+
45
+ - if nfe.total_servicos_cofins.to_f > 0.0
46
+ vCOFINS = nf_xml_value_monetary( nfe.total_servicos_cofins )
47
+
48
+ dCompet = nf_xml_value_date( nfe.servicos_data_prestacao )
49
+
50
+ - if nfe.total_servicos_deducao.to_f > 0.0
51
+ vDeducao = nf_xml_value_monetary( nfe.total_servicos_deducao )
52
+
53
+ - if nfe.total_servicos_outras_retencoes.to_f > 0.0
54
+ vOutro = nf_xml_value_monetary( nfe.total_servicos_outras_retencoes )
55
+
56
+ - if nfe.total_servicos_desconto_incondicionado.to_f > 0.0
57
+ vDescIncond = nf_xml_value_monetary( nfe.total_servicos_desconto_incondicionado )
58
+
59
+ - if nfe.total_servicos_desconto_condicionado.to_f > 0.0
60
+ vDescCond = nf_xml_value_monetary( nfe.total_servicos_desconto_condicionado )
61
+
62
+ - if nfe.total_servicos_iss_retido.to_f > 0.0
63
+ vISSRet = nf_xml_value_monetary( nfe.total_servicos_iss_retido )
64
+
65
+ cRegTrib = nfe.regime_tributario_servico.to_i
66
+
67
+ - if nfe.has_taxes_retention?
68
+ retTrib
69
+ - if nfe.total_retencao_pis.to_f > 0.0
70
+ vRetPIS = nf_xml_value_monetary( nfe.total_retencao_pis )
71
+ - if nfe.total_retencao_cofins.to_f > 0.0
72
+ vRetCOFINS = nf_xml_value_monetary( nfe.total_retencao_cofins )
73
+ - if nfe.total_retencao_csll.to_f > 0.0
74
+ vRetCSLL = nf_xml_value_monetary( nfe.total_retencao_csll )
75
+
76
+ - if nfe.total_retencao_base_calculo_irrf.to_f > 0.0
77
+ vBCIRRF = nf_xml_value_monetary( nfe.total_retencao_base_calculo_irrf )
78
+ - if nfe.total_retencao_irrf.to_f > 0.0
79
+ vIRRF = nf_xml_value_monetary( nfe.total_retencao_irrf )
80
+
81
+ - if nfe.total_retencao_base_calculo_previdencia.to_f > 0.0
82
+ vBCRetPrev = nf_xml_value_monetary( nfe.total_retencao_base_calculo_previdencia )
83
+ - if nfe.total_retencao_previdencia.to_f > 0.0
84
+ vRetPrev = nf_xml_value_monetary( nfe.total_retencao_previdencia )
@@ -0,0 +1,62 @@
1
+ cProd = nf_xml_value_text( item.codigo_produto, 60 )
2
+ cEAN = nf_xml_value_EAN( item.codigo_ean )
3
+ xProd = nf_xml_value_text( item.descricao_produto, 120 )
4
+ NCM = nf_xml_value_NCM( item.codigo_ncm )
5
+
6
+ - item.codigos_nve.each do |nve|
7
+ NVE = nf_xml_value_NVE(nve)
8
+
9
+ - if item.codigo_cest.present?
10
+ / #I05c
11
+ CEST = nf_xml_value_CEST( item.codigo_cest )
12
+
13
+ - if item.escala_relevante.present?
14
+ / #I05d
15
+ indEscala = item.escala_relevante
16
+
17
+ / Só precisa add o CNPJ do fabricante se tiver um indicador de escala relevante
18
+ - if item.cnpj_fabricante.present?
19
+ / #I05e
20
+ CNPJFab = item.cnpj_fabricante
21
+
22
+ - if item.codigo_beneficio_fiscal.present?
23
+ / #I05f
24
+ cBenef = item.codigo_beneficio_fiscal
25
+
26
+ - if item.codigo_extipi.present?
27
+ EXTIPI = nf_xml_value_EXTIPI( item.codigo_extipi )
28
+
29
+ CFOP = nf_xml_value_CFOP( item.cfop )
30
+ uCom = nf_xml_value_text( item.unidade_comercial, 6)
31
+ qCom = nf_xml_value_float( item.quantidade_comercial, 4)
32
+ vUnCom = nf_xml_value_float( item.valor_unitario_comercial, 10)
33
+ vProd = nf_xml_value_monetary(item.valor_total_produto)
34
+ cEANTrib = nf_xml_value_EAN( item.codigo_ean_tributavel )
35
+ uTrib = nf_xml_value_text( item.unidade_tributavel, 6)
36
+ qTrib = nf_xml_value_float( item.quantidade_tributavel, 4)
37
+ vUnTrib = nf_xml_value_float( item.valor_unitario_tributavel, 10)
38
+ - if item.total_frete.to_f > 0
39
+ vFrete = nf_xml_value_monetary(item.total_frete)
40
+ - if item.total_seguro.to_f > 0
41
+ vSeg = nf_xml_value_monetary(item.total_seguro)
42
+ - if item.total_desconto.to_f > 0
43
+ vDesc = nf_xml_value_monetary(item.total_desconto)
44
+ - if item.total_outros.to_f > 0
45
+ vOutro = nf_xml_value_monetary(item.total_outros)
46
+ indTot = nf_xml_value_boolean( item.soma_total_nfe )
47
+ - item.declaracoes_importacao.each do |declaracao|
48
+ DI
49
+ = render_xml('infNFe/det/prod/_tc_di', declaracao: declaracao)
50
+
51
+ - item.detalhes_exportacao.reject(&:ignore?).each do |exportacao|
52
+ detExport
53
+ = render_xml('infNFe/det/prod/_tc_det_export', exportacao: exportacao)
54
+
55
+ - if item.numero_pedido_compra.present?
56
+ xPed = nf_xml_value_number item.numero_pedido_compra, 15
57
+
58
+ - if item.item_pedido_compra.present?
59
+ nItemPed = nf_xml_value_number_fixed_size item.item_pedido_compra, 6
60
+
61
+ - if item.numero_fci.present?
62
+ nFCI = "#{item.numero_fci}".upcase
@@ -0,0 +1,11 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+ modBC = icms.modalidade_base_calculo
4
+ vBC = nf_xml_value_monetary icms.total_base_calculo
5
+ pICMS = nf_xml_value_percent icms.aliquota
6
+ vICMS = nf_xml_value_monetary icms.total
7
+
8
+ /################## FCP ##################\
9
+ - if icms.cfp_valor.to_f > 0
10
+ pFCP = nf_xml_value_percent( icms.cfp_percentual )
11
+ vFCP = nf_xml_value_monetary( icms.cfp_valor )
@@ -0,0 +1,28 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+ modBC = icms.modalidade_base_calculo
4
+ vBC = nf_xml_value_monetary icms.total_base_calculo
5
+ pICMS = nf_xml_value_percent icms.aliquota
6
+ vICMS = nf_xml_value_monetary icms.total
7
+
8
+ /################## FCP ##################\
9
+ - if icms.cfp_valor.to_f > 0
10
+ vBCFCP = nf_xml_value_monetary( icms.cfp_base_calculo )
11
+ pFCP = nf_xml_value_percent( icms.cfp_percentual )
12
+ vFCP = nf_xml_value_monetary( icms.cfp_valor )
13
+
14
+ /################## ICMS ST ##################\
15
+ modBCST = icms.modalidade_base_calculo_st
16
+ - if icms.mva_st.to_f > 0.0
17
+ pMVAST = nf_xml_value_percent icms.mva_st
18
+ - if icms.reducao_base_calculo_st.to_f > 0.0
19
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
20
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
21
+ pICMSST = nf_xml_value_percent icms.aliquota_st
22
+ vICMSST = nf_xml_value_monetary icms.total_st
23
+
24
+ /################## FCP ##################\
25
+ - if icms.cfp_st_valor.to_f > 0
26
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
27
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
28
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
@@ -0,0 +1,18 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+ modBC = icms.modalidade_base_calculo
4
+ pRedBC = nf_xml_value_percent icms.reducao_base_calculo
5
+ vBC = nf_xml_value_monetary icms.total_base_calculo
6
+ pICMS = nf_xml_value_percent icms.aliquota
7
+ vICMS = nf_xml_value_monetary icms.total
8
+
9
+ /################## FCP ##################\
10
+ - if icms.cfp_valor.to_f > 0
11
+ vBCFCP = nf_xml_value_monetary( icms.cfp_base_calculo )
12
+ pFCP = nf_xml_value_percent( icms.cfp_percentual )
13
+ vFCP = nf_xml_value_monetary( icms.cfp_valor )
14
+
15
+ /################## DESONERAÇÃO DE ICMS ##################\
16
+ - if icms.total_desoneracao.to_f > 0.0
17
+ vICMSDeson nf_xml_value_monetary icms.total_desoneracao
18
+ motDesICMS icms.motivo_desoneracao
@@ -0,0 +1,21 @@
1
+ orig = icms.origem
2
+ CSOSN = icms.codigo_cst
3
+
4
+ /################## ICMS ST ##################\
5
+ modBCST = icms.modalidade_base_calculo_st
6
+ - if icms.mva_st.to_f > 0.0
7
+ pMVAST = nf_xml_value_percent icms.mva_st
8
+ - if icms.reducao_base_calculo_st.to_f > 0.0
9
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
10
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
11
+ pICMSST = nf_xml_value_percent icms.aliquota_st
12
+ vICMSST = nf_xml_value_monetary icms.total_st
13
+
14
+ /################## FCP ##################\
15
+ - if icms.cfp_st_valor.to_f > 0
16
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
17
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
18
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
19
+
20
+ pCredSN = nf_xml_value_percent icms.aliquota_credito_sn
21
+ vCredICMSSN = nf_xml_value_monetary icms.total_credito_sn
@@ -0,0 +1,20 @@
1
+ / Utilizado para os CSTs 202 e 203
2
+
3
+ orig = icms.origem
4
+ CSOSN = icms.codigo_cst
5
+
6
+ /################## ICMS ST ##################\
7
+ modBCST = icms.modalidade_base_calculo_st
8
+ - if icms.mva_st.to_f > 0.0
9
+ pMVAST = nf_xml_value_percent icms.mva_st
10
+ - if icms.reducao_base_calculo_st.to_f > 0.0
11
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
12
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
13
+ pICMSST = nf_xml_value_percent icms.aliquota_st
14
+ vICMSST = nf_xml_value_monetary icms.total_st
15
+
16
+ /################## FCP ##################\
17
+ - if icms.cfp_st_valor.to_f > 0
18
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
19
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
20
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
@@ -0,0 +1,23 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+
4
+ /################## ICMS ST ##################\
5
+ modBCST = icms.modalidade_base_calculo_st
6
+ - if icms.mva_st.to_f > 0.0
7
+ pMVAST = nf_xml_value_percent icms.mva_st
8
+ - if icms.reducao_base_calculo_st.to_f > 0.0
9
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
10
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
11
+ pICMSST = nf_xml_value_percent icms.aliquota_st
12
+ vICMSST = nf_xml_value_monetary icms.total_st
13
+
14
+ /################## FCP ##################\
15
+ - if icms.cfp_st_valor.to_f > 0
16
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
17
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
18
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
19
+
20
+ /################## DESONERAÇÃO DE ICMS ##################\
21
+ - if icms.total_desoneracao.to_f > 0.0
22
+ vICMSDeson nf_xml_value_monetary icms.total_desoneracao
23
+ motDesICMS icms.motivo_desoneracao
@@ -0,0 +1,13 @@
1
+ orig = icms.origem
2
+ CSOSN = icms.codigo_cst
3
+
4
+ - if icms.total_base_calculo_st_retido.to_f > 0.0
5
+ vBCSTRet = nf_xml_value_monetary icms.total_base_calculo_st_retido
6
+ pST = nf_xml_value_percent( icms.aliquota_consumidor_final )
7
+ vICMSSTRet = nf_xml_value_monetary icms.total_st_retido
8
+
9
+ /################## FCP ##################\
10
+ - if icms.cfp_st_retido_valor.to_f > 0
11
+ vBCFCPSTRet = nf_xml_value_monetary( icms.cfp_st_retido_base_calculo )
12
+ pFCPSTRet = nf_xml_value_percent( icms.cfp_st_retido_percentual )
13
+ vFCPSTRet = nf_xml_value_monetary( icms.cfp_st_retido_valor )
@@ -0,0 +1,25 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+
4
+ - if icms.modalidade_base_calculo.present?
5
+ modBC = icms.modalidade_base_calculo
6
+ - if icms.reducao_base_calculo.present?
7
+ pRedBC = nf_xml_value_percent icms.reducao_base_calculo
8
+ - if icms.total_base_calculo.present?
9
+ vBC = nf_xml_value_monetary icms.total_base_calculo
10
+ - if icms.aliquota.present?
11
+ pICMS = nf_xml_value_percent icms.aliquota
12
+ - if icms.total_icms_operacao.present?
13
+ vICMSOp = nf_xml_value_monetary icms.total_icms_operacao
14
+ - if icms.percentual_diferimento.present?
15
+ pDif = nf_xml_value_percent icms.percentual_diferimento
16
+ - if icms.total_icms_diferido.present?
17
+ vICMSDif = nf_xml_value_monetary icms.total_icms_diferido
18
+ - if icms.total.present?
19
+ vICMS = nf_xml_value_monetary icms.total
20
+
21
+ /################## FCP ##################\
22
+ - if icms.cfp_valor.to_f > 0
23
+ vBCFCP = nf_xml_value_monetary( icms.cfp_base_calculo )
24
+ pFCP = nf_xml_value_percent( icms.cfp_percentual )
25
+ vFCP = nf_xml_value_monetary( icms.cfp_valor )
@@ -0,0 +1,12 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+ - if icms.total_base_calculo_st_retido.to_f > 0.0
4
+ vBCSTRet = nf_xml_value_monetary icms.total_base_calculo_st_retido
5
+ pST = nf_xml_value_percent( icms.aliquota_consumidor_final )
6
+ vICMSSTRet = nf_xml_value_monetary icms.total_st_retido
7
+
8
+ /################## FCP ##################\
9
+ - if icms.cfp_st_retido_valor.to_f > 0
10
+ vBCFCPSTRet = nf_xml_value_monetary( icms.cfp_st_retido_base_calculo )
11
+ pFCPSTRet = nf_xml_value_percent( icms.cfp_st_retido_percentual )
12
+ vFCPSTRet = nf_xml_value_monetary( icms.cfp_st_retido_valor )
@@ -0,0 +1,35 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+
4
+ modBC = icms.modalidade_base_calculo
5
+ pRedBC = nf_xml_value_percent icms.reducao_base_calculo
6
+ vBC = nf_xml_value_monetary icms.total_base_calculo
7
+ pICMS = nf_xml_value_percent icms.aliquota
8
+ vICMS = nf_xml_value_monetary icms.total
9
+
10
+ /################## FCP ##################\
11
+ - if icms.cfp_valor.to_f > 0
12
+ vBCFCP = nf_xml_value_monetary( icms.cfp_base_calculo )
13
+ pFCP = nf_xml_value_percent( icms.cfp_percentual )
14
+ vFCP = nf_xml_value_monetary( icms.cfp_valor )
15
+
16
+ /################## ICMS ST ##################\
17
+ modBCST = icms.modalidade_base_calculo_st
18
+ - if icms.mva_st.to_f > 0.0
19
+ pMVAST = nf_xml_value_percent icms.mva_st
20
+ - if icms.reducao_base_calculo_st.to_f > 0.0
21
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
22
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
23
+ pICMSST = nf_xml_value_percent icms.aliquota_st
24
+ vICMSST = nf_xml_value_monetary icms.total_st
25
+
26
+ /################## FCP ST ##################\
27
+ - if icms.cfp_st_valor.to_f > 0
28
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
29
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
30
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
31
+
32
+ /################## DESONERAÇÃO DE ICMS ##################\
33
+ - if icms.total_desoneracao.to_f > 0.0
34
+ vICMSDeson nf_xml_value_monetary icms.total_desoneracao
35
+ motDesICMS icms.motivo_desoneracao
@@ -0,0 +1,38 @@
1
+ orig = icms.origem
2
+ CST = icms.codigo_cst
3
+
4
+ - if icms.aliquota.to_f > 0.0
5
+ modBC = icms.modalidade_base_calculo
6
+ - if icms.reducao_base_calculo.to_f > 0.0
7
+ pRedBC = nf_xml_value_percent icms.reducao_base_calculo
8
+ vBC = nf_xml_value_monetary icms.total_base_calculo
9
+ pICMS = nf_xml_value_percent icms.aliquota
10
+ vICMS = nf_xml_value_monetary icms.total
11
+
12
+ /################## FCP ##################\
13
+ - if icms.cfp_valor.to_f > 0
14
+ vBCFCP = nf_xml_value_monetary( icms.cfp_base_calculo )
15
+ pFCP = nf_xml_value_percent( icms.cfp_percentual )
16
+ vFCP = nf_xml_value_monetary( icms.cfp_valor )
17
+
18
+ /################## ICMS ST ##################\
19
+ - if icms.aliquota_st.to_f > 0.0
20
+ modBCST = icms.modalidade_base_calculo_st
21
+ - if icms.mva_st.to_f > 0.0
22
+ pMVAST = nf_xml_value_percent icms.mva_st
23
+ - if icms.reducao_base_calculo_st.to_f > 0.0
24
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
25
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
26
+ pICMSST = nf_xml_value_percent icms.aliquota_st
27
+ vICMSST = nf_xml_value_monetary icms.total_st
28
+
29
+ /################## FCP ##################\
30
+ - if icms.cfp_st_valor.to_f > 0
31
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
32
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
33
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
34
+
35
+ /################## DESONERAÇÃO DE ICMS ##################\
36
+ - if icms.total_desoneracao.to_f > 0.0
37
+ vICMSDeson nf_xml_value_monetary icms.total_desoneracao
38
+ motDesICMS icms.motivo_desoneracao
@@ -0,0 +1,31 @@
1
+ orig = icms.origem
2
+ CSOSN = icms.codigo_cst
3
+
4
+ - if icms.aliquota.to_f > 0.0
5
+ modBC = icms.modalidade_base_calculo
6
+ - if icms.reducao_base_calculo.to_f > 0.0
7
+ pRedBC = nf_xml_value_percent icms.reducao_base_calculo
8
+ vBC = nf_xml_value_monetary icms.total_base_calculo
9
+ pICMS = nf_xml_value_percent icms.aliquota
10
+ vICMS = nf_xml_value_monetary icms.total
11
+
12
+ /################## ICMS ST ##################\
13
+ - if icms.aliquota_st.to_f > 0.0
14
+ modBCST = icms.modalidade_base_calculo_st
15
+ - if icms.mva_st.to_f > 0.0
16
+ pMVAST = nf_xml_value_percent icms.mva_st
17
+ - if icms.reducao_base_calculo_st.to_f > 0.0
18
+ pRedBCST = nf_xml_value_percent icms.reducao_base_calculo_st
19
+ vBCST = nf_xml_value_monetary icms.total_base_calculo_st
20
+ pICMSST = nf_xml_value_percent icms.aliquota_st
21
+ vICMSST = nf_xml_value_monetary icms.total_st
22
+
23
+ /################## FCP ##################\
24
+ - if icms.cfp_st_valor.to_f > 0
25
+ vBCFCPST = nf_xml_value_monetary( icms.cfp_st_base_calculo )
26
+ pFCPST = nf_xml_value_percent( icms.cfp_st_percentual )
27
+ vFCPST = nf_xml_value_monetary( icms.cfp_st_valor )
28
+
29
+ - if icms.aliquota_credito_sn.to_f > 0.0
30
+ pCredSN = nf_xml_value_percent icms.aliquota_credito_sn
31
+ vCredICMSSN = nf_xml_value_monetary icms.total_credito_sn
@@ -0,0 +1,15 @@
1
+ vBCUFDest = nf_xml_value_monetary( icms.total_base_calculo )
2
+
3
+ - if icms.total_fcp_destino.to_f > 0
4
+ vBCFCPUFDest = nf_xml_value_monetary( icms.bc_fcp_uf_destino )
5
+ pFCPUFDest = nf_xml_value_monetary( icms.percentual_fcp_uf_destino )
6
+
7
+ pICMSUFDest = nf_xml_value_monetary( icms.aliquota_interna_uf_destino )
8
+ pICMSInter = nf_xml_value_monetary( icms.aliquota_interestadual )
9
+ pICMSInterPart = nf_xml_value_monetary( icms.percentual_partilha_destino )
10
+
11
+ - if icms.total_fcp_destino.to_f > 0
12
+ vFCPUFDest = nf_xml_value_monetary( icms.total_fcp_destino )
13
+
14
+ vICMSUFDest = nf_xml_value_monetary( icms.total_destino )
15
+ vICMSUFRemet = nf_xml_value_monetary( icms.total_origem )
@@ -0,0 +1,27 @@
1
+ - if ipi.cnpj_produtor.present?
2
+ CNPJProd = nf_xml_value_cnpj( ipi.cnpj_produtor )
3
+
4
+ - if ipi.codigo_selo.present?
5
+ cSelo = nf_xml_value_text( ipi.codigo_selo, 60 )
6
+
7
+ - if ipi.quantidade_selo.present?
8
+ qSelo = nf_xml_value_number( ipi.quantidade_selo, 12 )
9
+
10
+ cEnq = nf_xml_value_codigo_enquadramento_IPI( ipi.codigo_enquadramento )
11
+
12
+ - if ipi.codigo_cst.in?(%w[00 49 50 99])
13
+ IPITrib
14
+ CST = ipi.codigo_cst
15
+
16
+ - if ipi.aliquota.to_f > 0.0
17
+ vBC = nf_xml_value_monetary( ipi.base_calculo )
18
+ pIPI = nf_xml_value_percent( ipi.aliquota )
19
+
20
+ - elsif ipi.quantidade_unidade.to_f > 0.0
21
+ qUnid = nf_xml_value_quantidade( ipi.quantidade_unidade )
22
+ vUnid = nf_xml_value_quantidade( ipi.total_unidade )
23
+
24
+ vIPI = nf_xml_value_monetary( ipi.total )
25
+ - else
26
+ IPINT
27
+ CST = ipi.codigo_cst
@@ -0,0 +1,17 @@
1
+ detPag
2
+ - if pagamento.indicacao_pagamento.present?
3
+ indPag = pagamento.indicacao_pagamento.to_i
4
+
5
+ tPag = nf_xml_fixed_code(pagamento.forma_pagamento, size: 2)
6
+ vPag = nf_xml_value_monetary( pagamento.total )
7
+ - if pagamento.cartao?
8
+ card
9
+ tpIntegra = pagamento.tipo_integracao
10
+ - if pagamento.cartao_cnpj.present?
11
+ CNPJ = nf_xml_value_cnpj( pagamento.cartao_cnpj )
12
+
13
+ - if pagamento.cartao_bandeira.present?
14
+ tBand = nf_xml_fixed_code( pagamento.cartao_bandeira, {size: 2} )
15
+
16
+ - if pagamento.cartao_autorizacao.present?
17
+ cAut = nf_xml_value_text( pagamento.cartao_autorizacao, 20 )
@@ -1,8 +1,8 @@
1
1
  module BrNfe
2
2
  module Version
3
- MAJOR = 2 #inclui alterações de API e pode quebrar compatibilidade com versões anteriores
4
- MINOR = 3 #inclui novas funcionalidades, sem quebrar APIs existentes
5
- PATCH = 2 #corrige bugs ou traz melhorias em implementações já existentes
6
- CURRENT = "#{MAJOR}.#{MINOR}.#{PATCH}"
3
+ MAJOR = 3 #inclui alterações de API e pode quebrar compatibilidade com versões anteriores
4
+ MINOR = 0 #inclui novas funcionalidades, sem quebrar APIs existentes
5
+ PATCH = 0 #corrige bugs ou traz melhorias em implementações já existentes
6
+ CURRENT = "#{MAJOR}.#{MINOR}.#{PATCH}.beta.1"
7
7
  end
8
8
  end
@@ -1,4 +1,4 @@
1
- default: &default
1
+ default: &default_nfe_v310
2
2
  codigo_tipo_emissao: 'NFe/infNFe/ide/tpEmis'
3
3
  codigo_nf: 'NFe/infNFe/ide/cNF'
4
4
  natureza_operacao: 'NFe/infNFe/ide/natOp'
@@ -134,7 +134,7 @@ default: &default
134
134
  numero_duplicata: 'nDup'
135
135
  vencimento: 'dVenc'
136
136
  total: 'vDup'
137
- pagamentos:
137
+ pagamentos: &default_pagamentos_v310
138
138
  root: 'NFe/infNFe/pag'
139
139
  forma_pagamento: 'tPag'
140
140
  total: 'vPag'
@@ -142,7 +142,7 @@ default: &default
142
142
  cartao_cnpj: 'card/CNPJ'
143
143
  cartao_bandeira: 'card/tBand'
144
144
  cartao_autorizacao: 'card/cAut'
145
- total_icms:
145
+ total_icms: &default_total_icms_v310
146
146
  root: 'NFe/infNFe/total/ICMSTot'
147
147
  total_icms_base_calculo: 'NFe/infNFe/total/ICMSTot/vBC'
148
148
  total_icms: 'NFe/infNFe/total/ICMSTot/vICMS'
@@ -198,9 +198,7 @@ default: &default
198
198
  protocol: 'nProt'
199
199
  processed_at: 'dhRegEvento'
200
200
  status_code: 'cStat'
201
-
202
-
203
- items:
201
+ items: &default_items_v310
204
202
  root: 'NFe/infNFe/det'
205
203
  codigo_produto: 'prod/cProd'
206
204
  codigo_ean: 'prod/cEAN'
@@ -230,7 +228,7 @@ default: &default
230
228
  total_ipi_devolucao: 'impostoDevol/IPI/vIPIDevol'
231
229
  informacoes_adicionais: 'infAdProd'
232
230
  total_tributos: 'imposto/vTotTrib'
233
- icms:
231
+ icms: &default_items_icms_v310
234
232
  root: 'imposto/ICMS'
235
233
  origem: 'imposto/ICMS/*/orig'
236
234
  cst: 'imposto/ICMS/*/CST'
@@ -325,7 +323,8 @@ default: &default
325
323
  icms_uf_destino:
326
324
  root: 'imposto/ICMSUFDest'
327
325
  total_base_calculo: 'imposto/ICMSUFDest/vBCUFDest'
328
- percentual_fcp: 'imposto/ICMSUFDest/pFCPUFDest'
326
+ bc_fcp_uf_destino: 'imposto/ICMSUFDest/vBCFCPUFDest'
327
+ percentual_fcp_uf_destino: 'imposto/ICMSUFDest/pFCPUFDest'
329
328
  aliquota_interna_uf_destino: 'imposto/ICMSUFDest/pICMSUFDest'
330
329
  aliquota_interestadual: 'imposto/ICMSUFDest/pICMSInter'
331
330
  percentual_partilha_destino: 'imposto/ICMSUFDest/pICMSInterPart'
@@ -369,4 +368,36 @@ default: &default
369
368
  nfe:
370
369
  v3_10:
371
370
  reader_xml_paths:
372
- <<: *default
371
+ <<: *default_nfe_v310
372
+ v4_00:
373
+ reader_xml_paths:
374
+ <<: *default_nfe_v310
375
+ pagamentos:
376
+ <<: *default_pagamentos_v310
377
+ troco: 'NFe/infNFe/pag/vTroco'
378
+ root: 'NFe/infNFe/pag/detPag'
379
+ indicacao_pagamento: 'indPag'
380
+ total_icms:
381
+ <<: *default_total_icms_v310
382
+ total_fcp: 'NFe/infNFe/total/ICMSTot/vFCP'
383
+ total_fcp_st: 'NFe/infNFe/total/ICMSTot/vFCPST'
384
+ total_fcp_st_retido: 'NFe/infNFe/total/ICMSTot/vFCPSTRet'
385
+ total_ipi_devolvido: 'NFe/infNFe/total/ICMSTot/vIPIDevol'
386
+
387
+ items:
388
+ <<: *default_items_v310
389
+ escala_relevante: 'prod/indEscala'
390
+ cnpj_fabricante: 'prod/CNPJFab'
391
+ codigo_beneficio_fiscal: 'prod/cBenef'
392
+ icms:
393
+ <<: *default_items_icms_v310
394
+ cfp_base_calculo: 'imposto/ICMS/*/vBCFCP'
395
+ cfp_percentual: 'imposto/ICMS/*/pFCP'
396
+ cfp_valor: 'imposto/ICMS/*/vFCP'
397
+ cfp_st_base_calculo: 'imposto/ICMS/*/vBCFCPST'
398
+ cfp_st_percentual: 'imposto/ICMS/*/pFCPST'
399
+ cfp_st_valor: 'imposto/ICMS/*/vFCPST'
400
+ cfp_st_retido_base_calculo: 'imposto/ICMS/*/vBCFCPSTRet'
401
+ cfp_st_retido_percentual: 'imposto/ICMS/*/pFCPSTRet'
402
+ cfp_st_retido_valor: 'imposto/ICMS/*/vFCPSTRet'
403
+ aliquota_consumidor_final: 'imposto/ICMS/*/pST'