tributus-engine 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,124 @@
1
+ from typing import Protocol
2
+ from decimal import Decimal
3
+
4
+ class ICbs(Protocol):
5
+ def valor_base_ibs_cbs(self) -> Decimal: ...
6
+ def aliquota_efetiva(self) -> Decimal: ...
7
+ def diferimento(self) -> Decimal: ...
8
+ def valor_cbs(self) -> Decimal: ...
9
+
10
+ class ICofins01_02(Protocol):
11
+ def base_cofins(self) -> Decimal: ...
12
+ def valor_cofins(self) -> Decimal: ...
13
+
14
+ class ICofins03(Protocol):
15
+ def valor_cofins(self) -> Decimal: ...
16
+
17
+ class IFcp(Protocol):
18
+ def valor_fcp(self) -> Decimal: ...
19
+
20
+ class IFcpDif(Protocol):
21
+ def valor_fcp_diferido(self) -> Decimal: ...
22
+
23
+ class IFcpEfet(Protocol):
24
+ def valor_fcp_efetivo(self) -> Decimal: ...
25
+
26
+ class IFcpST(Protocol):
27
+ def valor_fcp_st(self) -> Decimal: ...
28
+
29
+ class IIbsUf(Protocol):
30
+ def valor_base_ibs_cbs(self) -> Decimal: ...
31
+ def aliquota_efetiva(self) -> Decimal: ...
32
+ def diferimento(self) -> Decimal: ...
33
+ def valor_ibs_uf(self) -> Decimal: ...
34
+
35
+ class IIcms00(Protocol):
36
+ def base_icms_proprio(self) -> Decimal: ...
37
+ def valor_icms_proprio(self) -> Decimal: ...
38
+
39
+ class IIcms10(Protocol):
40
+ def base_icms_proprio(self) -> Decimal: ...
41
+ def valor_icms_proprio(self) -> Decimal: ...
42
+ def base_icms_st(self) -> Decimal: ...
43
+ def valor_icms_st(self) -> Decimal: ...
44
+ def valor_icms_st_desonerado(self) -> Decimal: ...
45
+
46
+ class IIcms101(Protocol):
47
+ def calcular_base_icms_proprio(self) -> Decimal: ...
48
+ def valor_credito_sn(self) -> Decimal: ...
49
+
50
+ class IIcms20(Protocol):
51
+ def base_reduzida_icms_proprio(self) -> Decimal: ...
52
+ def valor_icms_proprio(self) -> Decimal: ...
53
+ def valor_icms_desonerado(self) -> Decimal: ...
54
+
55
+ class IIcms201(Protocol):
56
+ def calcular_base_icms_proprio(self) -> Decimal: ...
57
+ def valor_icms_proprio(self) -> Decimal: ...
58
+ def valor_credito_sn(self) -> Decimal: ...
59
+ def base_icms_st(self) -> Decimal: ...
60
+ def valor_icms_st(self) -> Decimal: ...
61
+
62
+ class IIcms202_203(Protocol):
63
+ def calcular_base_icms_proprio(self) -> Decimal: ...
64
+ def valor_icms_proprio(self) -> Decimal: ...
65
+ def base_icms_st(self) -> Decimal: ...
66
+ def valor_icms_st(self) -> Decimal: ...
67
+
68
+ class IIcms30(Protocol):
69
+ def base_icms_proprio(self) -> Decimal: ...
70
+ def valor_icms_proprio(self) -> Decimal: ...
71
+ def base_icms_st(self) -> Decimal: ...
72
+ def valor_icms_st(self) -> Decimal: ...
73
+ def valor_icms_desonerado(self) -> Decimal: ...
74
+
75
+ class IIcms51(Protocol):
76
+ def base_icms_proprio(self) -> Decimal: ...
77
+ def valor_icms_operacao(self) -> Decimal: ...
78
+ def valor_icms_diferido(self) -> Decimal: ...
79
+ def valor_icms_proprio(self) -> Decimal: ...
80
+
81
+ class IIcms70(Protocol):
82
+ def base_icms_proprio(self) -> Decimal: ...
83
+ def valor_icms_proprio(self) -> Decimal: ...
84
+ def valor_icms_proprio_desonerado(self) -> Decimal: ...
85
+ def base_icms_st(self) -> Decimal: ...
86
+ def valor_icms_st(self) -> Decimal: ...
87
+ def valor_icms_st_desonerado(self) -> Decimal: ...
88
+
89
+ class IIcms90(Protocol):
90
+ def calcular_base_icms_proprio(self) -> Decimal: ...
91
+ def calcular_base_reduzida_icms_proprio(self) -> Decimal: ...
92
+ def valor_icms_proprio(self) -> Decimal: ...
93
+ def valor_icms_proprio_base_reduzida(self) -> Decimal: ...
94
+ def valor_icms_proprio_desonerado(self) -> Decimal: ...
95
+ def calcular_base_icms_st(self) -> Decimal: ...
96
+ def calcular_base_reduzida_icms_st(self) -> Decimal: ...
97
+ def valor_icms_st(self) -> Decimal: ...
98
+ def valor_icms_st_base_reduzida(self) -> Decimal: ...
99
+ def valor_icms_st_desonerado(self) -> Decimal: ...
100
+
101
+ class IIcms900(Protocol):
102
+ def calcular_base_icms_proprio(self) -> Decimal: ...
103
+ def calcular_base_reduzida_icms_proprio(self) -> Decimal: ...
104
+ def valor_icms_proprio(self) -> Decimal: ...
105
+ def valor_credito_sn(self) -> Decimal: ...
106
+ def valor_icms_proprio_base_reduzida(self) -> Decimal: ...
107
+ def calcular_base_icms_st(self) -> Decimal: ...
108
+ def calcular_base_reduzida_icms_st(self) -> Decimal: ...
109
+ def valor_icms_st(self) -> Decimal: ...
110
+ def valor_icms_st_base_reduzida(self) -> Decimal: ...
111
+
112
+ class IIpi50AdValorem(Protocol):
113
+ def calcular_base_ipi(self) -> Decimal: ...
114
+ def valor_ipi(self) -> Decimal: ...
115
+
116
+ class IIpiEspecifico(Protocol):
117
+ def valor_ipi(self) -> Decimal: ...
118
+
119
+ class IPis01_02(Protocol):
120
+ def base_pis(self) -> Decimal: ...
121
+ def valor_pis(self) -> Decimal: ...
122
+
123
+ class IPis03(Protocol):
124
+ def valor_pis(self) -> Decimal: ...
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: tributus-engine
3
+ Version: 0.2.0
4
+ Summary: Tributus Engine - Brazilian Tax Engine and Calculator Library
5
+ Author-email: Mackilem Van der Laan <mack.vdl@gmail.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: pydantic>=2.13.4
12
+ Requires-Dist: pytest>=9.0.3
13
+ Requires-Dist: PyYAML>=6.0.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: pytest-cov; extra == "dev"
17
+ Requires-Dist: build; extra == "dev"
18
+ Requires-Dist: twine; extra == "dev"
19
+
20
+ # Tributus Engine (Pacote Python)
21
+
22
+ Pacote Python da biblioteca Tributus Engine para calculo tributario brasileiro.
23
+
24
+ ## Instalacao
25
+
26
+ ```bash
27
+ pip install .
28
+ ```
29
+
30
+ ## O que a biblioteca cobre
31
+
32
+ - ICMS e CSTs principais
33
+ - FCP e DIFAL
34
+ - IPI
35
+ - PIS e COFINS
36
+ - IBS e CBS
37
+ - Biblioteca de calculo tributario com metodo centralizado via payload JSON
38
+ - Catalogo fiscal por NCM/CEST e UF
39
+
40
+ ## Casos de uso
41
+
42
+ - Calculo fiscal em ERP
43
+ - API REST de tributacao
44
+ - Simulacao de impacto tributario por produto
45
+ - Cenarios com aliquota manual para homologacao e testes
46
+
47
+ ## Uso Rapido
48
+
49
+ ### 1) Engine simplificada com payload dict
50
+
51
+ ```python
52
+ from tributus_engine import TaxEngine
53
+
54
+ engine = TaxEngine()
55
+
56
+ payload = {
57
+ "operation": {
58
+ "operation_type": "sale",
59
+ "document_type": "nfe",
60
+ "operation_date": "2026-06-02",
61
+ "issuer_state": "SP",
62
+ "recipient_state": "RJ",
63
+ "issuer_country": "BR",
64
+ "recipient_country": "BR",
65
+ "consumer_final": True,
66
+ "taxpayer_icms": False,
67
+ "presence_indicator": "2"
68
+ },
69
+ "company": {
70
+ "tax_regime": "lucro_presumido",
71
+ "crt": "3",
72
+ "has_pis_credit": False,
73
+ "has_cofins_credit": False,
74
+ "suframa": False,
75
+ "taxpayer_icms": False,
76
+ "taxpayer_ibs": False
77
+ },
78
+ "customer": {
79
+ "state": "RJ",
80
+ "taxpayer_icms": False,
81
+ "consumer_final": True,
82
+ "suframa": False,
83
+ "taxpayer_ibs": False
84
+ },
85
+ "product": {
86
+ "ncm": "22030000",
87
+ "cest": "0300100",
88
+ "origin": "0",
89
+ "fiscal_category": "industrialized",
90
+ "import_content": 0.0,
91
+ "benefit_code": None,
92
+ "is_imported": False,
93
+ "has_st": True,
94
+ "has_monophase": False,
95
+ "is_fuel": False,
96
+ "is_medicine": False
97
+ },
98
+ "values": {
99
+ "quantity": "5",
100
+ "unit_price": "200.00",
101
+ "gross_value": "1000.00",
102
+ "discount_value": "100.00",
103
+ "freight_value": "50.00",
104
+ "insurance_value": "10.00",
105
+ "other_expenses": "20.00"
106
+ }
107
+ }
108
+
109
+ result = engine.calculate_from_dict(payload)
110
+ print(result.to_dict())
111
+ ```
112
+
113
+ ### 2) Engine com taxas manuais (`taxes`)
114
+
115
+ ```python
116
+ payload["taxes"] = {
117
+ "enabled": ["ipi", "icms", "fcp", "pis", "cofins", "ibs", "cbs"],
118
+ "rates": {
119
+ "icms": "17.00",
120
+ "pis": "1.20",
121
+ "cofins": "5.40",
122
+ "ibs": "16.00",
123
+ "cbs": "8.50"
124
+ },
125
+ "icms": {
126
+ "cst": "00",
127
+ "aliquota_icms_proprio": "17.00"
128
+ },
129
+ "ipi": {
130
+ "aliquota_ipi": "10.00"
131
+ },
132
+ "pis": {
133
+ "aliquota_pis": "1.20"
134
+ },
135
+ "cofins": {
136
+ "aliquota_cofins": "5.40"
137
+ }
138
+ }
139
+
140
+ result = engine.calculate_from_dict(payload)
141
+ print(result.to_dict())
142
+ ```
143
+
144
+ ### 3) Estrutura de `taxes` suportada
145
+
146
+ Campos principais aceitos no payload JSON:
147
+
148
+ - `enabled`: lista dos tributos a calcular na sequencia centralizada.
149
+ - `rates`: aliquotas simples por tributo quando nao houver configuracao mais especifica.
150
+ - `ipi`: `aliquota_ipi` ou `mode: specific` + `aliquota_por_unidade`.
151
+ - `icms`: `cst`, `aliquota_icms_proprio`, `aliquota_icms_st`, `mva`, `percentual_reducao`, `percentual_reducao_st`, `percentual_diferimento`, `percentual_credito_sn`, `include_ipi_in_base`.
152
+ - `fcp`: `aliquota_fcp`, `aliquota_fcp_st`, `aliquota_diferimento_fcp`.
153
+ - `pis`: `aliquota_pis` ou `mode: specific` + `aliquota_por_unidade`.
154
+ - `cofins`: `aliquota_cofins` ou `mode: specific` + `aliquota_por_unidade`.
155
+ - `ibs`: `aliquota_efetiva_percentual`, `percentual_diferimento`.
156
+ - `cbs`: `aliquota_efetiva_percentual`, `percentual_diferimento`.
157
+
158
+ O retorno consolidado expõe `taxes.{nome}.base`, `taxes.{nome}.rate`, `taxes.{nome}.amount` e `total`.
159
+
160
+ ### 4) Consulta de impostos/taxas por NCM/CEST para todas as UFs
161
+
162
+ ```python
163
+ taxes_by_state = engine.list_taxes_for_sale_all_states_from_dict({
164
+ "product": {"ncm": "22030000", "cest": "0300100"}
165
+ })
166
+
167
+ print(taxes_by_state["SP"])
168
+ print(taxes_by_state["RJ"])
169
+ ```
170
+
171
+ ## Modo de resolucao de taxas
172
+
173
+ Prioridade da engine:
174
+
175
+ 1. `taxes` enviado no payload
176
+ 2. catalogo interno por NCM/CEST/UF
177
+ 3. fallback automatico do provider
178
+
179
+ Na versao atual do metodo centralizado, o fluxo principal esperado e receber as incidencias e aliquotas no proprio JSON. Catalogo/provider continuam como extensoes futuras da superficie publica.
180
+
181
+ ## Desenvolvimento
182
+
183
+ ```bash
184
+ python -m pip install -e .
185
+ python -m pytest tests
186
+ ```
@@ -0,0 +1,17 @@
1
+ tributus_engine/__init__.py,sha256=7AG7KRAJcGQ6ly19RBlLtP3o-Eu5jkxAvHUxA3xhwJk,130
2
+ tributus_engine/engine.py,sha256=cLqUBG13YEwz03k9sFSc5wKcL2vpmlIRc3dH2A06E5Y,28679
3
+ tributus_engine/implementations/__init__.py,sha256=j1-f7V9cr3JT_uTzySICsR8Zcrgk34lsRhBMJvff9o4,266
4
+ tributus_engine/implementations/cofins.py,sha256=q_RXnZgc1PYssI8tak_NN6Mrq6kh0FLkWIIwJwsndt8,1758
5
+ tributus_engine/implementations/ibs_cbs.py,sha256=no7aGE5HTxw67bWP8jcsGKSqhBKFuYqGaHtpG8vSz6M,3083
6
+ tributus_engine/implementations/ipi.py,sha256=0QWmBnKOKFFxccNaVB4bRR1Z-Jy4eHaIs1j-PjSLxgY,1496
7
+ tributus_engine/implementations/pis.py,sha256=_ajCtWLVVYU0dQt7vXkoPFeJkU_gi8u7BxIbQFIHhwk,1686
8
+ tributus_engine/implementations/icms/__init__.py,sha256=V35Bz_uFYOzoXHhxUsdOkO30DKm6WEvUwvnawFUrbpk,386
9
+ tributus_engine/implementations/icms/base.py,sha256=uVQer7Ki9OlUImh1Bi0OFrWr45_udwcEUkK4h5PTlwE,2770
10
+ tributus_engine/implementations/icms/cst.py,sha256=V10pH4cugNkho9ZwTCI1_iedFFPBaHn9GHQp-tPXW8M,22253
11
+ tributus_engine/implementations/icms/fcp.py,sha256=wSSFt_4at87iDZ8gQyhesvQgNo22Q1kApyKFgkB7U7g,1138
12
+ tributus_engine/interfaces/__init__.py,sha256=6fB0mfefdy-QgOBYPveKa8MGuM7d0Ex45ISf8iGRUng,350
13
+ tributus_engine/interfaces/protocols.py,sha256=6Jf9IER84HG_pY8Wnvn8IA9Xt_MbI1r1LyQNT1ensSI,4417
14
+ tributus_engine-0.2.0.dist-info/METADATA,sha256=1KRgzkgQ0EJeAkzSKSUUOQ2Tzre7-mwqapjudXOUPmU,5054
15
+ tributus_engine-0.2.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
16
+ tributus_engine-0.2.0.dist-info/top_level.txt,sha256=lelQoWyMaMvy-KscMO4rlmsLdc8mnEY2aD3aTN_kkyk,16
17
+ tributus_engine-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ tributus_engine