GithubHelp home page GithubHelp logo

laraveldaily / laravel-invoices Goto Github PK

View Code? Open in Web Editor NEW
1.3K 34.0 290.0 290 KB

Laravel package to generate PDF invoices from various customizable parameters

License: GNU General Public License v3.0

PHP 78.27% Blade 21.73%

laravel-invoices's Introduction

![Banner]

Laravel Invoices

Latest Stable Version Total Downloads Latest Unstable Version License

version 2 version 1

This Laravel package provides an easy to use interface to generate Invoice PDF files with your provided data.

Invoice file can be stored, downloaded, streamed on any of the filesystems you have configured. Supports different templates and locales.

Features

  • Taxes - fixed or rate - for item or for invoice
  • Discounts - fixed or by percentage - for item or for invoice
  • Shipping - add shipping price to your invoices
  • Automatic calculation - provide minimal set of information, or calculate yourself and provide what to print
  • Due date
  • Easy to customize currency format
  • Serial numbers as you like it
  • Templates
  • Translations
  • Global settings and overrides on-the-fly

Installation

Via Composer

$ composer require laraveldaily/laravel-invoices:^4.0

Older versions

After installing Laravel Invoices, publish its assets, views, translations and config using the invoices:install Artisan command:

$ php artisan invoices:install

Updates

Since it is evolving fast you might want to have latest template after update using Artisan command:

$ php artisan invoices:update

It will give a warning if you really want to override default resources

Or alternatively it can be done separately.

$ php artisan vendor:publish --tag=invoices.views --force
$ php artisan vendor:publish --tag=invoices.translations --force

Basic Usage

RandomController.php

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\InvoiceItem;

// ...

$customer = new Buyer([
    'name'          => 'John Doe',
    'custom_fields' => [
        'email' => '[email protected]',
    ],
]);

$item = InvoiceItem::make('Service 1')->pricePerUnit(2);

$invoice = Invoice::make()
    ->buyer($customer)
    ->discountByPercent(10)
    ->taxRate(15)
    ->shipping(1.99)
    ->addItem($item);

return $invoice->stream();

See result Invoice_AA_00001.pdf.

Advanced Usage

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Party;
use LaravelDaily\Invoices\Classes\InvoiceItem;

// ...

$client = new Party([
    'name'          => 'Roosevelt Lloyd',
    'phone'         => '(520) 318-9486',
    'custom_fields' => [
        'note'        => 'IDDQD',
        'business id' => '365#GG',
    ],
]);

$customer = new Party([
    'name'          => 'Ashley Medina',
    'address'       => 'The Green Street 12',
    'code'          => '#22663214',
    'custom_fields' => [
        'order number' => '> 654321 <',
    ],
]);

$items = [
    InvoiceItem::make('Service 1')
        ->description('Your product or service description')
        ->pricePerUnit(47.79)
        ->quantity(2)
        ->discount(10),
    InvoiceItem::make('Service 2')->pricePerUnit(71.96)->quantity(2),
    InvoiceItem::make('Service 3')->pricePerUnit(4.56),
    InvoiceItem::make('Service 4')->pricePerUnit(87.51)->quantity(7)->discount(4)->units('kg'),
    InvoiceItem::make('Service 5')->pricePerUnit(71.09)->quantity(7)->discountByPercent(9),
    InvoiceItem::make('Service 6')->pricePerUnit(76.32)->quantity(9),
    InvoiceItem::make('Service 7')->pricePerUnit(58.18)->quantity(3)->discount(3),
    InvoiceItem::make('Service 8')->pricePerUnit(42.99)->quantity(4)->discountByPercent(3),
    InvoiceItem::make('Service 9')->pricePerUnit(33.24)->quantity(6)->units('m2'),
    InvoiceItem::make('Service 11')->pricePerUnit(97.45)->quantity(2),
    InvoiceItem::make('Service 12')->pricePerUnit(92.82),
    InvoiceItem::make('Service 13')->pricePerUnit(12.98),
    InvoiceItem::make('Service 14')->pricePerUnit(160)->units('hours'),
    InvoiceItem::make('Service 15')->pricePerUnit(62.21)->discountByPercent(5),
    InvoiceItem::make('Service 16')->pricePerUnit(2.80),
    InvoiceItem::make('Service 17')->pricePerUnit(56.21),
    InvoiceItem::make('Service 18')->pricePerUnit(66.81)->discountByPercent(8),
    InvoiceItem::make('Service 19')->pricePerUnit(76.37),
    InvoiceItem::make('Service 20')->pricePerUnit(55.80),
];

$notes = [
    'your multiline',
    'additional notes',
    'in regards of delivery or something else',
];
$notes = implode("<br>", $notes);

