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.

FacturaRectificada is a lightweight reference model that identifies the original invoice being corrected by a rectification. When the tipoFactura field on a RegistroAlta is set to a rectification type from lista L2 (values R1 through R5), a populated FacturaRectificada must be included in the RegistroAlta objects array under the key facturaRectificada. The model carries three fields that uniquely identify the original invoice within the AEAT system.

Construction

use verifactuPHP\Models\FacturaRectificada;

$facturaRectificada = new FacturaRectificada([
    'IDEmisorFactura'        => 'B12345678',
    'numSerieFactura'        => 'FACT-2024-001',
    'fechaExpedicionFactura' => '2024-06-15',
]);
Attach it to a RegistroAlta via the objects array:
use verifactuPHP\Models\RegistroAlta;

$registro = new RegistroAlta(
    [
        'emisor'             => $emisor,
        'desglose'           => $desglose,
        'facturaRectificada' => $facturaRectificada,
        // other sub-models...
    ],
    [
        'numSerieFactura'        => 'RECT-2024-001',
        'fechaExpedicionFactura' => '2024-07-01',
        'tipoFactura'            => 'R1',
        'tipoRectificativa'      => 1,
        'cuotaTotal'             => -210.00,
        'importeTotal'           => -1210.00,
    ],
    0
);
The three fields in FacturaRectificada 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 corrected. Maps to API field IDEmisorFactura.
numSerieFactura
string
required
Series and number of the original invoice being corrected. Maps to API field NumSerieFactura.
fechaExpedicionFactura
string
required
Issue date of the original invoice being corrected, 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 = $facturaRectificada->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 FacturasRectificadas, matching the API’s expected structure. If getArrayData() returns an empty array (i.e. all fields are empty), the FacturasRectificadas key is omitted entirely from the payload.

empty()

FacturaRectificada::empty(): FacturaRectificada returns a FacturaRectificada 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 a rectification.
$placeholder = FacturaRectificada::empty();
When you do not need a rectification reference, pass FacturaRectificada::empty() (or simply omit the facturaRectificada key from the $objetos array). The RegistroAlta constructor will substitute FacturaRectificada::empty() automatically for any missing object key.

Build docs developers (and LLMs) love