Skip to main content

Receipt Generation

Basics

A complete example of generating a receipt is demonstrated in the following file: ./examples/document/receipt/create_receipt_with_custom_data.php

To generate a receipt, the following steps are required:

// 1. Creating a receipt
// (issuing a receipt in Hungarian language (Ft) paid in cash)
$receipt = new Receipt();

// 2. Initializing the header
$receipt->setHeader(new ReceiptHeader());

// 3. Setting the prefix
$receipt->getHeader()->setPrefix('RECEIPT');

// 4. Composing the receipt item with default data
// (1 sales item with 27% VAT content)
$item = new ReceiptItem('Sales item', 10000.0);

// a) Setting the net price of the item
$item->setNetPrice(10000.0);

// b) Setting the VAT amount of the item
$item->setVatAmount(2700.0);

// c) Setting the gross amount of the item
$item->setGrossAmount(12700.0);

// d) Adding item data to the receipt
$receipt->addItem($item);

// 5. Creating the receipt (generating)
$result = $agent->generateReceipt($receipt);

Expected and Optional Inputs

Receipt Header Data

DescriptionFieldTypeRequiredDefault Value
Call IDcallIdstring
Prefixprefixstringyes
Payment MethodpaymentMethodstringyescash
CurrencycurrencystringyesFt
Exchange BankexchangeBankstring
Exchange RateexchangeRatestring
Commentcommentstring
PDF TemplatepdfTemplatestring
Buyer Ledger IDbuyerLedgerIdstring

Receipt Item Data

DescriptionFieldTypeRequiredDefault Value
IDidstring
Quantityquantitydoubleyes
Quantity UnitquantityUnitstringyes
Net Unit PricenetUnitPricedoubleyes
VAT Ratevatstringyes
Net PricenetPricedoubleyes
VAT AmountvatAmountdoubleyes
Gross AmountgrossAmountdoubleyes
Ledger DataledgerDataReceiptItemLedger
Commentcommentstring

Receipt Item Ledger Data

DescriptionFieldTypeRequiredDefault Value
Revenue Ledger NumberrevenueLedgerNumberstring
VAT Ledger NumbervatLedgerNumberstring

Credit Note Data (Payment)

DescriptionFieldTypeRequiredDefault Value
Payment MethodpaymentMethodstringyescash
Amountamountdoubleyes
Descriptiondescriptionstring