File size: 23,252 Bytes
3b01fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
 
 
 
 
 
 
 
 
 
 
3b01fc7
 
 
 
 
 
7fd88a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b01fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
 
 
 
3b01fc7
 
7fd88a5
 
 
3b01fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
 
3b01fc7
 
 
 
 
 
 
 
 
7fd88a5
3b01fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
 
 
 
3b01fc7
 
7fd88a5
 
3b01fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
3b01fc7
 
 
 
 
 
 
 
 
 
 
 
7fd88a5
 
3b01fc7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#!/usr/bin/env python3
"""
validate_stamp_duty.py — Multi-jurisdiction property transfer tax estimator.

Usage:
    python scripts/validate_stamp_duty.py --country spain --value 2500000
    python scripts/validate_stamp_duty.py --country uk --value 1500000 --asset-type residential --additional-dwelling
    python scripts/validate_stamp_duty.py --country usa --value 3000000 --region new_york
    python scripts/validate_stamp_duty.py --country india --value 15000000 --region maharashtra
    python scripts/validate_stamp_duty.py --country spain --value 500000 --is-new --region madrid
    python scripts/validate_stamp_duty.py --country germany --value 2000000 --region berlin

IMPORTANT:
    Tax rates change frequently. This script provides ESTIMATES for analysis purposes only.
    Always verify current rates with qualified local tax counsel before any transaction.
    This output does not constitute tax advice.

RATE DATING (v16):
    Every result carries ``rates_effective`` (the statutory effective date of the
    band table used) and ``verification_status``. The playbook's own output
    standard requires an effective date on every rate cited; v15 emitted none
    and still used the UK SDLT bands that expired on 31 March 2025 and the +3%
    additional-dwelling surcharge that became +5% on 31 October 2024, plus
    pre-2023 Grunderwerbsteuer rates for Sachsen and Hamburg and the pre-2024
    rate for Thüringen. The v16 tables were updated from statute as known at
    2026-09 and were NOT live-verified against gov.uk / Landesfinanzministerien
    in the v16 build session — confirm before professional use.
"""

import argparse
import json
import sys

# Statutory effective dates of the band/rate tables below. Update together with
# the numbers; tests assert the fields are present in every result.
RATES_EFFECTIVE = {
    "spain":   "2025-01-01 (ITP/AJD by CCAA — Cataluña introduced progressive ITP bands 10–13% "
               "above EUR 600k from 2025-06-27; this table still applies the flat 10%: VERIFY)",
    "uk":      "2025-04-01 (SDLT residential bands; +5% additional dwelling from 2024-10-31; +2% NR)",
    "usa":     "2024 (state/county transfer taxes; NYC mansion tax brackets 2019)",
    "india":   "2024 (state stamp duty schedules)",
    "uae":     "2024 (DLD 4%; Abu Dhabi 2%)",
    "germany": "2024-01-01 (GrESt: Sachsen and Hamburg 5.5% since 2023-01-01; Thüringen 5.0% since 2024-01-01)",
    "france":  "2024 (droits de mutation ~5.8%; several départements raised to ~6.3% from 2025-04-01: VERIFY)",
}
VERIFICATION_STATUS = ("NOT LIVE-VERIFIED in the v16 build (no web access). Rates transcribed "
                       "from statute as known at 2026-09. Confirm with the official source "
                       "before relying on any figure.")

# ─── SPAIN ────────────────────────────────────────────────────────────────────

