Automating Spain Immigration (Extranjeria) Deadlines Under RD 1155/2024 & Ley 39/2015 in Python
Spanish immigration law firms (despachos de extranjeria and gestorias) lose 10 to 15 billable hours per week chasing blurry passport photos over WhatsApp and manually checking statutory deadlines in spreadsheets.
Under RD 1155/2024 (Spain's updated Immigration Regulation) and Ley 39/2015 (LPACAP), mixing up calendar days (dias naturales), business days (dias habiles), and date-to-date monthly rules (fecha a fecha) creates avoidable requerimientos or missed renewal windows.
Here is the deterministic Python logic behind Vigente for computing Spain immigration deadlines cleanly before filing on the Mercurio portal.
1. The Four Statutory Rules Every Extranjeria System Must Encode
- TIE Renewal Window (RD 1155/2024): Applications open 60 calendar days before card expiration and remain open 90 calendar days after expiration.
- Mercurio Subsanacion (Arts. 30.2 & 68.1 Ley 39/2015): 10 business days starting the day after notification/DEHu access, excluding Saturdays, Sundays, and applicable national/regional/local holidays.
- Administrative Silence (Art. 30.4 & 30.5 Ley 39/2015): 3 months (or 1 month for specific procedures) computed date-to-date; if the landing day is non-working, it rolls forward to the next business day.
- Judicial Appeal / Contencioso-Administrativo (Arts. 46.1 & 128.2 LJCA): 2 months, with August excluded as non-working in ordinary judicial proceedings (adding 1 month when the window crosses August).
2. Deterministic Python Deadline Engine
from datetime import date, timedelta import calendar # Example Spanish national public holidays (configure regional/local per province) FESTIVOS_ES_2026 = { date(2026, 1, 1), date(2026, 1, 6), date(2026, 4, 3), date(2026, 5, 1), date(2026, 8, 15), date(2026, 10, 12), date(2026, 11, 2), date(2026, 12, 8), date(2026, 12, 25), } def is_business_day(d: date, holidays: set[date]) -> bool: return d.weekday() < 5 and d not in holidays def add_business_days(notification_date: date, days: int, holidays: set[date]) -> date: """Art. 30.2 & 30.3 Ley 39/2015: starts day after notification.""" cur = notification_date counted = 0 while counted < days: cur += timedelta(days=1) if is_business_day(cur, holidays): counted += 1 return cur def tie_renewal_window(expiry: date) -> dict: """RD 1155/2024: 60 calendar days prior, 90 calendar days post-expiry.""" return { "internal_prealert_90d": (expiry - timedelta(days=90)).isoformat(), "legal_open_minus_60d": (expiry - timedelta(days=60)).isoformat(), "tie_expiry": expiry.isoformat(), "post_expiry_limit_plus_90d": (expiry + timedelta(days=90)).isoformat(), } def add_months_art30_4(start: date, months: int, holidays: set[date]) -> date: """Date-to-date monthly deadline rolled to next business day (Art. 30.5).""" m0 = start.month - 1 + months year = start.year + m0 // 12 month = m0 % 12 + 1 day = min(start.day, calendar.monthrange(year, month)[1]) target = date(year, month, day) while not is_business_day(target, holidays): target += timedelta(days=1) return target print("TIE Window:", tie_renewal_window(date(2026, 11, 15))) print("Mercurio 10d limit:", add_business_days(date(2026, 12, 4), 10, FESTIVOS_ES_2026)) print("Silence 3m limit:", add_months_art30_4(date(2026, 10, 10), 3, FESTIVOS_ES_2026)) 3. Eliminating Mercurio Requerimientos Before Upload
Even with clean deadline alerts, the biggest bottleneck in Spanish immigration offices is incomplete client intake:
- Clients send only the bio page of their passport instead of all pages.
- Volante de empadronamiento is older than 90 days.
- Criminal record certificates lack apostille or sworn translation.
- Model 790-052 tax receipt is missing before entering Mercurio.
Replacing ad-hoc WhatsApp threads with a structured mobile upload link per procedure validates legibility and missing pages before the lawyer ever opens Mercurio. Recovering 12 hours/week lets a small team handle 3 to 5 additional cases per month (600 to 1,200 EUR each) without hiring additional staff.
Live Tools & Operational Guides
- Mercurio Pre-Filing Workflow: Automatizar Expedientes para Mercurio (Vigente)
- Zero-Login Deadline Calculator: Calculadora de Plazos RD 1155/2024 y Ley 39/2015
- Firm Capacity & ROI Model: Calculadora ROI Despacho de Extranjeria