From 9ae0474de3610473ab2db5d093bfba0bf21c4c2b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 16:56:36 +1000 Subject: [PATCH 1/9] Fixes for type checking for purchase orders --- app/Filters/InvoiceFilters.php | 10 +++++++++- .../PurchaseOrder/StorePurchaseOrderRequest.php | 11 +++++++++-- .../PurchaseOrder/UpdatePurchaseOrderRequest.php | 6 ++++++ app/Jobs/Mail/NinjaMailerJob.php | 11 ++++++++--- .../2022_06_30_000126_add_flag_to_accounts_table.php | 1 + 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index b10fbc1fd02d..4bb25f5867e2 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -138,6 +138,14 @@ class InvoiceFilters extends QueryFilters }); } + public function without_deleted_clients() + { + + return $this->builder->whereHas('client', function ($query) { + $query->where('is_deleted',0); + }); + } + public function upcoming() { return $this->builder @@ -212,7 +220,7 @@ class InvoiceFilters extends QueryFilters { if (auth()->guard('contact')->user()) { return $this->contactViewFilter(); - } else { + } else { return $this->builder->company()->with(['invitations.company'], ['documents.company']); } diff --git a/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php b/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php index 5b63416e468e..6bad2016aee1 100644 --- a/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php +++ b/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php @@ -14,12 +14,15 @@ namespace App\Http\Requests\PurchaseOrder; use App\Http\Requests\Request; use App\Models\PurchaseOrder; +use App\Utils\Traits\CleanLineItems; use App\Utils\Traits\MakesHash; use Illuminate\Validation\Rule; class StorePurchaseOrderRequest extends Request { use MakesHash; + use CleanLineItems; + /** * Determine if the user is authorized to make this request. * @@ -43,8 +46,6 @@ class StorePurchaseOrderRequest extends Request $rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', auth()->user()->company()->id)]; $rules['discount'] = 'sometimes|numeric'; $rules['is_amount_discount'] = ['boolean']; - - $rules['line_items'] = 'array'; return $rules; @@ -56,6 +57,12 @@ class StorePurchaseOrderRequest extends Request $input = $this->decodePrimaryKeys($input); + if (isset($input['line_items']) && is_array($input['line_items'])) + $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + + $input['amount'] = 0; + $input['balance'] = 0; + $this->replace($input); } diff --git a/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php b/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php index d2e83154fb95..a95e1ee4c0c0 100644 --- a/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php +++ b/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php @@ -14,6 +14,7 @@ namespace App\Http\Requests\PurchaseOrder; use App\Http\Requests\Request; use App\Utils\Traits\ChecksEntityStatus; +use App\Utils\Traits\CleanLineItems; use App\Utils\Traits\MakesHash; use Illuminate\Validation\Rule; @@ -21,6 +22,7 @@ class UpdatePurchaseOrderRequest extends Request { use ChecksEntityStatus; use MakesHash; + use CleanLineItems; /** * Determine if the user is authorized to make this request. @@ -57,6 +59,10 @@ class UpdatePurchaseOrderRequest extends Request $input['id'] = $this->purchase_order->id; + if (isset($input['line_items']) && is_array($input['line_items'])) { + $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + } + $this->replace($input); } } diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 6e7296e96c52..ed5fc8476dde 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -318,20 +318,25 @@ class NinjaMailerJob implements ShouldQueue return true; /* GMail users are uncapped */ - if(Ninja::isHosted() && $this->nmo->settings->email_sending_method == 'gmail') + if(Ninja::isHosted() && ($this->nmo->settings->email_sending_method == 'gmail' || $this->nmo->settings->email_sending_method == 'office365')) return false; /* On the hosted platform, if the user is over the email quotas, we do not send the email. */ if(Ninja::isHosted() && $this->company->account && $this->company->account->emailQuotaExceeded()) return true; + /* To handle spam users we drop all emails from flagged accounts */ if(Ninja::isHosted() && $this->company->account && $this->nmo->company->account->is_flagged) return true; /* Ensure the user has a valid email address */ if(!str_contains($this->nmo->to_user->email, "@")) return true; - + + /* On the hosted platform we actively scan all outbound emails to ensure outbound email quality remains high */ + if(Ninja::isHosted()) + return (new \Modules\Admin\Jobs\Account\EmailQuality($this->nmo, $this->company))->run(); + return false; } @@ -373,7 +378,7 @@ class NinjaMailerJob implements ShouldQueue 'form_params' => [ 'client_id' => config('ninja.o365.client_id') , 'client_secret' => config('ninja.o365.client_secret') , - 'scope' => 'email Mail.ReadWrite Mail.Send offline_access profile User.Read openid', + 'scope' => 'email Mail.Send offline_access profile User.Read openid', 'grant_type' => 'refresh_token', 'refresh_token' => $user->oauth_user_refresh_token ], diff --git a/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php b/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php index 7118a7d7f564..c43b25db0c7a 100644 --- a/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php +++ b/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php @@ -15,6 +15,7 @@ class AddFlagToAccountsTable extends Migration { Schema::table('accounts', function (Blueprint $table) { $table->boolean('is_flagged')->default(0); + $table->boolean('is_verified_account')->default(0); }); } From 999ff54593cf02f5bde8d5eb1522a683c9eb2e19 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 16:58:57 +1000 Subject: [PATCH 2/9] Fixes for type checking for purchase orders --- app/Models/PurchaseOrder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index 253ce4072356..445535163633 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -153,7 +153,7 @@ class PurchaseOrder extends BaseModel public function vendor() { - return $this->belongsTo(Vendor::class); + return $this->belongsTo(Vendor::class)->withTrashed(); } public function history() From a20240b64f02e40002f2ff79c74dbb0036dbdcba Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 17:13:35 +1000 Subject: [PATCH 3/9] Fixes for type checking for purchase orders --- app/Utils/VendorHtmlEngine.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Utils/VendorHtmlEngine.php b/app/Utils/VendorHtmlEngine.php index 36cc99a9fb08..cbea4bb4fac0 100644 --- a/app/Utils/VendorHtmlEngine.php +++ b/app/Utils/VendorHtmlEngine.php @@ -63,6 +63,11 @@ class VendorHtmlEngine $this->vendor = $this->contact->vendor->load('company','country'); + if(!$this->vendor->currency_id){ + $this->vendor->currency_id = $this->company->settings->currency_id; + $this->vendor->save(); + } + $this->entity->load('vendor'); $this->settings = $this->company->settings; From af8ec95e2c7329b56a101be9ef4835e14512cf71 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 17:51:35 +1000 Subject: [PATCH 4/9] Fixes for surcharge visibility --- app/Services/PdfMaker/Design.php | 8 +++++--- app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index a1e7beaaae2b..85295f7d358d 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -60,6 +60,8 @@ class Design extends BaseDesign public $company; + public $client_or_vendor_entity; + /** @var array */ public $aging = []; @@ -803,7 +805,7 @@ class Design extends BaseDesign foreach ($taxes as $i => $tax) { $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content', 'content' => $tax['name'], 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i . '-label']], - ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->context['client']), 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i]], + ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i]], ]]; } } elseif ($variable == '$line_taxes') { @@ -816,13 +818,13 @@ class Design extends BaseDesign foreach ($taxes as $i => $tax) { $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content', 'content' => $tax['name'], 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i . '-label']], - ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->context['client']), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]], + ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]], ]]; } } elseif (Str::startsWith($variable, '$custom_surcharge')) { $_variable = ltrim($variable, '$'); // $custom_surcharge1 -> custom_surcharge1 - $visible = (int)$this->entity->{$_variable} != 0 || $this->entity->{$_variable} != '0' || !$this->entity->{$_variable}; + $visible = (int)$this->entity->{$_variable} > 0 || (int)$this->entity->{$_variable} < 0 || !$this->entity->{$_variable}; $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']], diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 8318d2434976..a6f60e9b9a1e 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -32,10 +32,12 @@ trait DesignHelpers if (isset($this->context['vendor'])) { $this->vendor = $this->context['vendor']; + $this->client_or_vendor_entity = $this->context['vendor']; } if (isset($this->context['client'])) { $this->client = $this->context['client']; + $this->client_or_vendor_entity = $this->context['client']; } if (isset($this->context['entity'])) { From fcdc69c8291f20f8aa9fe7ba4198378998a67ba5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 18:11:04 +1000 Subject: [PATCH 5/9] Fixes for surcharge visibility --- VERSION.txt | 2 +- app/Utils/TemplateEngine.php | 6 +++--- config/ninja.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 3238344b3b0d..3caaea554760 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.4.4 \ No newline at end of file +5.4.5 \ No newline at end of file diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index 9acf3093ad42..143164031d91 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -105,7 +105,7 @@ class TemplateEngine private function setSettingsObject() { - if($this->entity == 'purchase_order'){ + if($this->entity == 'purchaseOrder'){ $this->settings_entity = auth()->user()->company(); $this->settings = $this->settings_entity->settings; } @@ -153,7 +153,7 @@ class TemplateEngine $this->raw_body = $this->body; $this->raw_subject = $this->subject; - if($this->entity == 'purchase_order'){ + if($this->entity == 'purchaseOrder'){ $this->fakerValues(); } elseif ($this->entity_obj) { @@ -269,7 +269,7 @@ class TemplateEngine private function mockEntity() { if(!$this->entity && $this->template && str_contains($this->template, 'purchase_order')) - $this->entity = 'purchase_order'; + $this->entity = 'purchaseOrder'; DB::connection(config('database.default'))->beginTransaction(); diff --git a/config/ninja.php b/config/ninja.php index 508852f4a799..a10a75913a20 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.4.4', - 'app_tag' => '5.4.4', + 'app_version' => '5.4.5', + 'app_tag' => '5.4.5', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), From 3499ad885c902bf235993c813f380935b319ab8d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 18:19:40 +1000 Subject: [PATCH 6/9] Fixes for templates --- app/Utils/TemplateEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index 143164031d91..fb848bd6adb4 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -109,7 +109,7 @@ class TemplateEngine $this->settings_entity = auth()->user()->company(); $this->settings = $this->settings_entity->settings; } - elseif ($this->entity_obj) { + elseif ($this->entity_obj->client()->exists()) { $this->settings_entity = $this->entity_obj->client; $this->settings = $this->settings_entity->getMergedSettings(); } else { From 0ac5acda827f12153fcda130a217d9492be55ca3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 18:35:52 +1000 Subject: [PATCH 7/9] Fixes for templates --- app/Utils/TemplateEngine.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index fb848bd6adb4..4e0b6580de6d 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -84,6 +84,10 @@ class TemplateEngine public function build() { + + if ($this->template == 'email_template_null') + $this->template = 'email_template_purchase_order'; + return $this->setEntity() ->setSettingsObject() ->setTemplates() @@ -156,7 +160,7 @@ class TemplateEngine if($this->entity == 'purchaseOrder'){ $this->fakerValues(); } - elseif ($this->entity_obj) { + elseif ($this->entity_obj->client()->exists()) { $this->entityValues($this->entity_obj->client->primary_contact()->first()); } else { @@ -186,7 +190,7 @@ class TemplateEngine private function entityValues($contact) { - if($this->entity == 'purchase_order') + if($this->entity == 'purchaseOrder') $this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues(); else $this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues(); @@ -214,7 +218,7 @@ class TemplateEngine $data['footer'] = ''; $data['logo'] = auth()->user()->company()->present()->logo(); - if($this->entity_obj->client) + if($this->entity_obj->client()->exists()) $data = array_merge($data, Helpers::sharedEmailVariables($this->entity_obj->client)); else{ @@ -323,7 +327,7 @@ class TemplateEngine - if($this->entity == 'purchase_order') + if($this->entity == 'purchaseOrder') { $vendor = Vendor::factory()->create([ From 19d71337bad0021ce024957a19e26c9a47402858 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 18:56:19 +1000 Subject: [PATCH 8/9] Fixes for tests --- app/Http/Requests/Project/StoreProjectRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/Project/StoreProjectRequest.php b/app/Http/Requests/Project/StoreProjectRequest.php index 5af9c062f0c7..dfda233cbb10 100644 --- a/app/Http/Requests/Project/StoreProjectRequest.php +++ b/app/Http/Requests/Project/StoreProjectRequest.php @@ -58,6 +58,6 @@ class StoreProjectRequest extends Request public function getClient($client_id) { - return Client::find($client_id); + return Client::withTrashed()->find($client_id); } } From 330c5bcba14cc320b7c97792977884d480bf048f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 1 Jul 2022 19:24:22 +1000 Subject: [PATCH 9/9] Fixes for tests --- tests/Integration/EventTest.php | 124 ++++++++++++++++---------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/tests/Integration/EventTest.php b/tests/Integration/EventTest.php index d13e61f1d632..58bc6211c8aa 100644 --- a/tests/Integration/EventTest.php +++ b/tests/Integration/EventTest.php @@ -124,7 +124,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/expenses/', $data) + ])->postJson('/api/v1/expenses/', $data) ->assertStatus(200); @@ -137,7 +137,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/expenses/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/expenses/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -148,19 +148,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/expenses/bulk?action=archive', $data) + ])->postJson('/api/v1/expenses/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/expenses/bulk?action=restore', $data) + ])->postJson('/api/v1/expenses/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/expenses/bulk?action=delete', $data) + ])->postJson('/api/v1/expenses/bulk?action=delete', $data) ->assertStatus(200); } @@ -183,7 +183,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/vendors/', $data) + ])->postJson('/api/v1/vendors/', $data) ->assertStatus(200); @@ -197,7 +197,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/vendors/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/vendors/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -208,19 +208,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/vendors/bulk?action=archive', $data) + ])->postJson('/api/v1/vendors/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/vendors/bulk?action=restore', $data) + ])->postJson('/api/v1/vendors/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/vendors/bulk?action=delete', $data) + ])->postJson('/api/v1/vendors/bulk?action=delete', $data) ->assertStatus(200); } @@ -245,7 +245,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/tasks/', $data) + ])->postJson('/api/v1/tasks/', $data) ->assertStatus(200); @@ -259,7 +259,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/tasks/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/tasks/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -270,19 +270,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/tasks/bulk?action=archive', $data) + ])->postJson('/api/v1/tasks/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/tasks/bulk?action=restore', $data) + ])->postJson('/api/v1/tasks/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/tasks/bulk?action=delete', $data) + ])->postJson('/api/v1/tasks/bulk?action=delete', $data) ->assertStatus(200); } @@ -306,7 +306,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/credits/', $data) + ])->postJson('/api/v1/credits/', $data) ->assertStatus(200); @@ -320,7 +320,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/credits/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/credits/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -331,19 +331,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/credits/bulk?action=archive', $data) + ])->postJson('/api/v1/credits/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/credits/bulk?action=restore', $data) + ])->postJson('/api/v1/credits/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/credits/bulk?action=delete', $data) + ])->postJson('/api/v1/credits/bulk?action=delete', $data) ->assertStatus(200); } @@ -368,7 +368,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/quotes/', $data) + ])->postJson('/api/v1/quotes/', $data) ->assertStatus(200); @@ -382,7 +382,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/quotes/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/quotes/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -397,25 +397,25 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/quotes/bulk?action=archive', $data) + ])->postJson('/api/v1/quotes/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/quotes/bulk?action=restore', $data) + ])->postJson('/api/v1/quotes/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/quotes/bulk?action=approve', $data) + ])->postJson('/api/v1/quotes/bulk?action=approve', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/quotes/bulk?action=delete', $data) + ])->postJson('/api/v1/quotes/bulk?action=delete', $data) ->assertStatus(200); } @@ -449,7 +449,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/payments?include=invoices', $data) + ])->postJson('/api/v1/payments?include=invoices', $data) ->assertStatus(200); $arr = $response->json(); @@ -461,7 +461,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/payments/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/payments/' . $arr['data']['id'], $data) ->assertStatus(200); $data = [ @@ -471,19 +471,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/payments/bulk?action=archive', $data) + ])->postJson('/api/v1/payments/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/payments/bulk?action=restore', $data) + ])->postJson('/api/v1/payments/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/payments/bulk?action=delete', $data) + ])->postJson('/api/v1/payments/bulk?action=delete', $data) ->assertStatus(200); } @@ -507,7 +507,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/invoices/', $data) + ])->postJson('/api/v1/invoices/', $data) ->assertStatus(200); @@ -521,7 +521,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/invoices/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/invoices/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -532,19 +532,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/invoices/bulk?action=archive', $data) + ])->postJson('/api/v1/invoices/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/invoices/bulk?action=restore', $data) + ])->postJson('/api/v1/invoices/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/invoices/bulk?action=delete', $data) + ])->postJson('/api/v1/invoices/bulk?action=delete', $data) ->assertStatus(200); } @@ -571,7 +571,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/recurring_invoices/', $data); + ])->postJson('/api/v1/recurring_invoices/', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); } @@ -590,7 +590,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/recurring_invoices/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/recurring_invoices/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -601,19 +601,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/recurring_invoices/bulk?action=archive', $data) + ])->postJson('/api/v1/recurring_invoices/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/recurring_invoices/bulk?action=restore', $data) + ])->postJson('/api/v1/recurring_invoices/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/recurring_invoices/bulk?action=delete', $data) + ])->postJson('/api/v1/recurring_invoices/bulk?action=delete', $data) ->assertStatus(200); } @@ -636,7 +636,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/', $data) + ])->postJson('/api/v1/clients/', $data) ->assertStatus(200); @@ -650,7 +650,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/clients/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/clients/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -661,19 +661,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/bulk?action=archive', $data) + ])->postJson('/api/v1/clients/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/bulk?action=restore', $data) + ])->postJson('/api/v1/clients/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/clients/bulk?action=delete', $data) + ])->postJson('/api/v1/clients/bulk?action=delete', $data) ->assertStatus(200); } @@ -705,7 +705,7 @@ class EventTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', - ])->post('/api/v1/users?include=company_user', $data) + ])->postJson('/api/v1/users?include=company_user', $data) ->assertStatus(200); $arr = $response->json(); @@ -725,7 +725,7 @@ class EventTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', - ])->put('/api/v1/users/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/users/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -737,21 +737,21 @@ class EventTest extends TestCase 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', - ])->post('/api/v1/users/bulk?action=archive', $data) + ])->postJson('/api/v1/users/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', - ])->post('/api/v1/users/bulk?action=restore', $data) + ])->postJson('/api/v1/users/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', - ])->post('/api/v1/users/bulk?action=delete', $data) + ])->postJson('/api/v1/users/bulk?action=delete', $data) ->assertStatus(200); } @@ -772,7 +772,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/subscriptions/', $data) + ])->postJson('/api/v1/subscriptions/', $data) ->assertStatus(200); @@ -785,7 +785,7 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/subscriptions/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/subscriptions/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -796,19 +796,19 @@ class EventTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/subscriptions/bulk?action=archive', $data) + ])->postJson('/api/v1/subscriptions/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/subscriptions/bulk?action=restore', $data) + ])->postJson('/api/v1/subscriptions/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/subscriptions/bulk?action=delete', $data) + ])->postJson('/api/v1/subscriptions/bulk?action=delete', $data) ->assertStatus(200); } @@ -833,7 +833,7 @@ public function PurchaseOrderEvents() $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/purchase_orders/', $data) + ])->postJson('/api/v1/purchase_orders/', $data) ->assertStatus(200); @@ -847,7 +847,7 @@ public function PurchaseOrderEvents() $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/purchase_orders/' . $arr['data']['id'], $data) + ])->putJson('/api/v1/purchase_orders/' . $arr['data']['id'], $data) ->assertStatus(200); @@ -862,25 +862,25 @@ public function PurchaseOrderEvents() $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/purchase_orders/bulk?action=archive', $data) + ])->postJson('/api/v1/purchase_orders/bulk?action=archive', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/purchase_orders/bulk?action=restore', $data) + ])->postJson('/api/v1/purchase_orders/bulk?action=restore', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/purchase_orders/bulk?action=approve', $data) + ])->postJson('/api/v1/purchase_orders/bulk?action=approve', $data) ->assertStatus(200); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->post('/api/v1/purchase_orders/bulk?action=delete', $data) + ])->postJson('/api/v1/purchase_orders/bulk?action=delete', $data) ->assertStatus(200); }