SPAIN_ITP_BY_CCAA = {
    "andalucia":          {"general": 0.07,  "note": "Reduced 3.5% for buyers under 35 with conditions"},
    "aragon":             {"general": 0.08,  "note": ""},
    "asturias":           {"general": 0.08,  "note": ""},
    "baleares":           {"general": 0.11,  "note": "Up to 12% for properties > EUR 2M"},
    "canarias":           {"general": 0.065, "note": "IGIC (not IVA) applies in Canarias for new builds"},
    "cantabria":          {"general": 0.10,  "note": ""},
    "castilla_la_mancha": {"general": 0.09,  "note": ""},
    "castilla_leon":      {"general": 0.08,  "note": ""},
    "cataluna":           {"general": 0.10,  "note": "Reduced 5% for buyers under 33 with conditions"},
    "extremadura":        {"general": 0.08,  "note": "Reduced 7% for buyers under 35"},
    "galicia":            {"general": 0.10,  "note": ""},
    "la_rioja":           {"general": 0.07,  "note": ""},
    "madrid":             {"general": 0.06,  "note": "Lowest ITP in mainland Spain"},
    "murcia":             {"general": 0.08,  "note": ""},
    "navarra":            {"general": 0.06,  "note": "Regimen foral — own tax legislation"},
    "pais_vasco":         {"general": 0.04,  "note": "Regimen foral — Diputaciones Forales"},
    "valencia":           {"general": 0.10,  "note": ""},
    "default":            {"general": 0.07,  "note": "National reference — verify CCAA"},
}

SPAIN_AJD_BY_CCAA = {
    "madrid": 0.0075, "cataluna": 0.015, "andalucia": 0.012,
    "valencia": 0.02, "baleares": 0.012, "galicia": 0.015,
    "pais_vasco": 0.005, "navarra": 0.005, "default": 0.015,
}


def calc_spain(price, buyer_type, asset_type, is_new, region):
    rk = region.lower().replace(" ", "_").replace("-", "_")
    itp_data = SPAIN_ITP_BY_CCAA.get(rk, SPAIN_ITP_BY_CCAA["default"])
    itp_rate = itp_data["general"]
    ajd_rate = SPAIN_AJD_BY_CCAA.get(rk, SPAIN_AJD_BY_CCAA["default"])
    nr_retention = price * 0.03 if buyer_type == "non_resident" else 0

    if is_new:
        iva_rate = 0.10 if asset_type == "residential" else 0.21
        iva = price * iva_rate
        ajd = price * ajd_rate
        total = iva + ajd
        return {
            "country": "Spain", "transaction_type": "New build (primera transmision)",
            "region_ccaa": region, "price_eur": price,
            "taxes": {
                "IVA": {"amount": round(iva), "rate": f"{iva_rate*100:.0f}%",
                        "note": "10% residential / 21% commercial new build"},
                "AJD": {"amount": round(ajd), "rate": f"{ajd_rate*100:.2f}%"},
                "ITP": {"amount": 0, "note": "IVA and ITP are mutually exclusive — ITP does NOT apply to new builds"},
            },
            "total_buyer": round(total), "total_buyer_pct": f"{total/price*100:.2f}%",
            "non_resident_retention_3pct": round(nr_retention),
            "non_resident_note": (
                "MANDATORY if seller is non-resident: buyer withholds 3% of price -> "
                "Modelo 211 within 30 days of deed (IRNR Art.25.2). Buyer jointly liable."
                if buyer_type == "non_resident" else "Seller is resident — no retention required"
            ),
            "seller_obligations": [
                "Plusvalia municipal (IIVTNU): calculate by both real and objective method (STC TC 26/2021). Pay to municipality within 30 days.",
                "IRPF/IRNR: declare capital gain in annual return or Modelo 210 (NR).",
            ],
            "additional_costs": ["Notary fees: ~EUR 600-2,500", "Land Registry: ~EUR 400-2,000"],
            "disclaimer": "ESTIMATE ONLY. Verify with gestor/abogado before transaction.",
        }
    else:
        itp = price * itp_rate
        ajd = price * ajd_rate
        total = itp + ajd
        return {
            "country": "Spain", "transaction_type": "Resale (segunda o posterior transmision)",
            "region_ccaa": region, "price_eur": price,
            "taxes": {
                "ITP": {"amount": round(itp), "rate": f"{itp_rate*100:.0f}%",
                        "note": itp_data["note"] or f"Standard ITP for {region}"},
                "AJD": {"amount": round(ajd), "rate": f"{ajd_rate*100:.2f}%"},
                "IVA": {"amount": 0, "note": "IVA does NOT apply to resales"},
            },
            "total_buyer": round(total), "total_buyer_pct": f"{total/price*100:.2f}%",
            "non_resident_retention_3pct": round(nr_retention),
            "non_resident_note": (
                "MANDATORY: buyer withholds 3% of price -> Modelo 211 within 30 days. "
                "Buyer jointly liable if not withheld (IRNR Art.25.2 LIRNR)."
                if buyer_type == "non_resident" else "Seller is resident — no retention required"
            ),
            "seller_obligations": [
                "Plusvalia municipal (IIVTNU): calculate by BOTH methods (STC TC 26/2021). Use most favourable.",
                "IRPF capital gains: declare in annual return. Exemptions: over-65s, reinvestment in main residence.",
            ],
            "additional_costs": ["Notary fees: ~EUR 600-2,500", "Land Registry: ~EUR 400-2,000"],
            "disclaimer": "ESTIMATE ONLY. ITP rates change annually by CCAA. Verify with gestor/abogado.",
        }


