From dfd82520a2d37a5e520238d3e187e8dc410fd574 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 21 May 2022 08:37:19 +1000 Subject: [PATCH 1/4] Fixes for validation rules for exports --- app/Http/Requests/Report/GenericReportRequest.php | 2 +- routes/api.php | 2 +- tests/Feature/Export/ClientCsvTest.php | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php index c197b21d7670..e8e3e4f89a44 100644 --- a/app/Http/Requests/Report/GenericReportRequest.php +++ b/app/Http/Requests/Report/GenericReportRequest.php @@ -32,7 +32,7 @@ class GenericReportRequest extends Request 'end_date' => 'string|date', 'date_key' => 'string', 'date_range' => 'required|string', - 'report_keys' => 'present|array', + 'report_keys' => 'required|present|array', 'send_email' => 'required|bool', ]; } diff --git a/routes/api.php b/routes/api.php index fe04fbe3c2bf..158fe34c2fa3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -153,7 +153,7 @@ Route::group(['middleware' => ['throttle:100,1', 'api_db', 'token_auth', 'locale Route::post('recurring_quotes/bulk', 'RecurringQuoteController@bulk')->name('recurring_quotes.bulk'); Route::put('recurring_quotes/{recurring_quote}/upload', 'RecurringQuoteController@upload'); - Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:30,1'); + Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:50,1'); Route::post('reports/clients', 'Reports\ClientReportController'); Route::post('reports/contacts', 'Reports\ClientContactReportController'); diff --git a/tests/Feature/Export/ClientCsvTest.php b/tests/Feature/Export/ClientCsvTest.php index 0708848505c1..3002facc8095 100644 --- a/tests/Feature/Export/ClientCsvTest.php +++ b/tests/Feature/Export/ClientCsvTest.php @@ -45,6 +45,7 @@ class ClientCsvTest extends TestCase $data = [ "date_range" => "this_year", "report_keys" => [], + "send_email" => false ]; $response = $this->withHeaders([ @@ -62,6 +63,7 @@ class ClientCsvTest extends TestCase $data = [ "date_range" => "this_year", "report_keys" => [], + "send_email" => false ]; $response = $this->withHeaders([ From eff14075216e027545e3d419ca4e0d9899ef099a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 21 May 2022 09:53:05 +1000 Subject: [PATCH 2/4] Fixes for data array for migration email --- app/Mail/MigrationCompleted.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Mail/MigrationCompleted.php b/app/Mail/MigrationCompleted.php index ced994b6f2ae..52aafec22291 100644 --- a/app/Mail/MigrationCompleted.php +++ b/app/Mail/MigrationCompleted.php @@ -47,6 +47,28 @@ class MigrationCompleted extends Mailable $data['check_data'] = $this->check_data ?: ''; $data['logo'] = $this->company->present()->logo(); + $data = array_merge($data, [ + 'logo' => $this->company->present()->logo(), + 'settings' => $this->company->settings, + 'company' => $this->company, + 'client_count' => $this->company->clients()->count(), + 'product_count' => $this->company->products()->count(), + 'invoice_count' => $this->company->invoices()->count(), + 'quote_count' => $this->company->quotes()->count(), + 'credit_count' => $this->company->credits()->count(), + 'project_count' => $this->company->projects()->count(), + 'task_count' => $this->company->tasks()->count(), + 'vendor_count' => $this->company->vendors()->count(), + 'payment_count' => $this->company->payments()->count(), + 'recurring_invoice_count' => $this->company->recurring_invoices()->count(), + 'expense_count' => $this->company->expenses()->count(), + 'company_gateway_count' => $this->company->company_gateways()->count(), + 'client_gateway_token_count' => $this->company->client_gateway_tokens()->count(), + 'tax_rate_count' => $this->company->tax_rates()->count(), + 'document_count' => $this->company->documents()->count(), + + ]); + $result = $this->from(config('mail.from.address'), config('mail.from.name')) ->text('email.import.completed_text', $data) ->view('email.import.completed', $data); From bcd67cf42be4ebd0b4b3ac6b18f46f778ee03c3e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 21 May 2022 10:35:56 +1000 Subject: [PATCH 3/4] fixes for reports --- app/Http/Requests/Report/GenericReportRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php index e8e3e4f89a44..c197b21d7670 100644 --- a/app/Http/Requests/Report/GenericReportRequest.php +++ b/app/Http/Requests/Report/GenericReportRequest.php @@ -32,7 +32,7 @@ class GenericReportRequest extends Request 'end_date' => 'string|date', 'date_key' => 'string', 'date_range' => 'required|string', - 'report_keys' => 'required|present|array', + 'report_keys' => 'present|array', 'send_email' => 'required|bool', ]; } From fb680606e8b0962a6e5b6b41ebec50a4bca4c3e7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 21 May 2022 10:37:30 +1000 Subject: [PATCH 4/4] Handle no report key parameter --- app/Http/Requests/Report/GenericReportRequest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php index c197b21d7670..208e53aac682 100644 --- a/app/Http/Requests/Report/GenericReportRequest.php +++ b/app/Http/Requests/Report/GenericReportRequest.php @@ -36,4 +36,15 @@ class GenericReportRequest extends Request 'send_email' => 'required|bool', ]; } + + public function prepareForValidation() + { + $input = $this->all(); + + + if(!array_key_exists('report_keys', $input)) + $input['report_keys'] = []; + + $this->replace($input); + } }