Custom rules seem to be ignored
Fossil01 opened this issue · comments
I am probably doing something wrong, but I am switching back to this repo from @spaze his fork and added back some countries to config/vat_calculator.php
like so:
<?php
return [
/*
|--------------------------------------------------------------------------
| VAT rules
|--------------------------------------------------------------------------
|
| If you need to apply custom VAT rules for a specific country code,
| use this array to define the rules that fit your needs. All EU
| VAT rules are preconfigured inside but can be overwritten
| at this point
|
*/
'rules' => [
'GB' => [ // United Kingdom
'rate' => 0.20,
'exceptions' => [
// UK RAF Bases in Cyprus are taxed at Cyprus rate
'Akrotiri' => 0.19,
'Dhekelia' => 0.19,
],
],
'TR' => [ // Turkey
'rate' => 0.18,
],
'NO' => [ // Norway
'rate' => 0.25
],
],
But neither of these countries seem to be recognized and I get a VAT rate of 0% returned. I did run artisan config:cache
Artisan Tinker:
> $vat = new VatCalculator();
= Mpociot\VatCalculator\VatCalculator {#5936}
> $vat->getTaxRateForLocation('DE');
= 0.19
> $vat->getTaxRateForLocation('NO');
= 0
> config('vat_calculator');
= [
"rules" => [
"GB" => [
"rate" => 0.2,
"exceptions" => [
"Akrotiri" => 0.19,
"Dhekelia" => 0.19,
],
],
"TR" => [
"rate" => 0.18,
],
"NO" => [
"rate" => 0.25,
],
],
"business_country_code" => "FR",
"forward_soap_faults" => false,
"soap_timeout" => 30,
]
Looks like it misses the added data from the config file here and only uses the rules from the VatCalculator.php itself:
https://github.com/driesvints/vat-calculator/blob/3.x/src/VatCalculator.php#L785
Heya. The line you link to points to a docblock. Make sure to press "Y" before copying a line in github to always get the exact commit line you're pointing to.
Ah, here it is:
vat-calculator/src/VatCalculator.php
Line 780 in 3b31ecd
Seems it only looks for rules within the $this->taxRules variable in that file and never checks the extra rules in the config.
Any way you could look into this @driesvints? I'd love to push my changes live soon :-)
Heya, I don't have time right now, sorry. I'll get to this once I find some.
Lol jesus I am an idiot and was using use Mpociot\VatCalculator\VatCalculator;
which VS Code imported for me.
Instead I need to use the Facade use Mpociot\VatCalculator\Facades\VatCalculator