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
Description | Field | Type | Required | Default Value |
---|---|---|---|---|
Call ID | callId | string | ||
Prefix | prefix | string | yes | |
Payment Method | paymentMethod | string | yes | cash |
Currency | currency | string | yes | Ft |
Exchange Bank | exchangeBank | string | ||
Exchange Rate | exchangeRate | string | ||
Comment | comment | string | ||
PDF Template | pdfTemplate | string | ||
Buyer Ledger ID | buyerLedgerId | string |
Receipt Item Data
Description | Field | Type | Required | Default Value |
---|---|---|---|---|
ID | id | string | ||
Quantity | quantity | double | yes | |
Quantity Unit | quantityUnit | string | yes | |
Net Unit Price | netUnitPrice | double | yes | |
VAT Rate | vat | string | yes | |
Net Price | netPrice | double | yes | |
VAT Amount | vatAmount | double | yes | |
Gross Amount | grossAmount | double | yes | |
Ledger Data | ledgerData | ReceiptItemLedger | ||
Comment | comment | string | ||
Count of Data eraser code | dataDeletionCode | integer |
Receipt Item Ledger Data
Description | Field | Type | Required | Default Value |
---|---|---|---|---|
Revenue Ledger Number | revenueLedgerNumber | string | ||
VAT Ledger Number | vatLedgerNumber | string |
Credit Note Data (Payment)
Description | Field | Type | Required | Default Value |
---|---|---|---|---|
Payment Method | paymentMethod | string | yes | cash |
Amount | amount | double | yes | |
Description | description | string |