2019-05-16 07:36:53 +02:00
|
|
|
<?php
|
2020-09-14 13:11:46 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-09-14 13:11:46 +02:00
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-09-14 13:11:46 +02:00
|
|
|
*/
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2019-05-16 07:36:53 +02:00
|
|
|
namespace Tests\Integration;
|
|
|
|
|
|
|
|
use App\Models\CompanyLedger;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2020-03-28 04:45:11 +01:00
|
|
|
/** @test*/
|
2019-05-16 07:36:53 +02:00
|
|
|
class UpdateCompanyLedgerTest extends TestCase
|
|
|
|
{
|
|
|
|
use MockAccountData;
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
2022-06-21 12:00:57 +02:00
|
|
|
protected function setUp() :void
|
2019-05-16 07:36:53 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function testPaymentIsPresentInLedger()
|
|
|
|
{
|
2020-02-04 08:51:44 +01:00
|
|
|
$invoice = $this->invoice->service()->markPaid()->save();
|
2019-05-16 07:36:53 +02:00
|
|
|
|
|
|
|
$ledger = CompanyLedger::whereClientId($invoice->client_id)
|
|
|
|
->whereCompanyId($invoice->company_id)
|
|
|
|
->orderBy('id', 'DESC')
|
|
|
|
->first();
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$payment = $ledger->adjustment * -1;
|
2019-05-16 07:36:53 +02:00
|
|
|
$this->assertEquals($invoice->amount, $payment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function testInvoiceIsPresentInLedger()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
$invoice = $this->invoice->service()->markPaid()->save();
|
2019-05-16 07:36:53 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$this->assertGreaterThan(0, $invoice->company_ledger()->count());
|
2019-05-16 07:36:53 +02:00
|
|
|
}
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|