$invoice = Invoice::make('receipt')
    ->series('BIG')
    // ability to include translated invoice status
    // in case it was paid
    ->status(__('invoices::invoice.paid'))
    ->sequence(667)
    ->serialNumberFormat('{SEQUENCE}/{SERIES}')
    ->seller($client)
    ->buyer($customer)
    ->date(now()->subWeeks(3))
    ->dateFormat('m/d/Y')
    ->payUntilDays(14)
    ->currencySymbol('$')
    ->currencyCode('USD')
    ->currencyFormat('{SYMBOL}{VALUE}')
    ->currencyThousandsSeparator('.')
    ->currencyDecimalPoint(',')
    ->filename($client->name . ' ' . $customer->name)
    ->addItems($items)
    ->notes($notes)
    ->logo(public_path('vendor/invoices/sample-logo.png'))
    // You can additionally save generated invoice to configured disk
    ->save('public');

$link = $invoice->url();
// Then send email to party with link

// And return invoice itself to browser or have a different view
return $invoice->stream();

See result Roosevelt Lloyd Ashley Medina.pdf.

Alternatives using facade

Optionally you can use a facade to make new party or item

use Invoice;

$customer = Invoice::makeParty([
    'name' => 'John Doe',
]);

$item = Invoice::makeItem('Your service or product title')->pricePerUnit(9.99);

return Invoice::make()->buyer($customer)->addItem($item)->stream();

Templates

After publishing assets you can modify or make your own template for invoices.

Templates are stored in the resources/views/vendor/invoices/templates directory. There you will find default.blade.php template which is used by default.

You can specify which template to use by calling template method on Invoice object.

For example if you have resources/views/vendor/invoices/templates/my_company.blade.php it should look like this:

Invoice::make('receipt')->template('my_company');

Too see how things work in a template you can view default.blade.php as an example.

Config

return [
    'date' => [
        /**
         * Carbon date format
         */
        'format'         => 'Y-m-d',
        /**
         * Due date for payment since invoice's date.
         */
        'pay_until_days' => 7,
    ],

    'serial_number' => [
        'series'           => 'AA',
        'sequence'         => 1,
        /**
         * Sequence will be padded accordingly, for ex. 00001
         */
        'sequence_padding' => 5,
        'delimiter'        => '.',
        /**
         * Supported tags {SERIES}, {DELIMITER}, {SEQUENCE}
         * Example: AA.00001
         */
        'format'           => '{SERIES}{DELIMITER}{SEQUENCE}',
    ],

    'currency' => [
        'code'                => 'eur',
        /**
         * Usually cents
         * Used when spelling out the amount and if your currency has decimals.
         *
         * Example: Amount in words: Eight hundred fifty thousand sixty-eight EUR and fifteen ct.
         */
        'fraction'            => 'ct.',
        'symbol'              => '€',
        /**
         * Example: 19.00
         */
        'decimals'            => 2,
        /**
         * Example: 1.99
         */
        'decimal_point'       => '.',
        /**
         * By default empty.
         * Example: 1,999.00
         */
        'thousands_separator' => '',
        /**
         * Supported tags {VALUE}, {SYMBOL}, {CODE}
         * Example: 1.99 €
         */
        'format'              => '{VALUE} {SYMBOL}',
    ],

    'paper' => [
        // A4 = 210 mm x 297 mm = 595 pt x 842 pt
        'size'        => 'a4',
        'orientation' => 'portrait',
    ],

    'disk' => 'local',

    'seller' => [
        /**
         * Class used in templates via $invoice->seller
         *
         * Must implement LaravelDaily\Invoices\Contracts\PartyContract
         *      or extend LaravelDaily\Invoices\Classes\Party
         */
        'class' => \LaravelDaily\Invoices\Classes\Seller::class,

        /**
         * Default attributes for Seller::class
         */
        'attributes' => [
            'name'          => 'Towne, Smith and Ebert',
            'address'       => '89982 Pfeffer Falls Damianstad, CO 66972-8160',
            'code'          => '41-1985581',
            'vat'           => '123456789',
            'phone'         => '760-355-3930',
            'custom_fields' => [
                /**
                 * Custom attributes for Seller::class
                 *
                 * Used to display additional info on Seller section in invoice
                 * attribute => value
                 */
                'SWIFT' => 'BANK101',
            ],
        ],
    ],
];

Available Methods

Almost every configuration value can be overrided dynamically by methods.

Invoice

General

  • addItem(InvoiceItem $item)
  • addItems(Iterable)
  • name(string)
  • status(string) - invoice status [paid/due] if needed
  • seller(PartyContract)
  • buyer(PartyContract)
  • setCustomData(mixed) - allows user to attach additional data to invoice
  • getCustomData() - retrieves additional data to use in template
  • template(string)
  • logo(string) - path to logo
  • getLogo() - returns base64 encoded image, used in template to avoid path issues
  • filename(string) - overrides automatic filename
  • taxRate(float)
  • shipping(float) - shipping amount
  • totalDiscount(float) - If not provided calculates itself
  • totalTaxes(float) - If not provided calculates itself
  • totalAmount(float) - If not provided calculates itself
  • taxableAmount(float) - If not provided calculates itself

