Profit Loss report tests

This commit is contained in:
David Bomba 2023-07-24 12:54:08 +10:00
parent defde9fd0a
commit ad8a7f6766

View File

@ -120,6 +120,84 @@ class ProfitAndLossReportTest extends TestCase
$this->account->delete();
}
public function testMultiCurrencyInvoiceIncome()
{
$this->buildData();
$settings = ClientSettings::defaults();
$settings->currency_id = 2;
$client = Client::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
'is_deleted' => 0,
'settings' => $settings
]);
$client2 = Client::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
'is_deleted' => 0,
]);
Invoice::factory()->create([
'client_id' => $client->id,
'user_id' => $this->user->id,
'company_id' => $this->company->id,
'amount' => 10,
'balance' => 10,
'status_id' => 2,
'total_taxes' => 1,
'date' => now()->format('Y-m-d'),
'terms' => 'nada',
'discount' => 0,
'tax_rate1' => 0,
'tax_rate2' => 0,
'tax_rate3' => 0,
'tax_name1' => '',
'tax_name2' => '',
'tax_name3' => '',
'uses_inclusive_taxes' => false,
'exchange_rate' => 2
]);
Invoice::factory()->create([
'client_id' => $client2->id,
'user_id' => $this->user->id,
'company_id' => $this->company->id,
'amount' => 10,
'balance' => 10,
'status_id' => 2,
'total_taxes' => 1,
'date' => now()->format('Y-m-d'),
'terms' => 'nada',
'discount' => 0,
'tax_rate1' => 0,
'tax_rate2' => 0,
'tax_rate3' => 0,
'tax_name1' => '',
'tax_name2' => '',
'tax_name3' => '',
'uses_inclusive_taxes' => false,
'exchange_rate' => 1
]);
$pl = new ProfitLoss($this->company, $this->payload);
$pl->build();
$this->assertEquals(13.5, $pl->getIncome());
$this->assertEquals(1.5, $pl->getIncomeTaxes());
$this->account->delete();
}
public function testSimpleInvoiceIncome()
{
$this->buildData();