Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/josemmo/Verifactu-PHP/llms.txt

Use this file to discover all available pages before exploring further.

Verifactu-PHP uses PHP 8.1 backed string enums for all fixed-value fields required by the AEAT specification. Each enum case carries the exact string that is written into the XML payload — you never need to handle raw strings manually. All enums live in the josemmo\Verifactu\Models\Records namespace.
InvoiceType classifies the invoice being reported (<TipoFactura>). The value determines which validation rules apply — for example, recipient requirements and whether corrective details are mandatory.
CaseValueDescription
FacturaF1Standard invoice (Art. 6, 7.2 and 7.3 of R.D. 1619/2012)
SimplificadaF2Simplified invoice or invoice without recipient identification (Art. 6.1.D of R.D. 1619/2012)
SustitutivaF3Invoice issued to replace previously declared simplified invoices
R1R1Corrective invoice — Art. 80.1, 80.2, and well-founded legal error (error fundado en derecho)
R2R2Corrective invoice — Art. 80.3
R3R3Corrective invoice — Art. 80.4
R4R4Corrective invoice — other grounds
R5R5Corrective simplified invoice
use josemmo\Verifactu\Models\Records\InvoiceType;

$record->invoiceType = InvoiceType::Factura;       // standard F1 invoice
$record->invoiceType = InvoiceType::R1;            // corrective with full legal basis

// Check if it is a corrective type
$isCorrective = in_array($record->invoiceType, [
    InvoiceType::R1, InvoiceType::R2, InvoiceType::R3,
    InvoiceType::R4, InvoiceType::R5,
], true);
TaxType identifies which indirect tax applies to a breakdown line (<Impuesto>).
CaseValueDescription
IVA01Impuesto sobre el Valor Añadido — general Spanish VAT
IPSI02Impuesto sobre la Producción, los Servicios y la Importación (Ceuta & Melilla)
IGIC03Impuesto General Indirecto Canario (Canary Islands)
Other05Other applicable taxes
Value 04 is not defined — the AEAT specification skips it. Use Other (05) for any tax not covered by the first three cases.
use josemmo\Verifactu\Models\Records\TaxType;

$line->taxType = TaxType::IVA;   // mainland Spain
$line->taxType = TaxType::IGIC;  // Canary Islands operations
RegimeType identifies the special VAT regime or additional fiscal significance of a breakdown line (<ClaveRegimen>). Values C12, C13, and C16 are not defined in the specification and are intentionally absent.
CaseValueDescription
C0101General regime operation
C0202Export
C0303Operations under the special regime for second-hand goods, works of art, antiques, and collectibles
C0404Special regime for investment gold
C0505Special regime for travel agencies
C0606Special regime for groups of entities under IVA (advanced level)
C0707Special cash-accounting criterion regime
C0808Operations subject to IPSI / IGIC
C0909Invoicing of travel agency mediation services acting in the name and on behalf of others (D.A. 4ª R.D. 1619/2012)
C1010Collections on behalf of third parties of professional fees or intellectual/industrial property rights by professional associations or similar bodies
C1111Business premises rental operations
C1414Invoice with pending IVA accrual for public-administration construction certifications
C1515Invoice with pending IVA accrual for successive-tract operations
C1717Operations covered by the OSS or IOSS regimes (Chapter XI, Title IX)
C1818Equivalence surcharge (recargo de equivalencia)
C1919Operations under the Special Agriculture, Livestock, and Fishing Regime (REAGYP)
C2020Simplified regime
use josemmo\Verifactu\Models\Records\RegimeType;

$line->regimeType = RegimeType::C01; // standard general-regime invoice
$line->regimeType = RegimeType::C07; // cash-accounting criterion
OperationType classifies whether a breakdown line is subject to tax, non-subject, or exempt, and on what legal basis (<CalificacionOperacion> / <OperacionExenta>).
CaseValueDescription
SubjectS1Subject and not exempt — without reverse-charge mechanism
PassiveSubjectS2Subject and not exempt — with reverse-charge mechanism (inversión del sujeto pasivo)
NonSubjectN1Non-subject operation — Arts. 7, 14, and others
NonSubjectByLocationN2Non-subject by location rules
ExemptByArticle20E1Exempt under Art. 20
ExemptByArticle21E2Exempt under Art. 21
ExemptByArticle22E3Exempt under Art. 22
ExemptByArticles23And24E4Exempt under Arts. 23 and 24
ExemptByArticle25E5Exempt under Art. 25
ExemptByOtherE6Exempt on other grounds

Helper methods

OperationType also exposes three convenience instance methods to categorise a value at runtime:
MethodReturns true for
isSubject(): boolSubject, PassiveSubject
isNonSubject(): boolNonSubject, NonSubjectByLocation
isExempt(): boolExemptByArticle20 through ExemptByOther (E1–E6)
use josemmo\Verifactu\Models\Records\OperationType;

$line->operationType = OperationType::Subject;

// Runtime categorisation
if ($line->operationType->isExempt()) {
    // No taxRate / taxAmount needed for exempt lines
    $line->taxRate   = null;
    $line->taxAmount = null;
}

if ($line->operationType->isSubject()) {
    echo 'Taxable line — rate applies';
}
CorrectiveType specifies the method used to correct an original invoice (<TipoRectificativa>). Required for all R1R5 invoice types.
CaseValueDescription
SubstitutionSThe corrective invoice replaces the original entirely. The original is annulled. When used, both correctedBaseAmount and correctedTaxAmount must be provided.
DifferencesIThe corrective invoice supplements the original, carrying only the delta amounts. The original invoice remains valid.
use josemmo\Verifactu\Models\Records\CorrectiveType;
use josemmo\Verifactu\Models\Records\InvoiceType;

// Corrective invoice by substitution
$record->invoiceType       = InvoiceType::R1;
$record->correctiveType    = CorrectiveType::Substitution;
$record->correctedBaseAmount = '1000.00'; // required for Substitution
$record->correctedTaxAmount  = '210.00';  // required for Substitution

// Corrective invoice by differences
$record->invoiceType    = InvoiceType::R4;
$record->correctiveType = CorrectiveType::Differences;
// correctedBaseAmount and correctedTaxAmount must NOT be set
ForeignIdType specifies the type of identification document held by a foreign recipient (<IDOtro/IDType>). Used inside ForeignFiscalIdentifier objects added to RegistrationRecord::$recipients.
CaseValueDescription
VAT02NIF-IVA (foreign VAT identification number)
Passport03Passport
NationalId04Official identification document issued by the country or territory of residence
Residence05Certificate of residence
Other06Other proof of identity document
Unregistered07Not yet registered with AEAT. The record must be corrected later to replace this type with the actual document type.
Using Unregistered (07) creates an obligation to resubmit the record later with the correct identification type once the recipient has been registered with the AEAT.
use josemmo\Verifactu\Models\Records\ForeignFiscalIdentifier;
use josemmo\Verifactu\Models\Records\ForeignIdType;

$recipient = new ForeignFiscalIdentifier(
    name:    'ACME Corp.',
    country: 'US',
    type:    ForeignIdType::VAT,
    value:   'US123456789',
);

$record->recipients[] = $recipient;

Build docs developers (and LLMs) love