This package is built for Invoice Management and Generation for Laravel 5.5+, 6.x, 7.x (not tested for lower versions)
You can install the package via composer:
composer require dgvai/laravel-invoicer
Publish configuration file
php artisan vendor:publish --provider="DGvai\Invoicer\InvoicerServiceProvider"
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
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.
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.
Description: Set the buyer/user information.
setBuyer($name, $email, $phone = null)
Params
required Buyer Name : string
required Buyer Email : string
optional Buyer Phone : string
Description: Set the buyer/user shipping address.
setShippingAddr($address)
Params
required Buyer Shipping Address : string
Description: Set the buyer/user shipping cost.
setShippingCost($cost)
Params
required Buyer Shipping Cost : numeric
Description: Set the buyer/user Home Delivery cost.
setHomeDeliveryCost($cost)
Params
required Buyer Home Delivery Cost : numeric
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
Description: Apply coupon discount to your orders invoice.
applyCoupon($code, $discount)
Params
required Coupon Code : string
required Coupon Discount : integer/float
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
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.
Please see CHANGELOG for more information what has changed recently.
The MIT License (MIT). Please see License File for more information.