# ─── UK ───────────────────────────────────────────────────────────────────────

UK_ADDITIONAL_DWELLING_SURCHARGE = 0.05   # 3% until 2024-10-30; 5% from 2024-10-31
UK_NON_RESIDENT_SURCHARGE = 0.02


def calc_uk(price, buyer_type, asset_type, additional_dwelling):
    if asset_type == "residential":
        # Bands from 2025-04-01 (nil-rate band reverted from GBP 250k to 125k).
        slabs = [(125_000, 0.00), (250_000, 0.02), (925_000, 0.05),
                 (1_500_000, 0.10), (float("inf"), 0.12)]
    else:
        slabs = [(150_000, 0.00), (250_000, 0.02), (float("inf"), 0.05)]

    sdlt_base = 0.0
    prev = 0.0
    breakdown = []
    for limit, rate in slabs:
        band = max(0.0, min(price, limit) - prev)
        tax  = band * rate
        sdlt_base += tax
        breakdown.append({"band_up_to": f"{limit:,.0f}" if limit < 1e18 else f"above {prev:,.0f}",
                           "rate": f"{rate*100:.0f}%", "band_amount": round(band), "tax": round(tax)})
        prev = limit
        if price <= limit:
            break

    add_s = price * UK_ADDITIONAL_DWELLING_SURCHARGE if additional_dwelling else 0.0
    nr_s  = price * UK_NON_RESIDENT_SURCHARGE if buyer_type == "non_resident" else 0.0
    total = sdlt_base + add_s + nr_s

    return {
        "country": "United Kingdom (England & Northern Ireland)",
        "note": "Scotland uses LBTT; Wales uses LTT — different rates apply.",
        "asset_type": asset_type, "buyer_type": buyer_type, "price_gbp": price,
        "taxes": {
            "SDLT_base": round(sdlt_base),
            "slab_breakdown": breakdown,
            "additional_dwelling_surcharge_5pct": round(add_s),
            "non_resident_surcharge_2pct": round(nr_s),
        },
        "total_SDLT": round(total),
        "effective_rate": f"{total/price*100:.2f}%",
        "critical_deadline": "File SDLT1 return AND pay within 14 days of completion (SDLT Act 2003 s.76). Automatic GBP 100 penalty from day 1.",
        "cgt_note": "Seller: CGT on residential property must be reported and paid within 60 days of completion via HMRC UK Property account.",
        "disclaimer": "ESTIMATE ONLY. SDLT rules change. Verify with UK solicitor / HMRC before transaction.",
    }


# ─── USA ──────────────────────────────────────────────────────────────────────

