laravel-vat is a package that contains the Laravel related wiring code for ibericode/vat

Related tags

Laravel laravel-vat
Overview

Laravel VAT

Build Status Software License

See ibericode/vat-bundle for a Symfony version of this package.

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.

  • Fetch (historical) VAT rates for any European member state using jsonvat.com
  • 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:

composer require dannyvankooten/laravel-vat

The package will automatically register itself.

Usage

Check out the ibericode/vat README for general usage of this package.

Facades

You can use facades to retrieve an instance of the classes provided by ibericode/vat.

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.

Validation

The package registers two new validation rules.

vat_number

The field under validation must be a valid and existing VAT number.

country_code

The field under validation must be a valid ISO-3316 alpha-2 country code.

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.

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:

resources/lang/de.json

{
    "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.

Comments
  • Update to support Laravel 7.0

    Update to support Laravel 7.0

    Hi,

    Thank you for your great package. Please, review my changes, test with Laravel 7 and merge so we can use it on our Laravel 7 Projects.

    Thank in advance, Martin Dinkov, Sitewab Ltd.

    opened by MartinDinkov 3
  • Removing invalid jsonvat reference

    Removing invalid jsonvat reference

    Removing jsonvat reference as it's been abandoned, and was replaced by an internal solution in ibericode/vat

    See: https://github.com/ibericode/vat/issues/30

    opened by paulhennell 1
  • Compatibility with Laravel 5.8

    Compatibility with Laravel 5.8

    Yesterday Taylor Otwell released Laravel 5.8. I just tested this package with it and it works just fine. This is a PR so you can upgrade to Laravel 5.8.

    opened by quodos 1
  • Add support for L9

    Add support for L9

    Hey @dannyvankooten,

    i know you might be busy :) but Laravel 9 was released already a couple of days/weeks ago and I run into the case where I need you package and it basically blocks me/us :) Would you mind having a look here and maybe tag a new release?

    Thanks!

    opened by LKaemmerling 0
  • Improve compatibility with Laravel from 6.0

    Improve compatibility with Laravel from 6.0

    Avoid ongoing issues with compatibility. This technically is doing the same this package has always done and assumes support for the current major version.

    opened by m2de 0
  • - Added non eu pattern array to validate class

    - Added non eu pattern array to validate class

    • Merge in __construct() EU & non-EU array to check in validation
    • Added Swiss VAT regex
    • Added tests for Swiss regex
    • Added function to get VAT infos from Vies
    • Added VS Code subdir to .gitignore
    opened by gmutinel 0
Releases(2.0.7)
Owner
Danny van Kooten
Independent developer, writing open-source code for a living.
Danny van Kooten
Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.

VatCalculator Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be. Integrates with Laravel and Cashier — or in a st

Dries Vints 1.1k Jan 7, 2023
A small PHP library for validating VAT identification numbers (VATINs).

VATIN A small PHP library for validating VAT identification numbers (VATINs). Installation This library is available on Packagist: $ composer require

David de Boer 128 Oct 27, 2022
Advance features / Topics related to Laravel

Laravel Advance Topics Notes Includes : v1.0.0 - Service Container v1.1.0 - View Composer v1.2.0 - Polymorphic Relationships v1.3.0 - Custom Facade Im

Aadhar Gaur 1 Jan 16, 2022
Easy way to upload Laravel model related files from the request.

Easy way to upload laravel model related file from the requset.

Emon Khan 5 Dec 15, 2022
Geo-related tools PHP 7.3+ library built atop Geocoder and React libraries

Geotools Geotools is a PHP geo-related library, built atop Geocoder and React libraries. Features Batch geocode & reverse geocoding request(s) in seri

The League of Extraordinary Packages 1.3k Dec 27, 2022
A multitool library offering access to recommended security related libraries, standardised implementations of security defences, and secure implementations of commonly performed tasks.

SecurityMultiTool A multitool library offering access to recommended security related libraries, standardised implementations of security defences, an

Pádraic Brady 131 Oct 30, 2022
Keyword Generator Tool helps you discover keyword opportunities related to your query input.

This plugin simply helps you discover keyword opportunities related to your query input. Installation Download the zip file of the repository or clone

WP Refers 1 May 3, 2022
🔌 Convert Bootstrap CSS code to Tailwind CSS code

Tailwindo This tool can convert Your CSS framework (currently Bootstrap) classes in HTML/PHP (any of your choice) files to equivalent Tailwind CSS cla

Awssat 938 Dec 24, 2022
In Laravel, we commonly face the problem of adding repetitive filtering code, this package will address this problem.

Filterable In Laravel, we commonly face the problem of adding repetitive filtering code, sorting and search as well this package will address this pro

Zoran Shefot Bogoevski 1 Jun 21, 2022
This package provides convenient methods for making token code, sending and verifying mobile phone verification requests.

Laravel Mobile Verification Introduction Many web applications require users to verify their mobile phone numbers before using the application. Rather

M.Fouladgar 347 Dec 25, 2022
A simple package that helps PHP developers to generate the QR code signature as per Zakat authority (ZATCA) requirements of Saudi Arabia.

A PHP package that implements the e-invoice QR code signature requirements as designed by the Zakat authority of Saudi Arabia. How to install? compose

Muktar Sayed Saleh 5 Jun 13, 2022
Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

null 686 Dec 28, 2022
A Laravel chat package. You can use this package to create a chat/messaging Laravel application.

Chat Create a Chat application for your multiple Models Table of Contents Click to expand Introduction Installation Usage Adding the ability to partic

Tinashe Musonza 931 Dec 24, 2022
This package provides extended support for our spatie/enum package in Laravel.

Laravel support for spatie/enum This package provides extended support for our spatie/enum package in Laravel. Installation You can install the packag

Spatie 264 Dec 23, 2022
Testbench Component is the de-facto package that has been designed to help you write tests for your Laravel package

Laravel Testing Helper for Packages Development Testbench Component is the de-facto package that has been designed to help you write tests for your La

Orchestra Platform 1.9k Dec 29, 2022
🥳🔐 This package is a Laravel package that checks if an email address is a spammer

This package is a Laravel package that checks if an email address is a spammer. It verifies your signups and form submissions to confirm that they are legitimate.

Endurance, the Martian 15 Dec 19, 2022
GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn

GeoLocation in PHP (API) ?? ?? ?? This package helps you to know a lot of information about the current user by his ip address ?? ?? ?? This package h

Abdullah Karam 4 Dec 8, 2022
Automatic multi-tenancy for Laravel. No code changes needed.

Tenancy for Laravel — stancl/tenancy Automatic multi-tenancy for your Laravel app. You won't have to change a thing in your application's code. ✔️ No

Samuel Štancl 2.7k Jan 3, 2023
Laravel Code Tips

Laravel Code Tips This project is a simple Laravel application that uses: Ryan Chandler's Orbit package for storing data in markdown files, custom com

ARCHTECH 67 Dec 14, 2022