From 48422231707e057030564f7e0abe2fd753f13900 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 1 Nov 2023 14:09:47 +1100 Subject: [PATCH 1/3] Fixes for tests --- phpunit.xml | 4 +++- storage/app/public/.gitignore | 0 tests/Feature/Export/ReportCsvGenerationTest.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 storage/app/public/.gitignore diff --git a/phpunit.xml b/phpunit.xml index 70062c3f9d..113938ad5e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,7 @@ - + ./tests/Unit diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore old mode 100644 new mode 100755 diff --git a/tests/Feature/Export/ReportCsvGenerationTest.php b/tests/Feature/Export/ReportCsvGenerationTest.php index ae863ed95f..eb868ea852 100644 --- a/tests/Feature/Export/ReportCsvGenerationTest.php +++ b/tests/Feature/Export/ReportCsvGenerationTest.php @@ -284,7 +284,7 @@ class ReportCsvGenerationTest extends TestCase private function poll($hash) { - $response = Http::retry(50, 1000, throw: false) + $response = Http::retry(100, 400, throw: false) ->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, From 62bdc708c10624459dde7b841b1ee87d61e4dc2f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 1 Nov 2023 15:01:52 +1100 Subject: [PATCH 2/3] Catch division by zero errors --- app/Helpers/Invoice/InvoiceItemSum.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 4f95d5c7a2..3463d1a481 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -399,7 +399,12 @@ class InvoiceItemSum $item_tax = 0; - $amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)); + try { + $amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)); + } catch(\DivisionByZeroError $e) { + $amount = $this->item->line_total; + } + //$amount = ($this->sub_total > 0) ? $this->item->line_total - ($this->invoice->discount * ($this->item->line_total / $this->sub_total)) : 0; $item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount); From bdc4e53a1b36afdb5fc22e9a17d66c4a7c9ca544 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 1 Nov 2023 17:07:12 +1100 Subject: [PATCH 3/3] v5.7.41 --- VERSION.txt | 2 +- app/Services/Pdf/PdfBuilder.php | 17 ++++++++++++++--- config/ninja.php | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index d9d5c2ee53..6d2f642f57 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.7.40 \ No newline at end of file +5.7.41 \ No newline at end of file diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 07f55b3c7e..fa4431dead 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -614,7 +614,7 @@ class PdfBuilder } else { $_type = Str::startsWith($type, '$') ? ltrim($type, '$') : $type; - foreach ($this->service->config->pdf_variables["{$_type}_columns"] as $key => $cell) { + foreach ($this->service->config->pdf_variables[$table_type] as $key => $cell) { // We want to keep aliases like these: // $task.cost => $task.rate // $task.quantity => $task.hours @@ -773,7 +773,6 @@ class PdfBuilder */ public function buildTableHeader(string $type): array { - $this->processTaxColumns($type); $elements = []; @@ -785,11 +784,16 @@ class PdfBuilder ]; $table_type = "{$type}_columns"; + + $column_type = $type; - if ($type == 'product' && $this->service->config->entity instanceof Quote && !$this->service->config->settings_object?->sync_invoice_quote_columns) { + if ($type == 'product' && $this->service->config->entity instanceof Quote && !$this->service->config->settings?->sync_invoice_quote_columns) { $table_type = "product_quote_columns"; + $column_type = 'product_quote'; } + $this->processTaxColumns($column_type); + foreach ($this->service->config->pdf_variables[$table_type] as $column) { if (array_key_exists($column, $aliases)) { $elements[] = ['element' => 'th', 'content' => $aliases[$column] . '_label', 'properties' => ['data-ref' => "{$type}_table-" . substr($aliases[$column], 1) . '-th', 'hidden' => $this->service->config->settings->hide_empty_columns_on_pdf]]; @@ -831,6 +835,13 @@ class PdfBuilder $type_id = 2; } + /** 17-05-2023 need to explicity define product_quote here */ + if ($type == 'product_quote') { + $type_id = 1; + $column_type = 'product_quote'; + $type = 'product'; + } + // At the moment we pass "task" or "product" as type. // However, "pdf_variables" contains "$task.tax" or "$product.tax" <-- Notice the dollar sign. // This sprintf() will help us convert "task" or "product" into "$task" or "$product" without diff --git a/config/ninja.php b/config/ninja.php index 4f66c10299..9430d9200b 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -15,8 +15,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION','5.7.40'), - 'app_tag' => env('APP_TAG','5.7.40'), + 'app_version' => env('APP_VERSION','5.7.41'), + 'app_tag' => env('APP_TAG','5.7.41'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),