2017 © Pedro Peláez
 

module module-invoice

Module for generating invoices.

image

netcore/module-invoice

Module for generating invoices.

  • Thursday, July 12, 2018
  • by netcorelv
  • Repository
  • 3 Watchers
  • 0 Stars
  • 386 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 25 Versions
  • 21 % Grown

The README.md

Module for creating invoices

This module was made for easy invoices creating., (*1)

Features

  • Translatable invoice items
  • Invoice can be attached to user, order or any other related stuff
  • Custom PDF templates

Pre-installation

This module is part of Netcore CMS ecosystem and is only functional in a project that has following packages installed:, (*2)

  1. https://github.com/netcore/netcore
  2. https://github.com/netcore/module-admin
  3. https://github.com/netcore/module-translate

Installation

  1. Require this package using composer
    composer require netcore/module-invoice
  1. Publish assets/configuration/migrations
    php artisan module:publish Invoice
    php artisan module:publish-config Invoice
    php artisan module:publish-migration Invoice
  1. Important - Configure relations before migrating
    edit config/netcore/module-invoice.php file to enable/disable used relations
  1. Run the migrations and seeder
    php artisan migrate
    php artisan module:seed Invoice

Configuration

  • Configuration file is available at config/netcore/module-invoice.php

Relations

  • Relations will be loaded from config
    return [
        'relations' => [
            [
                'name'       => 'user', // relation name
                'type'       => 'belongsTo', // relation type
                'foreignKey' => 'user_id', // foreign key (user_id in invoices table in this case)
                'ownerKey'   => 'id', // owner key (id in related table in this case)
                'enabled'    => false, // is relation enabled? (it should be enable when migrating)
                'class'      => \App\User::class, // related model class

                // Datatable colum config
                'table' => [
                    'show' => true, // Show this column?
                    'name' => 'User', // Column name?

                    'searchable' => true, // Is column searchable?
                    'sortable'   => true, // Is column sortable?
                    'd_data'     => 'user', // Datatables data param
                    'd_name'     => 'user.first_name', // Datatables SQL field param
                    'modifier'   => 'fullName', // Accessor in model to format display format
                ],
            ],
        ...
    ];

User relation

  • To use ->forUser() method, you should implement getInvoiceReceiverData() method in your User model
    /**
     * Get user data for invoices.
     *
     * @return array
     */
    public function getInvoiceReceiverData(): array
    {
        return [
            'first_name' => $this->first_name,
            'last_name'  => $this->last_name,
            'email'      => $this->email,
            'phone'      => $this->phone,
        ];
    }

Creating invoice

  • To create invoice, you can use invoice() helper method
    $user = auth()->user();
    $items = [
        [
            'price' => 10.99,
            'name'  => 'Test item #1' // Name is equal for all languages 
        ],
        [
            'price' => 25.65,
            // Name is different for each language
            'translations' => [
                'en' => ['name' => 'First product.'],                    
                'ru' => ['name' => 'Первый товар..'],         
                'lv' => ['name' => 'Pirmā prece.'],
            ],
        ]
    ];

    $invoice = invoice()
        ->setItems($items)
        ->setPaymentDetails('VISA ending XXXX')

        ->forUser($user) // optional - set associated user (user relation should be enabled and configured)
        ->setInvoiceNr('MY123') // optional - set custom invoice nr.
        ->setVat(21) // optional - overrides vat specified in config
        ->setSender([ 'name' => 'My awesome company', ... ]) // optional - overrides sender data specified in config
        ->setReceiver([ 'first_name' => ..., 'last_name' => ... ]) // optional - overrides receiver data
        ->mergeReceiver([ 'some_additional_field' => ... ]) // optional - use if you need to add some extra receiver data

        ->make(); // build eveything up and returns Invoice instance

The Versions

12/07 2018

dev-master

9999999-dev http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

12/07 2018

v1.2.4

1.2.4.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

12/07 2018

1.1.x-dev

1.1.9999999.9999999-dev http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

12/07 2018

v1.2.3

1.2.3.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

04/07 2018

v1.2.2

1.2.2.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

29/06 2018

v1.2.1

1.2.1.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

18/06 2018

v1.2.0

1.2.0.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

24/05 2018

v1.1.3

1.1.3.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

24/05 2018

1.0.x-dev

1.0.9999999.9999999-dev http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

24/05 2018

v1.1.2

1.1.2.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

11/05 2018

v1.1.1

1.1.1.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

04/01 2018

v1.1.0

1.1.0.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

24/12 2017

v1.0.9

1.0.9.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

23/12 2017

v1.0.8

1.0.8.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

23/12 2017

v1.0.7

1.0.7.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

23/12 2017

dev-development

dev-development http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

20/12 2017

v1.0.6

1.0.6.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

16/12 2017

v1.0.5

1.0.5.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

15/12 2017

v1.0.4

1.0.4.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

15/12 2017

v1.0.3

1.0.3.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

15/12 2017

v1.0.2

1.0.2.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

15/12 2017

v1.0.1

1.0.1.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

14/12 2017

0.1.x-dev

0.1.9999999.9999999-dev http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

14/12 2017

v1.0.0

1.0.0.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs

27/11 2017

v0.0.1

0.0.1.0 http://netcore.lv

Module for generating invoices.

  Sources   Download

MIT

The Requires

 

by Viktors Ņikiforovs