2017 © Pedro Peláez
 

library laravel-vat

VAT library for Laravel

image

dannyvankooten/laravel-vat

VAT library for Laravel

  • Thursday, January 26, 2017
  • by dannyvankooten
  • Repository
  • 5 Watchers
  • 30 Stars
  • 30,615 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 7 Open issues
  • 4 Versions
  • 12 % Grown

The README.md

HEADS UP I suggest using ibericode/vat directly until #22 is tackled. Working with Laravel is not on my priority list so it would require someone else to send in a PR., (*1)

Laravel VAT

Build Status Software License, (*2)

See ibericode/vat-bundle for a Symfony version of this package., (*3)

laravel-vat is a package that contains the Laravel related wiring code for ibericode/vat, helping you deal with VAT legislation for businesses based in the EU., (*4)

  • Fetch (historical) VAT rates for any EU member state using ibericode/vat-rates.
  • Validate VAT numbers (by format, existence or both)
  • Validate ISO-3316 alpha-2 country codes
  • Determine whether a country is part of the EU
  • Geolocate IP addresses

Installation

You can install this package via Composer:, (*5)

composer require dannyvankooten/laravel-vat

The package will automatically register itself., (*6)

Usage

Check out the ibericode/vat README for general usage of this package., (*7)

Facades

You can use facades to retrieve an instance of the classes provided by ibericode/vat., (*8)

use DvK\Laravel\Vat\Facades\Rates;
use DvK\Laravel\Vat\Facades\Validator;
use DvK\Laravel\Vat\Facades\Countries;

// Get current standard VAT rate for a country
Rates::country('NL'); // 21.00

// Get reduced VAT rate
Rates::country('NL', 'reduced'); // 6.00

// Get reduced VAT rate on a given Date
Rates::country('NL', 'reduced', new \DateTime('2005-01-01')); // 19.00

// Get an array of rates in country code => rates format
Rates::all(); 

// Validate a VAT number by both format and existence
Validator::validate('NL50123'); // false

// Validate VAT number by format only
Validator::validateFormat('NL203458239B01'); // true

// Validate VAT number by existence (uses a remote HTTP service)
Validator::validateExistence('NL203458239B01') // false

// Get array of ISO-3316 country codes and country names
Countries::all(); // array of country codes + names

// Get name of country by ISO-3316 code
Countries::name('NL') // Netherlands

// Get array of EU country codes + names
Countries::europe(); // array of EU country codes + names

// Check if ISO-3316 code is in EU
Countries::inEurope('NL'); // true

// Get ISO-3316 code by IP address geo-location
Countries::ip('8.8.8.8'); // US

By default, VAT rates are cached for 24 hours using the default cache driver., (*9)

Validation

The package registers two new validation rules., (*10)

vat_number, (*11)

The field under validation must be a valid and existing VAT number., (*12)

country_code, (*13)

The field under validation must be a valid ISO-3316 alpha-2 country code., (*14)

use Illuminate\Http\Request;

class Controller {

    public function foo(Request $request)
    {
        $request->validate([
            'vat_number_field' => ['vat_number'],
            'country_code_field' => [ 'country_code' ],
        ]);
    }
}

Alternatively, you can also use the Rule objects directly., (*15)

use Illuminate\Http\Request;
use DvK\Laravel\Vat\Rules;

class Controller {

    public function foo(Request $request)
    {
        $request->validate([
            'vat_number_field' => [ new Rules\VatNumber() ],
            'country_code_field' => [ new Rules\Country() ],
        ]);
    }
}

Localization

You can translate the validation error message by Using Translation Strings As Keys for the following strings:, (*16)

resources/lang/de.json, (*17)

{
    "The :attribute must be a valid VAT number.": "Your translation for the VatNumber Rule",
    "The :attribute must be a valid country.": "Your translation for the Country Rule"
}

License

MIT licensed., (*18)

The Versions

26/01 2017

dev-master

9999999-dev

VAT library for Laravel

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

laravel vat

26/01 2017

1.0.2

1.0.2.0

VAT library for Laravel

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

laravel vat

16/01 2017

1.0.1

1.0.1.0

VAT library for Laravel

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

laravel vat

02/11 2016

1.0

1.0.0.0

VAT library for Laravel

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

laravel vat