fixes for invitations

This commit is contained in:
David Bomba 2020-07-23 16:13:12 +10:00
parent ce3696257f
commit e67c7995d9
3 changed files with 12 additions and 13 deletions

View File

@ -85,18 +85,18 @@ class ValidCreditsRules implements Rule
if(count($this->input['credits']) >=1){ 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(print_r($this->input,1));
info("total payments = {$total_payments}"); // info("total payments = {$total_payments}");
info("total credits available = " . array_sum(array_column($this->input['credits'], 'amount'))); // 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("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"; // $this->error_msg = "Sum of total payments and credits is greater than the total of invoices";
return false; // return false;
} // }
} }

View File

@ -18,6 +18,7 @@ use App\Utils\Ninja;
use App\Utils\Traits\Inviteable; use App\Utils\Traits\Inviteable;
use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesDates;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
@ -25,7 +26,8 @@ class QuoteInvitation extends BaseModel
{ {
use MakesDates; use MakesDates;
use Inviteable; use Inviteable;
use SoftDeletes;
protected $fillable = [ protected $fillable = [
'id', 'id',
'client_contact_id', 'client_contact_id',

View File

@ -55,8 +55,6 @@ class InvitationTest extends TestCase
//test pushing a contact invitation back on //test pushing a contact invitation back on
$contact = $this->invoice->client->contacts->where('is_primary', false)->first(); $contact = $this->invoice->client->contacts->where('is_primary', false)->first();
$new_invite = InvoiceInvitationFactory::create($this->invoice->company_id, $this->invoice->user_id); $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'])); $this->assertEquals(2, count($arr['data']['invitations']));
//Now test that adding a contact back on works!!
} }
} }