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.

RegistroAlta is the primary invoice record submitted to AEAT through the VeriFactu system. It combines the issuer details from an Emisor model with a tax breakdown (Desglose), an optional recipient (Destinatario), an optional third-party issuer (Tercero), and optional references to rectified or substituted invoices (FacturaRectificada, FacturaSustituida). The constructor accepts two arrays — one for sub-model objects and one for scalar data fields — plus a webhook ID integer.

Construction

RegistroAlta takes three constructor arguments:
  1. $objetos — an associative array of sub-model instances.
  2. $data — an associative array of scalar field values.
  3. $webhookID — an integer webhook ID (pass 0 to fall back to the Emisor’s default).
use verifactuPHP\Models\RegistroAlta;
use verifactuPHP\Models\Emisor;
use verifactuPHP\Models\Destinatario;
use verifactuPHP\Models\Desglose;
use verifactuPHP\Models\Tercero;
use verifactuPHP\Models\FacturaRectificada;
use verifactuPHP\Models\FacturaSustituida;

$emisor = new Emisor([
    'nif'        => 'B12345678',
    'nombre'     => 'Mi Empresa S.L.',
    'webhookID'  => 42,
    'enviarAeat' => true,
]);

$desglose = new Desglose([
    'impuesto'                      => 1,
    'claveRegimen'                  => 1,
    'tipoImpositivo'                => 21.0,
    'baseImponibleOImporteNoSujeto' => 1000.00,
    'cuotaRepercutida'              => 210.00,
]);

$destinatario = new Destinatario([
    'nombreRazon' => 'Cliente Final S.A.',
    'nif'         => 'A98765432',
]);

$registro = new RegistroAlta(
    [
        'emisor'              => $emisor,
        'destinatario'        => $destinatario,
        'desglose'            => $desglose,
        'tercero'             => Tercero::empty(),
        'facturaRectificada'  => FacturaRectificada::empty(),
        'facturaSustituida'   => FacturaSustituida::empty(),
    ],
    [
        'numSerieFactura'        => 'FACT-2024-001',
        'fechaExpedicionFactura' => '2024-06-15',
        'tipoFactura'            => 'F1',
        'descripcionOperacion'   => 'Servicios de consultoría',
        'cuotaTotal'             => 210.00,
        'importeTotal'           => 1210.00,
    ],
    0  // falls back to $emisor->getWebhookID() = 42
);

Objects array keys

The $objetos array accepts the following keys. Any omitted key defaults to the corresponding ::empty() factory:
KeyExpected typeDefault if omitted
emisorEmisorEmisor::empty()
destinatarioDestinatarioDestinatario::empty()
desgloseDesgloseDesglose::empty()
terceroTerceroTercero::empty()
facturaRectificadaFacturaRectificadaFacturaRectificada::empty()
facturaSustituidaFacturaSustituidaFacturaSustituida::empty()

Auto-set fields

Two fields are automatically derived from the attached Emisor and cannot be set manually via the $data array:
  • IDEmisorFactura — copied from $emisor->getNif().
  • NombreRazonEmisor — copied from $emisor->getNombre().
If you later call setEmisor(), both fields are updated automatically.

Webhook ID fallback

The effective webhook ID is resolved at construction time:
webhookID = $webhookID ?: $emisor->getWebhookID()
Pass a non-zero integer as the third constructor argument to override the Emisor’s default. Pass 0 to inherit it.

Fields

Identification

numSerieFactura
string
required
Invoice series and number (e.g. "FACT-2024-001"). Maps to API field NumSerieFactura. Must be unique within the issuer’s NIF.
fechaExpedicionFactura
string
required
Invoice issue date in YYYY-MM-DD format. Maps to API field FechaExpedicionFactura.
refExterna
string
Optional free-text external reference for your own internal systems. Maps to API field RefExterna.
fechaOperacion
string
Date the underlying operation took place, in YYYY-MM-DD format. Maps to API field FechaOperacion. Only required when the operation date differs from the issue date.
descripcionOperacion
string
Free-text description of the invoiced operation. Maps to API field DescripcionOperacion.

Invoice type and correction

tipoFactura
int|string
required
Invoice type, from lista L2 (e.g. "F1" = standard invoice, "F2" = simplified, "R1""R5" = rectification types). Both the integer ID and the string code are accepted. Maps to API field TipoFactura.
tipoRectificativa
int|string
Rectification method, from lista L3 (substitution or difference). Both the integer ID and the string code are accepted. Maps to API field TipoRectificativa. Required when tipoFactura is a rectification type (R1R5).
baseRectificada
float
Corrected taxable base amount from the original invoice. Maps to API field BaseRectificada. Used when tipoRectificativa indicates a substitution.
cuotaRectificada
float
Corrected VAT amount from the original invoice. Maps to API field CuotaRectificada.
cuotaRecargoRectificado
float
Corrected equivalence surcharge amount from the original invoice. Maps to API field CuotaRecargoRectificado.

