All Projects → sandervanhooft → Laravel Invoicable

sandervanhooft / Laravel Invoicable

Licence: mit
Easy invoice creation for Laravel

Projects that are alternatives of or similar to Laravel Invoicable

Eloquent Approval
Approval process for Laravel Eloquent models
Stars: ✭ 79 (-33.05%)
Mutual labels:  eloquent, laravel
Laravel Prefixed Ids
Friendly prefixed IDs for Laravel models
Stars: ✭ 88 (-25.42%)
Mutual labels:  eloquent, laravel
Laravel Approvable
Easily add an approval process to any laravel model.
Stars: ✭ 79 (-33.05%)
Mutual labels:  eloquent, laravel
Laravel Lucene Search
Laravel 4.2, 5.* package for full-text search over Eloquent models based on ZF2 Lucene.
Stars: ✭ 75 (-36.44%)
Mutual labels:  eloquent, laravel
Laravel Settings
Store key value pair in database as settings
Stars: ✭ 107 (-9.32%)
Mutual labels:  eloquent, laravel
Laravel Schedulable
Schedule and unschedule eloquent models elegantly without cron jobs
Stars: ✭ 78 (-33.9%)
Mutual labels:  eloquent, laravel
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (-25.42%)
Mutual labels:  eloquent, laravel
Laravel Optimistic Locking
Adds optimistic locking feature to eloquent models.
Stars: ✭ 71 (-39.83%)
Mutual labels:  eloquent, laravel
Laravel Translatable
Making Eloquent models translatable
Stars: ✭ 1,390 (+1077.97%)
Mutual labels:  eloquent, laravel
Sarala
Javascript library to communicate with RESTful API built following JSON API specification. inspired by Laravel’s Eloquent
Stars: ✭ 101 (-14.41%)
Mutual labels:  eloquent, laravel
Laravel Ownership
Laravel Ownership simplify management of Eloquent model's owner.
Stars: ✭ 71 (-39.83%)
Mutual labels:  eloquent, laravel
Laravel Cacheable
Rinvex Cacheable is a granular, intuitive, and fluent caching system for eloquent models. Simple, but yet powerful, plug-n-play with no hassle.
Stars: ✭ 107 (-9.32%)
Mutual labels:  eloquent, laravel
Elasticquent
Maps Laravel Eloquent models to Elasticsearch types
Stars: ✭ 1,172 (+893.22%)
Mutual labels:  eloquent, laravel
Requent
A GraphQL like interface to map a request to eloquent query with data transformation for Laravel.
Stars: ✭ 78 (-33.9%)
Mutual labels:  eloquent, laravel
Eloquent Settings
Eloquent Settings allows you to bind key-value pairs to any Laravel Eloquent model. It supports even casting for boolean, float or integer types.
Stars: ✭ 71 (-39.83%)
Mutual labels:  eloquent, laravel
Flattable
It helps you manage de-normalized tables
Stars: ✭ 81 (-31.36%)
Mutual labels:  eloquent, laravel
Eloquentfilter
An Eloquent Way To Filter Laravel Models And Their Relationships
Stars: ✭ 1,113 (+843.22%)
Mutual labels:  eloquent, laravel
Watchable
Enable users to watch various models in your application.
Stars: ✭ 65 (-44.92%)
Mutual labels:  eloquent, laravel
Laravel Likeable
Rate Eloquent models with Likes and Dislikes in Laravel. Development moved to Laravel Love package!
Stars: ✭ 95 (-19.49%)
Mutual labels:  eloquent, laravel
Invoice As A Service
💰 Simple invoicing service (REST API): from JSON to PDF
Stars: ✭ 106 (-10.17%)
Mutual labels:  invoice, laravel

laravel-invoicable

Latest Version on Packagist Software License Build Status Total Downloads

Easy invoice creation for Laravel. Unlike Laravel Cashier, this package is payment gateway agnostic.

If you're looking for Mollie payment processing, be sure to check out laravel-payable-redirect-mollie.

Structure

database/
resources
src/
tests/
vendor/

Install

Via Composer

$ composer require sander-van-hooft/laravel-invoicable

Next, you must install the service provider if you work with Laravel 5.4:

// config/app.php
'providers' => [
    ...
    SanderVanHooft\Invoicable\InvoicableServiceProvider::class,
];

You can publish the migration with:

$ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="migrations"

After the migration has been published you can create the invoices and invoice_lines tables by running the migrations:

$ php artisan migrate

Optionally, you can also publish the invoicable.php config file with:

$ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="config"

This is what the default config file looks like:

return [
    'default_currency' => 'EUR',
    'default_status' => 'concept',
    'locale' => 'nl_NL',
];

If you'd like to override the design of the invoice blade view and pdf, publish the view:

$ php artisan vendor:publish --provider="SanderVanHooft\Invoicable\InvoicableServiceProvider" --tag="views"

You can now edit receipt.blade.php in <project_root>/resources/views/invoicable/receipt.blade.php to match your style.

Usage

Money figures are in cents!

Add the invoicable trait to the Eloquent model which needs to be invoiced (typically an Order model):

use Illuminate\Database\Eloquent\Model;
use SanderVanHooft\Invoicable\IsInvoicable\IsInvoicableTrait;

class Order extends Model
{
    use IsInvoicableTrait; // enables the ->invoices() Eloquent relationship
}

Now you can create invoices for an Order:

$order = Order::first();
$invoice = $order->invoices()->create([]);

// To add a line to the invoice, use these example parameters:
//  Amount:
//      121 (€1,21) incl tax
//      100 (€1,00) excl tax
//  Description: 'Some description'
//  Tax percentage: 0.21 (21%)
$invoice = $invoice->addAmountInclTax(121, 'Some description', 0.21);
$invoice = $invoice->addAmountExclTax(100, 'Some description', 0.21);

// Invoice totals are now updated
echo $invoice->total; // 242
echo $invoice->tax; // 42

// Set additional information (optional)
$invoice->currency; // defaults to 'EUR' (see config file)
$invoice->status; // defaults to 'concept' (see config file)
$invoice->receiver_info; // defaults to null
$invoice->sender_info; // defaults to null
$invoice->payment_info; // defaults to null
$invoice->note; // defaults to null

// access individual invoice lines using Eloquent relationship
$invoice->lines;
$invoice->lines();

// Access as pdf
$invoice->download(); // download as pdf (returns http response)
$invoice->pdf(); // or just grab the pdf (raw bytes)

// Handling discounts
// By adding a line with a negative amount.
$invoice = $invoice->addAmountInclTax(-121, 'A nice discount', 0.21);

// Or by applying the discount and discribing the discount manually
$invoice = $invoice->addAmountInclTax(121 * (1 - 0.30), 'Product XYZ incl 30% discount', 0.21);

// Convenience methods
Invoice::findByReference($reference);
Invoice::findByReferenceOrFail($reference);
$invoice->invoicable() // Access the related model

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].