From f6f5b89af95a117532787cb4f1d30b7a90380ff4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 17 Dec 2019 21:50:45 +1100 Subject: [PATCH] Return company user settings as object (#3156) * Conditional in test * Add additional fields to payments * Additional fields for payments table * Return company user as object --- app/Http/Requests/Payment/StorePaymentRequest.php | 1 + app/Jobs/User/CreateUser.php | 2 +- app/Models/Payment.php | 3 ++- app/Transformers/CompanyUserTransformer.php | 2 +- app/Transformers/PaymentTransformer.php | 2 ++ database/migrations/2014_10_13_000000_create_users_table.php | 4 +++- tests/Feature/ClientModelTest.php | 3 +++ 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Payment/StorePaymentRequest.php b/app/Http/Requests/Payment/StorePaymentRequest.php index 4fa09fb560..d5120183ad 100644 --- a/app/Http/Requests/Payment/StorePaymentRequest.php +++ b/app/Http/Requests/Payment/StorePaymentRequest.php @@ -66,6 +66,7 @@ class StorePaymentRequest extends Request 'date' => 'required', 'client_id' => 'required', 'invoices' => new ValidPayableInvoicesRule(), + 'number' => 'nullable|unique', ]; return $rules; diff --git a/app/Jobs/User/CreateUser.php b/app/Jobs/User/CreateUser.php index 36d4541d6f..b8173cb5f1 100644 --- a/app/Jobs/User/CreateUser.php +++ b/app/Jobs/User/CreateUser.php @@ -71,7 +71,7 @@ class CreateUser 'is_admin' => 1, 'is_locked' => 0, 'permissions' => '', - 'settings' => json_encode(DefaultSettings::userSettings()), + 'settings' => DefaultSettings::userSettings(), ]); event(new UserWasCreated($user, $this->company)); diff --git a/app/Models/Payment.php b/app/Models/Payment.php index a75b634c58..3779bda717 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -55,7 +55,8 @@ class Payment extends BaseModel 'type_id', 'amount', 'date', - 'transaction_reference' + 'transaction_reference', + 'number' ]; protected $casts = [ diff --git a/app/Transformers/CompanyUserTransformer.php b/app/Transformers/CompanyUserTransformer.php index cf96c490d8..07a7caa9b6 100644 --- a/app/Transformers/CompanyUserTransformer.php +++ b/app/Transformers/CompanyUserTransformer.php @@ -51,7 +51,7 @@ class CompanyUserTransformer extends EntityTransformer // 'user_id' => $company_user->user_id, // 'company_id' => $company_user->company_id, 'permissions' => $company_user->permissions ?: '', - 'settings' => $company_user->settings ?: '', + 'settings' => $company_user->settings, 'is_owner' => (bool) $company_user->is_owner, 'is_admin' => (bool) $company_user->is_admin, 'is_locked' => (bool) $company_user->is_locked, diff --git a/app/Transformers/PaymentTransformer.php b/app/Transformers/PaymentTransformer.php index 8da1be54d7..091afb650a 100644 --- a/app/Transformers/PaymentTransformer.php +++ b/app/Transformers/PaymentTransformer.php @@ -70,6 +70,7 @@ class PaymentTransformer extends EntityTransformer 'assigned_user_id' => $this->encodePrimaryKey($payment->assigned_user_id), 'amount' => (float) $payment->amount, 'refunded' => (float) $payment->refunded, + 'applied' => (float) $payment->applied, 'transaction_reference' => $payment->transaction_reference ?: '', 'date' => $payment->date ?: '', 'is_manual' => (bool) $payment->is_manual, @@ -78,6 +79,7 @@ class PaymentTransformer extends EntityTransformer 'is_deleted' => (bool) $payment->is_deleted, 'type_id' => (string) $payment->payment_type_id ?: '', 'invitation_id' => (string) $payment->invitation_id ?: '', + 'number' => (string) $payment->number ?: '', 'client_id' => (string) $this->encodePrimaryKey($payment->client_id), 'client_contact_id' => (string) $this->encodePrimaryKey($payment->client_contact_id), 'company_gateway_id' => (string) $this->encodePrimaryKey($payment->company_gateway_id), diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index b780c77045..c16975ae61 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -422,7 +422,7 @@ class CreateUsersTable extends Migration $table->string('custom_value2')->nullable(); $table->string('custom_value3')->nullable(); $table->string('custom_value4')->nullable(); - + $table->timestamps(6); $table->softDeletes('deleted_at', 6); @@ -815,9 +815,11 @@ class CreateUsersTable extends Migration $t->unsignedInteger('status_id')->index(); $t->decimal('amount', 16, 4)->default(0); $t->decimal('refunded', 16, 4)->default(0); + $t->decimal('applied', 16, 4)->default(0); $t->date('date')->nullable(); $t->string('transaction_reference')->nullable(); $t->string('payer_id')->nullable(); + $t->string('number')->nullable(); $t->timestamps(6); $t->softDeletes('deleted_at', 6); $t->boolean('is_deleted')->default(false); diff --git a/tests/Feature/ClientModelTest.php b/tests/Feature/ClientModelTest.php index 1fda99cce4..eed4dc80f5 100644 --- a/tests/Feature/ClientModelTest.php +++ b/tests/Feature/ClientModelTest.php @@ -26,6 +26,9 @@ class ClientModelTest extends TestCase if(config('ninja.testvars.travis') !== false) $this->markTestSkipped('Skip test for Travis'); + + if(!config('ninja.testvars.stripe')) + $this->markTestSkipped('Skip test no company gateways installed'); }