Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/NemonInvocash/verifactu-php/llms.txt

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

FacturaSustituida is a lightweight reference model that identifies the original invoice being fully substituted by a new one. It is used alongside FacturaRectificada in scenarios where tipoRectificativa (lista L3) is set to the substitution method: rather than recording a difference amount, the correcting RegistroAlta replaces the original invoice entirely. Pass a populated FacturaSustituida instance in the RegistroAlta objects array under the key facturaSustituida when the rectification method is substitution.

Construction

use verifactuPHP\Models\FacturaSustituida;

$facturaSustituida = new FacturaSustituida([
    'IDEmisorFactura'        => 'B12345678',
    'numSerieFactura'        => 'FACT-2024-001',
    'fechaExpedicionFactura' => '2024-06-15',
]);
Attach it to a RegistroAlta that uses the substitution rectification method:
use verifactuPHP\Models\RegistroAlta;
use verifactuPHP\Models\FacturaRectificada;

$registro = new RegistroAlta(
    [
        'emisor'             => $emisor,
        'desglose'           => $desglose,
        'facturaRectificada' => new FacturaRectificada([
            'IDEmisorFactura'        => 'B12345678',
            'numSerieFactura'        => 'FACT-2024-001',
            'fechaExpedicionFactura' => '2024-06-15',
        ]),
        'facturaSustituida'  => $facturaSustituida,
        // other sub-models...
    ],
    [
        'numSerieFactura'        => 'SUST-2024-001',
        'fechaExpedicionFactura' => '2024-07-01',
        'tipoFactura'            => 'R1',
        'tipoRectificativa'      => 2,    // substitution — lista L3
        'baseRectificada'        => 1000.00,
        'cuotaRectificada'       => 210.00,
        'cuotaTotal'             => 252.00,
        'importeTotal'           => 1452.00,
    ],
    0
);
The three fields in FacturaSustituida must exactly match the IDEmisorFactura, NumSerieFactura, and FechaExpedicionFactura of the original RegistroAlta as stored in AEAT.

Fields

IDEmisorFactura
string
required
NIF of the issuer of the original invoice being substituted. Maps to API field IDEmisorFactura.
numSerieFactura
string
required
Series and number of the original invoice being substituted. Maps to API field NumSerieFactura.
fechaExpedicionFactura
string
required
Issue date of the original invoice being substituted, in YYYY-MM-DD format. Maps to API field FechaExpedicionFactura.

Getters and Setters

MethodDescription
getIDEmisorFactura(): stringReturns the issuer NIF of the original invoice.
setIDEmisorFactura(string $v): voidSets the issuer NIF of the original invoice.
getNumSerieFactura(): stringReturns the series/number of the original invoice.
setNumSerieFactura(string $v): voidSets the series/number of the original invoice.
getFechaExpedicionFactura(): stringReturns the issue date of the original invoice.
setFechaExpedicionFactura(string $v): voidSets the issue date of the original invoice.

getArrayData()

getArrayData(): array returns an associative array containing only the fields with non-empty string values. All three PHP property names map directly to the same names in the API payload:
PHP propertyAPI field key
IDEmisorFacturaIDEmisorFactura
numSerieFacturaNumSerieFactura
fechaExpedicionFacturaFechaExpedicionFactura
$data = $facturaSustituida->getArrayData();
// Output:
// [
//     'IDEmisorFactura'        => 'B12345678',
//     'NumSerieFactura'        => 'FACT-2024-001',
//     'FechaExpedicionFactura' => '2024-06-15',
// ]
RegistroAlta::getArrayData() wraps the result in a single-element array under the key FacturasSustituidas, matching the API’s expected structure. If getArrayData() returns an empty array (i.e. all fields are empty), the FacturasSustituidas key is omitted entirely from the payload.

empty()

FacturaSustituida::empty(): FacturaSustituida returns a FacturaSustituida with all three fields set to ''. Because getArrayData() skips empty strings, an empty instance produces no output in the API payload. Pass it to RegistroAlta when the invoice is not using the substitution rectification method.
$placeholder = FacturaSustituida::empty();
When you do not need a substitution reference, pass FacturaSustituida::empty() (or simply omit the facturaSustituida key from the $objetos array). The RegistroAlta constructor will substitute FacturaSustituida::empty() automatically for any missing object key.

Build docs developers (and LLMs) love