- Benchmark
- Setup
- Preview with minimal setup
- Entities
- Data providers
- Generating invoices
- Neon configuration
- Templates
Average output is ~9ms for pdf and ~ 1ms for svg
use Contributte\Invoice\Preview\PreviewFactory;
use Contributte\Invoice\Templates\ParaisoTemplate;
$template = new ParaisoTemplate();
// pdf
echo $template->renderToPdf(PreviewFactory::createOrder());
// svg
echo $template->renderToSvg(PreviewFactory::createOrder());
We have following entities: Company (seller), Customer, Account (bank account), Payment Info, Currency, Timestamps, Order and Item.
use Contributte\Invoice\Data\Company;
$company = new Company('Contributte', 'Prague', 'U haldy', '110 00', 'Czech Republic', 'CZ08304431', '08304431');
use Contributte\Invoice\Data\Customer;
$customer = new Customer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', 'CZ08304431', '08304431');
use Contributte\Invoice\Data\Account;
$account = new Account('CZ4808000000002353462013');
use Contributte\Invoice\Data\Account;
use Contributte\Invoice\Data\PaymentInformation;
$payment = new PaymentInformation(
[new Account('CZ4808000000002353462013')],
);
use Contributte\Invoice\Data\Account;
use Contributte\Invoice\Data\Company;
use Contributte\Invoice\Data\Customer;
use Contributte\Invoice\Data\Order;
use Contributte\Invoice\Data\PaymentInformation;
use Contributte\Invoice\Data\Timestamps;
$order = new Order(
date('Y') . '0001',
'$ 15.000,00',
new Company('Contributte', 'Prague', 'U haldy', '110 00', 'Czech Republic', 'CZ08304431', '08304431'),
new Customer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', 'CZ08304431', '08304431'),
new PaymentInformation(
[new Account('CZ4808000000002353462013')],
),
new Timestamps(
(new DateTime())->format('Y-m-d'),
(new DateTime('+ 1 week'))->format('Y-m-d'),
),
);
use Contributte\Invoice\Data\Item;
$order->addInlineItem('Logitech G700s Rechargeable Gaming Mouse', '$ 1.790,00', 4, '$ 7.160,00');
// or
$order->addItem(new Item('Logitech G700s Rechargeable Gaming Mouse', '$ 1.790,00', 4, '$ 7.160,00'));
In most applications we need only one seller and one or more same accounts. We use for them prepared data providers
use Contributte\Invoice\Data\Account;
use Contributte\Invoice\Data\Company;
use Contributte\Invoice\Provider\InvoiceAccountsProvider;
use Contributte\Invoice\Provider\InvoiceCompanyProvider;
$companyProvider = new InvoiceCompanyProvider(new Company(...));
$companyProvider->getCompany();
$accountsProvider = new InvoiceAccountsProvider([
new Account(...),
]);
$accountsProvider->getAccounts();
$accountsProvider->getAccount();
header('Content-Type: application/pdf; charset=utf-8');
echo $template->renderToPdf($order);
if you use nette, recommended way is
use Contributte\Invoice\Bridge\Nette\Response\InvoicePdfResponse;
class CustomPresenter {
public function actionPreview() {
// declare $template and $order
$this->sendResponse(new InvoicePdfResponse($template, $order));
}
}
extensions:
invoice: Contributte\Invoice\DI\InvoiceExtension
invoice:
company:
name: string
town: string
address: string
zip: string
country: string
## Optional below
vatNumber: string
id: string
accounts:
-
iban: string