From 15676a368388f4f339af14c926b024d1fdb1f84b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Apr 2023 21:11:55 +1000 Subject: [PATCH] building out tax model --- app/DataMapper/Tax/BaseRule.php | 18 ++++++++++++++++++ app/DataMapper/Tax/DE/Rule.php | 15 +++++++++------ app/DataMapper/Tax/TaxModel.php | 1 + 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 67ddbaf60d97..983d558ae8e7 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -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; diff --git a/app/DataMapper/Tax/DE/Rule.php b/app/DataMapper/Tax/DE/Rule.php index a1edb03ba5c7..af6dbc2b0a9c 100644 --- a/app/DataMapper/Tax/DE/Rule.php +++ b/app/DataMapper/Tax/DE/Rule.php @@ -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 } - -} +} \ No newline at end of file diff --git a/app/DataMapper/Tax/TaxModel.php b/app/DataMapper/Tax/TaxModel.php index 7f6425114360..32535f8415ba 100644 --- a/app/DataMapper/Tax/TaxModel.php +++ b/app/DataMapper/Tax/TaxModel.php @@ -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; }