mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
CSVs with custom columns
This commit is contained in:
parent
e0807a3a6a
commit
18ca64c72c
@ -172,8 +172,8 @@ class ClientExport extends BaseExport
|
|||||||
$entity['shipping_country'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : '';
|
$entity['shipping_country'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('client.currency', $this->input['report_keys'])) {
|
if (in_array('client.currency_id', $this->input['report_keys'])) {
|
||||||
$entity['currency'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
|
$entity['client.currency_id'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('client.industry_id', $this->input['report_keys'])) {
|
if (in_array('client.industry_id', $this->input['report_keys'])) {
|
||||||
|
@ -143,10 +143,13 @@ class ReportCsvGenerationTest extends TestCase
|
|||||||
|
|
||||||
$this->client = Client::factory()->create([
|
$this->client = Client::factory()->create([
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
|
// 'assigned_user_id', $this->user->id,
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'is_deleted' => 0,
|
'is_deleted' => 0,
|
||||||
'name' => 'bob',
|
'name' => 'bob',
|
||||||
'address1' => '1234'
|
'address1' => '1234',
|
||||||
|
'balance' => 100,
|
||||||
|
'paid_to_date' => 50,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ClientContact::factory()->create([
|
ClientContact::factory()->create([
|
||||||
@ -307,6 +310,35 @@ class ReportCsvGenerationTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testClientCustomColumnsCsvGeneration()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'date_range' => 'all',
|
||||||
|
'report_keys' => ["client.name","client.user","client.assigned_user","client.balance","client.paid_to_date","client.currency_id"],
|
||||||
|
'send_email' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/reports/clients', $data);
|
||||||
|
|
||||||
|
$csv = $response->streamedContent();
|
||||||
|
|
||||||
|
$this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Name'));
|
||||||
|
$this->assertEquals(100, $this->getFirstValueByColumn($csv, 'Balance'));
|
||||||
|
$this->assertEquals(50, $this->getFirstValueByColumn($csv, 'Paid to Date'));
|
||||||
|
$this->assertEquals($this->user->present()->name(), $this->getFirstValueByColumn($csv, 'Client User'));
|
||||||
|
$this->assertEquals('', $this->getFirstValueByColumn($csv, 'Client Assigned User'));
|
||||||
|
$this->assertEquals('USD', $this->getFirstValueByColumn($csv, 'Client Currency'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function testClientContactCsvGeneration()
|
public function testClientContactCsvGeneration()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user