Serial number

  • series(string)
  • sequence(int)
  • delimiter(string)
  • sequencePadding(int)
  • serialNumberFormat(string)
  • getSerialNumber() - returns formatted serial number

Date

  • date(CarbonInterface)
  • dateFormat(string) - Carbon format of date
  • payUntilDays(int) - Days payment due since invoice issued
  • getDate() - returns formatted date
  • getPayUntilDate() - return formatted due date

Currency

  • currencyCode(string) - EUR, USD etc.
  • currencyFraction(string) - Cents, Centimes, Pennies etc.
  • currencySymbol(string)
  • currencyDecimals(int)
  • currencyDecimalPoint(string)
  • currencyThousandsSeparator(string)
  • currencyFormat(string)
  • getAmountInWords(float, ?string $locale) - Spells out float to words, second parameter is locale
  • getTotalAmountInWords() - spells out total_amount
  • formatCurrency(float) - returns formatted value with currency settings '$ 1,99'

File

  • stream() - opens invoice in browser
  • download() - offers to download invoice
  • save($disk) - saves invoice to storage, use ->filename() for filename
  • url() - return url of saved invoice
  • toHtml() - render html view instead of pdf

InvoiceItem

  • make(string) - [static function] same as (new InvoiceItem())->title(string)
  • title(string) - product or service name
  • description(string) - additional information for service entry
  • units(string) - measurement units of item (adds units columns if set)
  • quantity(float) - amount of units of item
  • pricePerUnit(float)
  • discount(float) - discount in currency
  • discountByPercent(float) - discount by percents discountByPercent(15) means 15%
  • tax(float)
  • taxByPercent(float)
  • subTotalPrice(float) - If not provided calculates itself

Testing

$ composer test

Security

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

Author

License

GPL-3.0-only. Please see the license file for more information.

laravel-invoices's People

Contributors

c14r avatar dartui avatar dnwjn avatar dodaydream avatar eratorr avatar flavius-constantin avatar itskawsar avatar krls2020 avatar laraveldaily avatar liammcarthur avatar luca-alsina avatar luisprmat avatar marius-k avatar mc0de avatar noud avatar povilaskorop avatar ryancco avatar scarbous avatar treggats avatar vildanbina avatar xnekv03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-invoices's Issues

Making it service related invoice

Is your feature request related to a problem? Please describe.
I'm trying to generate service invoice but i'm asked by client to disable qty and unit per price and series.

Describe the solution you'd like
What I'm missing in class that it doesn't have any methods to control the view. (please tell me if I'm wrong). I'm going to contribute to this package by making it able to work with service type invoice and control some obvious view options.

Describe alternatives you've considered
Haven't considered anything else at the moment

Additional context
The reason why i'm writing here is because before i work i wanna make sure that it doesn't exists or just have some ideas from the author or someone interested in it.

Thank you for awesome package. I would love to contribute and help more :)

Generate many Invoices?

Is your feature request related to a problem? Please describe.
I'm trying to generate multiple invoices making a query to database and getting many rows/invoices. Then, when I get all the invoices I need, I don't find the way to generate a PDF file with all invoices.

Describe the solution you'd like
Create a new method to invocate it for generating many invoices, one by one printed in a only PDF file.

Error on Sample Demo

Describe the bug
Like on laraveldaily\laravel-invoices\src\Classes\InvoiceItem.php function 'calculate()' have null value
To Reproduce
Steps to reproduce the behavior:

  1. Install all as docs instruction

  2. Copy Sample demos code
    ` $customer = new Buyer([
    'name' => 'John Doe',
    'custom_fields' => [
    'email' => '[email protected]',
    ],
    ]);

    $item = (new InvoiceItem())->title('Service 1')->pricePerUnit(2);

    $invoice = Invoice::make()
    ->buyer($customer)
    ->addItem($item);

    return $invoice->stream();`

  3. I Included
    use LaravelDaily\Invoices\Invoice; use LaravelDaily\Invoices\Classes\Buyer; use LaravelDaily\Invoices\Classes\Party; use LaravelDaily\Invoices\Classes\InvoiceItem;

Argument 1 passed to LaravelDaily\Invoices\Classes\InvoiceItem::calculate() must be of the type integer, null given, called in C:\xampp\htdocs\wenow\vendor\laraveldaily\laravel-invoices\src\Traits\InvoiceHelpers.php on line 236

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • PHP 7.1

Additional context

Target class [] does not exist.

When I'm trying to implement, one of your samples, I'm getting the following Error:
Target class [] does not exist.

Screenshots
image
image

Lumen support

How can I use laravel-invoices with lumen?
I'm having a problem with register InvoiceServiceProvider in Lumen

$app->register(LaravelDaily\Invoices\InvoiceServiceProvider::class);

and it gave me this error
Call to undefined function LaravelDaily\Invoices\config_path()

Total Discount text

Is there a way to specify the discount text to be dynamically ?
Ie :
Total 20
Coupon (50%off) 5
Total amount 15

Or how else can I communicate WHY the discount is applied

