Skill for accounting and tax management of self-employed workers in Spain with mathematically accurate calculations.
[!CAUTION] WARNING: This skill is a support tool and does not replace professional advice. The calculations and suggestions generated must be reviewed by a qualified manager or professional. Use of this tool is at the user's sole responsibility. Mafia Claude Skills and its contributors are not responsible for errors in tax returns or penalties arising from its use.
Fundamental principles
- Mandatory mathematical accuracy: ALWAYS use the Python scripts for any calculation. NEVER calculate mentally.
- Legal basis: All operations follow the regulations of the AEAT (Tax Agency).
- Double verification: Every calculation must be verifiable and traceable.
Main workflow
Step 1: Identify the type of operation
What does the user need?
- Calculate quarterly VAT → Run
scripts/calcular_iva.py - Calculate quarterly IRPF → Run
scripts/calcular_irpf.py - Process invoices/expenses → Run
scripts/procesar_facturas.py - Generate accounting ledger → Run
scripts/generar_libro.py - Process Stripe/Substack income → Run
scripts/procesar_stripe.py - Regulatory query → See
references/normativa_fiscal.md
Step 2: Gather data
Request the necessary information from the user according to the operation:
For quarterly VAT:
- Invoices issued (taxable base + VAT charged)
- Deductible invoices received (taxable base + VAT paid)
- Quarter (Q1, Q2, Q3, Q4) and year
For IRPF (Form 130):
- Quarterly income (excluding VAT)
- Quarterly deductible expenses (excluding VAT)
- Withholdings made by clients
- Previous instalment payments of the year
For invoices:
- Invoice number
- Date
- Client/supplier NIF/CIF
- Description
- Taxable base
- Applicable VAT rate
- IRPF withholding (if applicable)
Step 3: Run calculations with scripts
MANDATORY to use scripts for all numerical calculations:
# Calcular IVA trimestral
python3 scripts/calcular_iva.py --iva-repercutido <cantidad> --iva-soportado <cantidad>
# Calcular IRPF modelo 130
python3 scripts/calcular_irpf.py --ingresos <cantidad> --gastos <cantidad> --retenciones <cantidad> --pagos-anteriores <cantidad>
# Procesar lista de facturas desde CSV
python3 scripts/procesar_facturas.py --archivo <ruta.csv> --tipo <emitidas|recibidas>
# Generar libro de ingresos y gastos
python3 scripts/generar_libro.py --trimestre <1-4> --año <YYYY> --facturas-emitidas <ruta> --facturas-recibidas <ruta>
Step 4: Present results
Show the user:
- Full breakdown of the calculation
- Final result with monetary format (€)
- Filing deadline if applicable
- Relevant warnings or considerations
VAT rates in Spain (2024-2025)
| Rate | Percentage | Application |
|---|---|---|
| General | 21% | Most goods and services |
| Reduced | 10% | Food, transport, hospitality |
| Super-reduced | 4% | Bread, milk, fruits, vegetables, books, press |
| Exempt | 0% | Healthcare, education, insurance, financial services |
IRPF withholdings on invoices
| Situation | Withholding |
|---|---|
| Professionals (general) | 15% |
| New self-employed (first 3 years) | 7% |
| Courses, conferences | 15% |
| Leases | 19% |
Quarterly filing deadlines
| Quarter | Period | Filing deadline |
|---|---|---|
| Q1 | January-March | April 1-20 |
| Q2 | April-June | July 1-20 |
| Q3 | July-September | October 1-20 |
| Q4 | October-December | January 1-30 (following year) |
Main deductible expenses
See full details in references/normativa_fiscal.md
100% deductible:
- Self-employed contribution
- Accountancy and advisory services
- Professional liability insurance
- Office supplies
- Hosting, domains, software
- Training related to the activity
- Advertising and marketing
Deductible with limits:
- Utilities (30% if you work from home)
- Vehicle (50% maximum, depending on professional use)
- Per diems and travel (with daily limits)
Important warnings
- Never round: Tax calculations must be exact to the cent.
- Keep supporting documents: Invoices must be kept for at least 4 years.
- Verify NIFs: Always validate that NIFs/CIFs are correct.
- VAT consistency: Input VAT is only deductible if it is linked to the activity.
Stripe/Substack integration
⚠️ IMPORTANT - Difference between Form 303 and Form 130
Form 303 (quarterly VAT):
- Does NOT include the taxable base in the filing
- It only reports:
- Box 03: Accrued VAT amount (21% of EU clients)
- Box 60: Exempt exports (taxable base of non-EU)
Form 130 (quarterly IRPF):
- It DOES include the taxable base (sum of EU + non-EU)
- Then deductible expenses (fees) are subtracted
- Result: net income for the quarter
IMPORTANT - Applied tax rules
1. The price charged INCLUDES VAT (Tax Inclusive)
- The amount you charge the client already has VAT included
- To extract the taxable base:
Base = Total / 1.21 - Do NOT multiply by 0.21 (that would add VAT on top)
- Example: If you charge €60 → Base = €49.59, VAT = €10.41
2. Territoriality is determined by COUNTRY, not by currency
- A client from Chile who pays in EUR → Export (no VAT)
- A customer from Spain who pays in USD → VAT applies
- Priority:
country (billing)>country (ip)
3. Payments without identified country → Conservative criterion (EU)
- If there is no country, it is treated as an EU customer (VAT applies)
- It is fiscally safer even if you pay a little more
4. The fees (Substack + Stripe) are deductible expenses
- They are subtracted in the personal income tax return (Form 130)
- They do NOT affect VAT
Supported formats
Substack CSV (native format):
email,date,currency,amount,Substack fee,Stripe fee,...,country (ip),country (billing)
user@mail.com,02-Oct-25,eur,€60.00,€6.00,€1.15,...,ES,ES
Stripe Dashboard CSV:
id,Amount,Currency,Created (UTC),country (billing),Status,...
pi_xxx,60.00,eur,2025-10-02,ES,succeeded,...
Using the script
# Procesar CSV de Substack o Stripe:
python3 scripts/procesar_stripe.py --archivo pagos.csv --trimestre 4 --año 2025
# El script automáticamente:
# - Detecta formato (Substack o Stripe)
# - Parsea importes con símbolo (€60.00, CA$140.00)
# - Extrae base imponible dividiendo por 1.21 (no multiplicando)
# - Clasifica por PAÍS del cliente (no por moneda)
# - Calcula fees como gastos deducibles
Generated results
For Form 303 (VAT):
- Box 03: VAT payable (21% of the EU base)
- Box 60: Exempt exports (non-EU customers) - IMPORTANT: it is reported as base, not as quota
For Form 130 (personal income tax):
- Taxable base: Sum of EU + non-EU customer bases
- Expenses: Substack + Stripe fees (deductible)
- Net income: Taxable base - Expenses
EU-27 countries (reference)
AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GR, HR, HU, IE, IT, LT, LU, LV, MT, NL, PL, PT, RO, SE, SI, SK
⚠️ United Kingdom (GB/UK) is NOT in the EU since 2021 → Exempt
Practical example
Pago de 60€ desde España (ES):
Base imponible: 60 / 1.21 = 49,59€
IVA incluido: 60 - 49,59 = 10,41€
Pago de 60€ desde Chile (CL):
Base imponible: 60€ (total, sin división)
IVA: 0€ (exportación exenta)
Pago de 85€ sin país identificado:
→ Tratado como UE (conservador)
Base imponible: 85 / 1.21 = 70,25€
IVA incluido: 85 - 70,25 = 14,75€
Regulatory queries
For questions about legislation, consult references/normativa_fiscal.md which contains:
- VAT Law (Law 37/1992)
- Personal Income Tax Law (Law 35/2006)
- Invoicing regulations
- AEAT criteria