Skip to main content

Generating a Cancellation Invoice

Basics

The example for generating a cancellation invoice is illustrated in the following file:

./examples/document/invoice/create_reverse_invoice.php

The steps required to generate the invoice are as follows:

// 1. Create a new cancellation invoice with custom data
$invoice = new ReverseInvoice(ReverseInvoice::INVOICE_TYPE_P_INVOICE);

// 2. Retrieve the invoice header
$header = $invoice->getHeader();

// 3. Set the invoice number
$header->setInvoiceNumber('TESZT-001');

// 4. Set the invoice issue date
$header->setIssueDate('2021-03-19');

// 5. Create the seller
$seller = new Seller();

// 6. Set seller email details
$seller->setEmailReplyTo('hello@evulon.hu');
$seller->setEmailSubject('Invoice Notification');
$seller->setEmailContent('Please pay the invoice, otherwise the current bank...');

// 7. Add the seller to the invoice
$invoice->setSeller($seller);

// 8. Create the buyer
$buyer = new Buyer();

// 9. Set the buyer's email address
$buyer->setEmail('vevoneve@example.org');

// 10. Add the buyer to the invoice
$invoice->setBuyer($buyer);

// 11. Generate the cancellation invoice
$result = $agent->generateReverseInvoice($invoice);

Required and Optional Inputs

Invoice Header Data

Invoice Header DataFieldTypeRequiredDefault
invoice numberinvoiceNumberstringyes
issue dateissueDatedate
fulfillment datefulFillmentdate
commentcommentstring
invoice templateinvoiceTemplateint

Seller Data

Seller DataFieldTypeRequiredDefault
email reply-toemailReplyTostring
email subjectemailSubjectstring
email contentemailContentstring

Buyer Data

Buyer DataFieldTypeRequiredDefault
emailemailstring