Invoices not saving

I keep getting a error Invalid argument supplied for foreach() (View: /resources/views/vendor/invoices/templates/default.blade.php) every time i do return $invoice->stream(); and using ->url(); for a return does not save the pdf. All my folder permissions are 0777 and set properly in the config.
Using "laraveldaily/laravel-invoices": "^2.0" with laravel 6.2

Error simple demo

Describe the bug
Method Illuminate\View\View::__toString() must not throw an exception, caught Facade\Ignition\Exceptions\ViewException: Class 'NumberFormatter' not found (View: D:\Dropbox\site\laravel-6\resources\views\vendor\invoices\templates\default.blade.php)

Window 10
Php 7.3.12
Laravel 6.2

** install **
composer require laraveldaily/laravel-invoices

php artisan invoices:install

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\InvoiceItem;

$customer = new Buyer([
'name' => 'John Doe',
'custom_fields' => [
'email' => '[email protected]',
],
]);

$item = (new InvoiceItem())->title('Service 1')->pricePerUnit(2);

$invoice = Invoice::make()
->buyer($customer)
->addItem($item);

return $invoice->stream();

pdf isn't showing CSS styles

image
this is what the pdf look like on print , it used to be fine but on day I Opened it looked like this
any Idea Why ??

Add option for tax calculation

Is your feature request related to a problem? Please describe.
I have opened a bug report #17.

Describe the solution you'd like
It would be nice to be able to set if the item prices are including or excluding tax. Currently, when using the taxRate() method it assumes that prices are excluding tax and applies extra tax to the total.

How to store PDF in dynamically generated folder?

Hi, I am trying to store my PDF in a folder which is dynamically generated each time the function is called.

Here is my Controller:

->save('pdf_public'.'/'.$shipment_id.'/');

I did the same with MaatWebsite Excel package, and it was working, but in this case, it shows this exception:

Disk [pdf_public/waq1/] does not have a configured driver.

My filesystems.php code:

'pdf_public' => [
            'driver' => 'local',
            'root' => public_path('uploads/release/'),
            'url' => env('APP_URL'),
            'visibility' => 'public',
        ],

What am trying to achieve is that every time the function is called, the pdf must be stored in the following location:

pdf_public/$shipment_id, whereas $shipment_id is different everytime.

Css and Style not working

This really is an amazing Package and eases many things in invoice generation. But I am having an issue:
When I try to Stream or download the PDF it doesn't work and web page just keeps on loading. But when I comment out the CSS link and Style, it downloads.

Send PDF as attachment in emails

Is your feature request related to a problem? Please describe.
Hi, I want to send invoice as attachment in email but don't want to save locally, can I do that?

Error with Laravel Invoices

Hi,
Installed and updated word for word as specified here; tried your first sample code below but get this error: https://flareapp.io/share/95JMb27r#F1. What could be wrong?

<?php
namespace App\Http\Controllers;

use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\InvoiceItem;

use Illuminate\Http\Request;

class TestInvoiceController extends Controller
{
    public function index() {
        $customer = new Buyer([
            'name'          => 'John Doe',
            'custom_fields' => [
                'email' => '[email protected]',
            ],
        ]);

        $item = (new InvoiceItem())->title('Service 1')->pricePerUnit(2);

        $invoice = Invoice::make()
            ->buyer($customer)
            ->discountByPercent(10)
            ->taxRate(15)
            ->shipping(1.99)
            ->addItem($item);

        return $invoice->stream();
    }

}

No styling applied

