Skip to content

Commit 33646c1

Browse files
author
MartkCz
committed
updated docs
1 parent db06ce0 commit 33646c1

1 file changed

Lines changed: 25 additions & 56 deletions

File tree

README.md

Lines changed: 25 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,45 @@ composer require webchemistry/invoice
88

99
## Usage
1010

11-
### Company data
11+
### Company
1212

1313
```php
14-
$company = new Company('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA');
14+
$factory = new WebChemistry\Invoice\InvoiceFactory();
15+
$company = $factory->createCompany('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', '0123456789', 'CZ0123456789');
16+
```
17+
18+
### Customer
1519

16-
$company->setFooter('footer');
17-
$company->setTin('1111');
18-
$company->setVaTin('CZ1111');
19-
$company->setLogo(__DIR__ . '/logo.png'); // Recommended height is 106px
20-
$company->setIsTax(TRUE);
20+
```php
21+
$factory = new WebChemistry\Invoice\InvoiceFactory();
22+
$customer = $factory->createCustomer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA');
23+
```
24+
25+
### Account
26+
27+
```php
28+
$factory = new WebChemistry\Invoice\InvoiceFactory();
29+
$account = $factory->createAccount('1111', 'CZ4808000000002353462015', 'GIGACZPX');
2130
```
2231

23-
### Customer data
32+
### Payment info
2433

2534
```php
26-
$customer = new Customer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA');
27-
$customer->setTin('08304431');
28-
$customer->setVaTin('CZ08304431');
35+
$factory = new WebChemistry\Invoice\InvoiceFactory();
36+
$payment = $factory->createPaymentInformation('Kč', '0123456789', '1234', 0.21);
2937
```
3038

31-
### Payment data
39+
### Order
3240

3341
```php
34-
$payment->setAccountNumber('1111');
35-
$payment = new Payment('2353462013/0800', 'Kč', '20150004');
36-
$payment->setIBan('CZ4808000000002353462013');
37-
$payment->setSwift('GIGACZPX');
38-
$payment->setDueDate(new \DateTime('+ 7 days'));
42+
$factory = new WebChemistry\Invoice\InvoiceFactory();
43+
$order = $factory->createOrder('20160001', new \DateTime('+ 14 days'), $account, $payment);
3944
```
4045

4146
Adding items
4247

4348
```php
44-
$payment->addItem(new Item('Logitech G700s Rechargeable Gaming Mouse', 4, 1790));
49+
$order->addItem('Logitech G700s Rechargeable Gaming Mouse', 4, 1790);
4550
```
4651

4752
### Customizing template
@@ -57,7 +62,7 @@ $template = new WebChemistry\Invoice\Data\Template();
5762
```php
5863
$invoice = new \WebChemistry\Invoice\Invoice($company);
5964

60-
$images = $invoice->create($customer, $payment);
65+
$images = $invoice->create($customer, $order);
6166
foreach ($images as $page => $invoice) {
6267
$invoice->save(__DIR__ . "/invoice-$page.jpg");
6368
}
@@ -68,40 +73,6 @@ header('Content-Type: image/jpeg');
6873
echo $images[0]->encode();
6974
```
7075

71-
## Memory optimization
72-
73-
```php
74-
$invoice->setSave(function (Intervention\Image\Image $image, $page) {
75-
$invoice->save(__DIR__ . "/invoice-$page.jpg");
76-
});
77-
```
78-
79-
## Translations
80-
At first visit [core](https://github.com/WebChemistry/Invoice/blob/master/src/Translator.php) component.
81-
82-
Supported languages: English (en), Czech (cs)
83-
84-
Change language:
85-
```php
86-
$invoce->getTranslator()->setLang('en');
87-
```
88-
89-
Custom translator:
90-
```php
91-
92-
class MyTranslator implements Nette\Localization\ITranslator {
93-
94-
public function translate($message, $count = NULL) { // $count is unnecessary
95-
// ...
96-
}
97-
98-
}
99-
100-
$invoice->setTranslator(new MyTranslator());
101-
```
102-
103-
or you can send pull-request with your translation to core component.
104-
10576
## Generating preview
10677

10778
```php
@@ -126,8 +97,6 @@ invoice:
12697
## Optional
12798
tin:
12899
vaTin:
129-
logo:
130-
footer:
131100
isTax:
132101
```
133102

@@ -148,4 +117,4 @@ First page:
148117
![first page](http://i.imgbox.com/pwFByZ1L.jpg)
149118

150119
Second page:
151-
![second page](http://i.imgbox.com/ebrwXldf.jpg)
120+
![second page](http://i.imgbox.com/ebrwXldf.jpg)

0 commit comments

Comments
 (0)