From 5ab37e056048edeaae1bbc808982fb0e9ad2ebe4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 25 Jul 2023 13:38:09 +1000 Subject: [PATCH] Fixes for tests --- app/Export/CSV/BaseExport.php | 4 +- .../Export/ReportCsvGenerationTest.php | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 8ef9419c94..8576bdfa83 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -624,8 +624,8 @@ class BaseExport return $transformed_invoice[$column]; } - if($column == 'status') - return $entity->stringStatus($entity->status_id); + // if($column == 'status') + // return $entity->stringStatus($entity->status_id); return ''; } diff --git a/tests/Feature/Export/ReportCsvGenerationTest.php b/tests/Feature/Export/ReportCsvGenerationTest.php index 65f2338475..53a9c39242 100644 --- a/tests/Feature/Export/ReportCsvGenerationTest.php +++ b/tests/Feature/Export/ReportCsvGenerationTest.php @@ -92,6 +92,38 @@ class ReportCsvGenerationTest extends TestCase 'payment.assigned_user_id' ]; + private $all_invoice_report_keys = [ + 'invoice.number', + 'invoice.amount', + 'invoice.balance', + 'invoice.paid_to_date', + 'invoice.discount', + 'invoice.po_number', + 'invoice.date', + 'invoice.due_date', + 'invoice.terms', + 'invoice.footer', + 'invoice.status', + 'invoice.public_notes', + 'invoice.private_notes', + 'invoice.uses_inclusive_taxes', + 'invoice.is_amount_discount', + 'invoice.partial', + 'invoice.partial_due_date', + 'invoice.custom_value1', + 'invoice.custom_value2', + 'invoice.custom_value3', + 'invoice.custom_value4', + 'invoice.custom_surcharge1', + 'invoice.custom_surcharge2', + 'invoice.custom_surcharge3', + 'invoice.custom_surcharge4', + 'invoice.exchange_rate', + 'invoice.total_taxes', + 'invoice.assigned_user_id', + 'invoice.user_id', + ]; + /** * start_date - Y-m-d end_date - Y-m-d @@ -365,6 +397,18 @@ class ReportCsvGenerationTest extends TestCase ])->post('/api/v1/reports/tasks', $data)->assertStatus(200); + $data = [ + 'date_range' => 'all', + 'report_keys' => array_merge(["task.date","task.number"], $this->all_invoice_report_keys), + 'send_email' => false, + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/reports/tasks', $data); + + } @@ -525,6 +569,18 @@ class ReportCsvGenerationTest extends TestCase ])->post('/api/v1/reports/payments', $data)->assertStatus(200); + + $data = [ + 'date_range' => 'all', + 'report_keys' => array_merge(["payment.amount","payment.date"],$this->all_invoice_report_keys), + 'send_email' => false, + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/reports/payments', $data); + }