USA_STATE_RATES = {
    "california":     {"rate": 0.0011, "note": "County rate ~$1.10/$1,000; cities may add separately"},
    "colorado":       {"rate": 0.001,  "note": "Documentary fee"},
    "connecticut":    {"rate": 0.0075, "note": "Conveyance tax"},
    "delaware":       {"rate": 0.03,   "note": "3% split buyer/seller; first-time buyer relief available"},
    "florida":        {"rate": 0.007,  "note": "Documentary stamps on deed"},
    "georgia":        {"rate": 0.001,  "note": "Real estate transfer tax"},
    "hawaii":         {"rate": 0.015,  "note": "Conveyance tax; progressive by price"},
    "illinois":       {"rate": 0.001,  "note": "State rate; Cook County and Chicago add more"},
    "maryland":       {"rate": 0.005,  "note": "State rate; county adds separately"},
    "massachusetts":  {"rate": 0.00456,"note": "$4.56 per $1,000 of price"},
    "michigan":       {"rate": 0.0075, "note": "State + county combined ~0.86%"},
    "new_jersey":     {"rate": 0.01,   "note": "Realty Transfer Fee; mansion tax 1% over USD 1M"},
    "new_york":       {"rate": 0.004,  "note": "State only; NYC adds 1-2.075%; mansion tax if >= USD 1M"},
    "pennsylvania":   {"rate": 0.01,   "note": "State 1%; local adds (Philadelphia total ~3.278%)"},
    "texas":          {"rate": 0.0,    "note": "No state real estate transfer tax"},
    "virginia":       {"rate": 0.0025, "note": "Grantor tax; buyer pays recordation separately"},
    "washington":     {"rate": 0.013,  "note": "REET; progressive 1.1-3% by price"},
    "generic":        {"rate": 0.01,   "note": "Generic estimate — verify specific state and county"},
}


def calc_usa(price, state):
    sk = state.lower().replace(" ", "_")
    sd = USA_STATE_RATES.get(sk, USA_STATE_RATES["generic"])
    tax = price * sd["rate"]
    mansion = 0.0
    mansion_note = "N/A"
    if sk == "new_york" and price >= 1_000_000:
        brackets = [(2e6,0.01),(3e6,0.0125),(5e6,0.014),(10e6,0.015),(15e6,0.02),(20e6,0.025),(25e6,0.029),(1e18,0.039)]
        for lim, rate in brackets:
            if price < lim:
                mansion = price * rate; break
        mansion_note = f"NYC Mansion Tax at applicable rate on USD {price:,.0f}"
    return {
        "country": "USA", "state": state, "price_usd": price,
        "taxes": {
            "state_transfer_tax": {"amount": round(tax), "rate": f"{sd['rate']*100:.3f}%", "note": sd["note"]},
            "mansion_tax": round(mansion) if mansion > 0 else "N/A",
            "mansion_tax_note": mansion_note,
        },
        "total_transfer_taxes": round(tax + mansion),
        "firpta_if_foreign_seller": (
            "Buyer withholds 15% of AMOUNT REALIZED from foreign seller. "
            "Exception: price <= USD 300K + buyer residence use = 0%. "
            "300K-1M + buyer residence use = 10%. File Form 8288 within 20 days."
        ),
        "exchange_1031_note": "QI must be engaged BEFORE closing. 45-day ID + 180-day closing windows are absolute.",
        "disclaimer": "ESTIMATE ONLY. Rates vary by state, county, city. Verify with local real estate attorney.",
    }


# ─── INDIA ────────────────────────────────────────────────────────────────────

INDIA_RATES = {
    "maharashtra":   {"rate": 0.07,  "reg": 0.01, "note": "+1% metro cess in Mumbai; women get 1% rebate"},
    "delhi":         {"rate": 0.06,  "reg": 0.01, "note": "Women buyers: 4%"},
    "karnataka":     {"rate": 0.056, "reg": 0.01, "note": ""},
    "tamil_nadu":    {"rate": 0.07,  "reg": 0.01, "note": ""},
    "telangana":     {"rate": 0.075, "reg": 0.005,"note": ""},
    "gujarat":       {"rate": 0.047, "reg": 0.01, "note": ""},
    "rajasthan":     {"rate": 0.06,  "reg": 0.01, "note": ""},
    "uttar_pradesh": {"rate": 0.07,  "reg": 0.01, "note": ""},
    "west_bengal":   {"rate": 0.07,  "reg": 0.01, "note": ""},
    "generic":       {"rate": 0.06,  "reg": 0.01, "note": "Generic — verify specific state"},
}


