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.

BreakdownDetails (josemmo\Verifactu\Models\Records\BreakdownDetails) represents one row in the Desglose (tax breakdown) section of a RegistrationRecord. Each invoice can carry multiple BreakdownDetails instances — one for each combination of tax type, regime, and operation classification that applies. The class enforces strict cross-field validation rules that mirror the AEAT schema requirements.

Properties

taxType
TaxType
required
The indirect tax that applies to this breakdown entry.
  • Must not be blank
  • Corresponds to XML field Impuesto
Enum caseRaw valueDescription
TaxType::IVA01Impuesto sobre el Valor Añadido
TaxType::IPSI02Impuesto sobre la Producción, los Servicios y la Importación (Ceuta & Melilla)
TaxType::IGIC03Impuesto General Indirecto Canario
TaxType::Other05Other indirect tax
regimeType
RegimeType
required
The special regime key or additional tax significance code.
  • Must not be blank
  • Corresponds to XML field ClaveRegimen
operationType
OperationType
required
Classification of the operation: whether it is subject to tax, non-subject, or exempt.
  • Must not be blank
  • Corresponds to XML field CalificacionOperacion (for subject/non-subject) or OperacionExenta (for exempt)
Enum caseRaw valueCategoryDescription
SubjectS1SubjectSubject and not exempt — no passive subject
PassiveSubjectS2SubjectSubject and not exempt — with passive subject
NonSubjectN1Non-subjectNot subject — Articles 7, 14, and others
NonSubjectByLocationN2Non-subjectNot subject by location rules
ExemptByArticle20E1ExemptExempt under Article 20
ExemptByArticle21E2ExemptExempt under Article 21
ExemptByArticle22E3ExemptExempt under Article 22
ExemptByArticles23And24E4ExemptExempt under Articles 23 and 24
ExemptByArticle25E5ExemptExempt under Article 25
ExemptByOtherE6ExemptExempt — other reason
baseAmount
string
required
The taxable base or non-subject amount as a formatted decimal string.
  • Must not be blank
  • Matches regex /^-?\d{1,12}\.\d{2}$/ — up to 12 integer digits and exactly 2 decimal places; negative values are allowed
  • Corresponds to XML field BaseImponibleOimporteNoSujeto
taxRate
string | null
default:"null"
The tax rate percentage applied to baseAmount.
  • Matches regex /^\d{1,3}\.\d{2}$/ — positive only, up to 3 integer digits and exactly 2 decimal places
  • Required when operationType is Subject or PassiveSubject
  • Forbidden for all other operation types
  • Corresponds to XML field TipoImpositivo
taxAmount
string | null
default:"null"
The tax amount resulting from applying taxRate to baseAmount.
  • Matches regex /^-?\d{1,12}\.\d{2}$/
  • Required when operationType is Subject or PassiveSubject
  • Forbidden for all other operation types
  • Corresponds to XML field CuotaRepercutida
surchargeRate
string | null
default:"null"
The equivalence surcharge (recargo de equivalencia) rate percentage.
  • Matches regex /^\d{1,3}\.\d{2}$/
  • Required when regimeType is RegimeType::C18 and operationType is subject
  • Forbidden for any other regime type or non-subject/exempt operations
  • Corresponds to XML field TipoRecargoEquivalencia
surchargeAmount
string | null
default:"null"
The equivalence surcharge amount resulting from applying surchargeRate to baseAmount.
  • Matches regex /^-?\d{1,12}\.\d{2}$/
  • Required when regimeType is RegimeType::C18 and operationType is subject
  • Forbidden for any other regime type or non-subject/exempt operations
  • Corresponds to XML field CuotaRecargoEquivalencia

Validation rules

validate() (inherited from josemmo\Verifactu\Models\Model) runs both per-property and cross-field checks.

Methods

fromXml()

public static function fromXml(UXML $xml): self
Imports a BreakdownDetails from a <sum1:DetalleDesglose> XML element. Throws josemmo\Verifactu\Exceptions\ImportException on missing or invalid fields.

export()

public function export(UXML $xml): void
Serialises the breakdown into a new <sum1:DetalleDesglose> child element appended to $xml. Called internally by RegistrationRecord.

validate()

Inherited from josemmo\Verifactu\Models\Model. Runs all property and cross-field constraints and throws josemmo\Verifactu\Exceptions\ValidationException on any violation.

Code examples

use josemmo\Verifactu\Models\Records\BreakdownDetails;
use josemmo\Verifactu\Models\Records\TaxType;
use josemmo\Verifactu\Models\Records\RegimeType;
use josemmo\Verifactu\Models\Records\OperationType;

// --- Subject operation (standard 21% VAT) ---
$subject = new BreakdownDetails();
$subject->taxType       = TaxType::IVA;
$subject->regimeType    = RegimeType::C01;
$subject->operationType = OperationType::Subject;
$subject->baseAmount    = '1000.00';
$subject->taxRate       = '21.00';
$subject->taxAmount     = '210.00';  // must be within ±0.02 of 1000 × 21 / 100
$subject->validate();


// --- Subject operation with equivalence surcharge (C18 regime) ---
$surcharge = new BreakdownDetails();
$surcharge->taxType        = TaxType::IVA;
$surcharge->regimeType     = RegimeType::C18;
$surcharge->operationType  = OperationType::Subject;
$surcharge->baseAmount     = '500.00';
$surcharge->taxRate        = '21.00';
$surcharge->taxAmount      = '105.00';
$surcharge->surchargeRate   = '5.20';
$surcharge->surchargeAmount = '26.00';  // must be within ±0.02 of 500 × 5.20 / 100
$surcharge->validate();


// --- Non-subject operation ---
$nonSubject = new BreakdownDetails();
$nonSubject->taxType       = TaxType::IVA;
$nonSubject->regimeType    = RegimeType::C01;
$nonSubject->operationType = OperationType::NonSubject;  // N1
$nonSubject->baseAmount    = '250.00';
// taxRate, taxAmount, surchargeRate, surchargeAmount must all be null
$nonSubject->validate();


// --- Exempt operation ---
$exempt = new BreakdownDetails();
$exempt->taxType       = TaxType::IVA;
$exempt->regimeType    = RegimeType::C01;
$exempt->operationType = OperationType::ExemptByArticle20;  // E1
$exempt->baseAmount    = '300.00';
// taxRate, taxAmount, surchargeRate, surchargeAmount must all be null
$exempt->validate();

Build docs developers (and LLMs) love