Invoice Generation
Basics
A complete example of generating a standard invoice can be found in the following file:
./examples/document/invoice/create_invoice_with_custom_data.php
The steps required for generating an invoice are as follows:
// 1. Creating a paper invoice (invoice to be paid by bank transfer, in Hungarian language (HUF), with today's issue and fulfillment date, and payment due in +8 days).
$invoice = new Invoice(Invoice::INVOICE_TYPE_P_INVOICE);
// 2. Adding custom header data to the invoice (e.g., invoice image template)
$invoice->getHeader()->setInvoiceTemplate(Invoice::INVOICE_TEMPLATE_8CM);
// 3. Adding seller data to the invoice
$invoice->setSeller(new Seller('OBER', '11111111-22222222-33333333'));
// 4. Adding buyer data (mandatory fields)
$buyer = new Buyer('Kovacs Bt.', '2030', 'Érd', 'Tarnoki street 23.');
// a) Adding buyer data to the invoice
$invoice->setBuyer($buyer);
// 5. Compiling invoice item with default data
// (1 item with 27% VAT content)
$item = new InvoiceItem('Item 1', 10000.0);
// a) Setting the net value of the item
$item->setNetPrice(10000.0);
// b) Setting the VAT amount of the item
$item->setVatAmount(2700.0);
// c) Setting the gross value of the item
$item->setGrossAmount(12700.0);
// d) Adding item data to the invoice
$invoice->addItem($item);
// 6. Generating the invoice
$result = $agent->generateInvoice($invoice);
Expected and Optional Inputs
Invoice Header Data
| Invoice Header Data | Field | Type | Mandatory | Default Value |
|---|---|---|---|---|
| Type | invoiceType | int | Yes | 1 |
| Issue Date | issueDate | date | Yes | Today |
| Fulfillment Date | fulfillment | date | Yes | Today |
| Payment Due | paymentDue | date | Yes | Issue date + 8 days |
| Payment Method | paymentMethod | string | Yes | Bank transfer |
| Currency | currency | string | Yes | Ft |
| Language | language | string | Yes | hu |
| Comment | comment | string | ||
| Exchange Bank | exchangeBank | string | ||
| Exchange Rate | exchangeRate | string | ||
| Order Number | orderNumber | string | ||
| Pro Forma Number | proformaNumber | string | ||
| Corrected Number | correctivedNumber | string | ||
| Logo | extraLogo | string | ||
| Prefix | prefix | string | ||
| Correction to Pay | correctionToPay | double | ||
| Paid | paid | boolean | false | |
| Profit VAT (being discontinued) | profitVat | boolean | false | |
| EU VAT | euVat | boolean | false | |
| Invoice Template | invoiceTemplate | string | SzlaMost | |
| Preview PDF | previewPdf | boolean | false | |
| Prepayment Invoice Number | prePaymentInvoiceNumber | string | ||
| Simplified Invoice Image | simpleItems | boolean | false |
The single-line margin VAT base method will be discontinued on 15 February 2027: do not use the header-level profitVat and the item-level priceGapVatBase fields in new integrations, and switch existing integrations before the cut-off date. Issue margin-scheme (differential VAT) invoices split into two line items: the first item is the purchase price of the underlying service/product with the K.AFA VAT code, the second item is the margin amount with the 27% VAT rate. Details on the Számla Agent VAT rates - K.AFA page; tour operators should also see the Simplified item data for tour operators page.
Simplified invoice image for tour operators (simpleItems)
Under Section 210/A of the Hungarian VAT Act (in force since 1 January 2026), tour operators are, as a general rule, not required to display the tax base and the amount of the margin-scheme VAT on the invoice image. From PHP API version 2.12.4 this is supported by the optional boolean simpleItems header field: when enabled, the invoice is issued with a simplified invoice image that hides the price and VAT details from the buyer, while the NAV Online Invoice data submission remains complete.
This function may only be used lawfully by taxable persons providing travel services under Section 210/A of the Hungarian VAT Act (tour operators). Using it for any other activity is not permitted.
Enable it on the invoice header with the setSimpleItems() method:
$invoice = new Invoice(Invoice::INVOICE_TYPE_P_INVOICE);
$invoice->getHeader()->setSimpleItems(true);
true: the<simpleItems>true</simpleItems>field is added to the header of the generated XML, and the document is created with the simplified (tour operator) invoice image.falseor not set (default): the field is not included in the XML at all, the system works in the default (non tour operator) mode.
A complete example can be found in ./examples/document/invoice/create_invoice_with_custom_data.php.
The feature cannot be used with a delivery note (DeliveryNote) or a corrective invoice (CorrectiveInvoice): in these cases the API throws a SzamlaAgentException with the message Egyszerűsített számlaképet szállítólevél és helyesbítő számla esetén nem lehet használni before the request is sent. On a reverse (storno) invoice the setting has no effect, because the reversal XML does not contain this field; the reversal inherits the state of the original document on the server side.
The server enforces further validation rules for requests with simpleItems enabled: at most 2 items, only Hungarian VAT rates, OSS must be off and the seller's tax number must be Hungarian, and the invoice template is overridden by the simplified view. Failing requests are rejected with error codes 551 to 556. For the full description, including what the buyer sees on the invoice and the behaviour per document type, see the Számla Agent page Simplified item data for tour operators (simpleItems).
Regardless of the simpleItems setting, the NAV Online Invoice data submission always contains the full item data, including the tax base and the amount of the VAT charged. The invoice image and the data visible in the NAV system may therefore differ; this is part of how the function works.
Seller Data
| Seller Data | Field | Type | Mandatory | Default Value |
|---|---|---|---|---|
| Bank | bank | string | ||
| Bank Account | bankAccount | string | ||
| Signatory Name | signatoryName | string | ||
| Email Reply To | emailReplyTo | string | ||
| Email Subject | emailSubject | string | ||
| Email Content | emailContent | string |
Buyer Data
| Buyer Data | Field | Type | Mandatory | Default Value |
|---|---|---|---|---|
| Identifier | id | string | ||
| Name | name | string | Yes | |
| Country | country | string | ||
| Zip Code | zipCode | string | Yes | |
| City | city | string | Yes | |
| Address | address | string | Yes | |
email | string | |||
| Send Email | sendEmail | boolean | true | |
| Tax Number | taxNumber | string | ||
| Group Identifier | groupIdentifier | string | ||
| EU Tax Number | taxNumberEU | string | ||
| Postal Name | postalName | string | ||
| Postal Country | postalCountry | string | ||
| Postal Zip | postalZip | string | ||
| Postal City | postalCity | string | ||
| Postal Address | postalAddress | string | ||
| Ledger Data | ledgerData | LedgerData | ||
| Signatory Name | signatoryName | string | ||
| Phone | phone | string | ||
| Comment | comment | string |
If the issuer account's tax type is new KATA and the account-level protection is on, a request that would invoice a business (typically when taxNumber or taxNumberEU is set) is rejected with error code 491. The setting is at Tax and financial data. Full description: Számla Agent New KATA protection.
Invoice notification
To send the invoice notification email after the invoice is created, set the buyer’s address with setEmail(...) and enable sending with setSendEmail(true).
There is no separate multi-recipient list: use the single email field (string) for all addresses. Separate multiple recipients with a comma, semicolon, or space; several such separators in a row are allowed. The server splits the string on these characters, trims each part, and every resulting part must be a valid email address on its own.
Optional seller fields emailReplyTo, emailSubject, and emailContent customize the notification message; see ./examples/document/invoice/create_invoice_with_custom_data.php.
Buyer Ledger Data
| Buyer Ledger Data | Field | Type | Mandatory | Default Value |
|---|---|---|---|---|
| Buyer Identifier | buyerId | string | ||
| Booking Date | bookingDate | date | Yes | |
| Buyer Ledger Number | buyerLedgerNumber | string | ||
| Continued Fulfillment | continuedFulfillment | boolean | Yes | false |
| Settlement Period Start | settlementPeriodStart | date | ||
| Settlement Period End | settlementPeriodEnd | date |
Invoice Item Data
| Invoice Item Data | Field | Type | Mandatory | Default Value |
|---|---|---|---|---|
| Identifier | id | string | ||
| Name | name | string | Yes | |
| Quantity | quantity | double | Yes | |
| Quantity Unit | quantityUnit | string | Yes | |
| Net Unit Price | netUnitPrice | double | Yes | |
| VAT | vat | string | Yes | |
| Price Gap VAT Base (being discontinued) | priceGapVatBase | double | ||
| Net Price | netPrice | double | Yes | |
| VAT Amount | vatAmount | double | Yes | |
| Gross Amount | grossAmount | double | Yes | |
| Comment | comment | comment | ||
| Count of Data eraser code | dataDeletionCode | integer |
The priceGapVatBase (price gap VAT base) field will be discontinued on 15 February 2027; do not use it in new integrations. For margin-scheme invoices submit two line items (K.AFA + 27%), see the warning at the profitVat field above and the Számla Agent VAT rates - K.AFA page.
Invoice Item Ledger Data
| Invoice Item Ledger Data | Field | Type | Mandatory | Default Value |
|---|---|---|---|---|
| Revenue Ledger Number | revenueLedgerNumber | string | ||
| VAT Ledger Number | vatLedgerNumber | string | ||
| Economic Event Type | economicEventType | string | ||
| VAT Economic Event Type | vatEconomicEventType | string | ||
| Settlement Period Start | settlementPeriodStart | date | ||
| Settlement Period End | settlementPeriodEnd | date |