1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fixes for tests

This commit is contained in:
David Bomba 2024-02-18 15:32:49 +11:00
parent 22793dbe52
commit e2287c6d57
2 changed files with 16 additions and 4 deletions

View File

@ -68,17 +68,17 @@ class AutoBillInvoice extends AbstractService
$this->applyCreditPayment();
}
nlog($this->client->getSetting('use_unapplied_payment'));
if($this->client->getSetting('use_unapplied_payment') != 'off') {
nlog("meeeeeeerp");
$this->applyUnappliedPayment();
}
//If this returns true, it means a partial invoice amount was paid as a credit and there is no further balance payable
if ($this->is_partial_amount && $this->invoice->partial == 0) {
if (($this->is_partial_amount && $this->invoice->partial == 0) || (int)$this->invoice->balance == 0) {
return;
}
nlog($this->invoice->toArray());
$amount = 0;
$invoice_total = 0;
@ -262,11 +262,13 @@ class AutoBillInvoice extends AbstractService
->where('client_id', $this->client->id)
->where('status_id', Payment::STATUS_COMPLETED)
->where('is_deleted', false)
->where('amount', '>', 'applied')
->whereColumn('amount', '>', 'applied')
->where('amount', '>', 0)
->orderBy('created_at')
->get();
nlog($unapplied_payments->pluck("id"));
$available_unapplied_balance = $unapplied_payments->sum('amount') - $unapplied_payments->sum('applied');
nlog("available unapplied balance = {$available_unapplied_balance}");

View File

@ -2,9 +2,19 @@
namespace Tests;
use App\Utils\Traits\AppSetup;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use AppSetup;
protected function setUp() :void
{
parent::setUp();
$this->buildCache(true);
}
}