mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for taxes
This commit is contained in:
parent
699c3cdd9b
commit
f9886fdf89
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
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
|
||||||
@ -33,6 +35,8 @@ class BaseRule implements RuleInterface
|
|||||||
|
|
||||||
public string $client_region = '';
|
public string $client_region = '';
|
||||||
|
|
||||||
|
public string $client_subregion = '';
|
||||||
|
|
||||||
public array $eu_country_codes = [
|
public array $eu_country_codes = [
|
||||||
'AT', // Austria
|
'AT', // Austria
|
||||||
'BE', // Belgium
|
'BE', // Belgium
|
||||||
@ -140,7 +144,9 @@ class BaseRule implements RuleInterface
|
|||||||
|
|
||||||
$this->client_region = $this->region_codes[$this->client->country->iso_3166_2] ?? '';
|
$this->client_region = $this->region_codes[$this->client->country->iso_3166_2] ?? '';
|
||||||
|
|
||||||
$this->client_subregion =
|
if($this->client_region == 'US'){
|
||||||
|
$this->client_subregion = $this->tax_data->geoState;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -152,12 +158,12 @@ class BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tax($product_tax_type): self
|
public function tax(mixed $type, ?InvoiceItem $item = null): self
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function taxByType($product_tax_type): self
|
public function taxByType(mixed $type): self
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace App\DataMapper\Tax\DE;
|
|||||||
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
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;
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
@ -45,24 +46,8 @@ class Rule extends BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setClient(Client $client): self
|
public function tax(mixed $type, ?InvoiceItem $item = null): self
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTaxData(Response $tax_data): self
|
|
||||||
{
|
|
||||||
$this->tax_data = $tax_data;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//need to add logic here to capture if
|
|
||||||
public function tax($type): self
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->client->is_tax_exempt) {
|
if ($this->client->is_tax_exempt) {
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\DataMapper\Tax;
|
namespace App\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\InvoiceItem;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\DataMapper\Tax\ZipTax\Response;
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ interface RuleInterface
|
|||||||
{
|
{
|
||||||
public function init();
|
public function init();
|
||||||
|
|
||||||
public function tax(mixed $type);
|
public function tax(mixed $type, ?InvoiceItem $item = null);
|
||||||
|
|
||||||
public function taxByType($type);
|
public function taxByType($type);
|
||||||
|
|
||||||
@ -38,9 +39,5 @@ interface RuleInterface
|
|||||||
|
|
||||||
public function override();
|
public function override();
|
||||||
|
|
||||||
public function setClient(Client $client);
|
|
||||||
|
|
||||||
public function setTaxData(Response $tax_data);
|
|
||||||
|
|
||||||
public function calculateRates();
|
public function calculateRates();
|
||||||
}
|
}
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace App\DataMapper\Tax\US;
|
namespace App\DataMapper\Tax\US;
|
||||||
|
|
||||||
use App\Models\Client;
|
|
||||||
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;
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
@ -25,22 +25,7 @@ class Rule extends BaseRule implements RuleInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxData(Response $tax_data): self
|
public function tax(mixed $type, ?InvoiceItem $item = null): self
|
||||||
{
|
|
||||||
$this->tax_data = $tax_data;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setClient(Client $client):self
|
|
||||||
{
|
|
||||||
$this->client = $client;
|
|
||||||
$this->client_iso_3166_2 = $client->country->iso_3166_2;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function tax($type): self
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->client->is_tax_exempt) {
|
if ($this->client->is_tax_exempt) {
|
||||||
@ -52,7 +37,7 @@ class Rule extends BaseRule implements RuleInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
else if($this->client->company->tax_data->regions->{$this->client_region}->tax_all_subregions || $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_iso_3166_2}->apply_tax){ //other regions outside of US
|
else if($this->client->company->tax_data->regions->{$this->client_region}->tax_all_subregions || $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->apply_tax){ //other regions outside of US
|
||||||
|
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user