Skip to content

Commit 442326a

Browse files
committed
better readme
1 parent c4b087f commit 442326a

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Manage invoices in your Laravel App
32

43
[![Latest Version on Packagist](https://img.shields.io/packagist/v/finller/laravel-invoices.svg?style=flat-square)](https://packagist.org/packages/finller/laravel-invoices)
@@ -80,10 +79,47 @@ return [
8079

8180
## Usage
8281

82+
## Store an invoice in your database
83+
84+
An invoice is just a model with InvoiceItem relationships, so you can create an invoice just like that:
85+
8386
```php
8487
use Finller\Invoice\Invoice;
88+
$invoice = new Invoice();
89+
$invoice->save();
90+
91+
$invoice->items()->saveMany([
92+
new InvoiceItem(),
93+
new InvoiceItem(),
94+
]);
95+
```
96+
97+
## Generate unique serial numbers automatically
98+
99+
This package provid an easy way to generate explicite serial number like "INV-0001" in a safe and automatic way.
85100

101+
You can configure the format of your serial number in the config file. The default format is `PPYYCCCC``(see config to understand the meaning of each letters).
102+
103+
Each time you create a new invoice, and if `invoices.serial_number.auto_generate` is set to `true`, the invoice will be given a unique serial number.
104+
105+
Serial number are generated one after the other, the new generated serial number is based on the `latest` one available.
106+
To determine which is the `latest` serial number you can extends `Finller\Invoice\Invoice`
107+
and override the `getLatestSerialNumber` method.
108+
By default the lastest invoice is queried like that `static::query()->latest('serial_number')->first();`.
109+
110+
## Managing multiple prefix and multiple series
111+
112+
In more complex app, you might need to have different prefix and/or series for your invoices.
113+
114+
For example, you might want to define a serie for each of your user and having serial numbers looking like: INV0001-00X where 1 is the id of the user.
115+
116+
When creating an invoice, you can define the prefix and the serie on the fly like that;
117+
118+
```php
119+
use Finller\Invoice\Invoice;
86120
$invoice = new Invoice();
121+
$invoice->prefix = "SPECIAL";
122+
$invoice->serie = $buyer_id;
87123
$invoice->save();
88124
```
89125

@@ -107,8 +143,8 @@ Please review [our security policy](../../security/policy) on how to report secu
107143

108144
## Credits
109145

110-
- [Quentin Gabriele](https://github.com/QuentinGab)
111-
- [All Contributors](../../contributors)
146+
- [Quentin Gabriele](https://github.com/QuentinGab)
147+
- [All Contributors](../../contributors)
112148

113149
## License
114150

0 commit comments

Comments
 (0)