Describe the bug
following the advanced example , with latest version on Laravel 7, there is no styling at all.

   public function downloadInvoice(Transaction $transaction)
    {
        $client = new Party([
            'name'          => 'Roosevelt Lloyd',
            'phone'         => '(520) 318-9486',
            'custom_fields' => [
                'note'        => 'IDDQD',
                'business id' => '365#GG',
            ],
        ]);

        $customer = new Party([
            'name'          => 'Ashley Medina',
            'address'       => 'The Green Street 12',
            'code'          => '#22663214',
            'custom_fields' => [
                'order number' => '> 654321 <',
            ],
        ]);

        $items = [
            (new InvoiceItem())->title('Service 1')->pricePerUnit(47.79)->quantity(2)->discount(10),
            (new InvoiceItem())->title('Service 2')->pricePerUnit(71.96)->quantity(2),
            (new InvoiceItem())->title('Service 3')->pricePerUnit(4.56),
            (new InvoiceItem())->title('Service 4')->pricePerUnit(87.51)->quantity(7)->discount(4)->units('kg'),
            (new InvoiceItem())->title('Service 5')->pricePerUnit(71.09)->quantity(7)->discountByPercent(9),
            (new InvoiceItem())->title('Service 6')->pricePerUnit(76.32)->quantity(9),
            (new InvoiceItem())->title('Service 7')->pricePerUnit(58.18)->quantity(3)->discount(3),
            (new InvoiceItem())->title('Service 8')->pricePerUnit(42.99)->quantity(4)->discountByPercent(3),
            (new InvoiceItem())->title('Service 9')->pricePerUnit(33.24)->quantity(6)->units('m2'),
            (new InvoiceItem())->title('Service 11')->pricePerUnit(97.45)->quantity(2),
            (new InvoiceItem())->title('Service 12')->pricePerUnit(92.82),
            (new InvoiceItem())->title('Service 13')->pricePerUnit(12.98),
            (new InvoiceItem())->title('Service 14')->pricePerUnit(160)->units('hours'),
            (new InvoiceItem())->title('Service 15')->pricePerUnit(62.21)->discountByPercent(5),
            (new InvoiceItem())->title('Service 16')->pricePerUnit(2.80),
            (new InvoiceItem())->title('Service 17')->pricePerUnit(56.21),
            (new InvoiceItem())->title('Service 18')->pricePerUnit(66.81)->discountByPercent(8),
            (new InvoiceItem())->title('Service 19')->pricePerUnit(76.37),
            (new InvoiceItem())->title('Service 20')->pricePerUnit(55.80),
        ];

        $notes = [
            'your multiline',
            'additional notes',
            'in regards of delivery or something else',
        ];
        $notes = implode("<br>", $notes);

        $invoice = Invoice::make('receipt')
            ->series('BIG')
            ->sequence(667)
            ->serialNumberFormat('{SEQUENCE}/{SERIES}')
            ->seller($client)
            ->buyer($customer)
            ->date(now()->subWeeks(3))
            ->dateFormat('m/d/Y')
            ->payUntilDays(14)
            ->currencySymbol('$')
            ->currencyCode('USD')
            ->currencyFormat('{SYMBOL}{VALUE}')
            ->currencyThousandsSeparator('.')
            ->currencyDecimalPoint(',')
            ->filename($client->name . ' ' . $customer->name)
            ->addItems($items)
            ->notes($notes)
            ->logo(public_path('vendor/invoices/sample-logo.png'))
            // You can additionally save generated invoice to configured disk
            ->save('public');

        $link = $invoice->url();
        // Then send email to party with link

        // And return invoice itself to browser or have a different view
        return $invoice->stream();
    }

Expected behavior
the result should be exact as the example provided here.

Output PDF
Roosevelt Lloyd Ashley Medina.pdf

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Chrome

How come there is no shipping

I have implemented this package before finding out that there is no way to add shipping. So there is no way to make the invoice add up to the amount customer paid because shipping is not being added. How come there is no shipping? it often show up in invoices or am I missing something here?

Wrong behavior when setting totals manually

Describe the bug
If I specify total tax manually, the taxable amount and total amount are always calculated automatically, even if I also set them manually.

To Reproduce
Steps to reproduce the behavior:
$invoice->totalTaxes(20);
$invoice->totalAmount(100);
$invoice->taxableAmount(80);

Expected behavior
$invoice->taxable_amount should be 80 and $invoice->total_amount should be 100.

Actual behavior
$invoice->taxable_amount is 100 and $invoice->total_amount is 120.

Additional context
I got to this problem because I'm entering all item prices including tax, and therefore the taxRate() method would induce extra tax to the total.

japanese characters not displaying properly

displaying squares instead of japanese characters!
I tried to change the font in default.blade.php but I'm getting ??? now

here is the result
Untitled

here is my lang file
`

'serial'          => 'シリアル番号',
'date'            => '請求日付',
'seller'          => '売り手',
'buyer'           => '買い手',
'address'         => '住所',
'code'            => 'Code',
'vat'             => 'VAT code',
'phone'           => '電話番号',
'description'     => '詳細',
'units'           => '単位',
'quantity'        => '数量',
'price'           => '価格',
'discount'        => '割引',
'tax'             => '税金',
'sub_total'       => '小計',
'total_discount'  => '合計割引',
'taxable_amount'  => '課税額',
'total_taxes'     => '合計税',
'tax_rate'        => '税率',
'total_amount'    => '合計金額',
'pay_until'       => 'お支払い締め切り',
'amount_in_words' => '文字金額',
'notes'           => '備考',
'shipping'        => '送料',

`

Any ideas?

Localisation

I can see that there are strings to be translated, but i cannot find how to translate the title of "INVOICE".

bootstrap css not implemented

Hi,

I installed laravel-invoices in my project (Laravel 6), but I ran an example in Readme, The style not affected pdf file.

I installed new Laravel (v7) with the package, it is working fine.

I tried a lot, but I failed, can you help me if there something I have to update?

Thank you

Bootstrap styles dont work

It was working earlier. I tried
<link rel="stylesheet" href="{{ public_path('/vendor/invoices/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ asset('/vendor/invoices/bootstrap.min.css') }}">
or even Cdn link. Nothing work in stream() also in dowload.

Please introduce the shipping charge

This package is awesome for invoices. But when I looked for the shipping charge option. I found that it is not there.
Please kindly add this feature.

Adding custom columns

