Rollback for nexus on invoice
This commit is contained in:
parent
39bdbb9c21
commit
54ab506599
|
|
@ -39,10 +39,6 @@ class BaseRule implements RuleInterface
|
||||||
|
|
||||||
public string $client_subregion = '';
|
public string $client_subregion = '';
|
||||||
|
|
||||||
private string $nexus = '';
|
|
||||||
|
|
||||||
private string $country_nexus = '';
|
|
||||||
|
|
||||||
public array $eu_country_codes = [
|
public array $eu_country_codes = [
|
||||||
'AT', // Austria
|
'AT', // Austria
|
||||||
'BE', // Belgium
|
'BE', // Belgium
|
||||||
|
|
@ -191,6 +187,7 @@ class BaseRule implements RuleInterface
|
||||||
|
|
||||||
$this->resolveRegions();
|
$this->resolveRegions();
|
||||||
|
|
||||||
|
|
||||||
if (!$this->isTaxableRegion()) {
|
if (!$this->isTaxableRegion()) {
|
||||||
$this->tax_data = null;
|
$this->tax_data = null;
|
||||||
$this->tax_rate1 = 0;
|
$this->tax_rate1 = 0;
|
||||||
|
|
@ -237,6 +234,7 @@ class BaseRule implements RuleInterface
|
||||||
* Destination - Client Tax Data
|
* Destination - Client Tax Data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$tax_data = false;
|
$tax_data = false;
|
||||||
|
|
||||||
if ($this->seller_region == 'US' && $this->client_region == 'US') {
|
if ($this->seller_region == 'US' && $this->client_region == 'US') {
|
||||||
|
|
@ -254,36 +252,20 @@ class BaseRule implements RuleInterface
|
||||||
if ($company->origin_tax_data->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
|
if ($company->origin_tax_data->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
|
||||||
|
|
||||||
$tax_data = $company->origin_tax_data;
|
$tax_data = $company->origin_tax_data;
|
||||||
$tax_data->nexus = $tax_data->geoState;
|
|
||||||
$tax_data->country_nexus = 'US';
|
|
||||||
|
|
||||||
} elseif ($this->invoice->location && $this->invoice->location->is_shipping_location && $this->invoice->location->tax_data) {
|
} elseif ($this->invoice->location && $this->invoice->location->is_shipping_location && $this->invoice->location->tax_data) {
|
||||||
|
|
||||||
$tax_data = $this->invoice->location->tax_data;
|
$tax_data = $this->invoice->location->tax_data;
|
||||||
|
|
||||||
$tax_data->nexus = $tax_data->geoState;
|
|
||||||
$tax_data->country_nexus = 'US';
|
|
||||||
|
|
||||||
} elseif ($this->client->tax_data) {
|
} elseif ($this->client->tax_data) {
|
||||||
|
|
||||||
$tax_data = $this->client->tax_data;
|
|
||||||
|
|
||||||
$tax_data->nexus = $tax_data->geoState;
|
$tax_data = $this->client->tax_data;
|
||||||
$tax_data->country_nexus = 'US';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->saveTaxData($tax_data);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private function saveTaxData(mixed $tax_data): self
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Applies the tax data to the invoice */
|
/** Applies the tax data to the invoice */
|
||||||
if (($this->invoice instanceof Invoice || $this->invoice instanceof Quote) && $tax_data) {
|
if (($this->invoice instanceof Invoice || $this->invoice instanceof Quote) && $tax_data) {
|
||||||
|
|
||||||
|
|
@ -301,8 +283,10 @@ class BaseRule implements RuleInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve Regions & Subregions
|
* Resolve Regions & Subregions
|
||||||
*
|
*
|
||||||
|
|
@ -377,9 +361,6 @@ class BaseRule implements RuleInterface
|
||||||
$this->tax_rate1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_rate;
|
$this->tax_rate1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_rate;
|
||||||
$this->tax_name1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_name;
|
$this->tax_name1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_name;
|
||||||
|
|
||||||
$this->nexus = 'AU';
|
|
||||||
$this->country_nexus = 'AU';
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -399,33 +380,18 @@ class BaseRule implements RuleInterface
|
||||||
if ($is_b2c && $is_over_threshold) {
|
if ($is_b2c && $is_over_threshold) {
|
||||||
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
||||||
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
||||||
|
|
||||||
$this->nexus = $this->client_subregion;
|
|
||||||
$this->country_nexus = $this->client_region;
|
|
||||||
}
|
}
|
||||||
// Otherwise, use origin country tax rates
|
// Otherwise, use origin country tax rates
|
||||||
elseif (in_array($company_country_code, $this->eu_country_codes)) {
|
elseif (in_array($company_country_code, $this->eu_country_codes)) {
|
||||||
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$company_country_code}->tax_rate;
|
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$company_country_code}->tax_rate;
|
||||||
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$company_country_code}->tax_name;
|
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$company_country_code}->tax_name;
|
||||||
|
|
||||||
$this->nexus = $company_country_code;
|
|
||||||
$this->country_nexus = $company_country_code;
|
|
||||||
|
|
||||||
} elseif ($is_over_threshold) {
|
} elseif ($is_over_threshold) {
|
||||||
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
||||||
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
||||||
|
|
||||||
$this->nexus = $this->client_subregion;
|
|
||||||
$this->country_nexus = $this->client_region;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
|
||||||
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
|
||||||
|
|
||||||
$this->nexus = $this->client_subregion;
|
|
||||||
$this->country_nexus = $this->client_region;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue