2022-05-10 12:06:40 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
namespace Tests\Feature\Export;
|
|
|
|
|
2022-05-12 02:57:58 +02:00
|
|
|
use App\Models\Company;
|
2022-05-10 12:06:40 +02:00
|
|
|
use App\Models\Invoice;
|
2022-05-12 02:57:58 +02:00
|
|
|
use App\Services\Report\ProfitLoss;
|
2022-05-10 12:06:40 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
use League\Csv\Writer;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
2022-05-12 02:57:58 +02:00
|
|
|
* @covers App\Services\Report\ProfitLoss
|
2022-05-10 12:06:40 +02:00
|
|
|
*/
|
|
|
|
class ProfitAndLossReportTest extends TestCase
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
use MockAccountData;
|
|
|
|
|
|
|
|
public function setUp() :void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->withoutMiddleware(
|
|
|
|
ThrottleRequests::class
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
|
|
|
|
$this->withoutExceptionHandling();
|
2022-05-12 03:10:47 +02:00
|
|
|
|
|
|
|
$this->buildData();
|
2022-05-10 12:06:40 +02:00
|
|
|
}
|
|
|
|
|
2022-05-12 03:10:47 +02:00
|
|
|
public $company;
|
|
|
|
|
|
|
|
public $payload;
|
|
|
|
|
2022-05-12 02:57:58 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* start_date - Y-m-d
|
|
|
|
end_date - Y-m-d
|
|
|
|
date_range -
|
|
|
|
all
|
|
|
|
last7
|
|
|
|
last30
|
|
|
|
this_month
|
|
|
|
last_month
|
|
|
|
this_quarter
|
|
|
|
last_quarter
|
|
|
|
this_year
|
|
|
|
custom
|
|
|
|
income_billed - true = Invoiced || false = Payments
|
|
|
|
expense_billed - true = Expensed || false = Expenses marked as paid
|
|
|
|
include_tax - true tax_included || false - tax_excluded
|
|
|
|
|
|
|
|
*/
|
2022-05-12 03:10:47 +02:00
|
|
|
|
|
|
|
private function buildData()
|
2022-05-10 12:06:40 +02:00
|
|
|
{
|
2022-05-12 03:10:47 +02:00
|
|
|
$this->company = Company::factory()->create([
|
2022-05-10 12:06:40 +02:00
|
|
|
'account_id' => $this->account->id,
|
|
|
|
]);
|
|
|
|
|
2022-05-12 03:10:47 +02:00
|
|
|
$this->payload = [
|
2022-05-12 02:57:58 +02:00
|
|
|
'start_date' => '2000-01-01',
|
|
|
|
'end_date' => '2030-01-11',
|
|
|
|
'date_range' => 'custom',
|
|
|
|
'income_billed' => true,
|
|
|
|
'include_tax' => false
|
|
|
|
];
|
2022-05-10 12:06:40 +02:00
|
|
|
|
2022-05-12 03:10:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testProfitLossInstance()
|
|
|
|
{
|
|
|
|
|
|
|
|
$pl = new ProfitLoss($this->company, $this->payload);
|
2022-05-12 02:57:58 +02:00
|
|
|
|
|
|
|
$this->assertInstanceOf(ProfitLoss::class, $pl);
|
2022-05-10 12:06:40 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|