taxlation-core 0.1.0__tar.gz

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,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 taxlation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.5
2
+ Name: taxlation-core
3
+ Version: 0.1.0
4
+ Summary: Core for translation of tax regulation into code.
5
+ Project-URL: Homepage, https://github.com/taxlation/taxlation
6
+ Project-URL: Issues, https://github.com/taxlation/taxlation/issues
7
+ Author-email: Taxlation <info@taxlation.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Taxlation Core Package
14
+
15
+ This package is the core package of taxlation.
@@ -0,0 +1,3 @@
1
+ # Taxlation Core Package
2
+
3
+ This package is the core package of taxlation.
@@ -0,0 +1,24 @@
1
+ [project]
2
+ name = "taxlation-core"
3
+ version = "0.1.0"
4
+ authors = [
5
+ { name= "Taxlation", email = "info@taxlation.com"}
6
+ ]
7
+ description = "Core for translation of tax regulation into code."
8
+ readme = "README.md"
9
+ requires-python = ">=3.12"
10
+ dependencies = []
11
+ license = "MIT"
12
+ license-files = ["LICEN[CS]E*"]
13
+
14
+ [project.urls]
15
+ Homepage = "https://github.com/taxlation/taxlation"
16
+ Issues = "https://github.com/taxlation/taxlation/issues"
17
+
18
+
19
+ [build-system]
20
+ requires = ["hatchling"]
21
+ build-backend = "hatchling.build"
22
+
23
+ [tool.hatch.build.targets.wheel]
24
+ packages = ["src/taxlation"]
@@ -0,0 +1,27 @@
1
+ from dataclasses import dataclass
2
+ import json
3
+
4
+ @dataclass
5
+ class Result():
6
+ origin: str
7
+ result: bool
8
+ explanation: str
9
+ trail: tuple["Result", ...] = ()
10
+
11
+ def __bool__(self) -> bool: # zodat je 'm nog in if/and kunt gebruiken
12
+ return self.result
13
+
14
+ def to_dict(self) -> dict:
15
+ d = {
16
+ "origin": self.origin,
17
+ "result": self.result,
18
+ "explanation": self.explanation
19
+ }
20
+
21
+ if self.trail:
22
+ d["trail"] = [s.to_dict() for s in self.trail]
23
+
24
+ return d
25
+
26
+ def __repr__(self) -> str:
27
+ return json.dumps(self.to_dict(), ensure_ascii= False, indent=2)
@@ -0,0 +1,35 @@
1
+ from contextvars import ContextVar
2
+ from datetime import date
3
+
4
+ context_reference_date: ContextVar[date | None]= ContextVar('_reference_date', default= None)
5
+
6
+ class VersionedClass:
7
+ """Selects the right version of an article class"""
8
+
9
+ def __init__(self, name: str, versions: dict[date, type]):
10
+ self._name = name
11
+ self._versions = dict(sorted(versions.items()))
12
+
13
+ def __call__(self,*, reference_date: date | None = None, **kwargs):
14
+ reference_date = reference_date or context_reference_date.get() or date.today()
15
+ apply_dataclass = None
16
+
17
+ for effective_date, dataclass in self._versions.items():
18
+ if effective_date <= reference_date:
19
+ apply_dataclass = dataclass
20
+ else:
21
+ break
22
+
23
+ if apply_dataclass is None:
24
+ raise ValueError(f"No version from {self._name} on {reference_date}")
25
+
26
+ if not callable(apply_dataclass):
27
+ return apply_dataclass
28
+
29
+ token = context_reference_date.set(reference_date)
30
+ try:
31
+ return apply_dataclass(**kwargs)
32
+ finally:
33
+ context_reference_date.reset(token)
34
+
35
+