Ir al contenido

Marcar Deducibilidad

Cálculo automático de deducibilidad del IVA según la normativa española LIVA (Ley 37/1992, Art. 95-97).

src/features/expenses/components/DeductibilityIndicator.tsx
<DeductibilityIndicator
isDeductible={deductibilityResult.isDeductible}
deductiblePercentage={deductibilityResult.deductiblePercentage}
deductibleTaxAmount={deductibilityResult.deductibleTaxAmount}
taxAmount={taxAmount}
explanation={deductibilityResult.explanation}
isInvestment={isInvestment}
showAmount={true}
size="md"
/>
interface ExpenseDeductibility {
is_deductible: boolean; // ¿Es deducible?
deductible_percentage: number; // % deducible (0-100)
deductible_tax_amount: number; // IVA deducible en €
non_deductible_reason?: NonDeductibleReason; // Razón si no es deducible
is_investment: boolean; // ¿Es bien de inversión?
}
type NonDeductibleReason =
| 'simplified_invoice' // Ticket sin NIF receptor (Art. 97 LIVA)
| 'missing_vendor_tax_id' // Falta NIF del proveedor
| 'personal_use' // Uso personal o no afecto
| 'prorrata' // Empresa con prorrata
| 'exempt_activity' // Actividad exenta de IVA
| 'partial_category'; // Categoría con deducción parcial
src/features/expenses/utils/deductibility.ts
import { calculateDeductibility } from '@/features/expenses/utils/deductibility';
const result = calculateDeductibility({
documentType: 'invoice',
vendorTaxId: 'B12345678',
taxAmount: 42, // IVA soportado
totalAmount: 242, // Total con IVA
category: 'Software y tecnología',
isInvestment: false,
}, prorrata = 100);
// Resultado:
// {
// isDeductible: true,
// deductiblePercentage: 100,
// deductibleTaxAmount: 42,
// explanation: 'IVA 100% deducible. Cumple todos los requisitos fiscales.'
// }
if (documentType === 'simplified_invoice' || documentType === 'receipt') {
return {
isDeductible: false,
deductiblePercentage: 0,
nonDeductibleReason: 'simplified_invoice',
explanation: 'El IVA de tickets y facturas simplificadas no es deducible (Art. 97 LIVA).'
};
}
if (!vendorTaxId || vendorTaxId.trim() === '') {
return {
isDeductible: false,
deductiblePercentage: 0,
nonDeductibleReason: 'missing_vendor_tax_id',
explanation: 'Se requiere NIF/CIF del proveedor para deducir el IVA (Art. 97 LIVA).'
};
}
const NON_DEDUCTIBLE_CATEGORIES = [
'Gastos personales',
'Seguros de vida',
'Multas y sanciones',
];
if (NON_DEDUCTIBLE_CATEGORIES.includes(category)) {
return {
isDeductible: false,
deductiblePercentage: 0,
nonDeductibleReason: 'personal_use',
explanation: `La categoría "${category}" no es deducible fiscalmente.`
};
}
const PARTIAL_DEDUCTIBLE_CATEGORIES = {
'Vehículos': 50, // Art. 95.3 LIVA
'Combustible': 50,
'Mantenimiento vehículo': 50,
'Comidas': 50,
'Representación': 50,
};
const categoryDeductibility = PARTIAL_DEDUCTIBLE_CATEGORIES[category] || 100;
const finalPercentage = (categoryDeductibility * prorrata) / 100;
const deductibleTaxAmount = (taxAmount * finalPercentage) / 100;

Un gasto se considera bien de inversión si:

  1. Importe total ≥ 3.005,06€ (umbral Art. 108 LIVA)
  2. Categoría de activo fijo: Maquinaria, Equipos informáticos, Mobiliario, Vehículos, Instalaciones
export const INVESTMENT_THRESHOLD = 3005.06;
export function isInvestmentGood(totalAmount: number, category?: string): boolean {
const investmentCategories = [
'Maquinaria',
'Equipos informáticos',
'Mobiliario',
'Vehículos',
'Instalaciones',
'Equipamiento',
];
if (totalAmount >= INVESTMENT_THRESHOLD) {
return investmentCategories.some(cat =>
category?.toLowerCase().includes(cat.toLowerCase())
);
}
return false;
}

Implicaciones fiscales:

  • Modelo 303: Casilla 30 (IVA bienes de inversión)
  • Regularización durante 5 años (Art. 110 LIVA)

El componente muestra un badge con tooltip explicativo:

  • Verde (100%): Deducible completo
  • Amarillo (1-99%): Deducible parcial
  • Rojo (0%): No deducible

Tooltip incluye:

  • Explicación de la regla aplicada
  • IVA soportado vs IVA deducible
  • Indicador de bien de inversión si aplica