From 1d8df0ec275a6ad6492d11fca511a26d6c4acdea Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:43:37 +0200 Subject: [PATCH 01/14] Update Countries.php --- src/Facades/Countries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/Countries.php b/src/Facades/Countries.php index a30a2160ce..3becb1d818 100644 --- a/src/Facades/Countries.php +++ b/src/Facades/Countries.php @@ -8,7 +8,7 @@ class Countries extends Facade { protected static function getFacadeAccessor() { - return \DvK\Vat\Countries::class; + return \Ibericode\Vat\Countries::class; } } From f4516e210da28314036bc9d39603320dd5139f31 Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:44:25 +0200 Subject: [PATCH 02/14] Update Rates.php --- src/Facades/Rates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/Rates.php b/src/Facades/Rates.php index af111b49b9..ee369e6ce9 100644 --- a/src/Facades/Rates.php +++ b/src/Facades/Rates.php @@ -8,7 +8,7 @@ class Rates extends Facade { protected static function getFacadeAccessor() { - return \DvK\Vat\Rates\Rates::class; + return \Ibericode\Vat\Rates\Rates::class; } } From 57bc737cf5d1eeec5acf669aa5c2443776da6171 Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:44:39 +0200 Subject: [PATCH 03/14] Update Validator.php --- src/Facades/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/Validator.php b/src/Facades/Validator.php index 31708b7b33..9ac49470f2 100644 --- a/src/Facades/Validator.php +++ b/src/Facades/Validator.php @@ -8,7 +8,7 @@ class Validator extends Facade { protected static function getFacadeAccessor() { - return \DvK\Vat\Validator::class; + return \Ibericode\Vat\Validator::class; } } From 24227bdfe1ae4cc66bfa4e9ea7c486c6630d9313 Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:45:49 +0200 Subject: [PATCH 04/14] Update VatServiceProvider.php --- src/VatServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VatServiceProvider.php b/src/VatServiceProvider.php index 944c3310b7..7a8483da98 100644 --- a/src/VatServiceProvider.php +++ b/src/VatServiceProvider.php @@ -8,9 +8,9 @@ use DvK\Laravel\Vat\Facades\Validator as VatValidator; use DvK\Laravel\Vat\Rules; -use DvK\Vat\Countries; -use DvK\Vat\Rates\Rates; -use DvK\Vat\Validator; +use Ibericode\Vat\Countries; +use Ibericode\Vat\Rates\Rates; +use Ibericode\Vat\Validator; class VatServiceProvider extends ServiceProvider { From e0b99611a7ed082397343d38684bc7d9165f3edc Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:46:09 +0200 Subject: [PATCH 05/14] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 33bd8b98c4..1058b92f15 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=7.1", - "ibericode/vat": "^1.2", + "ibericode/vat": "^2.0", "illuminate/contracts": "5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*", "illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*" }, From 4d23c5a93d1c66e29b9f2e84d9ef00b3740f6987 Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:02:15 +0200 Subject: [PATCH 06/14] Update FacadesTest.php --- tests/FacadesTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/FacadesTest.php b/tests/FacadesTest.php index 23ff6d1f40..51248f3125 100644 --- a/tests/FacadesTest.php +++ b/tests/FacadesTest.php @@ -6,9 +6,9 @@ use DvK\Laravel\Vat\Facades\Rates as RatesFacade; use DvK\Laravel\Vat\Facades\Validator as ValidatorFacade; -use DvK\Vat\Countries; -use DvK\Vat\Rates\Rates; -use DvK\Vat\Validator; +use Ibericode\Vat\Countries; +use Ibericode\Vat\Rates\Rates; +use Ibericode\Vat\Validator; use Orchestra\Testbench\TestCase; @@ -28,4 +28,4 @@ public function testValidator() { self::assertEquals((new Validator())->validateFormat('foobar'), ValidatorFacade::validateFormat('foobar')); } -} \ No newline at end of file +} From 3edacce7869ac613b419e5ba4f4ad8fd40901e1e Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:40:56 +0200 Subject: [PATCH 07/14] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index a333af9e36..4ca2b41cdc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -> **HEADS UP** I suggest using [ibericode/vat](https://github.com/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. - Laravel VAT ================ From a6d2e957b38b60edee486300f645d55abb134964 Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 19:59:00 +0200 Subject: [PATCH 08/14] Update Rates.php --- src/Facades/Rates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/Rates.php b/src/Facades/Rates.php index ee369e6ce9..29c8f6ef64 100644 --- a/src/Facades/Rates.php +++ b/src/Facades/Rates.php @@ -8,7 +8,7 @@ class Rates extends Facade { protected static function getFacadeAccessor() { - return \Ibericode\Vat\Rates\Rates::class; + return \Ibericode\Vat\Rates::class; } } From 0edc52b3f3a66cb758b08fb65b3e1d2aa982214e Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:00:10 +0200 Subject: [PATCH 09/14] Update FacadesTest.php --- tests/FacadesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FacadesTest.php b/tests/FacadesTest.php index 51248f3125..c1c6dac69f 100644 --- a/tests/FacadesTest.php +++ b/tests/FacadesTest.php @@ -7,7 +7,7 @@ use DvK\Laravel\Vat\Facades\Validator as ValidatorFacade; use Ibericode\Vat\Countries; -use Ibericode\Vat\Rates\Rates; +use Ibericode\Vat\Rates; use Ibericode\Vat\Validator; use Orchestra\Testbench\TestCase; From 741bd5eb36d252e94a7c69840020bb67e151024c Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:42:58 +0200 Subject: [PATCH 10/14] Update FacadesTest.php --- tests/FacadesTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/FacadesTest.php b/tests/FacadesTest.php index c1c6dac69f..e09334730f 100644 --- a/tests/FacadesTest.php +++ b/tests/FacadesTest.php @@ -16,16 +16,16 @@ class ServiceProviderTest extends TestCase { public function testCountries() { - self::assertEquals((new Countries())->all(), CountriesFacade::all()); + self::assertEquals(new Countries(), new CountriesFacade); } public function testRates() { - self::assertEquals((new Rates())->all(), RatesFacade::all()); + self::assertEquals((new Rates())->getRateForCountry('NL'), RatesFacade::getRateForCountry('NL')); } public function testValidator() { - self::assertEquals((new Validator())->validateFormat('foobar'), ValidatorFacade::validateFormat('foobar')); + self::assertEquals((new Validator())->validateVatNumberFormat('foobar'), ValidatorFacade::validateVatNumberFormat('foobar')); } } From 3ad8c578caedce4ba98543d126dc676725fd4dd4 Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:44:45 +0200 Subject: [PATCH 11/14] Update Country.php --- src/Rules/Country.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rules/Country.php b/src/Rules/Country.php index a711c35df6..768765fede 100644 --- a/src/Rules/Country.php +++ b/src/Rules/Country.php @@ -16,7 +16,7 @@ class Country implements Rule */ public function passes($attribute, $value) { - $countries = Countries::all(); + $countries = new Countries(); return isset($countries[$value]); } @@ -29,4 +29,4 @@ public function message() { return __('The :attribute must be a valid country.'); } -} \ No newline at end of file +} From f02c26c8ffd5733c3cce2319014d6891c320323c Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:46:06 +0200 Subject: [PATCH 12/14] Update VatNumber.php --- src/Rules/VatNumber.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rules/VatNumber.php b/src/Rules/VatNumber.php index 53a3452799..0d930d8266 100644 --- a/src/Rules/VatNumber.php +++ b/src/Rules/VatNumber.php @@ -16,7 +16,7 @@ class VatNumber implements Rule */ public function passes($attribute, $value) { - return Validator::validate($value); + return Validator::validateVatNumber($value); } /** @@ -28,4 +28,4 @@ public function message() { return __('The :attribute must be a valid VAT number.'); } -} \ No newline at end of file +} From 24d6a32a042fa33b8fc96be8c790536ad79d429b Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:49:48 +0200 Subject: [PATCH 13/14] Update README.md --- README.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4ca2b41cdc..df4ed93fdf 100644 --- a/README.md +++ b/README.md @@ -40,25 +40,20 @@ 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 +Rates::getRateForCountry('NL'); // 21 +Rates::getRateForCountry('NL', 'standard'); // 21 // Get reduced VAT rate -Rates::country('NL', 'reduced'); // 6.00 +Rates::getRateForCountry('NL', 'reduced'); // 9 // 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(); +Rates::getRateForCountryOnDate('NL', new \DateTime('2010-01-01'), 'standard'); // 19.00 // Validate a VAT number by both format and existence -Validator::validate('NL50123'); // false +Validator::validateVatNumberFormat('NL203458239B01'); // true (checks format) // Validate VAT number by format only -Validator::validateFormat('NL203458239B01'); // true - -// Validate VAT number by existence (uses a remote HTTP service) -Validator::validateExistence('NL203458239B01') // false +Validator::validateVatNumber('NL203458239B01'); // false (checks format + existence) // Get array of ISO-3316 country codes and country names Countries::all(); // array of country codes + names From 3acf8ef81b2e234156c4dc2226e6f0f1a90eec9f Mon Sep 17 00:00:00 2001 From: Restingo <84022569+Restingo@users.noreply.github.com> Date: Mon, 26 Sep 2022 20:55:56 +0200 Subject: [PATCH 14/14] Update README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index df4ed93fdf..7367575b42 100644 --- a/README.md +++ b/README.md @@ -56,19 +56,19 @@ Validator::validateVatNumberFormat('NL203458239B01'); // true (checks format) Validator::validateVatNumber('NL203458239B01'); // false (checks format + existence) // Get array of ISO-3316 country codes and country names -Countries::all(); // array of country codes + names +$countries = new Countries(); -// Get name of country by ISO-3316 code -Countries::name('NL') // Netherlands +// access country name using array access +echo $countries['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 +// loop over countries +foreach ($countries as $code => $name) { + // ... +} -// Get ISO-3316 code by IP address geo-location -Countries::ip('8.8.8.8'); // US +// check if country is in EU +$countries->isCountryCodeInEU('NL'); // true +$countries->isCountryCodeInEU('US'); // false ``` By default, VAT rates are cached for 24 hours using the default cache driver.