Skip to content

This package is built for Invoice Management and Generation for Laravel 5.5+, 6.x, 7.x (not tested for lower versions)

License

Notifications You must be signed in to change notification settings

dgvai/laravel-invoicer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Invoicer - Invoice Generator Package for Laravel

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

This package is built for Invoice Management and Generation for Laravel 5.5+, 6.x, 7.x (not tested for lower versions)

Contents

Installation

You can install the package via composer:

    composer require dgvai/laravel-invoicer

Publish Configuration

Publish configuration file

    php artisan vendor:publish --provider="DGvai\Invoicer\InvoicerServiceProvider"

Setup and configure

You can update your app environment (.env) (If needed). The environment Values are all your choice. Peek a look at config/invoicer.php

Configure your configuration file, the required details for the values are documentated as commented in config/invoicer.php file.

After done configuraing

    php artisan config:cache

Usage

Generate Invoice

From your controller:

use DGvai\Invoicer\Invoicer;
use App\Http\Controllers\Controller;

class InvoiceController extends Controller
{
    public function show()
    {

        $invoice = new Invoicer();
        $invoice->setupInvoice('#HDG-4657F-DH8')
                ->setBuyer('John Doe','email@email.com','0100001000')
                ->setShippingAddr('0/3B Abul Tabul Conference Road, DG Street, China');

        $invoice->addItem('Lorem Ipsum Product Name 1',3.5,'Pc',230.5,20)
                ->addItem('Lorem Ipsum Product Name 2',3,'Kg',120.33,10.2,60)
                ->addItem('Bigger Abul Tabul Product Name This Time',1,'Pc',550.52,10,10);

        $invoice->setPaymentState('UNPAID','important','Pay before 24-02-2020');

        $pdf = $invoice->generate();

        if($pdf->success)
        {
            return $pdf->filename;
        }
    }
}

NOTE This is the minimalist basic need to generate invoice PDF.
Example PDF Have look at this example pdf generated.
Example PDF (v2) Have look at this advanced example (v2) pdf generated.

Available Methods

Setup Invoice

Description: Setup the invoice.

    setupInvoice($invoice_no, $issue_date = null)

Params
required Invoice No : string
optional Issue Date : string : By default it will take current date.

Setup Buyer Informations

Description: Set the buyer/user information.

    setBuyer($name, $email, $phone = null)

Params
required Buyer Name : string
required Buyer Email : string
optional Buyer Phone : string

Set Shipping Address

Description: Set the buyer/user shipping address.

    setShippingAddr($address)

Params
required Buyer Shipping Address : string

Set Shipping Cost

Description: Set the buyer/user shipping cost.

    setShippingCost($cost)

Params
required Buyer Shipping Cost : numeric

Set Home Delivery Cost

Description: Set the buyer/user Home Delivery cost.

    setHomeDeliveryCost($cost)

Params
required Buyer Home Delivery Cost : numeric

Add Items

Description: Add the items buyer/user bought, eg. from cart or order history.

    addItem($title, $qty, $unit, $unit_price, $discount, $extra_cost = 0, $additional_shipping = 0)

Params
required Item Title : string
required Item Quantity : integer/float
required Item Unit : string : eg. Pc/Kg/Plate...
required Item Unit Price : decimal
required Item Discount : decimal
optional Item Extra Cost : decimal
optional Item Additional Shipping Cost : decimal

Apply Coupon Discount

Description: Apply coupon discount to your orders invoice.

    applyCoupon($code, $discount)

Params
required Coupon Code : string
required Coupon Discount : integer/float

Set Payment State

Description: Set the payment state of the invoice. Also add some notes.

    setPaymentState($state, $label='info', $additional=null)

Params
required State : string : eg. PAID, UNPAID, PENDING...
optional Label : enums : [success/important/warning]
optional Additional : string : Additional note on payment to show

Generate

Description: Generate the Invoice PDF.

    generate($path_to_save=null)

Params
optional Path/to/filename.pdf : string : The full path of saving with filename. By default it will save on public/invoices path.

Changelog

Please see CHANGELOG for more information what has changed recently.

License

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

About

This package is built for Invoice Management and Generation for Laravel 5.5+, 6.x, 7.x (not tested for lower versions)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published