Many thanks for the great work. I have encountered a problem in trying to customize the invoice generated and I've looked through the previous issues and the documentation and have not yet been able to find a solution.

Is there a way of adding a custom column to the pdf?

Bootstrap can't render

When I use return view at that time it displayed perfectly. But when stream() it was not working

Invoice looks different like on example pdf

Describe the bug
I installed version laravel-invoices:^1.3. Copy and paste a basic example from GitHub to the controller. My invoice looks different from the basic example invoce.pdf

What I did incorrectly?
Screenshot 2020-12-20 at 16 02 35

Thanks

Invoice incorrectly rendered and takes a long time with php artisan serve

I know that this bug will be hard to resolve, perhaps impossible , but, for the records...

It took me a long time to pinpoint my issue: In fact, the invoice I tried to render (even the demo one), took a minute to render. Every time, a single minute ! Not a second more, not a second less !
And even more, the rendering was completely different from the demo PDF. It was clear that the CSS file did not seem to be used.
So, I tried to remove the CSS link from the template, and boom. Almost instant rendering !

It was clear to me that the CSS file could not be retrieved (hence the 60s timeout and wrong rendering).
After thinking a minute, I thought that it was clear : php embedded server CANNOT serve more than ONE connection at once. And this connection was used by the call to the invoice, so when the invoice asked to the embedded server another connection to serve the CSS file, it failed!

My workaround was to setup an Apache or Nginx server to serve my project... overkill and I always managed to do without.... but....

