Skip to main content
The Party class represents either the seller or buyer in a FacturaE invoice. It supports both legal entities (companies) and natural persons.

Static Constructors

company()

Create a legal entity (company) party.
taxNumber
string
required
Tax identification number (NIF/CIF)
name
string
required
Company legal name
return
Party
Returns a new Party instance representing a company
$company = Party::company('B12345678', 'Mi Empresa SL');

person()

Create a natural person party.
taxNumber
string
required
Tax identification number (NIF/DNI)
name
string
required
Person’s first name
firstSurname
string
required
Person’s first surname
lastSurname
string|null
Person’s second surname (optional)
return
Party
Returns a new Party instance representing a person
$person = Party::person(
    taxNumber: '12345678A',
    name: 'Juan',
    firstSurname: 'García',
    lastSurname: 'López'
);

Fluent Setters

address()

Set the party’s address.
street
string
required
Street address
postalCode
string
required
Postal code
town
string
required
Town/city name
province
string
required
Province name
countryCode
string
default:"ESP"
ISO 3166-1 alpha-3 country code
return
Party
Returns self for method chaining
$party->address(
    street: 'Calle Mayor 1, 3º A',
    postalCode: '28001',
    town: 'Madrid',
    province: 'Madrid',
    countryCode: 'ESP'
);

tradeName()

Set the trade name (nombre comercial).
tradeName
string
required
Trade name
return
Party
Returns self for method chaining
$party->tradeName('Nombre Comercial');

email()

Set the email address.
email
string
required
Email address
return
Party
Returns self for method chaining
$party->email('[email protected]');

phone()

Set the phone number.
phone
string
required
Phone number
return
Party
Returns self for method chaining
$party->phone('+34912345678');

fax()

Set the fax number.
fax
string
required
Fax number
return
Party
Returns self for method chaining
$party->fax('+34912345679');

website()

Set the website URL.
website
string
required
Website URL
return
Party
Returns self for method chaining
$party->website('https://www.empresa.com');

contactPeople()

Set the contact person name.
value
string
required
Contact person name
return
Party
Returns self for method chaining
$party->contactPeople('Juan García');

cnoCnae()

Set the CNO or CNAE code (economic activity classification).
value
string
required
CNO/CNAE code
return
Party
Returns self for method chaining
$party->cnoCnae('6201');

ineTownCode()

Set the INE town code.
value
string
required
INE town code
return
Party
Returns self for method chaining
$party->ineTownCode('28079');

merchantRegister()

Set the merchant register data (Registro Mercantil).
book
string|null
Book (Tomo)
register
string|null
Register name
sheet
string|null
Sheet (Hoja)
folio
string|null
Folio
section
string|null
Section (Sección)
volume
string|null
Volume (Libro)
return
Party
Returns self for method chaining
$party->merchantRegister(
    book: '1234',
    register: 'Madrid',
    sheet: 'M-12345',
    folio: '100',
    section: '8',
    volume: '5678'
);

centre()

Add an administrative centre.
role
string
required
Role code (e.g., ‘01’ for fiscal, ‘02’ for receiver, ‘03’ for payer)
code
string
required
Centre code
name
string|null
Centre name
return
Party
Returns self for method chaining
$party->centre(
    role: '01',
    code: 'C001',
    name: 'Oficina Central'
);

Getters

isLegalEntity()

return
bool
Returns true if the party is a company, false if it’s a person
if ($party->isLegalEntity()) {
    // Handle company
}

taxNumber()

return
string
Returns the tax identification number

name()

return
string
Returns the name (company name or person’s first name)

firstSurname()

return
string|null
Returns the first surname (only for persons)

lastSurname()

return
string|null
Returns the second surname (only for persons)

getTradeName()

return
string|null
Returns the trade name

getAddress()

return
Address|null
Returns the Address entity

getEmail()

return
string|null
Returns the email address

getPhone()

return
string|null
Returns the phone number

getFax()

return
string|null
Returns the fax number

getWebsite()

return
string|null
Returns the website URL

getContactPeople()

return
string|null
Returns the contact person name

getCnoCnae()

return
string|null
Returns the CNO/CNAE code

getIneTownCode()

return
string|null
Returns the INE town code

getBook()

return
string|null
Returns the merchant register book

getMerchantRegister()

return
string|null
Returns the merchant register name

getSheet()

return
string|null
Returns the merchant register sheet

getFolio()

return
string|null
Returns the merchant register folio

getSection()

return
string|null
Returns the merchant register section

getVolume()

return
string|null
Returns the merchant register volume

getCentres()

return
array
Returns array of centres: array<int, array{role: string, code: string, name: ?string}>

Complete Example

use PhpFacturae\Party;

// Company example
$seller = Party::company('B12345678', 'Mi Empresa SL')
    ->address(
        street: 'Calle Mayor 1, 3º A',
        postalCode: '28001',
        town: 'Madrid',
        province: 'Madrid'
    )
    ->tradeName('Nombre Comercial')
    ->email('[email protected]')
    ->phone('+34912345678')
    ->website('https://www.empresa.com')
    ->cnoCnae('6201');

// Person example
$buyer = Party::person(
    taxNumber: '12345678A',
    name: 'Juan',
    firstSurname: 'García',
    lastSurname: 'López'
)
    ->address(
        street: 'Gran Vía 10',
        postalCode: '28013',
        town: 'Madrid',
        province: 'Madrid'
    )
    ->email('[email protected]')
    ->phone('+34987654321');

Build docs developers (and LLMs) love