Skip to content

Commit 2b4628c

Browse files
madisvainclaude
andcommitted
Change rate_comments values from string to list to capture all TEDB annotations per rate
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fcb7408 commit 2b4628c

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

docs/docs/api/vat-rates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ GET https://api.vatcomply.com/vat_rates
6767
| `parking_rate` | number\|null | Parking rate, if applicable |
6868
| `currency` | string | Country currency code |
6969
| `member_state` | boolean | Always `true` (EU member state) |
70-
| `rate_comments` | object | Map of rate value to TEDB annotation (e.g. geographic limitation). Empty object if no comments. |
70+
| `rate_comments` | object | Map of rate value to list of TEDB annotations (e.g. geographic limitations, applicable categories). Empty object if no comments. |
7171

7272
## Filter by Country
7373

vatcomply/management/commands/load_vat_rates.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ def handle(self, *args, **options):
9393
category = result.get("category")
9494
annotation = comment or (category.get("description", "") if category else "")
9595
if annotation:
96-
info["rate_comments"][str(float(value))] = annotation
96+
key = str(float(value))
97+
if key not in info["rate_comments"]:
98+
info["rate_comments"][key] = []
99+
if annotation not in info["rate_comments"][key]:
100+
info["rate_comments"][key].append(annotation)
97101

98102
# Build country name + currency lookup
99103
country_lookup = {}

vatcomply/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class VATRateSchema(Serializer):
108108
parking_rate: float | None = None
109109
currency: str = ""
110110
member_state: bool = True
111-
rate_comments: dict[str, str] = {}
111+
rate_comments: dict[str, list[str]] = {}
112112

113113

114114
class RatesResponseSchema(Serializer):

vatcomply/tests/test_vat_rates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_vat_rates_austria_rate_comments(client, vat_rates_db):
9090
at = data[0]
9191
assert at["standard_rate"] == 20.0
9292
assert 19.0 in at["reduced_rates"]
93-
assert at["rate_comments"]["19.0"] == "Jungholz, Mittelberg"
93+
assert at["rate_comments"]["19.0"] == ["Jungholz, Mittelberg"]
9494
assert at["parking_rate"] == 13.0
9595

9696

0 commit comments

Comments
 (0)