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.

InvoiceIdentifier (josemmo\Verifactu\Models\Records\InvoiceIdentifier) is the composite key that uniquely identifies an invoice within the VERI*FACTU system. It appears in both registration and cancellation record headers as the invoice’s own identity, and is also used as the chain link reference that cryptographically connects consecutive records together.

Constructor

public function __construct(
    ?string $issuerId = null,
    ?string $invoiceNumber = null,
    ?DateTimeImmutable $issueDate = null,
)
All constructor parameters are optional — you can also set properties directly after construction. Any non-null argument passed to the constructor is written to the corresponding property.
issuerId
string | null
default:"null"
NIF of the invoice issuer. When provided, sets $this->issuerId.
invoiceNumber
string | null
default:"null"
Invoice series and number. When provided, sets $this->invoiceNumber.
issueDate
DateTimeImmutable | null
default:"null"
Issue date of the invoice. When provided, sets $this->issueDate.

Properties

issuerId
string
required
NIF of the entity obliged to issue the invoice (IDEmisorFactura).
  • Must not be blank
  • Exactly 9 characters
  • Corresponds to XML field IDFactura/IDEmisorFactura (or IDEmisorFacturaAnulada in cancellation records)
invoiceNumber
string
required
Combined invoice series and number that uniquely identifies the invoice within the issuer’s records.
  • Must not be blank
  • Maximum 60 characters
  • Corresponds to XML field IDFactura/NumSerieFactura (or NumSerieFacturaAnulada in cancellation records)
issueDate
DateTimeImmutable
required
Calendar date on which the invoice was issued. The time component is always ignored — only the date portion is serialised and compared.
  • Must not be blank
  • Corresponds to XML field IDFactura/FechaExpedicionFactura formatted as dd-mm-yyyy

Methods

fromXml()

public static function fromXml(UXML $xml): self
Imports an InvoiceIdentifier from a <sum1:IDFactura> (or equivalent) XML element. Automatically detects whether to read standard or Anulada-suffixed fields. Throws josemmo\Verifactu\Exceptions\ImportException on missing or malformed elements.

export()

public function export(UXML $xml, bool $isCancellation): void
Writes the three identifier fields as direct children of the provided $xml element — no wrapper child node is created, because the identifier fields appear inside several different parent nodes across the AEAT schema.
xml
UXML
required
The parent XML element to which the fields are appended.
isCancellation
bool
required
When true, the Anulada suffix is appended to each field name (IDEmisorFacturaAnulada, NumSerieFacturaAnulada, FechaExpedicionFacturaAnulada). Pass false for standard registration records.

equals()

public function equals(InvoiceIdentifier $other): bool
Compares this identifier with another. Two identifiers are considered equal when all three fields match: issuerId, invoiceNumber, and the date portion of issueDate (time is ignored).
other
InvoiceIdentifier
required
The identifier to compare against.

Code examples

use josemmo\Verifactu\Models\Records\InvoiceIdentifier;
use DateTimeImmutable;

// Constructor shorthand
$id = new InvoiceIdentifier('A12345678', 'F-2024/001', new DateTimeImmutable('2024-06-15'));

// Property assignment (equivalent)
$id = new InvoiceIdentifier();
$id->issuerId      = 'A12345678';
$id->invoiceNumber = 'F-2024/001';
$id->issueDate     = new DateTimeImmutable('2024-06-15');

// Validate
$id->validate();

// Equality check
$other = new InvoiceIdentifier('A12345678', 'F-2024/001', new DateTimeImmutable('2024-06-15 23:59:59'));
var_dump($id->equals($other)); // bool(true) — time part is ignored

// Exporting: fields are written directly into $parentXml
// $id->export($parentXml, false);  // registration: IDEmisorFactura, NumSerieFactura, ...
// $id->export($parentXml, true);   // cancellation: IDEmisorFacturaAnulada, ...

Build docs developers (and LLMs) love