Skip to main content

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 DataFieldTypeMandatoryDefault Value
TypeinvoiceTypeintYes1
Issue DateissueDatedateYesToday
Fulfillment DatefulfillmentdateYesToday
Payment DuepaymentDuedateYesIssue date + 8 days
Payment MethodpaymentMethodstringYesBank transfer
CurrencycurrencystringYesFt
LanguagelanguagestringYeshu
Commentcommentstring
Exchange BankexchangeBankstring
Exchange RateexchangeRatestring
Order NumberorderNumberstring
Pro Forma NumberproformaNumberstring
Corrected NumbercorrectivedNumberstring
LogoextraLogostring
Prefixprefixstring
Correction to PaycorrectionToPaydouble
Paidpaidbooleanfalse
Profit VATprofitVatbooleanfalse
EU VATeuVatbooleanfalse
Invoice TemplateinvoiceTemplatestringSzlaMost
Preview PDFpreviewPdfbooleanfalse
Prepayment Invoice NumberprePaymentInvoiceNumberstring

Seller Data

Seller DataFieldTypeMandatoryDefault Value
Bankbankstring
Bank AccountbankAccountstring
Signatory NamesignatoryNamestring
Email Reply ToemailReplyTostring
Email SubjectemailSubjectstring
Email ContentemailContentstring

Buyer Data

Buyer DataFieldTypeMandatoryDefault Value
Identifieridstring
NamenamestringYes
Countrycountrystring
Zip CodezipCodestringYes
CitycitystringYes
AddressaddressstringYes
Emailemailstring
Send EmailsendEmailbooleantrue
Tax NumbertaxNumberstring
Group IdentifiergroupIdentifierstring
EU Tax NumbertaxNumberEUstring
Postal NamepostalNamestring
Postal CountrypostalCountrystring
Postal ZippostalZipstring
Postal CitypostalCitystring
Postal AddresspostalAddressstring
Ledger DataledgerDataLedgerData
Signatory NamesignatoryNamestring
Phonephonestring
Commentcommentstring

Buyer Ledger Data

Buyer Ledger DataFieldTypeMandatoryDefault Value
Buyer IdentifierbuyerIdstring
Booking DatebookingDatedateYes
Buyer Ledger NumberbuyerLedgerNumberstring
Continued FulfillmentcontinuedFulfillmentbooleanYesfalse
Settlement Period StartsettlementPeriodStartdate
Settlement Period EndsettlementPeriodEnddate

Invoice Item Data

Invoice Item DataFieldTypeMandatoryDefault Value
Identifieridstring
NamenamestringYes
QuantityquantitydoubleYes
Quantity UnitquantityUnitstringYes
Net Unit PricenetUnitPricedoubleYes
VATvatstringYes
Price Gap VAT BasepriceGapVatBasedouble
Net PricenetPricedoubleYes
VAT AmountvatAmountdoubleYes
Gross AmountgrossAmountdoubleYes
Commentcommentcomment
Count of Data eraser codedataDeletionCodeinteger

Invoice Item Ledger Data

Invoice Item Ledger DataFieldTypeMandatoryDefault Value
Revenue Ledger NumberrevenueLedgerNumberstring
VAT Ledger NumbervatLedgerNumberstring
Economic Event TypeeconomicEventTypestring
VAT Economic Event TypevatEconomicEventTypestring
Settlement Period StartsettlementPeriodStartdate
Settlement Period EndsettlementPeriodEnddate