Special flags

subsanacion
int|string
Indicates this record corrects a previously rejected registration, from lista L4. Both the integer ID and the string code are accepted. Maps to API field Subsanacion.
rechazoPrevio
int|string
Prior rejection flag, from lista L17. Both the integer ID and the string code are accepted. Maps to API field RechazoPrevio.
facturaSimplificadaArt7273
int|string
Marks the invoice as a simplified invoice under Articles 72 and 73, from lista L4. Both the integer ID and the string code are accepted. Maps to API field FacturaSimplificadaArt7273.
facturaSinIdentifDestinatarioArt61d
int|string
Marks the invoice as one without identified recipient under Article 61d, from lista L5. Both the integer ID and the string code are accepted. Maps to API field FacturaSinIdentifDestArt61d.
macrodato
int|string
Flags this as a large-value transaction (macrodato), from lista L14. Both the integer ID and the string code are accepted. Maps to API field Macrodato.
emitidaPorTercODestinatario
int|string
Indicates the invoice was issued by a third party or by the recipient (self-billing), from lista L6. Both the integer ID and the string code are accepted. Maps to API field EmitidaPorTercODesti. When set, populate the tercero or destinatario object accordingly.
cupon
int|string
Coupon flag, from lista L4. Both the integer ID and the string code are accepted. Maps to API field Cupon.

Totals

cuotaTotal
float
required
Total tax amount for the invoice (sum of all cuotaRepercutida values across desgloses). Maps to API field CuotaTotal.
importeTotal
float
required
Total invoice amount including tax (taxable base + cuotaTotal). Maps to API field ImporteTotal.

Webhook

webhookID
int
Webhook ID to receive the AEAT submission result notification. Maps to API field webhook_id. Falls back to the attached Emisor’s webhookID when 0 is passed to the constructor.

Getters and Setters

MethodDescription
getEmisor(): EmisorReturns the attached Emisor.
setEmisor(Emisor $v): voidReplaces the Emisor and re-derives IDEmisorFactura and NombreRazonEmisor.
getDestinatario(): DestinatarioReturns the attached Destinatario.
setDestinatario(Destinatario $v): voidReplaces the Destinatario.
getDesglose(): DesgloseReturns the attached Desglose.
setDesglose(Desglose $v): voidReplaces the Desglose.
getTercero(): TerceroReturns the attached Tercero.
setTercero(Tercero $v): voidReplaces the Tercero.
getFacturaRectificada(): FacturaRectificadaReturns the FacturaRectificada reference.
setFacturaRectificada(FacturaRectificada $v): voidReplaces the FacturaRectificada reference.
getFacturaSustituida(): FacturaSustituidaReturns the FacturaSustituida reference.
setFacturaSustituida(FacturaSustituida $v): voidReplaces the FacturaSustituida reference.
getIDEmisorFactuara(): stringReturns the auto-set issuer NIF.
setIDEmisorFactuara(string $v): voidOverrides the auto-set issuer NIF.
getNumSerieFactura(): stringReturns the invoice series/number.
setNumSerieFactura(string $v): voidSets the invoice series/number.
getFechaExpedicionFactura(): stringReturns the issue date.
setFechaExpedicionFactura(string $v): voidSets the issue date.
getRefExterna(): stringReturns the external reference.
setRefExterna(string $v): voidSets the external reference.
getTipoFactura(): int|stringReturns the invoice type (lista L2).
setTipoFactura(int|string $v): voidSets the invoice type (lista L2).
getSubsanacion(): int|stringReturns the correction flag (lista L4).
setSubsanacion(int|string $v): voidSets the correction flag (lista L4).
getRechazoPrevio(): int|stringReturns the prior rejection flag (lista L17).
setRechazoPrevio(int|string $v): voidSets the prior rejection flag (lista L17).
getTipoRectificativa(): int|stringReturns the rectification method (lista L3).
setTipoRectificativa(int|string $v): voidSets the rectification method (lista L3).
getBaseRectificada(): floatReturns the corrected taxable base.
setBaseRectificada(float $v): voidSets the corrected taxable base.
getCuotaRectificada(): floatReturns the corrected VAT amount.
setCuotaRectificada(float $v): voidSets the corrected VAT amount.
getCuotaRecargoRectificado(): floatReturns the corrected surcharge amount.
setCuotaRecargoRectificado(float $v): voidSets the corrected surcharge amount.
| getFacturaSimplificadaArt7273(): int\|string | Returns the simplified invoice flag (lista L4). | | setFacturaSimplificadaArt7273(int\|string $v): void | Sets the simplified invoice flag (lista L4). | | getFacturaSinIdentifDestinatarioArt61d(): int\|string | Returns the no-recipient-ID flag (lista L5). | | setFacturaSinIdentifDestinatarioArt61d(int\|string $v): void | Sets the no-recipient-ID flag (lista L5). | | getMacrodato(): int\|string | Returns the large transaction flag (lista L14). | | setMacrodato(int\|string $v): void | Sets the large transaction flag (lista L14). | | getEmitidaPorTercODestinatario(): int\|string | Returns the third-party/recipient issuance flag (lista L6). | | setEmitidaPorTercODestinatario(int\|string $v): void | Sets the third-party/recipient issuance flag (lista L6). | | getCupon(): int\|string | Returns the coupon flag (lista L4). | | setCupon(int\|string $v): void | Sets the coupon flag (lista L4). | | getCuotaTotal(): float | Returns the total tax amount. | | setCuotaTotal(float $v): void | Sets the total tax amount. | | getImporteTotal(): float | Returns the total invoice amount. | | setImporteTotal(float $v): void | Sets the total invoice amount. | | getWebhookID(): int | Returns the effective webhook ID. | | setWebhookID(int $v): void | Overrides the webhook ID. |

