diff --git a/tests/Feature/Export/ProfitAndLossReportTest.php b/tests/Feature/Export/ProfitAndLossReportTest.php index 52ba1b37342d..be680c16047e 100644 --- a/tests/Feature/Export/ProfitAndLossReportTest.php +++ b/tests/Feature/Export/ProfitAndLossReportTest.php @@ -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();