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 | profitVat | boolean | false | |
EU VAT | euVat | boolean | false | |
Invoice Template | invoiceTemplate | string | SzlaMost | |
Preview PDF | previewPdf | boolean | false | |
Prepayment Invoice Number | prePaymentInvoiceNumber | string |
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 |
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 | 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 |
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 |