Invoice class is the core component of PHP FacturaE. It provides a fluent interface for building electronic invoices compliant with the Spanish FacturaE format.
Creating an Invoice
create()
Create a new invoice instance.The invoice number
Returns a new Invoice instance
Core Properties
series()
Set the invoice series.The invoice series identifier
Returns self for method chaining
date()
Set the invoice issue date.The issue date. Can be a date string (parsed by DateTimeImmutable) or a DateTimeImmutable object
Returns self for method chaining
operationDate()
Set the operation date (when the transaction occurred).The operation date
Returns self for method chaining
billingPeriod()
Set the billing period for the invoice.Start date of the billing period
End date of the billing period
Returns self for method chaining
schema()
Set the FacturaE schema version.The schema version enum value
Returns self for method chaining
type()
Set the invoice type.The invoice type enum value
Returns self for method chaining
currency()
Set the invoice currency.ISO 4217 currency code (default: ‘EUR’)
Returns self for method chaining
description()
Set the invoice description.Invoice description
Returns self for method chaining
Parties
seller()
Set the seller (supplier) party.The seller Party instance
Returns self for method chaining
buyer()
Set the buyer (customer) party.The buyer Party instance
Returns self for method chaining
Invoice Lines
line()
Add a standard invoice line with Spanish tax shortcuts.Line item description
Unit price (without taxes)
Quantity
VAT (IVA) rate percentage
Income tax withholding (IRPF) rate percentage
Canary Islands tax (IGIC) rate percentage
Equivalence surcharge rate percentage
Special tax (IE) rate percentage
Whether special tax is withheld
Line discount amount
Product/article code
Additional detailed description
Unit of measure enum value
Returns self for method chaining
exemptLine()
Add a tax-exempt line with exemption reason.Line item description
Unit price
Quantity
Tax exemption reason (e.g., legal article reference)
Line discount amount
Product/article code
Unit of measure enum value
Returns self for method chaining
customLine()
Add a line with custom tax configuration.Line item description
Unit price
Array of TaxBreakdown objects
Quantity
Line discount amount
Product/article code
Unit of measure enum value
Special taxable event enum value
Reason for special taxable event
Returns self for method chaining
Payments
payment()
Add a custom payment object.Payment entity instance
Returns self for method chaining
transferPayment()
Add a bank transfer payment.Bank account IBAN
Payment due date
Payment amount (null for full invoice amount)
Returns self for method chaining
cashPayment()
Add a cash payment.Payment due date
Payment amount (null for full invoice amount)
Returns self for method chaining
cardPayment()
Add a card payment.Payment due date
Payment amount (null for full invoice amount)
Returns self for method chaining
directDebitPayment()
Add a direct debit payment.Bank account IBAN for direct debit
Payment due date
Payment amount (null for full invoice amount)
Returns self for method chaining
splitPayments()
Split payment into multiple installments.Payment method enum value
Number of installments
Due date for the first installment
Days between each installment
Bank account IBAN (required for Transfer and DirectDebit)
Returns self for method chaining
Corrective Invoices
corrects()
Mark this invoice as a correction of another invoice.Number of the invoice being corrected
Reason for the correction
Correction method
Series of the invoice being corrected
Start of correction period
End of correction period
Returns self for method chaining
legalLiteral()
Add a legal literal text to the invoice.Legal text to include
Returns self for method chaining
Discounts & Charges
generalDiscount()
Add a general discount at invoice level.Reason for the discount
Discount rate percentage
Fixed discount amount
Returns self for method chaining
generalCharge()
Add a general charge at invoice level.Reason for the charge
Charge rate percentage
Fixed charge amount
Returns self for method chaining
Attachments
attach()
Attach a file to the invoice.Attachment entity instance
Returns self for method chaining
attachFile()
Attach a file directly from a file path.Path to the file
Description of the attachment
MIME type (auto-detected if null)
Returns self for method chaining
Signing
sign()
Set the signer for the invoice.Signer implementation (e.g., Pkcs12Signer)
Returns self for method chaining
Output
toXml()
Generate the FacturaE XML string.XML string of the invoice
If the invoice fails validation
export()
Export the invoice to an XML file.File path where the XML will be saved
Returns self for method chaining
If the invoice fails validation