Fixes for custom values

This commit is contained in:
David Bomba 2023-07-18 14:26:52 +10:00
parent 0a5747998d
commit 6af38604af
3 changed files with 16 additions and 6 deletions

View File

@ -764,7 +764,7 @@ class BaseExport
{ {
$header = []; $header = [];
// nlog($this->input['report_keys']); nlog($this->input['report_keys']);
foreach (array_merge($this->input['report_keys'], $this->forced_keys) as $value) { 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('payment.', '', $key);
$key = str_replace('expense.', '', $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); // nlog($header);

View File

@ -62,10 +62,11 @@ class QuoteItemExport extends BaseExport
'terms' => 'terms', 'terms' => 'terms',
'total_taxes' => 'total_taxes', 'total_taxes' => 'total_taxes',
'currency' => 'currency_id', 'currency' => 'currency_id',
'qty' => 'item.quantity', 'quantity' => 'item.quantity',
'unit_cost' => 'item.cost', 'cost' => 'item.cost',
'product_key' => 'item.product_key', 'product_key' => 'item.product_key',
'cost' => 'item.product_cost', 'buy_price' => 'item.product_cost',
'cost' => 'item.cost',
'notes' => 'item.notes', 'notes' => 'item.notes',
'discount' => 'item.discount', 'discount' => 'item.discount',
'is_amount_discount' => 'item.is_amount_discount', 'is_amount_discount' => 'item.is_amount_discount',

View File

@ -525,6 +525,7 @@ class ReportCsvGenerationTest extends TestCase
])->post('/api/v1/reports/quote_items', $data); ])->post('/api/v1/reports/quote_items', $data);
$csv = $response->streamedContent(); $csv = $response->streamedContent();
nlog($csv);
$this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name')); $this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name'));
$this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Quote Number')); $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('0', $this->getFirstValueByColumn($csv, 'Discount'));
$this->assertEquals('item notes', $this->getFirstValueByColumn($csv, 'Notes')); $this->assertEquals('item notes', $this->getFirstValueByColumn($csv, 'Notes'));
$this->assertEquals('product key', $this->getFirstValueByColumn($csv, 'Product')); $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('GST', $this->getFirstValueByColumn($csv, 'Tax Name 1'));
$this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Tax Rate 1')); $this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Tax Rate 1'));