diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index cf33bfff88eb..db501c6aeb68 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -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; } diff --git a/app/DataMapper/Tax/DE/Rule.php b/app/DataMapper/Tax/DE/Rule.php index b80424d41354..fafd70820e7e 100644 --- a/app/DataMapper/Tax/DE/Rule.php +++ b/app/DataMapper/Tax/DE/Rule.php @@ -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; } diff --git a/app/DataMapper/Tax/RuleInterface.php b/app/DataMapper/Tax/RuleInterface.php index 3b0699c6d62c..6cd933567645 100644 --- a/app/DataMapper/Tax/RuleInterface.php +++ b/app/DataMapper/Tax/RuleInterface.php @@ -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); diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index af30769ed536..0a34474a2de4 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -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; } diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index d86dd9275aee..cae8ce5612fa 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -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; diff --git a/tests/Unit/Tax/EuTaxTest.php b/tests/Unit/Tax/EuTaxTest.php index d77859078ae4..711f63cef22c 100644 --- a/tests/Unit/Tax/EuTaxTest.php +++ b/tests/Unit/Tax/EuTaxTest.php @@ -351,6 +351,7 @@ class EuTaxTest extends TestCase ]); $process = new Rule(); + $process->setTaxData(new Response([])); $process->setClient($client); $process->init();