Statistics
198
11
0
47d
Badges
Dependencies

Build Status

PHP Invoice

Installation

php 7.1

composer require webchemistry/invoice

php 5.5

composer require webchemistry/invoice:^1.0

Usage

Company

$company = WebChemistry\Invoice\InvoiceFactory::createCompany('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', '0123456789', 'CZ0123456789');

Customer

$customer = WebChemistry\Invoice\InvoiceFactory::createCustomer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA');

Account

$account = WebChemistry\Invoice\InvoiceFactory::createAccount('1111', 'CZ4808000000002353462015', 'GIGACZPX');

Payment info

$payment = WebChemistry\Invoice\InvoiceFactory::createPaymentInformation('', '0123456789', '1234', 0.21);

Order

$order = WebChemistry\Invoice\InvoiceFactory::createOrder('20160001', new \DateTime('+ 14 days'), $account, $payment);

Adding items

$order->addItem('Logitech G700s Rechargeable Gaming Mouse', 4, 1790);

Customizing

$template = new WebChemistry\Invoice\Data\Template();

// ...
class CustomFormatter implements IFormatter {
	
	/**
	 * @param float $float
	 * @return string
	 */
	public function formatNumber($float) {}

	/**
	 * @param float $float
	 * @param string $currency
	 * @return string
	 */
	public function formatMoney($float, $currency) {}

	/**
	 * @param \DateTime $date
	 * @return string
	 */
	public function formatDate(\DateTime $date) {}
	
}

Generating invoices

$invoice = new \WebChemistry\Invoice\Invoice($company);

$images = $invoice->create($customer, $order);
foreach ($images as $page => $invoice) {
	$invoice->save(__DIR__ . "/invoice-$page.jpg");
}

// Show first page

header('Content-Type: image/jpeg');
echo $images[0]->encode();

Generating preview

header('Content-Type: image/jpeg');
echo $invoice->generatePreview();

Nette DI

extensions:
	invoice: WebChemistry\Invoice\DI\InvoiceExtension

invoice:
	lang: en
	company:
		name:
		town:
		address:
		zip:
		country:
		## Optional
		tin:
		vaTin:
		isTax:

class Component {

	public function __construct(WebChemistry\Invoice\Invoice $invoice) {
		// ...
	}
}

Previews

First page: first page

Second page: second page

Customizing: customizing

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com