1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for EU Taxes

This commit is contained in:
David Bomba 2023-04-10 17:33:24 +10:00
parent f9886fdf89
commit 05b55ca724
6 changed files with 9 additions and 18 deletions

View File

@ -11,9 +11,7 @@
namespace App\DataMapper\Tax;
use App\DataMapper\InvoiceItem;
use App\DataMapper\Tax\ZipTax\Response;
use App\DataProviders\USStates;
use App\Models\Client;
class BaseRule implements RuleInterface
@ -36,7 +34,7 @@ class BaseRule implements RuleInterface
public string $client_region = '';
public string $client_subregion = '';
public array $eu_country_codes = [
'AT', // Austria
'BE', // Belgium
@ -158,7 +156,7 @@ class BaseRule implements RuleInterface
return $this;
}
public function tax(mixed $type, ?InvoiceItem $item = null): self
public function tax($item = null): self
{
return $this;
}

View File

@ -11,12 +11,10 @@
namespace App\DataMapper\Tax\DE;
use App\Models\Client;
use App\Models\Product;
use App\DataMapper\InvoiceItem;
use App\DataMapper\Tax\BaseRule;
use App\DataMapper\Tax\RuleInterface;
use App\DataMapper\Tax\ZipTax\Response;
class Rule extends BaseRule implements RuleInterface
{
@ -46,7 +44,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
public function tax(mixed $type, ?InvoiceItem $item = null): self
public function tax($item = null): self
{
if ($this->client->is_tax_exempt) {
@ -55,7 +53,7 @@ class Rule extends BaseRule implements RuleInterface
} elseif ($this->client->company->tax_data->regions->EU->tax_all_subregions || $this->client->company->tax_data->regions->EU->subregions->{$this->client_iso_3166_2}->apply_tax) {
$this->taxByType($type);
$this->taxByType($item->tax_id);
return $this;
}

View File

@ -11,15 +11,11 @@
namespace App\DataMapper\Tax;
use App\DataMapper\InvoiceItem;
use App\Models\Client;
use App\DataMapper\Tax\ZipTax\Response;
interface RuleInterface
{
public function init();
public function tax(mixed $type, ?InvoiceItem $item = null);
public function tax($item = null);
public function taxByType($type);

View File

@ -12,10 +12,8 @@
namespace App\DataMapper\Tax\US;
use App\Models\Product;
use App\DataMapper\InvoiceItem;
use App\DataMapper\Tax\BaseRule;
use App\DataMapper\Tax\RuleInterface;
use App\DataMapper\Tax\ZipTax\Response;
class Rule extends BaseRule implements RuleInterface
{
@ -25,7 +23,7 @@ class Rule extends BaseRule implements RuleInterface
return $this;
}
public function tax(mixed $type, ?InvoiceItem $item = null): self
public function tax($item = null): self
{
if ($this->client->is_tax_exempt) {
@ -33,7 +31,7 @@ class Rule extends BaseRule implements RuleInterface
}
else if($this->client->company->tax_data->regions->US->tax_all_subregions || $this->client->company->tax_data->regions->US->subregions->{$this->tax_data->geoState}->apply_tax){
$this->taxByType($type);
$this->taxByType($item->tax_id);
return $this;
}

View File

@ -200,7 +200,7 @@ class InvoiceItemSum
*/
private function calcTaxesAutomatically(): self
{
$this->rule->tax($this->item->tax_id ?? null);
$this->rule->tax($this->item);
$this->item->tax_name1 = $this->rule->tax_name1;
$this->item->tax_rate1 = $this->rule->tax_rate1;

View File

@ -351,6 +351,7 @@ class EuTaxTest extends TestCase
]);
$process = new Rule();
$process->setTaxData(new Response([]));
$process->setClient($client);
$process->init();