You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-3Lines changed: 39 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,3 @@
1
-
2
1
# Manage invoices in your Laravel App
3
2
4
3
[](https://packagist.org/packages/finller/laravel-invoices)
@@ -80,10 +79,47 @@ return [
80
79
81
80
## Usage
82
81
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
+
83
86
```php
84
87
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.
85
100
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;
86
120
$invoice = new Invoice();
121
+
$invoice->prefix = "SPECIAL";
122
+
$invoice->serie = $buyer_id;
87
123
$invoice->save();
88
124
```
89
125
@@ -107,8 +143,8 @@ Please review [our security policy](../../security/policy) on how to report secu
0 commit comments