mcp-server-taxcode 0.1.1__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.
- mcp_server_taxcode-0.1.1.dist-info/METADATA +307 -0
- mcp_server_taxcode-0.1.1.dist-info/RECORD +19 -0
- mcp_server_taxcode-0.1.1.dist-info/WHEEL +4 -0
- mcp_server_taxcode-0.1.1.dist-info/entry_points.txt +3 -0
- mcp_server_taxcode-0.1.1.dist-info/licenses/LICENSE +190 -0
- taxcode_mcp/__init__.py +14 -0
- taxcode_mcp/auth.py +65 -0
- taxcode_mcp/client.py +218 -0
- taxcode_mcp/config.py +95 -0
- taxcode_mcp/db.py +1450 -0
- taxcode_mcp/errors.py +399 -0
- taxcode_mcp/middleware.py +169 -0
- taxcode_mcp/profiles.py +180 -0
- taxcode_mcp/server.py +526 -0
- taxcode_mcp/ssrf.py +287 -0
- taxcode_mcp/tools/__init__.py +41 -0
- taxcode_mcp/tools/compliance.py +542 -0
- taxcode_mcp/tools/statutes.py +156 -0
- taxcode_mcp/tools/system.py +72 -0
taxcode_mcp/db.py
ADDED
|
@@ -0,0 +1,1450 @@
|
|
|
1
|
+
"""DuckDB database layer for statutory corpora and regulatory guidance."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import threading
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import duckdb
|
|
10
|
+
|
|
11
|
+
from taxcode_mcp.config import settings
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
# Canonical initial seed data for US Federal and Puerto Rico tax provisions
|
|
16
|
+
INITIAL_STATUTES: list[dict[str, Any]] = [
|
|
17
|
+
{
|
|
18
|
+
"id": "us-irc-933",
|
|
19
|
+
"jurisdiction": "US",
|
|
20
|
+
"corpus": "IRC",
|
|
21
|
+
"citation": "26 U.S.C. § 933",
|
|
22
|
+
"section": "933",
|
|
23
|
+
"title": "Income from sources within Puerto Rico",
|
|
24
|
+
"text_es": (
|
|
25
|
+
"En el caso de un individuo que sea residente de buena fe de Puerto Rico durante todo "
|
|
26
|
+
"el año tributario, el ingreso bruto no incluirá ingresos derivados de fuentes dentro "
|
|
27
|
+
"de Puerto Rico (excepto cantidades por servicios prestados a los Estados Unidos)."
|
|
28
|
+
),
|
|
29
|
+
"text_en": (
|
|
30
|
+
"In the case of an individual who is a bona fide resident of Puerto Rico during the "
|
|
31
|
+
"entire taxable year, gross income does not include income derived from sources within "
|
|
32
|
+
"Puerto Rico (except amounts received for services performed as an employee of the US)."
|
|
33
|
+
),
|
|
34
|
+
"effective_year": 1954,
|
|
35
|
+
"source_url": "https://uscode.house.gov/view.xhtml?req=granuleid:USC-prelim-title26-section933",
|
|
36
|
+
"cross_references": ["26 U.S.C. § 937", "26 CFR § 1.937-1", "26 U.S.C. § 865"],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "us-irc-937",
|
|
40
|
+
"jurisdiction": "US",
|
|
41
|
+
"corpus": "IRC",
|
|
42
|
+
"citation": "26 U.S.C. § 937",
|
|
43
|
+
"section": "937",
|
|
44
|
+
"title": "Residence and source rules involving possessions",
|
|
45
|
+
"text_es": (
|
|
46
|
+
"Establece los requisitos estatutarios para determinar residencia de buena fe en "
|
|
47
|
+
"posesiones (presencia física, centro tributario 'tax home' y conexión más cercana), "
|
|
48
|
+
"así como las reglas de fuente de ingresos aplicables a posesiones."
|
|
49
|
+
),
|
|
50
|
+
"text_en": (
|
|
51
|
+
"Rules for determining bona fide residency in possessions (presence test, tax home "
|
|
52
|
+
"test, and closer connection test) and statutory principles for sourcing income."
|
|
53
|
+
),
|
|
54
|
+
"effective_year": 2004,
|
|
55
|
+
"source_url": "https://uscode.house.gov/view.xhtml?req=granuleid:USC-prelim-title26-section937",
|
|
56
|
+
"cross_references": ["26 U.S.C. § 933", "26 CFR § 1.937-1", "26 CFR § 1.937-2"],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "us-irc-865",
|
|
60
|
+
"jurisdiction": "US",
|
|
61
|
+
"corpus": "IRC",
|
|
62
|
+
"citation": "26 U.S.C. § 865",
|
|
63
|
+
"section": "865",
|
|
64
|
+
"title": "Source rules for personal property sales",
|
|
65
|
+
"text_es": (
|
|
66
|
+
"Salvo disposición expresa en contrario, el ingreso derivado de la venta de bienes "
|
|
67
|
+
"personales (incluyendo valores negociables y acciones) se atribuirá a la residencia "
|
|
68
|
+
"del vendedor."
|
|
69
|
+
),
|
|
70
|
+
"text_en": (
|
|
71
|
+
"Except as otherwise provided in this section, income from the sale of personal "
|
|
72
|
+
"property (including corporate stock and marketable securities) is sourced to the "
|
|
73
|
+
"residence of the seller."
|
|
74
|
+
),
|
|
75
|
+
"effective_year": 1986,
|
|
76
|
+
"source_url": "https://uscode.house.gov/view.xhtml?req=granuleid:USC-prelim-title26-section865",
|
|
77
|
+
"cross_references": ["26 U.S.C. § 937", "26 CFR § 1.937-2"],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "us-cfr-1-937-1",
|
|
81
|
+
"jurisdiction": "US",
|
|
82
|
+
"corpus": "CFR",
|
|
83
|
+
"citation": "26 CFR § 1.937-1",
|
|
84
|
+
"section": "1.937-1",
|
|
85
|
+
"title": "Bona fide residency in a possession",
|
|
86
|
+
"text_es": (
|
|
87
|
+
"Reglamentación del Tesoro que articula las cinco alternativas de presencia física "
|
|
88
|
+
"(regla de 183 días, regla de 549 días en 3 años, límite de 90 días en EE.UU.), "
|
|
89
|
+
"el requisito de no mantener tax home fuera, y los factores de conexión más cercana."
|
|
90
|
+
),
|
|
91
|
+
"text_en": (
|
|
92
|
+
"Treasury Regulation detailing the presence test alternatives (183-day rule, 549-day "
|
|
93
|
+
"3-year rule, 90-day US presence limit), the tax home rule, and closer connection."
|
|
94
|
+
),
|
|
95
|
+
"effective_year": 2006,
|
|
96
|
+
"source_url": "https://www.ecfr.gov/current/title-26/section-1.937-1",
|
|
97
|
+
"cross_references": ["26 U.S.C. § 937", "26 CFR § 1.937-2"],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "us-cfr-1-937-2",
|
|
101
|
+
"jurisdiction": "US",
|
|
102
|
+
"corpus": "CFR",
|
|
103
|
+
"citation": "26 CFR § 1.937-2",
|
|
104
|
+
"section": "1.937-2",
|
|
105
|
+
"title": "Income from sources within a possession",
|
|
106
|
+
"text_es": (
|
|
107
|
+
"Reglas de fuente para posesiones y regla de lookback de 10 años para ganancias "
|
|
108
|
+
"acumuladas (built-in gains) sobre bienes adquiridos antes de establecer residencia."
|
|
109
|
+
),
|
|
110
|
+
"text_en": (
|
|
111
|
+
"Sourcing rules for possessions and 10-year built-in gain lookback rules under "
|
|
112
|
+
"Treas. Reg. § 1.937-2(f) for property held prior to establishing bona fide residency."
|
|
113
|
+
),
|
|
114
|
+
"effective_year": 2006,
|
|
115
|
+
"source_url": "https://www.ecfr.gov/current/title-26/section-1.937-2",
|
|
116
|
+
"cross_references": ["26 U.S.C. § 937", "26 CFR § 1.937-1"],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "pr-cri-1010-01",
|
|
120
|
+
"jurisdiction": "PR",
|
|
121
|
+
"corpus": "CRI",
|
|
122
|
+
"citation": "PR CRI Sec. 1010.01",
|
|
123
|
+
"section": "1010.01",
|
|
124
|
+
"title": "Definiciones generales / General Definitions",
|
|
125
|
+
"text_es": (
|
|
126
|
+
"Define términos fundamentales bajo el Código de Rentas Internas de Puerto Rico "
|
|
127
|
+
"(Ley 1-2011), incluyendo individuo residente, corporación foránea y año contributivo."
|
|
128
|
+
),
|
|
129
|
+
"text_en": (
|
|
130
|
+
"Defines fundamental statutory terms under the PR Internal Revenue Code (Ley 1-2011), "
|
|
131
|
+
"including resident individual, foreign corporation, taxable year, and person."
|
|
132
|
+
),
|
|
133
|
+
"effective_year": 2011,
|
|
134
|
+
"source_url": "https://hacienda.pr.gov/publicaciones/codigo-de-rentas-internas-de-puerto-rico-de-2011",
|
|
135
|
+
"cross_references": ["PR CRI Sec. 1031.01", "PR CRI Sec. 1062.01"],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "pr-cri-1031-01",
|
|
139
|
+
"jurisdiction": "PR",
|
|
140
|
+
"corpus": "CRI",
|
|
141
|
+
"citation": "PR CRI Sec. 1031.01",
|
|
142
|
+
"section": "1031.01",
|
|
143
|
+
"title": "Ingreso bruto / Gross Income",
|
|
144
|
+
"text_es": (
|
|
145
|
+
"Incluye ganancias, beneficios e ingresos derivados de sueldos, profesiones, "
|
|
146
|
+
"comercio o ventas en propiedad, y excluye partidas estatutariamente exentas."
|
|
147
|
+
),
|
|
148
|
+
"text_en": (
|
|
149
|
+
"Includes gains, profits, and income derived from salaries, professions, commerce, "
|
|
150
|
+
"or sales of property, while excluding statutory exclusions."
|
|
151
|
+
),
|
|
152
|
+
"effective_year": 2011,
|
|
153
|
+
"source_url": "https://hacienda.pr.gov/publicaciones/codigo-de-rentas-internas-de-puerto-rico-de-2011",
|
|
154
|
+
"cross_references": ["PR CRI Sec. 1010.01", "PR CRI Sec. 1031.02"],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "pr-ley60-2021-01",
|
|
158
|
+
"jurisdiction": "PR",
|
|
159
|
+
"corpus": "LEY60",
|
|
160
|
+
"citation": "Ley 60-2019 Sec. 2021.01",
|
|
161
|
+
"section": "2021.01",
|
|
162
|
+
"title": "Individuos Residentes Inversionistas - Cualificación",
|
|
163
|
+
"text_es": (
|
|
164
|
+
"Establece requisitos para acogerse al Capítulo 2 del Código de Incentivos, "
|
|
165
|
+
"incluyendo no haber sido residente de PR en los 10 años anteriores y "
|
|
166
|
+
"adquirir una residencia principal."
|
|
167
|
+
),
|
|
168
|
+
"text_en": (
|
|
169
|
+
"Establishes eligibility criteria for Individual Resident Investors under Act 60 "
|
|
170
|
+
"Chapter 2 (formerly Act 22), including 10-year non-residency and home purchase."
|
|
171
|
+
),
|
|
172
|
+
"effective_year": 2019,
|
|
173
|
+
"source_url": "https://bvirtualogp.pr.gov/",
|
|
174
|
+
"cross_references": ["Ley 60-2019 Sec. 2022.01", "26 U.S.C. § 933"],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"id": "pr-ley60-2022-01",
|
|
178
|
+
"jurisdiction": "PR",
|
|
179
|
+
"corpus": "LEY60",
|
|
180
|
+
"citation": "Ley 60-2019 Sec. 2022.01",
|
|
181
|
+
"section": "2022.01",
|
|
182
|
+
"title": "Exención Contributiva sobre Ganancias de Capital e Intereses",
|
|
183
|
+
"text_es": (
|
|
184
|
+
"Dispone exención total (100%) sobre ganancias de capital e intereses para decretos "
|
|
185
|
+
"previos a 2027 (y tasa del 4% para decretos solicitados desde 2027)."
|
|
186
|
+
),
|
|
187
|
+
"text_en": (
|
|
188
|
+
"Provides 100% tax exemption on capital gains, dividends, and interest post-residency "
|
|
189
|
+
"(4% capital gains rate for decrees requested on or after Jan 1, 2027)."
|
|
190
|
+
),
|
|
191
|
+
"effective_year": 2019,
|
|
192
|
+
"source_url": "https://bvirtualogp.pr.gov/",
|
|
193
|
+
"cross_references": ["Ley 60-2019 Sec. 2021.01", "26 CFR § 1.937-2"],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"id": "pr-ley60-2031-01",
|
|
197
|
+
"jurisdiction": "PR",
|
|
198
|
+
"corpus": "LEY60",
|
|
199
|
+
"citation": "Ley 60-2019 Sec. 2031.01",
|
|
200
|
+
"section": "2031.01",
|
|
201
|
+
"title": "Exportación de Servicios y Comercio - Cualificación",
|
|
202
|
+
"text_es": (
|
|
203
|
+
"Cualifica negocios dedicados a la exportación de servicios elegibles prestados "
|
|
204
|
+
"desde Puerto Rico hacia mercados exteriores sin nexo previo en la isla (ex-Ley 20)."
|
|
205
|
+
),
|
|
206
|
+
"text_en": (
|
|
207
|
+
"Qualifies businesses engaged in export services conducted from Puerto Rico to "
|
|
208
|
+
"foreign or mainland markets with no prior nexus in the island (formerly Act 20)."
|
|
209
|
+
),
|
|
210
|
+
"effective_year": 2019,
|
|
211
|
+
"source_url": "https://bvirtualogp.pr.gov/",
|
|
212
|
+
"cross_references": ["Ley 60-2019 Sec. 2032.01", "26 U.S.C. § 957"],
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"id": "pr-ley60-2032-01",
|
|
216
|
+
"jurisdiction": "PR",
|
|
217
|
+
"corpus": "LEY60",
|
|
218
|
+
"citation": "Ley 60-2019 Sec. 2032.01",
|
|
219
|
+
"section": "2032.01",
|
|
220
|
+
"title": "Tasa Fija Preferencial de 4% sobre Ingreso de Desarrollo",
|
|
221
|
+
"text_es": (
|
|
222
|
+
"Fija una tasa del 4% sobre el ingreso neto de desarrollo para exportación, "
|
|
223
|
+
"100% de exención sobre dividendos, y 75% de exención en contribución "
|
|
224
|
+
"sobre la propiedad."
|
|
225
|
+
),
|
|
226
|
+
"text_en": (
|
|
227
|
+
"Establishes a 4% corporate rate on export net income, 100% exemption on dividends, "
|
|
228
|
+
"and 75% exemption on property taxes."
|
|
229
|
+
),
|
|
230
|
+
"effective_year": 2019,
|
|
231
|
+
"source_url": "https://bvirtualogp.pr.gov/",
|
|
232
|
+
"cross_references": ["Ley 60-2019 Sec. 2031.01", "PR CRI Sec. 1010.01"],
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"id": "pr-act22-2012",
|
|
236
|
+
"jurisdiction": "PR",
|
|
237
|
+
"corpus": "LEY22",
|
|
238
|
+
"citation": "Act 22-2012 Sec. 3",
|
|
239
|
+
"section": "3",
|
|
240
|
+
"title": "Exención Contributiva sobre Ganancias de Capital (Histórico Ley 22)",
|
|
241
|
+
"text_es": (
|
|
242
|
+
"Exención total del 100% sobre ganancias de capital devengadas luego de establecer "
|
|
243
|
+
"residencia bajo la Ley 22 original (sin requisito de donación anual compulsoria)."
|
|
244
|
+
),
|
|
245
|
+
"text_en": (
|
|
246
|
+
"Predecessor 100% tax exemption on capital gains accrued post-residency under original "
|
|
247
|
+
"Act 22-2012 (prior to Act 60 mandatory charitable donations)."
|
|
248
|
+
),
|
|
249
|
+
"effective_year": 2012,
|
|
250
|
+
"superseded_year": 2019,
|
|
251
|
+
"source_url": "https://bvirtualogp.pr.gov/",
|
|
252
|
+
"cross_references": ["Ley 60-2019 Sec. 2022.01", "26 U.S.C. § 933"],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"id": "ga-ocga-48-7-1",
|
|
256
|
+
"jurisdiction": "GA",
|
|
257
|
+
"corpus": "OCGA",
|
|
258
|
+
"citation": "O.C.G.A. § 48-7-1",
|
|
259
|
+
"section": "48-7-1",
|
|
260
|
+
"title": "Income Tax Definitions / Residency Rules",
|
|
261
|
+
"text_es": (
|
|
262
|
+
"Define residente de Georgia como todo individuo con residencia legal en "
|
|
263
|
+
"Georgia el día de pago del impuesto, que resida en el estado al menos "
|
|
264
|
+
"183 días del año contributivo, o que mantenga una vivienda permanente en Georgia."
|
|
265
|
+
),
|
|
266
|
+
"text_en": (
|
|
267
|
+
"Defines Georgia resident as any individual who is a legal resident of Georgia on "
|
|
268
|
+
"income tax day, who resides within the state for 183 days or more in the aggregate "
|
|
269
|
+
"during the taxable year, or who maintains a permanent place of abode within the state."
|
|
270
|
+
),
|
|
271
|
+
"effective_year": 2024,
|
|
272
|
+
"source_url": "https://dor.georgia.gov/",
|
|
273
|
+
"cross_references": [
|
|
274
|
+
"O.C.G.A. § 48-7-20",
|
|
275
|
+
"O.C.G.A. § 48-7-30",
|
|
276
|
+
"Ga. Comp. R. & Regs. r. 560-7-3-.01",
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"id": "ga-ocga-48-7-20-2024",
|
|
281
|
+
"jurisdiction": "GA",
|
|
282
|
+
"corpus": "OCGA",
|
|
283
|
+
"citation": "O.C.G.A. § 48-7-20",
|
|
284
|
+
"section": "48-7-20",
|
|
285
|
+
"title": "Individual Income Tax Rates (2024 Flat Rate: 5.49%)",
|
|
286
|
+
"text_es": (
|
|
287
|
+
"Establece una tasa impositiva fija (flat tax) de 5.49% sobre el ingreso neto "
|
|
288
|
+
"tributable de individuos para el año contributivo 2024 bajo HB 1023."
|
|
289
|
+
),
|
|
290
|
+
"text_en": (
|
|
291
|
+
"Imposes a flat individual income tax rate of 5.49% on Georgia taxable net income "
|
|
292
|
+
"for tax year 2024 pursuant to HB 1023, eliminating previous graduated brackets."
|
|
293
|
+
),
|
|
294
|
+
"effective_year": 2024,
|
|
295
|
+
"superseded_year": 2025,
|
|
296
|
+
"source_url": "https://dor.georgia.gov/taxes/individual-income-tax",
|
|
297
|
+
"cross_references": ["O.C.G.A. § 48-7-1", "O.C.G.A. § 48-7-27"],
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"id": "ga-ocga-48-7-20-2025",
|
|
301
|
+
"jurisdiction": "GA",
|
|
302
|
+
"corpus": "OCGA",
|
|
303
|
+
"citation": "O.C.G.A. § 48-7-20",
|
|
304
|
+
"section": "48-7-20",
|
|
305
|
+
"title": "Individual Income Tax Rates (2025 Flat Rate: 5.39%)",
|
|
306
|
+
"text_es": (
|
|
307
|
+
"Acelera la reducción de la tasa impositiva individual fija al 5.39% para el "
|
|
308
|
+
"año contributivo 2025 bajo HB 1015."
|
|
309
|
+
),
|
|
310
|
+
"text_en": (
|
|
311
|
+
"Accelerates the reduction of the flat individual income tax rate to 5.39% for "
|
|
312
|
+
"tax year 2025 pursuant to HB 1015."
|
|
313
|
+
),
|
|
314
|
+
"effective_year": 2025,
|
|
315
|
+
"superseded_year": 2026,
|
|
316
|
+
"source_url": "https://dor.georgia.gov/taxes/individual-income-tax",
|
|
317
|
+
"cross_references": ["O.C.G.A. § 48-7-1", "O.C.G.A. § 48-7-27"],
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"id": "ga-ocga-48-7-20-2026",
|
|
321
|
+
"jurisdiction": "GA",
|
|
322
|
+
"corpus": "OCGA",
|
|
323
|
+
"citation": "O.C.G.A. § 48-7-20",
|
|
324
|
+
"section": "48-7-20",
|
|
325
|
+
"title": "Individual Income Tax Rates (2026 Target Flat Rate: 4.99%)",
|
|
326
|
+
"text_es": (
|
|
327
|
+
"Establece la tasa impositiva fija objetivo de 4.99% sobre el ingreso neto "
|
|
328
|
+
"tributable a partir del 1 de enero de 2026 bajo HB 1023."
|
|
329
|
+
),
|
|
330
|
+
"text_en": (
|
|
331
|
+
"Imposes the target flat individual income tax rate of 4.99% for taxable years "
|
|
332
|
+
"beginning on or after January 1, 2026 pursuant to HB 1023."
|
|
333
|
+
),
|
|
334
|
+
"effective_year": 2026,
|
|
335
|
+
"superseded_year": None,
|
|
336
|
+
"source_url": "https://dor.georgia.gov/taxes/individual-income-tax",
|
|
337
|
+
"cross_references": ["O.C.G.A. § 48-7-1", "O.C.G.A. § 48-7-27"],
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"id": "ga-ocga-48-7-27",
|
|
341
|
+
"jurisdiction": "GA",
|
|
342
|
+
"corpus": "OCGA",
|
|
343
|
+
"citation": "O.C.G.A. § 48-7-27",
|
|
344
|
+
"section": "48-7-27",
|
|
345
|
+
"title": "Computation of Georgia Taxable Net Income",
|
|
346
|
+
"text_es": (
|
|
347
|
+
"Dispone el cálculo del ingreso neto gravable a partir del AGI federal, deducción "
|
|
348
|
+
"estándar de $12,000 (solteros) o $24,000 (casados), y exclusión de hasta $65,000 "
|
|
349
|
+
"en ingresos de jubilación para mayores de 65 años."
|
|
350
|
+
),
|
|
351
|
+
"text_en": (
|
|
352
|
+
"Calculates Georgia taxable net income from Federal AGI, allowing standard "
|
|
353
|
+
"deductions of $12,000 (single) or $24,000 (married filing jointly), and a "
|
|
354
|
+
"retirement income exclusion of up to $65,000 for age 65+ ($35,000 for ages 62-64)."
|
|
355
|
+
),
|
|
356
|
+
"effective_year": 2024,
|
|
357
|
+
"source_url": "https://dor.georgia.gov/taxes/individual-income-tax",
|
|
358
|
+
"cross_references": ["O.C.G.A. § 48-7-20", "26 U.S.C. § 62"],
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"id": "ga-ocga-48-7-30",
|
|
362
|
+
"jurisdiction": "GA",
|
|
363
|
+
"corpus": "OCGA",
|
|
364
|
+
"citation": "O.C.G.A. § 48-7-30",
|
|
365
|
+
"section": "48-7-30",
|
|
366
|
+
"title": "Taxation of Nonresidents",
|
|
367
|
+
"text_es": (
|
|
368
|
+
"Grava a personas no residentes sobre su ingreso bruto derivado de fuentes de "
|
|
369
|
+
"Georgia, incluyendo compensación por servicios realizados en Georgia y "
|
|
370
|
+
"actividades comerciales locales."
|
|
371
|
+
),
|
|
372
|
+
"text_en": (
|
|
373
|
+
"Taxes nonresidents on gross income derived from Georgia sources, including "
|
|
374
|
+
"compensation for services performed within Georgia, property located in Georgia, "
|
|
375
|
+
"and business conducted in the state."
|
|
376
|
+
),
|
|
377
|
+
"effective_year": 2024,
|
|
378
|
+
"source_url": "https://dor.georgia.gov/",
|
|
379
|
+
"cross_references": ["O.C.G.A. § 48-7-1", "O.C.G.A. § 48-7-20"],
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"id": "ga-reg-560-7-3-01",
|
|
383
|
+
"jurisdiction": "GA",
|
|
384
|
+
"corpus": "GAREG",
|
|
385
|
+
"citation": "Ga. Comp. R. & Regs. r. 560-7-3-.01",
|
|
386
|
+
"section": "560-7-3-.01",
|
|
387
|
+
"title": "Residence and Domicile",
|
|
388
|
+
"text_es": (
|
|
389
|
+
"Reglamento del Departamento de Ingresos de Georgia sobre domicilio y residencia. "
|
|
390
|
+
"El domicilio en Georgia se presume continuo a menos que el contribuyente demuestre "
|
|
391
|
+
"abandono definitivo y adquisición de nuevo domicilio."
|
|
392
|
+
),
|
|
393
|
+
"text_en": (
|
|
394
|
+
"Georgia Department of Revenue rule governing residence and legal domicile. "
|
|
395
|
+
"Domicile in Georgia is presumed to continue until the taxpayer establishes "
|
|
396
|
+
"abandonment and acquisition of a permanent domicile elsewhere."
|
|
397
|
+
),
|
|
398
|
+
"effective_year": 2023,
|
|
399
|
+
"source_url": "https://rules.sos.ga.gov/gac/560-7-3-.01",
|
|
400
|
+
"cross_references": ["O.C.G.A. § 48-7-1", "26 U.S.C. § 937"],
|
|
401
|
+
},
|
|
402
|
+
# State of California (Revenue and Taxation Code & FTB Regulations)
|
|
403
|
+
{
|
|
404
|
+
"id": "ca-rtc-17014",
|
|
405
|
+
"jurisdiction": "CA",
|
|
406
|
+
"corpus": "RTC",
|
|
407
|
+
"citation": "Cal. Rev. & Tax Code § 17014",
|
|
408
|
+
"section": "17014",
|
|
409
|
+
"title": "Definition of Resident (Non-Temporary Purpose Test)",
|
|
410
|
+
"text_es": (
|
|
411
|
+
"Define residente como todo individuo que permanezca en California para fines "
|
|
412
|
+
"que no sean temporales o transitorios, y todo domiciliado que esté fuera del estado "
|
|
413
|
+
"de forma temporal. Aplica el criterio de conexión más cercana."
|
|
414
|
+
),
|
|
415
|
+
"text_en": (
|
|
416
|
+
"Defines resident as every individual who is in California for other than a temporary "
|
|
417
|
+
"or transitory purpose, and every individual domiciled in California who is outside "
|
|
418
|
+
"the state for a temporary or transitory purpose. Presumption under § 17016 "
|
|
419
|
+
"at 9 months."
|
|
420
|
+
),
|
|
421
|
+
"effective_year": 2024,
|
|
422
|
+
"source_url": "https://www.ftb.ca.gov/",
|
|
423
|
+
"cross_references": [
|
|
424
|
+
"Cal. Rev. & Tax Code § 17041",
|
|
425
|
+
"18 CCR § 17014",
|
|
426
|
+
],
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"id": "ca-rtc-17041",
|
|
430
|
+
"jurisdiction": "CA",
|
|
431
|
+
"corpus": "RTC",
|
|
432
|
+
"citation": "Cal. Rev. & Tax Code § 17041",
|
|
433
|
+
"section": "17041",
|
|
434
|
+
"title": "Individual Income Tax Rates and Brackets",
|
|
435
|
+
"text_es": (
|
|
436
|
+
"Grava el ingreso tributable de California con tasas escalonadas del 1% al 12.3%, "
|
|
437
|
+
"más 1% de recargo para servicios de salud mental sobre ingresos mayores a $1M "
|
|
438
|
+
"(Proposición 63), para una tasa marginal máxima de 13.3%."
|
|
439
|
+
),
|
|
440
|
+
"text_en": (
|
|
441
|
+
"Imposes graduated income tax rates on California taxable income ranging from 1% to "
|
|
442
|
+
"12.3%, plus a 1% Mental Health Services Tax surcharge on taxable income exceeding "
|
|
443
|
+
"$1,000,000, creating a top marginal individual rate of 13.3%."
|
|
444
|
+
),
|
|
445
|
+
"effective_year": 2024,
|
|
446
|
+
"source_url": "https://www.ftb.ca.gov/",
|
|
447
|
+
"cross_references": ["Cal. Rev. & Tax Code § 17014"],
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"id": "ca-rtc-17951",
|
|
451
|
+
"jurisdiction": "CA",
|
|
452
|
+
"corpus": "RTC",
|
|
453
|
+
"citation": "Cal. Rev. & Tax Code § 17951",
|
|
454
|
+
"section": "17951",
|
|
455
|
+
"title": "Gross Income of Nonresidents and Sourcing",
|
|
456
|
+
"text_es": (
|
|
457
|
+
"Para no residentes, el ingreso bruto comprende únicamente ingresos derivados de "
|
|
458
|
+
"fuentes en California, incluyendo negocios, profesiones y servicios personales "
|
|
459
|
+
"realizados dentro del estado."
|
|
460
|
+
),
|
|
461
|
+
"text_en": (
|
|
462
|
+
"In the case of nonresidents, gross income includes only gross income from sources "
|
|
463
|
+
"within California, including income from a business, trade, or profession conducted "
|
|
464
|
+
"in the state, and compensation for personal services performed in California."
|
|
465
|
+
),
|
|
466
|
+
"effective_year": 2024,
|
|
467
|
+
"source_url": "https://www.ftb.ca.gov/",
|
|
468
|
+
"cross_references": [
|
|
469
|
+
"Cal. Rev. & Tax Code § 17014",
|
|
470
|
+
"Cal. Rev. & Tax Code § 17041",
|
|
471
|
+
],
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"id": "ca-ccr-17014",
|
|
475
|
+
"jurisdiction": "CA",
|
|
476
|
+
"corpus": "CACCR",
|
|
477
|
+
"citation": "18 CCR § 17014",
|
|
478
|
+
"section": "17014",
|
|
479
|
+
"title": "FTB Residence and Domicile Guidelines",
|
|
480
|
+
"text_es": (
|
|
481
|
+
"Reglamento de la FTB sobre residencia y domicilio. Aplica el criterio de conexión "
|
|
482
|
+
"más cercana evaluando propiedades inmuebles, familia, cuentas bancarias, licencias "
|
|
483
|
+
"profesionales y afiliaciones comerciales."
|
|
484
|
+
),
|
|
485
|
+
"text_en": (
|
|
486
|
+
"FTB regulation detailing domicile and residence determination. A person may have "
|
|
487
|
+
"multiple residences but only one domicile. Applies the closest connection test "
|
|
488
|
+
"evaluating real property, family, bank accounts, business affiliations, and licenses."
|
|
489
|
+
),
|
|
490
|
+
"effective_year": 2023,
|
|
491
|
+
"source_url": "https://www.ftb.ca.gov/",
|
|
492
|
+
"cross_references": ["Cal. Rev. & Tax Code § 17014"],
|
|
493
|
+
},
|
|
494
|
+
# State of New York (Tax Law & Department of Taxation and Finance Regulations)
|
|
495
|
+
{
|
|
496
|
+
"id": "ny-tax-605",
|
|
497
|
+
"jurisdiction": "NY",
|
|
498
|
+
"corpus": "NYTAX",
|
|
499
|
+
"citation": "NY Tax Law § 605(b)",
|
|
500
|
+
"section": "605",
|
|
501
|
+
"title": "Resident Individual and Domicile Defined",
|
|
502
|
+
"text_es": (
|
|
503
|
+
"Define individuo residente como domiciliado en Nueva York a menos que no mantenga "
|
|
504
|
+
"vivienda permanente en NY y pase menos de 30 días en el estado; o no domiciliado "
|
|
505
|
+
"que mantenga vivienda permanente y pase más de 183 días en NY (Residente Estatutario)."
|
|
506
|
+
),
|
|
507
|
+
"text_en": (
|
|
508
|
+
"Defines resident individual as one domiciled in New York unless they maintain no "
|
|
509
|
+
"permanent abode in NY and spend under 30 days in state; or one not domiciled who "
|
|
510
|
+
"maintains a permanent place of abode and spends over 183 days in NY."
|
|
511
|
+
),
|
|
512
|
+
"effective_year": 2024,
|
|
513
|
+
"source_url": "https://www.tax.ny.gov/",
|
|
514
|
+
"cross_references": ["NY Tax Law § 601", "20 NYCRR § 105.20"],
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"id": "ny-tax-601",
|
|
518
|
+
"jurisdiction": "NY",
|
|
519
|
+
"corpus": "NYTAX",
|
|
520
|
+
"citation": "NY Tax Law § 601",
|
|
521
|
+
"section": "601",
|
|
522
|
+
"title": "Personal Income Tax Rates",
|
|
523
|
+
"text_es": (
|
|
524
|
+
"Grava el ingreso tributable de Nueva York con tasas escalonadas de hasta 10.9% "
|
|
525
|
+
"para personas con altos ingresos, más el impuesto municipal de la Ciudad de "
|
|
526
|
+
"Nueva York (hasta 3.876%) para residentes de NYC."
|
|
527
|
+
),
|
|
528
|
+
"text_en": (
|
|
529
|
+
"Imposes graduated income tax on New York taxable income with top marginal rates up "
|
|
530
|
+
"to 10.9% for high-income earners, plus applicable New York City personal income tax "
|
|
531
|
+
"(up to 3.876%) for NYC residents."
|
|
532
|
+
),
|
|
533
|
+
"effective_year": 2024,
|
|
534
|
+
"source_url": "https://www.tax.ny.gov/",
|
|
535
|
+
"cross_references": ["NY Tax Law § 605"],
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"id": "ny-reg-105-20",
|
|
539
|
+
"jurisdiction": "NY",
|
|
540
|
+
"corpus": "NYCRR",
|
|
541
|
+
"citation": "20 NYCRR § 105.20",
|
|
542
|
+
"section": "105.20",
|
|
543
|
+
"title": "Rules for Determining Domicile (5 Primary Factors)",
|
|
544
|
+
"text_es": (
|
|
545
|
+
"Reglamento de auditoría de domicilio de NY que establece los 5 factores primarios: "
|
|
546
|
+
"Vivienda, Negocio Activo, Tiempo, Objetos de Valor Sentimental ('Near and Dear') "
|
|
547
|
+
"y Familia."
|
|
548
|
+
),
|
|
549
|
+
"text_en": (
|
|
550
|
+
"New York DTF regulation establishing the 5 primary factors for domicile audit "
|
|
551
|
+
"evaluation: Home, Active Business Involvement, Time Allocation, Items of Personal "
|
|
552
|
+
"Significance ('Near and Dear'), and Family."
|
|
553
|
+
),
|
|
554
|
+
"effective_year": 2024,
|
|
555
|
+
"source_url": "https://www.tax.ny.gov/",
|
|
556
|
+
"cross_references": ["NY Tax Law § 605"],
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"id": "ny-reg-132-18",
|
|
560
|
+
"jurisdiction": "NY",
|
|
561
|
+
"corpus": "NYCRR",
|
|
562
|
+
"citation": "20 NYCRR § 132.18",
|
|
563
|
+
"section": "132.18",
|
|
564
|
+
"title": "Convenience of the Employer Rule",
|
|
565
|
+
"text_es": (
|
|
566
|
+
"Dispone que la compensación de empleados no residentes por servicios realizados fuera "
|
|
567
|
+
"del estado se atribuye a Nueva York si el trabajo remoto se realiza por conveniencia "
|
|
568
|
+
"del empleado y no por necesidad del empleador."
|
|
569
|
+
),
|
|
570
|
+
"text_en": (
|
|
571
|
+
"Provides that compensation of a nonresident employee for services performed out of "
|
|
572
|
+
"state is sourced to New York if the services are performed outside NY for the "
|
|
573
|
+
"employee's convenience rather than by necessity of the employer."
|
|
574
|
+
),
|
|
575
|
+
"effective_year": 2024,
|
|
576
|
+
"source_url": "https://www.tax.ny.gov/",
|
|
577
|
+
"cross_references": ["NY Tax Law § 605"],
|
|
578
|
+
},
|
|
579
|
+
# State of Florida (Constitutional & Statutory Absence of Individual Income Tax)
|
|
580
|
+
{
|
|
581
|
+
"id": "fl-const-7-5",
|
|
582
|
+
"jurisdiction": "FL",
|
|
583
|
+
"corpus": "FLCONST",
|
|
584
|
+
"citation": "Fla. Const. Art. VII § 5",
|
|
585
|
+
"section": "Art. VII Sec. 5",
|
|
586
|
+
"title": "Constitutional Prohibition of Personal Income Tax",
|
|
587
|
+
"text_es": (
|
|
588
|
+
"Prohíbe constitucionalmente cualquier impuesto sobre el ingreso de personas "
|
|
589
|
+
"naturales residentes o ciudadanas de Florida, garantizando la ausencia de "
|
|
590
|
+
"impuesto estatal sobre ingresos individuales."
|
|
591
|
+
),
|
|
592
|
+
"text_en": (
|
|
593
|
+
"Prohibits any tax upon the income of natural persons who are residents or citizens "
|
|
594
|
+
"of Florida, guaranteeing the absence of state individual income taxation."
|
|
595
|
+
),
|
|
596
|
+
"effective_year": 1968,
|
|
597
|
+
"source_url": "https://www.flsenate.gov/",
|
|
598
|
+
"cross_references": ["Fla. Stat. § 222.17"],
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
"id": "fl-stat-222-17",
|
|
602
|
+
"jurisdiction": "FL",
|
|
603
|
+
"corpus": "FLSTAT",
|
|
604
|
+
"citation": "Fla. Stat. § 222.17",
|
|
605
|
+
"section": "222.17",
|
|
606
|
+
"title": "Manifesting and Evidencing Domicile in Florida",
|
|
607
|
+
"text_es": (
|
|
608
|
+
"Autoriza a toda persona que haya establecido domicilio en Florida a manifestarlo "
|
|
609
|
+
"formalmente mediante declaración jurada radicada ante el secretario del tribunal de "
|
|
610
|
+
"circuito del condado correspondiente."
|
|
611
|
+
),
|
|
612
|
+
"text_en": (
|
|
613
|
+
"Authorizes any person who has established a domicile in Florida to manifest that "
|
|
614
|
+
"domicile by filing a sworn, notarized statement of domicile with the clerk of the "
|
|
615
|
+
"circuit court in the county of residence."
|
|
616
|
+
),
|
|
617
|
+
"effective_year": 2024,
|
|
618
|
+
"source_url": "https://www.flsenate.gov/",
|
|
619
|
+
"cross_references": ["Fla. Const. Art. VII § 5", "Fla. Stat. § 196.031"],
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"id": "fl-stat-196-031",
|
|
623
|
+
"jurisdiction": "FL",
|
|
624
|
+
"corpus": "FLSTAT",
|
|
625
|
+
"citation": "Fla. Stat. § 196.031",
|
|
626
|
+
"section": "196.031",
|
|
627
|
+
"title": "Exemption of Homesteads",
|
|
628
|
+
"text_es": (
|
|
629
|
+
"Concede hasta $50,000 de exención contributiva sobre la propiedad principal a "
|
|
630
|
+
"residentes permanentes. Solicitar la exención de 'homestead' constituye prueba "
|
|
631
|
+
"prima facie de domicilio en Florida."
|
|
632
|
+
),
|
|
633
|
+
"text_en": (
|
|
634
|
+
"Grants up to $50,000 homestead property tax exemption to persons who maintain "
|
|
635
|
+
"permanent residence. Claiming Florida homestead establishes prima facie proof of "
|
|
636
|
+
"Florida domicile."
|
|
637
|
+
),
|
|
638
|
+
"effective_year": 2024,
|
|
639
|
+
"source_url": "https://www.flsenate.gov/",
|
|
640
|
+
"cross_references": ["Fla. Stat. § 222.17"],
|
|
641
|
+
},
|
|
642
|
+
# State of Texas (Constitutional Prohibition of Individual Income Tax)
|
|
643
|
+
{
|
|
644
|
+
"id": "tx-const-8-24a",
|
|
645
|
+
"jurisdiction": "TX",
|
|
646
|
+
"corpus": "TXCONST",
|
|
647
|
+
"citation": "Tex. Const. art. VIII § 24-a",
|
|
648
|
+
"section": "Art. VIII Sec. 24-a",
|
|
649
|
+
"title": "Constitutional Prohibition of Personal Income Tax",
|
|
650
|
+
"text_es": (
|
|
651
|
+
"Enmienda constitucional aprobada en 2019 que prohíbe a la legislatura de Texas "
|
|
652
|
+
"imponer impuestos sobre el ingreso neto de individuos o su participación en "
|
|
653
|
+
"sociedades y asociaciones no incorporadas."
|
|
654
|
+
),
|
|
655
|
+
"text_en": (
|
|
656
|
+
"Constitutional amendment approved by voters in 2019 prohibiting the Texas legislature "
|
|
657
|
+
"from imposing a tax on the net incomes of individuals, including an individual's "
|
|
658
|
+
"share of partnership and unincorporated association income."
|
|
659
|
+
),
|
|
660
|
+
"effective_year": 2019,
|
|
661
|
+
"source_url": "https://statutes.capitol.texas.gov/",
|
|
662
|
+
"cross_references": ["Tex. Tax Code § 171.001"],
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"id": "tx-tax-171-001",
|
|
666
|
+
"jurisdiction": "TX",
|
|
667
|
+
"corpus": "TXTAX",
|
|
668
|
+
"citation": "Tex. Tax Code § 171.001",
|
|
669
|
+
"section": "171.001",
|
|
670
|
+
"title": "Texas Franchise Tax (Entity Level)",
|
|
671
|
+
"text_es": (
|
|
672
|
+
"Impone el impuesto de franquicia únicamente a entidades comerciales organizadas o con "
|
|
673
|
+
"negocios en Texas sobre su margen bruto, sin gravar a personas naturales."
|
|
674
|
+
),
|
|
675
|
+
"text_en": (
|
|
676
|
+
"Imposes franchise tax on each taxable entity chartered or organized in Texas or doing "
|
|
677
|
+
"business in Texas based on gross margin, maintaining zero taxation on individuals."
|
|
678
|
+
),
|
|
679
|
+
"effective_year": 2024,
|
|
680
|
+
"source_url": "https://statutes.capitol.texas.gov/",
|
|
681
|
+
"cross_references": ["Tex. Const. art. VIII § 24-a"],
|
|
682
|
+
},
|
|
683
|
+
# State of Washington (Capital Gains Excise Tax & No Income Tax)
|
|
684
|
+
{
|
|
685
|
+
"id": "wa-rcw-82-87-040",
|
|
686
|
+
"jurisdiction": "WA",
|
|
687
|
+
"corpus": "RCW",
|
|
688
|
+
"citation": "RCW 82.87.040",
|
|
689
|
+
"section": "82.87.040",
|
|
690
|
+
"title": "Tax Imposed on Long-Term Capital Gains",
|
|
691
|
+
"text_es": (
|
|
692
|
+
"Impuesto especial del 7% sobre ganancias de capital a largo plazo de individuos "
|
|
693
|
+
"que excedan la deducción estándar anual ($250,000 indexada por inflación)."
|
|
694
|
+
),
|
|
695
|
+
"text_en": (
|
|
696
|
+
"7% excise tax on individual annual net long-term capital gains allocated to "
|
|
697
|
+
"Washington in excess of statutory standard deduction ($250,000 indexed for inflation)."
|
|
698
|
+
),
|
|
699
|
+
"effective_year": 2022,
|
|
700
|
+
"source_url": "https://app.leg.wa.gov/RCW/default.aspx?cite=82.87.040",
|
|
701
|
+
"cross_references": ["RCW 82.87.020", "Wash. Const. art. VII § 1"],
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"id": "wa-rcw-82-87-020",
|
|
705
|
+
"jurisdiction": "WA",
|
|
706
|
+
"corpus": "RCW",
|
|
707
|
+
"citation": "RCW 82.87.020",
|
|
708
|
+
"section": "82.87.020",
|
|
709
|
+
"title": "Capital Gains Tax Definitions and Resident Sourcing",
|
|
710
|
+
"text_es": (
|
|
711
|
+
"Define residente de Washington para el impuesto de ganancias de capital como "
|
|
712
|
+
"persona natural domiciliada en el estado al momento de la venta o intercambio."
|
|
713
|
+
),
|
|
714
|
+
"text_en": (
|
|
715
|
+
"Defines resident for Washington capital gains excise tax purposes as an individual "
|
|
716
|
+
"domiciled in Washington at the time the long-term capital asset was sold or exchanged."
|
|
717
|
+
),
|
|
718
|
+
"effective_year": 2022,
|
|
719
|
+
"source_url": "https://app.leg.wa.gov/RCW/default.aspx?cite=82.87.020",
|
|
720
|
+
"cross_references": ["RCW 82.87.040"],
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
"id": "wa-const-7-1",
|
|
724
|
+
"jurisdiction": "WA",
|
|
725
|
+
"corpus": "WACONST",
|
|
726
|
+
"citation": "Wash. Const. art. VII § 1",
|
|
727
|
+
"section": "Art. VII Sec. 1",
|
|
728
|
+
"title": "Constitutional Uniformity and Prohibition of Net Income Tax",
|
|
729
|
+
"text_es": (
|
|
730
|
+
"Disposición constitucional de tributación uniforme que prohíbe impuestos "
|
|
731
|
+
"progresivos sobre el ingreso neto según interpretado en doctrina judicial histórica."
|
|
732
|
+
),
|
|
733
|
+
"text_en": (
|
|
734
|
+
"Constitutional requirement that all taxes be uniform upon the same class of property, "
|
|
735
|
+
"historically interpreted to prohibit graduated net income taxes."
|
|
736
|
+
),
|
|
737
|
+
"effective_year": 1889,
|
|
738
|
+
"source_url": "https://leg.wa.gov/CodeReviser/Pages/WAConstitution.aspx",
|
|
739
|
+
"cross_references": ["RCW 82.87.040"],
|
|
740
|
+
},
|
|
741
|
+
# Commonwealth of Massachusetts (Part B Income Tax & Fair Share Surtax)
|
|
742
|
+
{
|
|
743
|
+
"id": "ma-const-amend-44",
|
|
744
|
+
"jurisdiction": "MA",
|
|
745
|
+
"corpus": "MACONST",
|
|
746
|
+
"citation": "Mass. Const. amend. art. XLIV",
|
|
747
|
+
"section": "Art. XLIV",
|
|
748
|
+
"title": "Fair Share Amendment (4% Millionaires' Surtax)",
|
|
749
|
+
"text_es": (
|
|
750
|
+
"Enmienda constitucional que impone una sobretasa adicional del 4% sobre la porción "
|
|
751
|
+
"del ingreso imponible anual que exceda $1,000,000 (indexado por inflación)."
|
|
752
|
+
),
|
|
753
|
+
"text_en": (
|
|
754
|
+
"Constitutional amendment imposing an additional 4% surtax on the portion of annual "
|
|
755
|
+
"taxable income exceeding $1,000,000, creating a top rate of 9.0%."
|
|
756
|
+
),
|
|
757
|
+
"effective_year": 2023,
|
|
758
|
+
"source_url": "https://malegislature.gov/Laws/Constitution",
|
|
759
|
+
"cross_references": ["M.G.L. c. 62 § 4"],
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"id": "ma-gl-62-4",
|
|
763
|
+
"jurisdiction": "MA",
|
|
764
|
+
"corpus": "MGL",
|
|
765
|
+
"citation": "M.G.L. c. 62 § 4",
|
|
766
|
+
"section": "62-4",
|
|
767
|
+
"title": "Personal Income Tax Rates",
|
|
768
|
+
"text_es": (
|
|
769
|
+
"Tasa básica de impuesto sobre el ingreso personal de Massachusetts del 5.0% sobre "
|
|
770
|
+
"ingreso imponible de Parte B (salarios, negocios y pensiones)."
|
|
771
|
+
),
|
|
772
|
+
"text_en": (
|
|
773
|
+
"Standard 5.0% flat income tax rate on Part B taxable personal income (wages, trade, "
|
|
774
|
+
"business, and interest income)."
|
|
775
|
+
),
|
|
776
|
+
"effective_year": 2024,
|
|
777
|
+
"source_url": "https://malegislature.gov/Laws/GeneralLaws/PartI/TitleIX/Chapter62/Section4",
|
|
778
|
+
"cross_references": ["Mass. Const. amend. art. XLIV", "M.G.L. c. 62 § 1"],
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
"id": "ma-gl-62-1f",
|
|
782
|
+
"jurisdiction": "MA",
|
|
783
|
+
"corpus": "MGL",
|
|
784
|
+
"citation": "M.G.L. c. 62 § 1(f)",
|
|
785
|
+
"section": "62-1(f)",
|
|
786
|
+
"title": "Definition of Resident (Domicile and 183-Day Rule)",
|
|
787
|
+
"text_es": (
|
|
788
|
+
"Define residente como persona domiciliada en Massachusetts o no domiciliada que "
|
|
789
|
+
"mantenga un lugar permanente de morada y pase más de 183 días en el estado."
|
|
790
|
+
),
|
|
791
|
+
"text_en": (
|
|
792
|
+
"Defines resident as any natural person domiciled in Massachusetts, or non-domiciliary "
|
|
793
|
+
"maintaining a permanent place of abode and spending more than 183 days in the state."
|
|
794
|
+
),
|
|
795
|
+
"effective_year": 2024,
|
|
796
|
+
"source_url": "https://malegislature.gov/Laws/GeneralLaws/PartI/TitleIX/Chapter62/Section1",
|
|
797
|
+
"cross_references": ["M.G.L. c. 62 § 4"],
|
|
798
|
+
},
|
|
799
|
+
# State of New Jersey (Gross Income Tax & Convenience of Employer)
|
|
800
|
+
{
|
|
801
|
+
"id": "nj-stat-54a-1-2",
|
|
802
|
+
"jurisdiction": "NJ",
|
|
803
|
+
"corpus": "NJSA",
|
|
804
|
+
"citation": "N.J.S.A. 54A:1-2",
|
|
805
|
+
"section": "54A:1-2",
|
|
806
|
+
"title": "Definition of Resident Individual",
|
|
807
|
+
"text_es": (
|
|
808
|
+
"Define residente de NJ por domicilio (salvo morada permanente exterior con <= 30 "
|
|
809
|
+
"días en NJ) o residente estatutario con morada permanente en NJ y más de 183 días."
|
|
810
|
+
),
|
|
811
|
+
"text_en": (
|
|
812
|
+
"Defines resident individual based on domicile or statutory residency (maintaining a "
|
|
813
|
+
"permanent place of abode in NJ and spending more than 183 days in NJ)."
|
|
814
|
+
),
|
|
815
|
+
"effective_year": 2024,
|
|
816
|
+
"source_url": "https://lis.njleg.state.nj.us/",
|
|
817
|
+
"cross_references": ["N.J.S.A. 54A:2-1", "N.J.A.C. 18:35-5.2"],
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
"id": "nj-stat-54a-2-1",
|
|
821
|
+
"jurisdiction": "NJ",
|
|
822
|
+
"corpus": "NJSA",
|
|
823
|
+
"citation": "N.J.S.A. 54A:2-1",
|
|
824
|
+
"section": "54A:2-1",
|
|
825
|
+
"title": "New Jersey Gross Income Tax Rates",
|
|
826
|
+
"text_es": (
|
|
827
|
+
"Escalas progresivas de impuesto sobre el ingreso bruto que varían entre 1.4% y una "
|
|
828
|
+
"tasa marginal máxima de 10.75% para ingresos mayores a $1,000,000."
|
|
829
|
+
),
|
|
830
|
+
"text_en": (
|
|
831
|
+
"Graduated gross income tax brackets ranging from 1.4% up to top marginal rate of "
|
|
832
|
+
"10.75% on taxable income exceeding $1,000,000."
|
|
833
|
+
),
|
|
834
|
+
"effective_year": 2024,
|
|
835
|
+
"source_url": "https://lis.njleg.state.nj.us/",
|
|
836
|
+
"cross_references": ["N.J.S.A. 54A:1-2"],
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
"id": "nj-admin-18-35-5-2",
|
|
840
|
+
"jurisdiction": "NJ",
|
|
841
|
+
"corpus": "NJAC",
|
|
842
|
+
"citation": "N.J.A.C. 18:35-5.2",
|
|
843
|
+
"section": "18:35-5.2",
|
|
844
|
+
"title": "Convenience of the Employer Rule (Reciprocal Sourcing)",
|
|
845
|
+
"text_es": (
|
|
846
|
+
"Regla recíproca de conveniencia del patrono aprobada en 2023 que grava a no "
|
|
847
|
+
"residentes que teletrabajen si su estado aplica regla similar (ej. Nueva York)."
|
|
848
|
+
),
|
|
849
|
+
"text_en": (
|
|
850
|
+
"Reciprocal convenience of employer sourcing rule enacted in 2023 sourcing "
|
|
851
|
+
"telecommuting compensation of nonresidents to NJ if their resident state "
|
|
852
|
+
"imposes a convenience rule."
|
|
853
|
+
),
|
|
854
|
+
"effective_year": 2023,
|
|
855
|
+
"source_url": "https://www.nj.gov/treasury/taxation/",
|
|
856
|
+
"cross_references": ["N.J.S.A. 54A:5-8"],
|
|
857
|
+
},
|
|
858
|
+
# State of Illinois (Flat Income Tax & Nonresident Sourcing)
|
|
859
|
+
{
|
|
860
|
+
"id": "il-stat-35-ilcs-5-201",
|
|
861
|
+
"jurisdiction": "IL",
|
|
862
|
+
"corpus": "ILCS",
|
|
863
|
+
"citation": "35 ILCS 5/201",
|
|
864
|
+
"section": "5/201",
|
|
865
|
+
"title": "Illinois Individual Income Tax Rate",
|
|
866
|
+
"text_es": (
|
|
867
|
+
"Impuesto estatal no graduado a tasa fija del 4.95% sobre el ingreso neto de "
|
|
868
|
+
"personas naturales, mandatado por la Constitución de Illinois."
|
|
869
|
+
),
|
|
870
|
+
"text_en": (
|
|
871
|
+
"Constitutionally mandated non-graduated flat income tax rate of 4.95% on net income "
|
|
872
|
+
"of individuals, trusts, and estates."
|
|
873
|
+
),
|
|
874
|
+
"effective_year": 2024,
|
|
875
|
+
"source_url": "https://www.ilga.gov/legislation/ilcs/ilcs3.asp?ActID=577",
|
|
876
|
+
"cross_references": ["35 ILCS 5/1501(a)(20)", "35 ILCS 5/301"],
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
"id": "il-stat-35-ilcs-5-1501",
|
|
880
|
+
"jurisdiction": "IL",
|
|
881
|
+
"corpus": "ILCS",
|
|
882
|
+
"citation": "35 ILCS 5/1501(a)(20)",
|
|
883
|
+
"section": "5/1501(a)(20)",
|
|
884
|
+
"title": "Definition of Resident",
|
|
885
|
+
"text_es": (
|
|
886
|
+
"Define residente como persona en Illinois para fines no transitorios o temporales, "
|
|
887
|
+
"o domiciliada en Illinois ausente temporalmente."
|
|
888
|
+
),
|
|
889
|
+
"text_en": (
|
|
890
|
+
"Defines resident as an individual who is in Illinois for other than a temporary "
|
|
891
|
+
"or transitory purpose during the taxable year or who is domiciled in Illinois."
|
|
892
|
+
),
|
|
893
|
+
"effective_year": 2024,
|
|
894
|
+
"source_url": "https://www.ilga.gov/legislation/ilcs/ilcs3.asp?ActID=577",
|
|
895
|
+
"cross_references": ["35 ILCS 5/201"],
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
"id": "il-stat-35-ilcs-5-301",
|
|
899
|
+
"jurisdiction": "IL",
|
|
900
|
+
"corpus": "ILCS",
|
|
901
|
+
"citation": "35 ILCS 5/301",
|
|
902
|
+
"section": "5/301",
|
|
903
|
+
"title": "Compensation and Nonresident Income Sourcing",
|
|
904
|
+
"text_es": (
|
|
905
|
+
"Reglas de asignación de ingresos y salarios de no residentes a Illinois basándose "
|
|
906
|
+
"en servicios efectivamente prestados en el estado."
|
|
907
|
+
),
|
|
908
|
+
"text_en": (
|
|
909
|
+
"Rules for allocating and sourcing compensation and business income of nonresidents "
|
|
910
|
+
"based on physical days of services performed within Illinois."
|
|
911
|
+
),
|
|
912
|
+
"effective_year": 2024,
|
|
913
|
+
"source_url": "https://www.ilga.gov/legislation/ilcs/ilcs3.asp?ActID=577",
|
|
914
|
+
"cross_references": ["35 ILCS 5/201"],
|
|
915
|
+
},
|
|
916
|
+
]
|
|
917
|
+
|
|
918
|
+
INITIAL_PUBLICATIONS: list[dict[str, Any]] = [
|
|
919
|
+
{
|
|
920
|
+
"id": "pr-cc-ri-26-13",
|
|
921
|
+
"category": "carta-circular",
|
|
922
|
+
"doc_number": "CC RI 26-13",
|
|
923
|
+
"doc_date": "2026-06-30",
|
|
924
|
+
"title": "Radicación electrónica obligatoria de planillas de individuos",
|
|
925
|
+
"summary": (
|
|
926
|
+
"Instrucciones y requisitos técnicos para la radicación compulsoria a través de SURI "
|
|
927
|
+
"de las planillas de contribución sobre ingresos de individuos."
|
|
928
|
+
),
|
|
929
|
+
"source_url": "https://hacienda.pr.gov/publicaciones/carta-circular-de-rentas-internas-num-26-13",
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"id": "pr-da-23-04",
|
|
933
|
+
"category": "determinacion-administrativa",
|
|
934
|
+
"doc_number": "DA 23-04",
|
|
935
|
+
"doc_date": "2023-08-15",
|
|
936
|
+
"title": "Tratamiento contributivo de transferencias de propiedad bajo Ley 60",
|
|
937
|
+
"summary": (
|
|
938
|
+
"Determinación administrativa sobre exenciones contributivas en la enajenación de "
|
|
939
|
+
"activos de capital por parte de inversionistas residentes con decreto bajo Ley 60."
|
|
940
|
+
),
|
|
941
|
+
"source_url": "https://hacienda.pr.gov/publicaciones/determinacion-administrativa-num-23-04",
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
"id": "pr-da-21-04",
|
|
945
|
+
"category": "determinacion-administrativa",
|
|
946
|
+
"doc_number": "DA 21-04",
|
|
947
|
+
"doc_date": "2021-04-12",
|
|
948
|
+
"title": "Procedimiento de cumplimiento anual para decretos de individuos",
|
|
949
|
+
"summary": (
|
|
950
|
+
"Directrices para la presentación de informes anuales de cumplimiento y comprobantes "
|
|
951
|
+
"de donaciones benéficas requeridas por el Código de Incentivos de Puerto Rico."
|
|
952
|
+
),
|
|
953
|
+
"source_url": "https://hacienda.pr.gov/publicaciones/determinacion-administrativa-num-21-04",
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"id": "ga-dor-pb-it-2024-01",
|
|
957
|
+
"category": "policy-bulletin",
|
|
958
|
+
"doc_number": "DOR PB IT-2024-01",
|
|
959
|
+
"doc_date": "2024-04-20",
|
|
960
|
+
"title": "Georgia Flat Tax Rate and Standard Deduction Adjustments under HB 1023",
|
|
961
|
+
"summary": (
|
|
962
|
+
"Guidance from the Georgia Department of Revenue explaining the reduction in the "
|
|
963
|
+
"individual income tax rate to 5.49% for tax year 2024 and elimination of "
|
|
964
|
+
"graduated brackets."
|
|
965
|
+
),
|
|
966
|
+
"source_url": "https://dor.georgia.gov/document/document/policy-bulletin-it-2024-01/download",
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
"id": "ga-dor-pb-it-2022-02",
|
|
970
|
+
"category": "policy-bulletin",
|
|
971
|
+
"doc_number": "DOR PB IT-2022-02",
|
|
972
|
+
"doc_date": "2022-05-18",
|
|
973
|
+
"title": "Georgia Pass-Through Entity Tax (PTET) Guidance under HB 149",
|
|
974
|
+
"summary": (
|
|
975
|
+
"Technical guidelines for eligible S corporations and partnerships electing to pay "
|
|
976
|
+
"tax at the entity level to mitigate the federal limitation on individual state and "
|
|
977
|
+
"local tax (SALT) deductions."
|
|
978
|
+
),
|
|
979
|
+
"source_url": "https://dor.georgia.gov/document/document/policy-bulletin-it-2022-02/download",
|
|
980
|
+
},
|
|
981
|
+
]
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
class TaxDatabase:
|
|
985
|
+
"""Thread-safe DuckDB manager for tax statutes and administrative guidance."""
|
|
986
|
+
|
|
987
|
+
def __init__(self, db_path: str = ":memory:") -> None:
|
|
988
|
+
self.db_path = db_path
|
|
989
|
+
self._lock = threading.Lock()
|
|
990
|
+
self._mem_conn: duckdb.DuckDBPyConnection | None = None
|
|
991
|
+
if self.db_path == ":memory:":
|
|
992
|
+
self._mem_conn = duckdb.connect(":memory:")
|
|
993
|
+
self._init_db()
|
|
994
|
+
|
|
995
|
+
def _get_write_conn(self) -> duckdb.DuckDBPyConnection:
|
|
996
|
+
if self._mem_conn is not None:
|
|
997
|
+
return self._mem_conn
|
|
998
|
+
return duckdb.connect(self.db_path)
|
|
999
|
+
|
|
1000
|
+
def _get_read_conn(self) -> duckdb.DuckDBPyConnection:
|
|
1001
|
+
if self._mem_conn is not None:
|
|
1002
|
+
return self._mem_conn
|
|
1003
|
+
return duckdb.connect(self.db_path, read_only=True)
|
|
1004
|
+
|
|
1005
|
+
def _init_db(self) -> None:
|
|
1006
|
+
"""Create tables and seed initial data if required."""
|
|
1007
|
+
with self._lock:
|
|
1008
|
+
conn = self._get_write_conn()
|
|
1009
|
+
try:
|
|
1010
|
+
conn.execute(
|
|
1011
|
+
"""
|
|
1012
|
+
CREATE TABLE IF NOT EXISTS statutes (
|
|
1013
|
+
id VARCHAR PRIMARY KEY,
|
|
1014
|
+
jurisdiction VARCHAR,
|
|
1015
|
+
corpus VARCHAR,
|
|
1016
|
+
citation VARCHAR,
|
|
1017
|
+
section VARCHAR,
|
|
1018
|
+
title VARCHAR,
|
|
1019
|
+
text_es VARCHAR,
|
|
1020
|
+
text_en VARCHAR,
|
|
1021
|
+
effective_year INTEGER,
|
|
1022
|
+
superseded_year INTEGER,
|
|
1023
|
+
source_url VARCHAR,
|
|
1024
|
+
cross_references VARCHAR[]
|
|
1025
|
+
);
|
|
1026
|
+
"""
|
|
1027
|
+
)
|
|
1028
|
+
conn.execute(
|
|
1029
|
+
"""
|
|
1030
|
+
CREATE TABLE IF NOT EXISTS publications (
|
|
1031
|
+
id VARCHAR PRIMARY KEY,
|
|
1032
|
+
category VARCHAR,
|
|
1033
|
+
doc_number VARCHAR UNIQUE,
|
|
1034
|
+
doc_date VARCHAR,
|
|
1035
|
+
title VARCHAR,
|
|
1036
|
+
summary VARCHAR,
|
|
1037
|
+
source_url VARCHAR
|
|
1038
|
+
);
|
|
1039
|
+
"""
|
|
1040
|
+
)
|
|
1041
|
+
|
|
1042
|
+
# Seed initial statutes if table is empty
|
|
1043
|
+
statute_count = conn.execute("SELECT COUNT(*) FROM statutes;").fetchone()
|
|
1044
|
+
if statute_count and statute_count[0] == 0:
|
|
1045
|
+
for s in INITIAL_STATUTES:
|
|
1046
|
+
conn.execute(
|
|
1047
|
+
"""
|
|
1048
|
+
INSERT INTO statutes (
|
|
1049
|
+
id, jurisdiction, corpus, citation, section,
|
|
1050
|
+
title, text_es, text_en, effective_year,
|
|
1051
|
+
superseded_year, source_url, cross_references
|
|
1052
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
|
1053
|
+
""",
|
|
1054
|
+
[
|
|
1055
|
+
s["id"],
|
|
1056
|
+
s["jurisdiction"],
|
|
1057
|
+
s["corpus"],
|
|
1058
|
+
s["citation"],
|
|
1059
|
+
s["section"],
|
|
1060
|
+
s["title"],
|
|
1061
|
+
s["text_es"],
|
|
1062
|
+
s["text_en"],
|
|
1063
|
+
s["effective_year"],
|
|
1064
|
+
s.get("superseded_year"),
|
|
1065
|
+
s["source_url"],
|
|
1066
|
+
s["cross_references"],
|
|
1067
|
+
],
|
|
1068
|
+
)
|
|
1069
|
+
|
|
1070
|
+
# Seed initial publications if table is empty
|
|
1071
|
+
pub_count = conn.execute("SELECT COUNT(*) FROM publications;").fetchone()
|
|
1072
|
+
if pub_count and pub_count[0] == 0:
|
|
1073
|
+
for p in INITIAL_PUBLICATIONS:
|
|
1074
|
+
conn.execute(
|
|
1075
|
+
"""
|
|
1076
|
+
INSERT INTO publications (
|
|
1077
|
+
id, category, doc_number, doc_date, title, summary, source_url
|
|
1078
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?);
|
|
1079
|
+
""",
|
|
1080
|
+
[
|
|
1081
|
+
p["id"],
|
|
1082
|
+
p["category"],
|
|
1083
|
+
p["doc_number"],
|
|
1084
|
+
p["doc_date"],
|
|
1085
|
+
p["title"],
|
|
1086
|
+
p["summary"],
|
|
1087
|
+
p["source_url"],
|
|
1088
|
+
],
|
|
1089
|
+
)
|
|
1090
|
+
finally:
|
|
1091
|
+
if self._mem_conn is None:
|
|
1092
|
+
conn.close()
|
|
1093
|
+
|
|
1094
|
+
def get_connection(self) -> duckdb.DuckDBPyConnection:
|
|
1095
|
+
"""Open a DuckDB connection or in-memory cursor.
|
|
1096
|
+
|
|
1097
|
+
Uses ``read_only=True`` for non-memory files to allow multiple concurrent readers.
|
|
1098
|
+
"""
|
|
1099
|
+
if self._mem_conn is not None:
|
|
1100
|
+
return self._mem_conn.cursor()
|
|
1101
|
+
return duckdb.connect(self.db_path, read_only=True)
|
|
1102
|
+
|
|
1103
|
+
def get_stats(self) -> tuple[int, int]:
|
|
1104
|
+
"""Return the count of indexed (statutes, publications)."""
|
|
1105
|
+
with self._lock:
|
|
1106
|
+
conn = self._get_read_conn()
|
|
1107
|
+
try:
|
|
1108
|
+
s_count = conn.execute("SELECT COUNT(*) FROM statutes;").fetchone()
|
|
1109
|
+
p_count = conn.execute("SELECT COUNT(*) FROM publications;").fetchone()
|
|
1110
|
+
return (
|
|
1111
|
+
s_count[0] if s_count else 0,
|
|
1112
|
+
p_count[0] if p_count else 0,
|
|
1113
|
+
)
|
|
1114
|
+
finally:
|
|
1115
|
+
if self._mem_conn is None:
|
|
1116
|
+
conn.close()
|
|
1117
|
+
|
|
1118
|
+
def lookup_statute(
|
|
1119
|
+
self,
|
|
1120
|
+
citation_or_section: str,
|
|
1121
|
+
jurisdiction: str | None = None,
|
|
1122
|
+
tax_year: int | None = None,
|
|
1123
|
+
lang: str = "en",
|
|
1124
|
+
) -> dict[str, Any] | None:
|
|
1125
|
+
"""Find a statute by exact citation or section code and optional tax year."""
|
|
1126
|
+
query_val = citation_or_section.strip()
|
|
1127
|
+
with self._lock:
|
|
1128
|
+
conn = self._get_read_conn()
|
|
1129
|
+
try:
|
|
1130
|
+
sql = """
|
|
1131
|
+
SELECT id, jurisdiction, corpus, citation, section, title,
|
|
1132
|
+
text_es, text_en, effective_year, superseded_year,
|
|
1133
|
+
source_url, cross_references
|
|
1134
|
+
FROM statutes
|
|
1135
|
+
WHERE (
|
|
1136
|
+
LOWER(citation) = LOWER(?)
|
|
1137
|
+
OR LOWER(section) = LOWER(?)
|
|
1138
|
+
OR LOWER(REPLACE(citation, ' ', '')) = LOWER(REPLACE(?, ' ', ''))
|
|
1139
|
+
)
|
|
1140
|
+
"""
|
|
1141
|
+
params: list[Any] = [query_val, query_val, query_val]
|
|
1142
|
+
if jurisdiction:
|
|
1143
|
+
sql += " AND UPPER(jurisdiction) = UPPER(?)"
|
|
1144
|
+
params.append(jurisdiction.strip())
|
|
1145
|
+
|
|
1146
|
+
if tax_year is not None:
|
|
1147
|
+
sql += (
|
|
1148
|
+
" AND effective_year <= ? "
|
|
1149
|
+
"AND (superseded_year IS NULL OR ? < superseded_year)"
|
|
1150
|
+
)
|
|
1151
|
+
params.extend([tax_year, tax_year])
|
|
1152
|
+
|
|
1153
|
+
sql += " ORDER BY effective_year DESC LIMIT 1;"
|
|
1154
|
+
result = conn.execute(sql, params).fetchone()
|
|
1155
|
+
if not result:
|
|
1156
|
+
return None
|
|
1157
|
+
|
|
1158
|
+
text = result[7] if lang.lower() == "en" else result[6]
|
|
1159
|
+
matched_citation = result[3]
|
|
1160
|
+
|
|
1161
|
+
history_rows = conn.execute(
|
|
1162
|
+
"""
|
|
1163
|
+
SELECT effective_year, superseded_year, id
|
|
1164
|
+
FROM statutes
|
|
1165
|
+
WHERE LOWER(citation) = LOWER(?)
|
|
1166
|
+
ORDER BY effective_year DESC;
|
|
1167
|
+
""",
|
|
1168
|
+
[matched_citation],
|
|
1169
|
+
).fetchall()
|
|
1170
|
+
available_versions = [
|
|
1171
|
+
{
|
|
1172
|
+
"effective_year": h[0],
|
|
1173
|
+
"superseded_year": h[1],
|
|
1174
|
+
"is_current": h[1] is None,
|
|
1175
|
+
"id": h[2],
|
|
1176
|
+
}
|
|
1177
|
+
for h in history_rows
|
|
1178
|
+
]
|
|
1179
|
+
|
|
1180
|
+
return {
|
|
1181
|
+
"id": result[0],
|
|
1182
|
+
"jurisdiction": result[1],
|
|
1183
|
+
"corpus": result[2],
|
|
1184
|
+
"citation": result[3],
|
|
1185
|
+
"section": result[4],
|
|
1186
|
+
"title": result[5],
|
|
1187
|
+
"operative_text": text,
|
|
1188
|
+
"text_es": result[6],
|
|
1189
|
+
"text_en": result[7],
|
|
1190
|
+
"effective_year": result[8],
|
|
1191
|
+
"superseded_year": result[9],
|
|
1192
|
+
"is_current": result[9] is None,
|
|
1193
|
+
"available_versions": available_versions,
|
|
1194
|
+
"source_url": result[10],
|
|
1195
|
+
"cross_references": result[11] or [],
|
|
1196
|
+
"language": lang.lower(),
|
|
1197
|
+
"official_language": "es" if result[1] == "PR" else "en",
|
|
1198
|
+
}
|
|
1199
|
+
finally:
|
|
1200
|
+
if self._mem_conn is None:
|
|
1201
|
+
conn.close()
|
|
1202
|
+
|
|
1203
|
+
def search_statutes(
|
|
1204
|
+
self,
|
|
1205
|
+
query: str,
|
|
1206
|
+
jurisdiction: str | None = None,
|
|
1207
|
+
corpus: str | None = None,
|
|
1208
|
+
tax_year: int | None = None,
|
|
1209
|
+
lang: str = "en",
|
|
1210
|
+
limit: int = 5,
|
|
1211
|
+
) -> list[dict[str, Any]]:
|
|
1212
|
+
"""Search statutes across title, citation, and multilingual operative text."""
|
|
1213
|
+
q = f"%{query.strip().lower()}%"
|
|
1214
|
+
with self._lock:
|
|
1215
|
+
conn = self._get_read_conn()
|
|
1216
|
+
try:
|
|
1217
|
+
sql = """
|
|
1218
|
+
SELECT id, jurisdiction, corpus, citation, section, title,
|
|
1219
|
+
text_es, text_en, effective_year, superseded_year,
|
|
1220
|
+
source_url, cross_references
|
|
1221
|
+
FROM statutes
|
|
1222
|
+
WHERE (
|
|
1223
|
+
LOWER(title) LIKE ?
|
|
1224
|
+
OR LOWER(citation) LIKE ?
|
|
1225
|
+
OR LOWER(text_en) LIKE ?
|
|
1226
|
+
OR LOWER(text_es) LIKE ?
|
|
1227
|
+
)
|
|
1228
|
+
"""
|
|
1229
|
+
params: list[Any] = [q, q, q, q]
|
|
1230
|
+
if jurisdiction:
|
|
1231
|
+
sql += " AND UPPER(jurisdiction) = UPPER(?)"
|
|
1232
|
+
params.append(jurisdiction.strip())
|
|
1233
|
+
if corpus:
|
|
1234
|
+
sql += " AND UPPER(corpus) = UPPER(?)"
|
|
1235
|
+
params.append(corpus.strip())
|
|
1236
|
+
if tax_year is not None:
|
|
1237
|
+
sql += (
|
|
1238
|
+
" AND effective_year <= ? "
|
|
1239
|
+
"AND (superseded_year IS NULL OR ? < superseded_year)"
|
|
1240
|
+
)
|
|
1241
|
+
params.extend([tax_year, tax_year])
|
|
1242
|
+
|
|
1243
|
+
sql += " ORDER BY effective_year DESC, id LIMIT ?;"
|
|
1244
|
+
params.append(limit)
|
|
1245
|
+
|
|
1246
|
+
rows = conn.execute(sql, params).fetchall()
|
|
1247
|
+
output: list[dict[str, Any]] = []
|
|
1248
|
+
for r in rows:
|
|
1249
|
+
text = r[7] if lang.lower() == "en" else r[6]
|
|
1250
|
+
output.append(
|
|
1251
|
+
{
|
|
1252
|
+
"id": r[0],
|
|
1253
|
+
"jurisdiction": r[1],
|
|
1254
|
+
"corpus": r[2],
|
|
1255
|
+
"citation": r[3],
|
|
1256
|
+
"section": r[4],
|
|
1257
|
+
"title": r[5],
|
|
1258
|
+
"operative_text": text,
|
|
1259
|
+
"effective_year": r[8],
|
|
1260
|
+
"superseded_year": r[9],
|
|
1261
|
+
"is_current": r[9] is None,
|
|
1262
|
+
"source_url": r[10],
|
|
1263
|
+
"cross_references": r[11] or [],
|
|
1264
|
+
}
|
|
1265
|
+
)
|
|
1266
|
+
return output
|
|
1267
|
+
finally:
|
|
1268
|
+
if self._mem_conn is None:
|
|
1269
|
+
conn.close()
|
|
1270
|
+
|
|
1271
|
+
def list_publications(
|
|
1272
|
+
self,
|
|
1273
|
+
category: str | None = None,
|
|
1274
|
+
since_date: str | None = None,
|
|
1275
|
+
limit: int = 10,
|
|
1276
|
+
) -> list[dict[str, Any]]:
|
|
1277
|
+
"""List administrative circulars and determinations."""
|
|
1278
|
+
with self._lock:
|
|
1279
|
+
conn = self._get_read_conn()
|
|
1280
|
+
try:
|
|
1281
|
+
sql = """
|
|
1282
|
+
SELECT id, category, doc_number, doc_date, title, summary, source_url
|
|
1283
|
+
FROM publications
|
|
1284
|
+
WHERE 1=1
|
|
1285
|
+
"""
|
|
1286
|
+
params: list[Any] = []
|
|
1287
|
+
if category:
|
|
1288
|
+
sql += " AND LOWER(category) = LOWER(?)"
|
|
1289
|
+
params.append(category.strip())
|
|
1290
|
+
if since_date:
|
|
1291
|
+
sql += " AND doc_date >= ?"
|
|
1292
|
+
params.append(since_date.strip())
|
|
1293
|
+
|
|
1294
|
+
sql += " ORDER BY doc_date DESC LIMIT ?;"
|
|
1295
|
+
params.append(limit)
|
|
1296
|
+
|
|
1297
|
+
rows = conn.execute(sql, params).fetchall()
|
|
1298
|
+
return [
|
|
1299
|
+
{
|
|
1300
|
+
"id": r[0],
|
|
1301
|
+
"category": r[1],
|
|
1302
|
+
"doc_number": r[2],
|
|
1303
|
+
"doc_date": r[3],
|
|
1304
|
+
"title": r[4],
|
|
1305
|
+
"summary": r[5],
|
|
1306
|
+
"source_url": r[6],
|
|
1307
|
+
}
|
|
1308
|
+
for r in rows
|
|
1309
|
+
]
|
|
1310
|
+
finally:
|
|
1311
|
+
if self._mem_conn is None:
|
|
1312
|
+
conn.close()
|
|
1313
|
+
|
|
1314
|
+
def insert_statute(self, statute: dict[str, Any]) -> None:
|
|
1315
|
+
"""Insert a statute into the database."""
|
|
1316
|
+
with self._lock:
|
|
1317
|
+
conn = self._get_write_conn()
|
|
1318
|
+
try:
|
|
1319
|
+
conn.execute(
|
|
1320
|
+
"""
|
|
1321
|
+
INSERT INTO statutes (
|
|
1322
|
+
id, jurisdiction, corpus, citation, section,
|
|
1323
|
+
title, text_es, text_en, effective_year,
|
|
1324
|
+
superseded_year, source_url, cross_references
|
|
1325
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
|
1326
|
+
""",
|
|
1327
|
+
[
|
|
1328
|
+
statute["id"],
|
|
1329
|
+
statute["jurisdiction"],
|
|
1330
|
+
statute["corpus"],
|
|
1331
|
+
statute["citation"],
|
|
1332
|
+
statute["section"],
|
|
1333
|
+
statute["title"],
|
|
1334
|
+
statute.get("text_es", ""),
|
|
1335
|
+
statute.get("text_en", ""),
|
|
1336
|
+
statute.get("effective_year", 2026),
|
|
1337
|
+
statute.get("superseded_year"),
|
|
1338
|
+
statute.get("source_url", ""),
|
|
1339
|
+
statute.get("cross_references", []),
|
|
1340
|
+
],
|
|
1341
|
+
)
|
|
1342
|
+
finally:
|
|
1343
|
+
if self._mem_conn is None:
|
|
1344
|
+
conn.close()
|
|
1345
|
+
|
|
1346
|
+
def upsert_statute(self, statute: dict[str, Any]) -> None:
|
|
1347
|
+
"""Insert or update a statute in the database."""
|
|
1348
|
+
with self._lock:
|
|
1349
|
+
conn = self._get_write_conn()
|
|
1350
|
+
try:
|
|
1351
|
+
conn.execute(
|
|
1352
|
+
"""
|
|
1353
|
+
INSERT INTO statutes (
|
|
1354
|
+
id, jurisdiction, corpus, citation, section,
|
|
1355
|
+
title, text_es, text_en, effective_year,
|
|
1356
|
+
superseded_year, source_url, cross_references
|
|
1357
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1358
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
1359
|
+
jurisdiction = EXCLUDED.jurisdiction,
|
|
1360
|
+
corpus = EXCLUDED.corpus,
|
|
1361
|
+
citation = EXCLUDED.citation,
|
|
1362
|
+
section = EXCLUDED.section,
|
|
1363
|
+
title = EXCLUDED.title,
|
|
1364
|
+
text_es = EXCLUDED.text_es,
|
|
1365
|
+
text_en = EXCLUDED.text_en,
|
|
1366
|
+
effective_year = EXCLUDED.effective_year,
|
|
1367
|
+
superseded_year = EXCLUDED.superseded_year,
|
|
1368
|
+
source_url = EXCLUDED.source_url,
|
|
1369
|
+
cross_references = EXCLUDED.cross_references;
|
|
1370
|
+
""",
|
|
1371
|
+
[
|
|
1372
|
+
statute["id"],
|
|
1373
|
+
statute["jurisdiction"],
|
|
1374
|
+
statute["corpus"],
|
|
1375
|
+
statute["citation"],
|
|
1376
|
+
statute["section"],
|
|
1377
|
+
statute["title"],
|
|
1378
|
+
statute.get("text_es", ""),
|
|
1379
|
+
statute.get("text_en", ""),
|
|
1380
|
+
statute.get("effective_year", 2026),
|
|
1381
|
+
statute.get("superseded_year"),
|
|
1382
|
+
statute.get("source_url", ""),
|
|
1383
|
+
statute.get("cross_references", []),
|
|
1384
|
+
],
|
|
1385
|
+
)
|
|
1386
|
+
finally:
|
|
1387
|
+
if self._mem_conn is None:
|
|
1388
|
+
conn.close()
|
|
1389
|
+
|
|
1390
|
+
def upsert_publication(self, pub: dict[str, Any]) -> None:
|
|
1391
|
+
"""Insert or update an administrative publication in the database."""
|
|
1392
|
+
with self._lock:
|
|
1393
|
+
conn = self._get_write_conn()
|
|
1394
|
+
try:
|
|
1395
|
+
conn.execute(
|
|
1396
|
+
"""
|
|
1397
|
+
INSERT INTO publications (
|
|
1398
|
+
id, category, doc_number, doc_date, title, summary, source_url
|
|
1399
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
1400
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
1401
|
+
category = EXCLUDED.category,
|
|
1402
|
+
doc_number = EXCLUDED.doc_number,
|
|
1403
|
+
doc_date = EXCLUDED.doc_date,
|
|
1404
|
+
title = EXCLUDED.title,
|
|
1405
|
+
summary = EXCLUDED.summary,
|
|
1406
|
+
source_url = EXCLUDED.source_url;
|
|
1407
|
+
""",
|
|
1408
|
+
[
|
|
1409
|
+
pub["id"],
|
|
1410
|
+
pub["category"],
|
|
1411
|
+
pub["doc_number"],
|
|
1412
|
+
pub["doc_date"],
|
|
1413
|
+
pub["title"],
|
|
1414
|
+
pub.get("summary", ""),
|
|
1415
|
+
pub.get("source_url", ""),
|
|
1416
|
+
],
|
|
1417
|
+
)
|
|
1418
|
+
finally:
|
|
1419
|
+
if self._mem_conn is None:
|
|
1420
|
+
conn.close()
|
|
1421
|
+
|
|
1422
|
+
def delete_statute(self, statute_id: str) -> bool:
|
|
1423
|
+
"""Delete a statute by ID."""
|
|
1424
|
+
with self._lock:
|
|
1425
|
+
conn = self._get_write_conn()
|
|
1426
|
+
try:
|
|
1427
|
+
res = conn.execute(
|
|
1428
|
+
"DELETE FROM statutes WHERE id = ? RETURNING id;", [statute_id]
|
|
1429
|
+
).fetchone()
|
|
1430
|
+
return res is not None
|
|
1431
|
+
finally:
|
|
1432
|
+
if self._mem_conn is None:
|
|
1433
|
+
conn.close()
|
|
1434
|
+
|
|
1435
|
+
def delete_publication(self, pub_id: str) -> bool:
|
|
1436
|
+
"""Delete a publication by ID."""
|
|
1437
|
+
with self._lock:
|
|
1438
|
+
conn = self._get_write_conn()
|
|
1439
|
+
try:
|
|
1440
|
+
res = conn.execute(
|
|
1441
|
+
"DELETE FROM publications WHERE id = ? RETURNING id;", [pub_id]
|
|
1442
|
+
).fetchone()
|
|
1443
|
+
return res is not None
|
|
1444
|
+
finally:
|
|
1445
|
+
if self._mem_conn is None:
|
|
1446
|
+
conn.close()
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
# Global default database instance configured via settings.DB_PATH
|
|
1450
|
+
db = TaxDatabase(settings.DB_PATH)
|