diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index c99a66475a6f..e1bb510896cb 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -764,7 +764,7 @@ class BaseExport { $header = []; - // nlog($this->input['report_keys']); + nlog($this->input['report_keys']); foreach (array_merge($this->input['report_keys'], $this->forced_keys) as $value) { @@ -839,7 +839,15 @@ class BaseExport $key = str_replace('payment.', '', $key); $key = str_replace('expense.', '', $key); - $header[] = "{$prefix}" . ctrans("texts.{$key}"); + if(in_array($key, ['quote1','quote2','quote3','quote4','credit1','credit2','credit3','credit4','purchase_order1','purchase_order2','purchase_order3','purchase_order4'])) + { + $number = substr($key, -1); + $header[] = ctrans('texts.item') . " ". ctrans("texts.custom_value{$number}"); + } + else + { + $header[] = "{$prefix}" . ctrans("texts.{$key}"); + } } // nlog($header); diff --git a/app/Export/CSV/QuoteItemExport.php b/app/Export/CSV/QuoteItemExport.php index 7d310d93eaa0..9af20df7b5ca 100644 --- a/app/Export/CSV/QuoteItemExport.php +++ b/app/Export/CSV/QuoteItemExport.php @@ -62,10 +62,11 @@ class QuoteItemExport extends BaseExport 'terms' => 'terms', 'total_taxes' => 'total_taxes', 'currency' => 'currency_id', - 'qty' => 'item.quantity', - 'unit_cost' => 'item.cost', + 'quantity' => 'item.quantity', + 'cost' => 'item.cost', 'product_key' => 'item.product_key', - 'cost' => 'item.product_cost', + 'buy_price' => 'item.product_cost', + 'cost' => 'item.cost', 'notes' => 'item.notes', 'discount' => 'item.discount', 'is_amount_discount' => 'item.is_amount_discount', diff --git a/tests/Feature/Export/ReportCsvGenerationTest.php b/tests/Feature/Export/ReportCsvGenerationTest.php index 94c529dc68dd..946918126873 100644 --- a/tests/Feature/Export/ReportCsvGenerationTest.php +++ b/tests/Feature/Export/ReportCsvGenerationTest.php @@ -525,6 +525,7 @@ class ReportCsvGenerationTest extends TestCase ])->post('/api/v1/reports/quote_items', $data); $csv = $response->streamedContent(); +nlog($csv); $this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name')); $this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Quote Number')); @@ -534,7 +535,7 @@ class ReportCsvGenerationTest extends TestCase $this->assertEquals('0', $this->getFirstValueByColumn($csv, 'Discount')); $this->assertEquals('item notes', $this->getFirstValueByColumn($csv, 'Notes')); $this->assertEquals('product key', $this->getFirstValueByColumn($csv, 'Product')); - $this->assertEquals('custom 1', $this->getFirstValueByColumn($csv, 'Custom Quote 1')); + $this->assertEquals('custom 1', $this->getFirstValueByColumn($csv, 'Item Custom Value 1')); $this->assertEquals('GST', $this->getFirstValueByColumn($csv, 'Tax Name 1')); $this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Tax Rate 1'));