mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 22:54:25 +01:00
Tax rule refactor
This commit is contained in:
parent
55a1ddf3c6
commit
4ad389ccec
@ -139,12 +139,8 @@ class BaseRule implements RuleInterface
|
||||
if(!array_key_exists($this->client->country->iso_3166_2, $this->region_codes))
|
||||
throw new \Exception('Country not supported');
|
||||
|
||||
nlog($this->client->country->iso_3166_2);
|
||||
|
||||
$this->client_region = $this->region_codes[$this->client->country->iso_3166_2] ?? '';
|
||||
|
||||
nlog($this->client_region);
|
||||
|
||||
match($this->client_region){
|
||||
'US' => $this->client_subregion = $this->tax_data->geoState,
|
||||
'EU' => $this->client_subregion = $this->client->country->iso_3166_2,
|
||||
|
@ -144,19 +144,19 @@ class Rule extends BaseRule implements RuleInterface
|
||||
public function calculateRates(): self
|
||||
{
|
||||
if ($this->client->is_tax_exempt) {
|
||||
nlog("tax exempt");
|
||||
// nlog("tax exempt");
|
||||
$this->vat_rate = 0;
|
||||
$this->reduced_vat_rate = 0;
|
||||
}
|
||||
elseif($this->client_subregion != $this->vendor_iso_3166_2 && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt)
|
||||
{
|
||||
nlog("euro zone and tax exempt");
|
||||
// nlog("euro zone and tax exempt");
|
||||
$this->vat_rate = 0;
|
||||
$this->reduced_vat_rate = 0;
|
||||
}
|
||||
elseif(!in_array($this->client_subregion, $this->eu_country_codes) && ($this->foreign_consumer_tax_exempt || $this->foreign_business_tax_exempt)) //foreign + tax exempt
|
||||
{nlog($this->client_subregion);
|
||||
nlog("foreign and tax exempt");
|
||||
{
|
||||
// nlog("foreign and tax exempt");
|
||||
$this->vat_rate = 0;
|
||||
$this->reduced_vat_rate = 0;
|
||||
}
|
||||
@ -164,18 +164,18 @@ class Rule extends BaseRule implements RuleInterface
|
||||
{
|
||||
if(($this->vendor_iso_3166_2 != $this->client_subregion) && $this->client->company->tax_data->regions->EU->has_sales_above_threshold)
|
||||
{
|
||||
nlog("eu zone with sales above threshold");
|
||||
// nlog("eu zone with sales above threshold");
|
||||
$this->vat_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->vat_rate;
|
||||
$this->reduced_vat_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->reduced_vat_rate;
|
||||
}
|
||||
else {
|
||||
nlog("EU with intra-community supply ie DE to DE");
|
||||
// nlog("EU with intra-community supply ie DE to DE");
|
||||
$this->vat_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->vat_rate;
|
||||
$this->reduced_vat_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_vat_rate;
|
||||
}
|
||||
}
|
||||
else {
|
||||
nlog("default tax");
|
||||
// nlog("default tax");
|
||||
$this->vat_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->vat_rate;
|
||||
$this->reduced_vat_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_vat_rate;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user