def calc_india(price, state):
    sk = state.lower().replace(" ", "_")
    sd = INDIA_RATES.get(sk, INDIA_RATES["generic"])
    stamp = price * sd["rate"]
    reg   = price * sd["reg"]
    return {
        "country": "India", "state": state, "price_inr": price,
        "taxes": {
            "stamp_duty": {"amount": round(stamp), "rate": f"{sd['rate']*100:.1f}%", "note": sd["note"]},
            "registration_fee": {"amount": round(reg), "rate": f"{sd['reg']*100:.1f}%"},
        },
        "total_buyer": round(stamp + reg),
        "total_pct": f"{(stamp+reg)/price*100:.2f}%",
        "circle_rate_warning": (
            "CRITICAL: If circle rate > transaction price, stamp duty is on circle rate. "
            "Also triggers Sec.50C (seller deemed consideration) and Sec.56(2)(x) (buyer deemed income) if diff > INR 50,000."
        ),
        "tds_194ia": "If price > INR 50 lakhs: buyer deducts 1% TDS via Form 26QB within 30 days. Buyer is assessee-in-default if not done.",
        "disclaimer": "ESTIMATE ONLY. Rates change annually per state. Verify with local advocate before registration.",
    }


# ─── UAE ──────────────────────────────────────────────────────────────────────

def calc_uae(price, emirate):
    rates = {
        "dubai":         {"dld": 0.04, "note": "DLD 4%; typically split 2% buyer + 2% seller"},
        "abu_dhabi":     {"dld": 0.02, "note": "Abu Dhabi registration fee 2%"},
        "sharjah":       {"dld": 0.04, "note": ""},
        "ras_al_khaimah":{"dld": 0.02, "note": ""},
        "generic":       {"dld": 0.04, "note": "Generic UAE — verify specific emirate"},
    }
    ek = emirate.lower().replace(" ", "_")
    rd = rates.get(ek, rates["generic"])
    dld = price * rd["dld"]
    return {
        "country": "UAE", "emirate": emirate, "price_aed": price,
        "taxes": {
            "DLD_transfer_fee": {"amount": round(dld), "rate": f"{rd['dld']*100:.0f}%", "note": rd["note"]},
            "trustee_office_fee": "AED 4,000 (properties > AED 500K)",
            "agency_fee_typical": "2% of price (negotiable)",
        },
        "total_government_fees_approx": round(dld + 4000),
        "no_cgt": "UAE imposes no capital gains tax on property disposals for individuals.",
        "freehold_note": "Foreign buyers restricted to designated freehold zones only.",
        "vat_note": "Commercial sale/lease: 5% VAT. Residential: exempt.",
        "disclaimer": "ESTIMATE ONLY. Verify current DLD fees with DLD or registered trustee.",
    }


# ─── GERMANY ──────────────────────────────────────────────────────────────────

GERMANY_GRESTS = {
    "bavaria": 0.035, "bayern": 0.035,
    "sachsen": 0.055,            # 5.5% since 2023-01-01 (v15 still had 3.5%)
    "hamburg": 0.055,            # 5.5% since 2023-01-01 (v15 still had 4.5%)
    "bremen": 0.05,
    "berlin": 0.06, "hessen": 0.06, "mecklenburg_vorpommern": 0.06,
    "sachsen_anhalt": 0.05, "schleswig_holstein": 0.065, "brandenburg": 0.065,
    "thuringen": 0.05,           # 5.0% since 2024-01-01 (v15 still had 6.5%)
    "nordrhein_westfalen": 0.065, "saarland": 0.065,
    "rheinland_pfalz": 0.05, "niedersachsen": 0.05, "baden_wurttemberg": 0.05,
    "default": 0.05,
}


