twm/laravel-invoice

这是我创建的包 laravel-invoice

1.0 2023-06-08 12:38 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

这里应该放置你的描述。请限制为一两段话。考虑添加一个简短的示例。

支持我们

我们投入了大量资源来创建 一流的开放式源代码包。您可以通过 购买我们的付费产品之一 来支持我们。

我们非常感谢您从家乡寄给我们明信片,说明您正在使用我们的哪个包。您可以在 我们的联系页面 找到我们的地址。我们将在 我们的虚拟明信片墙 上公布所有收到的明信片。

安装

您可以通过 composer 安装此包

composer require twm/laravel-invoice

您可以使用以下命令发布并运行迁移

php artisan vendor:publish --tag="laravel-invoice-migrations"
php artisan migrate

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="laravel-invoice-config"

这是已发布配置文件的内容

return [
];

可选地,您可以使用以下命令发布视图

php artisan vendor:publish --tag="laravel-invoice-views"

用法

// You have to create an array with pairs key-value with invoice table columns 

$example = [
   'client_id' => null,
        'customer_name' => $faker->company(),
        'customer_reg_com_nr' => $faker->word(),
        'customer_cui' => $faker->word(),
        'customer_address' => $faker->address(),
        'customer_iban' => Str::random(10),
        'customer_bank' => $faker->word(),
        'customer_county' => 'Bucuresti',
        'provider_name' => $faker->company(),
        'provider_reg_com_nr' => $faker->word(),
        'provider_cui' => $faker->word(),
        'provider_address' => $faker->address(),
        'provider_iban' => Str::random(10),
        'provider_bank' => $faker->word(),
        'provider_capital' => '200 RON',
        'cota' => 19,
        'termen_de_plata' => '2023-05-31',
        'payment_url' => 'www.example.com' //optional
];

/** For each line of invoice lines you have to create a collection with lines like this */

// Initialize an empty collection

$linesCollection = collect([]);

foreach($lines as $line) {
   $line = (new Line())->name('Product name')
                        ->unit('buc')
                        ->quantity(4)
                        ->price(100)
                        ->pret_fara_tva(19)
                        ->valoare_fara_tva(19)
                        ->valoare_tva(19);
   // If you want to create a line with discount you have to use the discount method after price method
                        '.....'
                        ->price(100)
                        ->discount(100)
                        '.....'
            
   $linesCollection->push($line);
}

/** To generate invoice you have to use this line */

$invoice = InvoiceGenerator::init()->make($example)->lines($linesCollection);

/** first argument is the name of invoice and the second is the disk you want to save the invoice */
$invoice->generate('Invoice_name.pdf','local');


/** If you want to generate an existing invoice use this */

$inv = Invoice::first();

GenerateExisting::generate($inv,'Invoice_name.pdf');

测试

composer test

变更日志

请参阅 CHANGELOG 以获取有关最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 以获取详细信息。

安全漏洞

请查阅 我们的安全策略 了解如何报告安全漏洞。

致谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件