So, perhaps instead of getting the CSS file from HTTP, we could get it directly from the disk ? Would it work with DomPDF ?
It would also fail for embedded images I think (but I haven't tried), but can we also load them from disk directly ??

"Ct." still shows irrespective of setting in currencyFraction(string)

Describe the bug
Amount in words still ends with "ct." Where else is this setting meant to display?

To Reproduce
Set
->currencyFraction("anything")

Expected behavior
Expect it to show the currency fraction word or its abbreviation.

Screenshots
Not necessary

Desktop (please complete the following information):
All

Indian Rupee Symbol Not Supported

The Indian Rupee Symbol (₹) does not show up when used, instead '?' symbol appears in the generated PDF.

How do we integrate the symbol?

Custom Templates?

thank you for the great package. After installation, I see the default template. In the readme, it claims the 'templates' feature. Does it mean we can add custom templates? how to use the new templates? Thanks!

Not a bug but a support question: How dows page breaks work?

I looked into the blade file but I can't seem to detect how the page breaks are handled. I would like to make shure that no column headers are shown on empty rows like this:

Instead, if pagebreak happens, at least one row of the prevoius rows should be shifted to the next page, otherwise the column headers don't make sense? See picture what I mean

image

Generate the link to saved invoice pdf file

Hi,
I tried to use '$link = $invoice->url();' in the example to generate the a link to the saved file. The file is saved under an 'invoices' folder like this:
->filename('invoices/abc.134343') ->save('local');

the result of $link is '/storage/invoices/abc.134343.pdf'. when I tried with http://my-host-domain/storage/invoices/abc.134343.pdf but failed. Comparing my code to the example code, the only difference is that I used '->save('local'), not '->save('public')'. I don't want the file to be saved to the 'public' directory to protect user privacy. I want to show a download link on a user's dashboard if s/he wants to download the invoice pdf file. Is there a way to create the link without saving the file in 'public'?

Many thanks,

Template/ Bootstrap doesn't work

Describe the bug
On Laravel 7.28. After the 'composer update' the invoice package is on 1.3.11. then the template/bootstrap doesn't work anymore. I tried 'php artisan invoices:update' as instructed, but the template still doesn't work. any suggestion? do I need to update to version 2 even I am using Laravel 7? thanks.

Laravel 6.3.0 - $style value 5 behavior is not implemented.

Describe the bug

invoicesErr

To Reproduce
Steps to reproduce the behavior:

  1. composer require laraveldaily/laravel-invoices
  2. php artisan invoices:install
  3. Create InvoiceController, Add Basic Code to show() method

`
..
use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\InvoiceItem;

class InvoiceController extends Controller{

public function show(Invoice $invoice)
{

     $customer = new Buyer([
        'name'          => 'John Doe',
        'custom_fields' => [
            'email' => '[email protected]',
        ],
    ]);

    

    $item = (new InvoiceItem())->title('Service 1')->pricePerUnit(2);



    $invoice = Invoice::make()
        ->buyer($customer)
        ->discountByPercent(10)
        ->taxRate(15)
        ->shipping(1.99)
        ->addItem($item);


    return $invoice->stream();
}

}`

  1. My web.php

Route::get('/test', 'InvoiceController@show');

  1. See error

Same error if I put the code to web.php

Expected behavior
Fix bug or give solution

Bootstrap.css not loaded within relative path

Having the same problems as #16

I had to change
<link rel="stylesheet" href="{{ asset('vendor/invoices/bootstrap.min.css') }}">
to
<link rel="stylesheet" href="{{ public_path('vendor' . DIRECTORY_SEPARATOR . 'invoices' . DIRECTORY_SEPARATOR . 'bootstrap.min.css') }}">

At first I found this in Artisan command, so I wanted to send pull request for this code:
@if(app()->runningInConsole()) <link rel="stylesheet" href="{{ public_path('vendor' . DIRECTORY_SEPARATOR . 'invoices' . DIRECTORY_SEPARATOR . 'bootstrap.min.css') }}"> @else <link rel="stylesheet" href="{{ asset('vendor/invoices/bootstrap.min.css') }}"> @endif
But it also failed with standard no-console requests.

It seems DomPdf includes everything as files only, not requests. If it is related to Laravel version, it seems to me better to include all style inline (e.g. via @include of separate file with Bootstrap css)

Server

Laravel 7.3.0
PHP 7.3.1
Apache 2.4.37
OS Windows 7 Pro SP1

Client

OS Windows 7 Pro SP1
Google Chrome 80.0.3987.163

Unable to locate any files from public folder

Hi,

I am facing issue with using this package with laravel nuxt project. When i generate the invoice it runs smoothly however i dont see any images, css in the pdf. They cannot be found.

image

But all of the used css and images within the template are accessible via these links for example:

http://localhost:800/vendor/invoices/bootstrap.min.css

This is the way how css is included:
<link rel="stylesheet" href="{{ asset('/vendor/invoices/bootstrap.min.css') }}">
The asset method is giving the same url as above. I checked via tinker.

And this is the way the image is used:
<img src="{{ public_path('/vendor/invoices/logo.png')}}" width="20%" alt="">

Do you know what might be the issue? I was googling a lot and found something about settings in dom PDF

$dompdf->set_option('isRemoteEnabled', true);

But i do not know if that might do the trick or how to set it up.

Thank you

Multiple Custom Invoice templates

Hi,

Currently, Laravel Invoices has only one template.
Is there any way to support for multiple other custom invoice templates?

Allow other people or developers to create there own custom templates or use from a set of templates.

Logo image not showing

Describe the bug
I don't see any logo when I use sample code from documentation. Instead of logo there is only whitespace.

To Reproduce
Steps to reproduce the behavior:

  1. Use sample code from Advanced Usage part of documentation. There is line ->logo(public_path('vendor/invoices/sample-logo.png'))
  2. Save the document
  3. Open saved file.

Expected behavior
There should be sample-logo.png in the page header.

Screenshots
bug-invoice

Desktop (please complete the following information):

  • Laravel 6.x
  • PHP 7.3
  • laravel-invoices 1.3

Additional context
When I try other PNG images, they have wrong colors (for example background which should be white is black and text which should be black is white).

Payments

Is your feature request related to a problem? Please describe.
Do you have any plans to implement adding payments to invoices? We have use cases where an invoice would have prepayment made.

Describe the solution you'd like
It would be good to have either a method to add total payments e.g paymentsTotalAmount() that would be removed from an invoice amount owed total. A brilliant solution would be to be able to add payment items to the invoice to be displayed in a separate area.

Remove 'Please pay until'

For example i am using package for generate invoice on fly when customer has been charged by stripe. Then invoice is already paid.

Describe the solution you'd like
Maybe something like that ->payUntilDays(null) ? It will means already paid ?

Can't save invoice in the background without the return $invoice->stream(); method.

Describe the bug
Saving the invoice without necessarily having to return to browser gives an error. If you omit return $invoice->stream(); it throws an error.

To Reproduce
Steps to reproduce the behavior:

  1. Create the invoice normally up to ...->save('public') and comment out the return $invoice->stream();
  2. See error

Expected behavior
Save the invoice to disk and continue generating other invoices.

Library not generating invoice on shared hosting - works on localhost

Hello guys,

I am facing pretty frustrating issue. I have developed website which works like a charm locally on my windows pc. Once i cloned the site on my shared hosting - linux the library does not work.

I created simple job which is dispatched after order is paid and it generates invoice and thats it. When I run php artisan queue:work and dispatch the job following error occures:

[2020-06-15 06:47:19] local.ERROR: Imagick::clone method is deprecated and it's use should be avoided {"exception":"[object] (ErrorException(code: 0): Imagick::clone method is deprecated and it's use should be avoided at /data/6/d/6d7bb24a-b665-46c0-94cc-3d1fa48bc41f/naucma.online/web/Naucma/vendor/dompdf/dompdf/lib/Cpdf.php:4872)

I have found out that based on post here that Cpdf file has to be modified. That did not help. Only thing that helps is when i delete these lines from the default.blade.php template file

@if($invoice->logo)
<img src="{{ $invoice->getLogo() }}" alt="logo" height="100">
@endif

Also my second bug is that when i press the back button on the after order processing page in the browser which leads me to the url where the job gets dispatched i get Class 'LaravelDaily\Invoices\Classes\Buyer' not found which his really strange.

Here is the job code:

