building out tax model

This commit is contained in:
David Bomba 2023-04-10 21:11:55 +10:00
parent 76d2780a60
commit 15676a3683
3 changed files with 28 additions and 6 deletions

View File

@ -155,6 +155,24 @@ class BaseRule implements RuleInterface
return $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;
}
public function taxForeignEntity(mixed $item): self
{
if($this->client_region == 'US') {
$this->tax_rate1 = $this->tax_data->taxSales * 100;
$this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
}
else {
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
$this->tax_name1 = "Tax";
}
return $this;
}
public function setTaxData(Response $tax_data): self
{
$this->tax_data = $tax_data;

View File

@ -47,15 +47,19 @@ class Rule extends BaseRule implements RuleInterface
return $this->taxExempt();
} elseif ($this->client->company->tax_data->regions->EU->tax_all_subregions || $this->client->company->tax_data->regions->EU->subregions->{$this->client_subregion}->apply_tax) {
}
elseif ($this->client->company->tax_data->regions->EU->tax_all_subregions || $this->client->company->tax_data->regions->EU->subregions->{$this->client_subregion}->apply_tax) {
$this->taxByType($item->tax_id);
return $this;
}
elseif ($this->client_region != 'EU' && $this->isTaxableRegion()) { //foreign entity with tax obligations
$this->taxForeignEntity($item);
return $this;
}
return $this;
}
@ -184,5 +188,4 @@ class Rule extends BaseRule implements RuleInterface
}
}
}

View File

@ -62,6 +62,7 @@ class TaxModel
$this->regions->AU->subregions->AU = new \stdClass();
$this->regions->AU->subregions->AU->apply_tax = false;
$this->regions->AU->subregions->AU->tax_rate = 10;
$this->regions->AU->subregions->AU->tax_name = 'GST';
return $this;
}