def calc_germany(price, bundesland):
    lk = bundesland.lower().replace(" ", "_")
    rate = GERMANY_GRESTS.get(lk, GERMANY_GRESTS["default"])
    grests = price * rate
    notary = price * 0.015
    return {
        "country": "Germany", "bundesland": bundesland, "price_eur": price,
        "taxes": {
            "Grunderwerbsteuer_GrESt": {"amount": round(grests), "rate": f"{rate*100:.1f}%"},
            "notary_and_land_registry_approx": {"amount": round(notary), "rate": "~1.5%"},
        },
        "total_buyer_approx": round(grests + notary),
        "share_deal_warning": "GrESt triggers if >=90% of shares in property-owning company acquired (post-2021). Get specialist advice.",
        "speculation_tax": "Individuals: capital gain taxed as ordinary income if sold within 10 years of purchase. Exempt after 10 years.",
        "disclaimer": "ESTIMATE ONLY. GrESt varies by Bundesland. Verify with German Notar.",
    }


# ─── FRANCE ───────────────────────────────────────────────────────────────────

def calc_france(price, is_new):
    if is_new:
        tva = price * 0.20
        droits = price * 0.00715
        notary = price * 0.008
        return {
            "country": "France", "transaction_type": "New build (VEFA)", "price_eur": price,
            "taxes": {
                "TVA": {"amount": round(tva), "rate": "20%", "note": "10% possible for some affordable housing"},
                "Droits_de_mutation_reduced": {"amount": round(droits), "rate": "0.715%"},
                "Notary_fees_approx": {"amount": round(notary), "rate": "~0.8%"},
            },
            "total_buyer_approx": round(tva + droits + notary),
            "disclaimer": "ESTIMATE ONLY. Verify with French notaire.",
        }
    else:
        droits = price * 0.057
        notary = price * 0.008
        return {
            "country": "France", "transaction_type": "Resale (revente)", "price_eur": price,
            "taxes": {
                "Droits_de_mutation": {"amount": round(droits), "rate": "~5.7-5.8%",
                                       "note": "Departmental 4.5% + communal 1.2% + national 0.1%"},
                "Notary_fees_approx": {"amount": round(notary), "rate": "~0.8%"},
            },
            "total_buyer_approx": round(droits + notary),
            "plus_value_note": (
                "Seller plus-value: 36.2% total (19% income + 17.2% social). "
                "Abatements after 5 years. Full exemption: 22 years (income) / 30 years (social). "
                "Principal residence always exempt."
            ),
            "disclaimer": "ESTIMATE ONLY. Verify with French notaire.",
        }


# ─── CLI ──────────────────────────────────────────────────────────────────────

def main():
    parser = argparse.ArgumentParser(description="Multi-jurisdiction property transfer tax estimator.")
    parser.add_argument("--country", required=True,
                        choices=["spain", "uk", "usa", "india", "uae", "germany", "france"])
    parser.add_argument("--value", type=float, required=True, help="Transaction price in local currency")
    parser.add_argument("--buyer-type", default="resident", choices=["resident", "non_resident"])
    parser.add_argument("--asset-type", default="residential", choices=["residential", "commercial", "industrial"])
    parser.add_argument("--region", default="default", help="CCAA / state / Bundesland / emirate")
    parser.add_argument("--is-new", action="store_true", help="New build (Spain, France)")
    parser.add_argument("--additional-dwelling", action="store_true", help="Additional dwelling surcharge (UK +3%%)")
    args = parser.parse_args()

    dispatch = {
        "spain":   lambda: calc_spain(args.value, args.buyer_type, args.asset_type, args.is_new, args.region),
        "uk":      lambda: calc_uk(args.value, args.buyer_type, args.asset_type, args.additional_dwelling),
        "usa":     lambda: calc_usa(args.value, args.region),
        "india":   lambda: calc_india(args.value, args.region),
        "uae":     lambda: calc_uae(args.value, args.region if args.region != "default" else "dubai"),
        "germany": lambda: calc_germany(args.value, args.region),
        "france":  lambda: calc_france(args.value, args.is_new),
    }
    result = dispatch[args.country]()
    result["rates_effective"] = RATES_EFFECTIVE[args.country]
    result["verification_status"] = VERIFICATION_STATUS
    print(json.dumps(result, indent=2, ensure_ascii=False))


if __name__ == "__main__":
    main()