getArrayData()

getArrayData(): array assembles the full API-ready payload. Only non-empty scalar fields are included. Sub-models are embedded under their own keys when their own getArrayData() returns a non-empty array:
Sub-model propertyEmbedded under key
destinatarioDestinatarios (single-element array)
desgloseDesglose (single-element array)
terceroTercero (single-element array)
facturaRectificadaFacturasRectificadas (single-element array)
facturaSustituidaFacturasSustituidas (single-element array)
Scalar PHP property names map to API field names as follows:
PHP propertyAPI field key
IDEmisorFactuaraIDEmisorFactura
numSerieFacturaNumSerieFactura
fechaExpedicionFacturaFechaExpedicionFactura
refExternaRefExterna
nombreRazonEmisorNombreRazonEmisor
subsanacionSubsanacion
rechazoPrevioRechazoPrevio
tipoFacturaTipoFactura
tipoRectificativaTipoRectificativa
baseRectificadaBaseRectificada
cuotaRectificadaCuotaRectificada
cuotaRecargoRectificadoCuotaRecargoRectificado
fechaOperacionFechaOperacion
descripcionOperacionDescripcionOperacion
facturaSimplificadaArt7273FacturaSimplificadaArt7273
facturaSinIdentifDestinatarioArt61dFacturaSinIdentifDestArt61d
macrodatoMacrodato
emitidaPorTercODestinatarioEmitidaPorTercODesti
cuponCupon
cuotaTotalCuotaTotal
importeTotalImporteTotal
webhookIDwebhook_id
$payload = $registro->getArrayData();
// Example output (abbreviated):
// [
//     'IDEmisorFactura'               => 'B12345678',
//     'NombreRazonEmisor'             => 'Mi Empresa S.L.',
//     'NumSerieFactura'               => 'FACT-2024-001',
//     'FechaExpedicionFactura'        => '2024-06-15',
//     'TipoFactura'                   => 'F1',
//     'DescripcionOperacion'          => 'Servicios de consultoría',
//     'CuotaTotal'                    => 210.0,
//     'ImporteTotal'                  => 1210.0,
//     'webhook_id'                    => 42,
//     'Destinatarios' => [['NombreRazon' => 'Cliente Final S.A.', 'NIF' => 'A98765432']],
//     'Desglose'      => [['Impuesto' => 1, 'ClaveRegimen' => 1, ...]],
// ]

empty()

RegistroAlta::empty(): RegistroAlta returns a RegistroAlta with all sub-models set to their respective ::empty() instances, all string fields set to '', all integer and flag fields set to 0, and all float fields set to 0.0. Use it as a safe placeholder or as a base for incremental construction in tests.
$placeholder = RegistroAlta::empty();
An empty() instance will not produce a valid AEAT submission — populate at minimum numSerieFactura, fechaExpedicionFactura, tipoFactura, cuotaTotal, and importeTotal, and attach a valid Emisor and Desglose before calling getArrayData() for real use.

Build docs developers (and LLMs) love