索鲁姆设计 / 发票
为您的客户在Laravel中生成PDF发票
v2.00
2024-09-07 09:52 UTC
Requires
- php: ^8.1|^8.2|^8.3|^8.4
- ext-bcmath: *
- dompdf/dompdf: ^2|^3
- illuminate/support: ^5|^6|^7|^8|^9|^10|^11|^12
- nesbot/carbon: ^2|^3
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^5|^6|^7|^8|^9
- phpunit/phpunit: ^8|^9|^10|^11
- sempro/phpunit-pretty-print: ^1.4
README
介绍
发票是一个用于为您的客户生成PDF发票的Laravel库。PDF可以被下载或直接在浏览器中流式传输。它是高度可定制的,您还可以修改整个输出视图。
安装
要开始使用,请使用Composer包管理器进行安装
composer require solumdesignum/invoices
接下来,使用vendor:publish命令发布资源
php artisan vendor:publish --provider="SolumDeSignum\Invoices\InvoicesServiceProvider"
此命令将配置文件发布到您的配置目录,如果不存在,则会创建。
发票功能
配置文件包含配置信息。
<?php declare(strict_types=1); return [ 'templates' => [ 'default', ], /* |-------------------------------------------------------------------------- | Default Currency |-------------------------------------------------------------------------- | | This value is the default currency that is going to be used in invoices. | You can change it on each invoice individually. */ 'currency' => 'EUR', /* |-------------------------------------------------------------------------- | Default Decimal Precision |-------------------------------------------------------------------------- | | This value is the default decimal precision that is going to be used | to perform all the calculations. */ 'decimals' => 2, /* |-------------------------------------------------------------------------- | Default Invoice Logo |-------------------------------------------------------------------------- | | This value is the default invoice logo that is going to be used in invoices. | You can change it on each invoice individually. */ 'logo' => 'http://i.imgur.com/t9G3rFM.png', /* |-------------------------------------------------------------------------- | Default Invoice Logo Height |-------------------------------------------------------------------------- | | This value is the default invoice logo height that is going to be used in invoices. | You can change it on each invoice individually. */ 'logo_height' => 60, /* |-------------------------------------------------------------------------- | Default Invoice Buissness Details |-------------------------------------------------------------------------- | | This value is going to be the default attribute displayed in | the customer model. */ 'business_details' => [ 'name' => env('APP_NAME', 'My Company'), 'id' => '1234567890', 'phone' => '+34 123 456 789', 'location' => 'Main Street 1st', 'zip' => '08241', 'city' => 'Barcelona', 'country' => 'Spain', ], /* |-------------------------------------------------------------------------- | Default Invoice Footnote |-------------------------------------------------------------------------- | | This value is going to be at the end of the document, sometimes telling you | some copyright message or simple legal terms. */ 'footnote' => '', /* |-------------------------------------------------------------------------- | Default Tax Rates |-------------------------------------------------------------------------- | | This array group multiple tax rates. | | The tax type accepted values are: 'percentage' and 'fixed'. | The percentage type calculates the tax depending on the invoice price, and | the fixed type simply adds a fixed amount to the total price. | You can't mix percentage and fixed tax rates. */ 'tax_rates' => [ [ 'name' => '', 'tax' => 0, 'tax_type' => 'percentage', ], ], /* | Default Invoice Due Date |-------------------------------------------------------------------------- | | This value is the default due date that is going to be used in invoices. | You can change it on each invoice individually. | You can set it null to remove the due date on all invoices. */ 'due_date' => date('M dS ,Y', strtotime('+3 months')), /* | Default pagination parameter |-------------------------------------------------------------------------- | | This value is the default pagination parameter. | If true and page count are higher than 1, pagination will show at the bottom. */ 'with_pagination' => true, /* | Duplicate header parameter |-------------------------------------------------------------------------- | | This value is the default header parameter. | If true header will be duplicated on each page. */ 'duplicate_header' => false, ];
示例发票
这是使用本库生成的示例发票
$invoice = (new \SolumDeSignum\Invoices\Invoices()) ->addItem('Test Item', 10.25, 2, "1412") ->addItem('Test Item 2', 5, 2, "923") ->addItem('Test Item 3', 15.55, 5, "42") ->addItem('Test Item 4', 1.25, 1, "923") ->addItem('Test Item 5', 3.12, 1, "3142") ->addItem('Test Item 6', 6.41, 3, "452") ->addItem('Test Item 7', 2.86, 1, "1526") ->addItem('Test Item 8', 5, 2, 923, 'https://dummyimage.com/64x64/000/fff') ->setNumber(4021) ->setWithPagination(true) ->setDuplicateHeader(true) ->setDueDate(Carbon::now()->addMonths(1)) ->setNotes('Lrem ipsum dolor sit amet, consectetur adipiscing elit.') ->setCustomerDetails( new Collection([ 'name' => 'Oskars Germovs', 'id' => '12345678A', 'phone' => '+371 000 000 00', 'location' => 'C / Unknown Street 1st', 'zip' => '08241', 'city' => 'Manresa', 'country' => 'Spain', ]) ) ->setBusinessDetails( new Collection([ 'id' => '123456789', 'name' => 'Solum DeSignum', 'phone' => '+371 000 000 00', 'location' => 'C / Unknown Street 1st', 'zip' => 'LV-1046', 'city' => 'Riga', 'country' => 'Latvia', ]) ) ->download('demo') ->save('public/myinvoicename.pdf');
作者
许可证
索鲁姆设计发票是开源软件,许可协议为MIT许可。
想法
本包基于consoletvs/invoices包。