mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for EU Taxes
This commit is contained in:
parent
f9886fdf89
commit
05b55ca724
@ -11,9 +11,7 @@
|
|||||||
|
|
||||||
namespace App\DataMapper\Tax;
|
namespace App\DataMapper\Tax;
|
||||||
|
|
||||||
use App\DataMapper\InvoiceItem;
|
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
use App\DataProviders\USStates;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
|
||||||
class BaseRule implements RuleInterface
|
class BaseRule implements RuleInterface
|
||||||
@ -36,7 +34,7 @@ class BaseRule implements RuleInterface
|
|||||||
public string $client_region = '';
|
public string $client_region = '';
|
||||||
|
|
||||||
public string $client_subregion = '';
|
public string $client_subregion = '';
|
||||||
|
|
||||||
public array $eu_country_codes = [
|
public array $eu_country_codes = [
|
||||||
'AT', // Austria
|
'AT', // Austria
|
||||||
'BE', // Belgium
|
'BE', // Belgium
|
||||||
@ -158,7 +156,7 @@ class BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tax(mixed $type, ?InvoiceItem $item = null): self
|
public function tax($item = null): self
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,10 @@
|
|||||||
|
|
||||||
namespace App\DataMapper\Tax\DE;
|
namespace App\DataMapper\Tax\DE;
|
||||||
|
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\DataMapper\InvoiceItem;
|
use App\DataMapper\InvoiceItem;
|
||||||
use App\DataMapper\Tax\BaseRule;
|
use App\DataMapper\Tax\BaseRule;
|
||||||
use App\DataMapper\Tax\RuleInterface;
|
use App\DataMapper\Tax\RuleInterface;
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
|
||||||
|
|
||||||
class Rule extends BaseRule implements RuleInterface
|
class Rule extends BaseRule implements RuleInterface
|
||||||
{
|
{
|
||||||
@ -46,7 +44,7 @@ class Rule extends BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tax(mixed $type, ?InvoiceItem $item = null): self
|
public function tax($item = null): self
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->client->is_tax_exempt) {
|
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) {
|
} 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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,11 @@
|
|||||||
|
|
||||||
namespace App\DataMapper\Tax;
|
namespace App\DataMapper\Tax;
|
||||||
|
|
||||||
use App\DataMapper\InvoiceItem;
|
|
||||||
use App\Models\Client;
|
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
|
||||||
|
|
||||||
interface RuleInterface
|
interface RuleInterface
|
||||||
{
|
{
|
||||||
public function init();
|
public function init();
|
||||||
|
|
||||||
public function tax(mixed $type, ?InvoiceItem $item = null);
|
public function tax($item = null);
|
||||||
|
|
||||||
public function taxByType($type);
|
public function taxByType($type);
|
||||||
|
|
||||||
|
@ -12,10 +12,8 @@
|
|||||||
namespace App\DataMapper\Tax\US;
|
namespace App\DataMapper\Tax\US;
|
||||||
|
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\DataMapper\InvoiceItem;
|
|
||||||
use App\DataMapper\Tax\BaseRule;
|
use App\DataMapper\Tax\BaseRule;
|
||||||
use App\DataMapper\Tax\RuleInterface;
|
use App\DataMapper\Tax\RuleInterface;
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
|
||||||
|
|
||||||
class Rule extends BaseRule implements RuleInterface
|
class Rule extends BaseRule implements RuleInterface
|
||||||
{
|
{
|
||||||
@ -25,7 +23,7 @@ class Rule extends BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tax(mixed $type, ?InvoiceItem $item = null): self
|
public function tax($item = null): self
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->client->is_tax_exempt) {
|
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){
|
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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ class InvoiceItemSum
|
|||||||
*/
|
*/
|
||||||
private function calcTaxesAutomatically(): self
|
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_name1 = $this->rule->tax_name1;
|
||||||
$this->item->tax_rate1 = $this->rule->tax_rate1;
|
$this->item->tax_rate1 = $this->rule->tax_rate1;
|
||||||
|
@ -351,6 +351,7 @@ class EuTaxTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$process = new Rule();
|
$process = new Rule();
|
||||||
|
$process->setTaxData(new Response([]));
|
||||||
$process->setClient($client);
|
$process->setClient($client);
|
||||||
$process->init();
|
$process->init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user