`<?php

namespace App\Jobs;

use App\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
use LaravelDaily\Invoices\Invoice;
use LaravelDaily\Invoices\Classes\Buyer;
use LaravelDaily\Invoices\Classes\InvoiceItem;

class GenerateInvoice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

private $order;
/**
 * Create a new job instance.
 *
 * @return void
 */
public function __construct(Order $order)
{
    $this->order = $order;
}

/**
 * Execute the job.
 *
 * @return void
 */
public function handle()
{
    $items = array();

    $customer = new Buyer([
        'name'          => $this->order->user->name,
        'custom_fields' => [
            'email' => $this->order->user->email,
        ],
    ]);


    if (count($this->order->courses) > 0) {
        foreach ($this->order->courses as $course) {
            array_push($items, (new InvoiceItem())->title($course->title . ' - Kurz')->pricePerUnit($course->price / 1.2));
        }
    }

    if (count($this->order->occurences) > 0) {
        foreach ($this->order->occurences as $occurence) {
            array_push($items, (new InvoiceItem())->title($occurence->training->title . ' - Školenie')->pricePerUnit($occurence->training->price / 1.2));
        }
    }

    $invoice = Invoice::make()
        ->name('Faktúra')
        ->series($this->order->id)
        ->buyer($customer)
        ->discountByPercent($this->order->discount)
        ->totalTaxes($this->order->order_net - $this->order->order_gross)
        ->totalAmount($this->order->order_net)
        ->taxableAmount($this->order->order_net - $this->order->order_gross)
        ->addItems($items)
        ->logo(public_path('vendor/invoices/sample-logo.png'))
        ->filename($this->order->id . ' ' . $this->order->user->id);

    $invoice->save('local');
}

}`

Dont you know what might be wrong please?

Choosing the language for the total amount in words

It will be helpful if you can specify the language for the $formatter = new NumberFormatter('en', NumberFormatter::SPELLOUT); in CurrencyFormatter.php so you will be able to provide a different language than English for the amount in words.

Class 'NumberFormatter' not found

Describe the bug
I am using laravel/framework (v5.6.39): and PHP 7.3.9.
I am using version ^1.3.8, and when i try to initiate the call to laravel invoices, i get an error saying
"message": "Class 'NumberFormatter' not found (View: /app/resources/views/vendor/invoices/templates/default.blade.php)", "exception": "ErrorException", "file": "/app/vendor/laraveldaily/laravel-invoices/src/Traits/CurrencyFormatter.php", "line": 152,

Expected behavior
It is supposed to download the generated invoice

Desktop (please complete the following information):

  • OS: Catalina
  • Browser Chrome
  • Version latest

Additional context
Add any other context about the problem here.

Invoice style not applied

For some reason bootstrap is not working in the generated pdf.
This is my code:

$client = new Party([
            'name'          => $request->receiver,
            'phone'         => $request->phone_no_1,
            'address'       => $request->address.', '.$request->postal_code.' '.$request->deligation,
        ]);

        $customer = new Party([
            'name'          => 'Ashley Medina',
            'address'       => 'The Green Street 12',
            'code'          => '#22663214',
            'custom_fields' => [
                'order number' => '> 654321 <',
            ],
        ]);

        $items = [
            (new InvoiceItem())->title($request->packet)->pricePerUnit($request->price)->quantity($request->quantity)
        ];

        $notes = [$request->note];
        $notes = implode("<br>", $notes);

        $invoice = Invoice::make('receipt')
            ->seller($client)
            ->buyer($customer)
            ->date(now()->subWeeks(3))
            ->currencySymbol('')
            ->currencyCode('DT')
            ->currencyThousandsSeparator('.')
            ->currencyDecimalPoint(',')
            ->filename('test')
            ->addItems($items)
            ->notes($notes)
            ->logo(public_path('vendor/invoices/logo.png'))
            // You can additionally save generated invoice to configured disk
            ->save('public');

This is my generated pdf:

test.pdf

PS: I am using Laravel 8 and laravel-invoices 2.0

'discount' value is incorrect if new InvoiceItem with 'discountByPercent()' and subTotalPrice()' together

Describe the bug
InvoiceItem 'discount' value is incorrect if new InvoiceItem is initialized with 'discountByPercent()' and subTotalPrice()' together.

To Reproduce
Steps to reproduce the behavior:
$item = (new InvoiceItem())->title('Service 1')->pricePerUnit(66.81)->quantity(1)->discountByPercent(8)->subTotalPrice('61.47');
In above code, without setting the sub_total_price, the value for 'discount' property is 5.34 which is correct.
if using 'subTotalPrice' method to set the sub_total_price as well, the value for 'discount' is 8 instead.

From instruction, we should be able to use 'subTotalPrice' method on InvoiceItem?
subTotalPrice(float) - If not provided calculates itself

Expected behavior
the value of 'discount' should be calculated correctly no matter whether 'subTotalPrice()' is called or not.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [ Windows 10]
  • Browser [chrome]
  • Version [84]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.