# Lines and taxes

Basic lines

$invoice->line(
description: 'Laptop computer',
quantity: 2,
price: 899.99,
vat: 21
);

Method signature

public function line(
string $description,
float $price,
float $quantity = 1,
?float $vat = null,
?float $irpf = null,
?float $igic = null,
?float $surcharge = null,
?float $ie = null,
bool $ieWithheld = false,
?float $discount = null,
?string $articleCode = null,
?string $detailedDescription = null,
?UnitOfMeasure $unit = null,
): self

Tax shortcuts

VAT:

$invoice->line('Software license', price: 100, vat: 21); // Standard 21%
$invoice->line('Book', price: 20, vat: 10); // Reduced 10%
$invoice->line('Essential food', price: 15, vat: 4); // Super-reduced 4%

IRPF (withholding):

$invoice->line('Legal advisory', price: 2000, vat: 21, irpf: 15);

IGIC (Canary Islands):

$invoice->line('Product', price: 100, igic: 7);

Don’t combine VAT and IGIC on the same line.

Equivalence surcharge:

$invoice->line('Retail product', price: 100, vat: 21, surcharge: 5.2);

Surcharge rates: VAT 21% → 5.2%, VAT 10% → 1.4%, VAT 4% → 0.5%.

Excise duties (IE):

$invoice->line('Alcohol', price: 50, vat: 21, ie: 10);

Line-level discounts

$invoice->line('Product', quantity: 10, price: 100, discount: 20, vat: 21);
// Subtotal: 1000, Discount -20% = 800, VAT +168, Total: 968

Article codes and units

use PhpFacturae\Enums\UnitOfMeasure;
$invoice->line('Electricity', quantity: 150.5, price: 0.15,
unit: UnitOfMeasure::KWh, vat: 21, articleCode: 'ELEC-001');

Exempt lines

$invoice->exemptLine(
description: 'Professional training course',
price: 2000,
reason: 'Exempt under Article 20 LIVA'
);

Custom tax configuration

use PhpFacturae\Entities\TaxBreakdown;
use PhpFacturae\Enums\Tax;
$invoice->customLine(
description: 'Complex service',
price: 1000,
taxes: [
new TaxBreakdown(Tax::IVA, rate: 21),
new TaxBreakdown(Tax::IRPF, rate: 15),
]
);

Tax enum (29 types)

Tax::IVA // Value Added Tax
Tax::IPSI // Production Tax (Ceuta and Melilla)
Tax::IGIC // Canary Islands Indirect General Tax
Tax::IRPF // IRPF Withholding
Tax::IRNR // Non-Resident Income Tax
Tax::IE // Excise Duty
Tax::RA // Agricultural equivalence surcharge
Tax::ITPAJD // Transfer Tax
Tax::REIVA // Equivalence surcharge (VAT)
Tax::REIGIC // Equivalence surcharge (IGIC)
Tax::REIPSI // Equivalence surcharge (IPSI)
// ... and 18 more specialized