diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 5c6aa4cc74e9..06ca9b9f5d23 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -217,9 +217,11 @@ class BaseRule implements RuleInterface return $this; } - $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; - + if(isset($this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion})) { + $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; + } + return $this; } diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 1925880dbb7b..eccd827a9aa6 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -116,7 +116,6 @@ class InvoiceItemSum { if (!$this->invoice->line_items || !is_array($this->invoice->line_items)) { $this->items = []; - return $this; } @@ -146,7 +145,8 @@ class InvoiceItemSum } //should we be filtering by client country here? do we need to reflect at the company <=> client level? - if (in_array($this->client->country->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions + // if (in_array($this->client->country->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions + if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions $class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule"; @@ -216,7 +216,12 @@ class InvoiceItemSum return $this; } - + + /** + * calcTaxes + * + * @return self + */ private function calcTaxes() { if ($this->calc_tax) {