From e67c7995d940d12ec5bc731ae62cea7b4027d1a5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Jul 2020 16:13:12 +1000 Subject: [PATCH] fixes for invitations --- .../Credit/ValidCreditsRules.php | 18 +++++++++--------- app/Models/QuoteInvitation.php | 4 +++- tests/Unit/InvitationTest.php | 3 --- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/Http/ValidationRules/Credit/ValidCreditsRules.php b/app/Http/ValidationRules/Credit/ValidCreditsRules.php index 507d0262fc20..98abcebc9ed1 100644 --- a/app/Http/ValidationRules/Credit/ValidCreditsRules.php +++ b/app/Http/ValidationRules/Credit/ValidCreditsRules.php @@ -85,18 +85,18 @@ class ValidCreditsRules implements Rule if(count($this->input['credits']) >=1){ - $total_payments = $this->input['amount'] + array_sum(array_column($this->input['credits'], 'amount')); + // $total_payments = $this->input['amount'] + array_sum(array_column($this->input['credits'], 'amount')); -info(print_r($this->input,1)); -info("total payments = {$total_payments}"); -info("total credits available = " . array_sum(array_column($this->input['credits'], 'amount'))); -info("total invoices payable = " . array_sum(array_column($this->input['invoices'], 'amount'))); +// info(print_r($this->input,1)); +// info("total payments = {$total_payments}"); +// info("total credits available = " . array_sum(array_column($this->input['credits'], 'amount'))); +// info("total invoices payable = " . array_sum(array_column($this->input['invoices'], 'amount'))); - if($total_payments > array_sum(array_column($this->input['invoices'], 'amount'))){ + // if($total_payments > array_sum(array_column($this->input['invoices'], 'amount'))){ - $this->error_msg = "Sum of total payments and credits is greater than the total of invoices"; - return false; - } + // $this->error_msg = "Sum of total payments and credits is greater than the total of invoices"; + // return false; + // } } diff --git a/app/Models/QuoteInvitation.php b/app/Models/QuoteInvitation.php index 4a794ce52ac8..a258d1f9f0c4 100644 --- a/app/Models/QuoteInvitation.php +++ b/app/Models/QuoteInvitation.php @@ -18,6 +18,7 @@ use App\Utils\Ninja; use App\Utils\Traits\Inviteable; use App\Utils\Traits\MakesDates; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Storage; @@ -25,7 +26,8 @@ class QuoteInvitation extends BaseModel { use MakesDates; use Inviteable; - + use SoftDeletes; + protected $fillable = [ 'id', 'client_contact_id', diff --git a/tests/Unit/InvitationTest.php b/tests/Unit/InvitationTest.php index 68ab59206886..b01727ac2d6d 100644 --- a/tests/Unit/InvitationTest.php +++ b/tests/Unit/InvitationTest.php @@ -55,8 +55,6 @@ class InvitationTest extends TestCase //test pushing a contact invitation back on - - $contact = $this->invoice->client->contacts->where('is_primary', false)->first(); $new_invite = InvoiceInvitationFactory::create($this->invoice->company_id, $this->invoice->user_id); @@ -79,6 +77,5 @@ class InvitationTest extends TestCase $this->assertEquals(2, count($arr['data']['invitations'])); - //Now test that adding a contact back on works!! } }