yeknava / simple-invoice
simple invoice package for laravel
0.2
2020-07-29 19:49 UTC
Requires
- php: >= 7.1
- ext-json: *
- illuminate/database: 5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*
- illuminate/support: 5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*
- nesbot/carbon: ^2.0@dev
Requires (Dev)
- fzaninotto/faker: ^1.4
- orchestra/testbench: ^5.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.1
This package is auto-updated.
Last update: 2025-04-29 01:03:10 UTC
README
Laravel Simple Invoice Package.
Installation
Use the package manager composer to install simple invoice package.
composer require yeknava/simple-invoice
Usage
Run this command in your terminal:
php artisan vendor:publish
Add Biller trait to payers models and Add InvoiceOwner trait to payee models if there is any.
<?php
use Yeknava\SimpleInvoice\Biller;
class User extends Model {
use Biller;
}
<?php
use Yeknava\SimpleInvoice\InvoiceOwner;
class OwnerModel extends Model {
use InvoiceOwner;
}
$user = User::find(1);
$user1 = (new UserModel([]));
$user1->save();
$user2 = (new OwnerModel([]));
$user2->save();
$invoice = $user1->newBill('bill title');
$invoice->setOwner($user2);
$invoice->addItem((new InvoiceItem(1000, 'item1'))
->setTax(100)
->setItem(ItemModel::find(1))
->setQuantity(5)
->setShippingPrice(100)
->setDiscountInPercent(10));
$invoice->addItem((new InvoiceItem(1000, 'item2'))
->setTax(100)
->setQuantity(5)
->setShippingPrice(100)
->setDiscountInPercent(10));
$generatedInvoice = $invoice->setExpiredDate(Carbon::now())->generate();
try {
$generatedInvoice->paid();
} catch (ExpiredInvoiceException $e) {
}
$invoice = $invoice->setExpiredDate(Carbon::now()->addDay())->generate();
$invoice = $invoice->paid();
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.