From 78e429d559bccba57c20914e220526ebc1cbf26d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 19 Apr 2023 16:51:01 +1000 Subject: [PATCH] Fixes for taxes --- app/DataMapper/Tax/BaseRule.php | 6 ++++++ app/DataMapper/Tax/ZipTax/Response.php | 2 ++ app/Helpers/Invoice/InvoiceItemSum.php | 2 +- app/Jobs/Invoice/CreateXInvoice.php | 2 ++ app/Transformers/CompanyTransformer.php | 2 +- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 492aeca29ab1..25bef16a0f75 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -176,7 +176,13 @@ class BaseRule implements RuleInterface return $this; } + elseif($this->client_region == 'AU'){ + + $this->tax_rate1 = 10; + $this->tax_name1 = 'GST'; + 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; diff --git a/app/DataMapper/Tax/ZipTax/Response.php b/app/DataMapper/Tax/ZipTax/Response.php index fbc20a5d364b..1358fccb2d6c 100644 --- a/app/DataMapper/Tax/ZipTax/Response.php +++ b/app/DataMapper/Tax/ZipTax/Response.php @@ -97,6 +97,8 @@ class Response public function __construct($data) { + if(!$data) + return; foreach($data as $key => $value){ $this->{$key} = $value; diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index f11255a75ac5..f3cfc2cf7427 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -146,7 +146,7 @@ class InvoiceItemSum $class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule"; - $tax_data = new Response($this->invoice->tax_data); + $tax_data = new Response($this->invoice?->tax_data); $this->rule = new $class(); $this->rule diff --git a/app/Jobs/Invoice/CreateXInvoice.php b/app/Jobs/Invoice/CreateXInvoice.php index 0b843825fead..18ca57899d00 100644 --- a/app/Jobs/Invoice/CreateXInvoice.php +++ b/app/Jobs/Invoice/CreateXInvoice.php @@ -20,6 +20,8 @@ class CreateXInvoice implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + public $deleteWhenMissingModels = true; + public function __construct(private Invoice $invoice, private bool $alterPDF, private string $custom_pdf_path = "") { } diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 36f543c7abf5..37c1e8011a48 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -195,7 +195,7 @@ class CompanyTransformer extends EntityTransformer 'notify_vendor_when_paid' => (bool) $company->notify_vendor_when_paid, 'invoice_task_hours' => (bool) $company->invoice_task_hours, 'calculate_taxes' => (bool) $company->calculate_taxes, - 'tax_data' => $company->tax_data ?: '', + 'tax_data' => $company->tax_data ?: new \stdClass, ]; }