Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Invoice Bundle Laravel Package

2lenet/invoice-bundle

View on GitHub
Deep Wiki
Context7

InvoiceBundle v2

This bundle is useful to manage invoice in your project.

Installation

To install the bundle:

composer require 2le/invoice-bundle

Configuration

To configure the bundle, in the doctrine service configuration file ("config/packages/doctrine.yaml"), you have to define which entity will get the role of customer.

For exemple, if you want to use your User entity, you will add this block at the end of file :

config/packages/doctrine.yaml:
    ...
    orm:
        ...
        resolve_target_entities:
            Lle\InvoiceBundle\Model\CustomerInterface: App\Entity\User
            Lle\InvoiceBundle\Model\ProductInterface: App\Entity\Product
            Lle\InvoiceBundle\Model\CustomerInterface: App\Entity\Guest
            Lle\InvoiceBundle\Model\ProductInterface: App\Entity\InvoiceProduct
            Lle\InvoiceBundle\Model\SellerInterface: App\Entity\Establishment
            Lle\InvoiceBundle\Model\InvoiceInterface: App\Entity\Invoice
            Lle\InvoiceBundle\Model\InvoiceLineInterface: App\Entity\InvoiceLine
            Lle\InvoiceBundle\Model\PaymentInterface: App\Entity\Payment
            Lle\InvoiceBundle\Model\PaymentConditionInterface: App\Entity\PaymentCondition
            Lle\InvoiceBundle\Model\PaymentTypeInterface: App\Entity\PaymentType
            Lle\InvoiceBundle\Model\VatRateInterface: App\Entity\VatRate

Then, when the bundle expect a CustomerInterface you can pass an user. Once this listener is configured, Doctrine will know how to replace the customer interface. And that's the same for the Product entity.

To get more info about relationships with abstract classes and interfaces, you can check official Symfony Documentation here

Do not forget to implement methods on your entity using bundle traits and add your custom needs.

class Invoice implements InvoiceInterface
{
    use InvoiceTrait;
    
    ...
}

PDF Parameter

Use PdfGenerator To export invoice in PDF, you have to define paramater in the file "config/packages/lle_invoice.yaml". For example, you can define parameter like that :

lle_invoice:
  # Relative path to image (png or jpg) from root directory
  logo: 'public/image/image.jpg'
  header: 'header \n address'
  footer: 'footer \n info'

logo: Path of image to put on Invoice header

The other fields concern the company who made fixtures.

Usage

In this bundle, there are several services : InvoiceManager, InvoiceLineManager, InvoiceExporter, InvoicePDF. You can use all of them with Dependency Injection. You can use EasyAdmin or EasyAdminPlus to manage this entity.

Invoice Manager

InvoiceManager is a service that let you generate a draft invoice or validate an invoice.

Generate a draft invoice

A draft invoice is an invoice with pre-filled fields.

Example:

    public function index(InvoiceManager $invoiceManager): Response
    {
        ...
        // To get a draft Invoice
        $invoiceManager->generate();    
        ...  
    }

But if you want to get more pre-filled fields, you can pass an entity that implements CustomerInterface :

    public function index(InvoiceManager $invoiceManager): Response
    {
        ...
        // Entity User implements CustomerInterface in this example
        $invoiceManager->generate($user);    
        ...  
    }

Validate an invoice

If you want to validate an invoice, you can use the InvoiceManager. Validate an Invoice set the invoice number, puts current date and set status to "Validate".

Example:

    public function index(InvoiceManager $invoiceManager): Response
    {
        ...
        $invoiceManager->validate($invoice);    
        ...  
    }

Then, you can persist your entity or do whatever you want.

Invoice Exporter

You can export one or more invoice in csv format.

Example:

    public function index(InvoiceExporter $invoiceExporter, Invoice $invoice): Response
    {
        ...
        $invoiceExporter->export([$invoice]);    
        ...  
    }

You can choose the filename with: export([$invoice1, $invoice2], 'invoice_export.csv');

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware