1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 01:11:34 +02:00
invoiceninja/tests/Integration/UpdateCompanyLedgerTest.php
2020-09-14 21:11:46 +10:00

69 lines
1.7 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Tests\Integration;
use App\Events\Invoice\InvoiceWasCreated;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Events\Payment\PaymentWasCreated;
use App\Jobs\Invoice\MarkInvoicePaid;
use App\Models\Account;
use App\Models\Activity;
use App\Models\Company;
use App\Models\CompanyLedger;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\User;
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\MockAccountData;
use Tests\TestCase;
/** @test*/
class UpdateCompanyLedgerTest extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
public function setUp() :void
{
parent::setUp();
$this->makeTestData();
}
/**
* @test
*/
public function testPaymentIsPresentInLedger()
{
$invoice = $this->invoice->service()->markPaid()->save();
$ledger = CompanyLedger::whereClientId($invoice->client_id)
->whereCompanyId($invoice->company_id)
->orderBy('id', 'DESC')
->first();
$payment = $ledger->adjustment * -1;
$this->assertEquals($invoice->amount, $payment);
}
/**
* @test
*/
public function testInvoiceIsPresentInLedger()
{
$invoice = $this->invoice->service()->markPaid()->save();
$this->assertGreaterThan(0, $invoice->company_ledger()->count());
}
}