1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Fixes for tests

This commit is contained in:
David Bomba 2023-08-24 17:09:39 +10:00
parent 2bc75feb21
commit 4efc0dbb9a
2 changed files with 29 additions and 13 deletions

View File

@ -840,11 +840,11 @@ class BaseExport
$header = []; $header = [];
// nlog($this->input['report_keys']);
foreach ($this->input['report_keys'] as $value) { foreach ($this->input['report_keys'] as $value) {
$key = array_search($value, $this->entity_keys); $key = array_search($value, $this->entity_keys);
$original_key = $key;
nlog("{$key} => {$value}"); nlog("{$key} => {$value}");
$prefix = ''; $prefix = '';
@ -920,20 +920,36 @@ class BaseExport
$key = str_replace('payment.', '', $key); $key = str_replace('payment.', '', $key);
$key = str_replace('expense.', '', $key); $key = str_replace('expense.', '', $key);
// if( in_array($key, ['quote1','quote2','quote3','quote4','credit1','credit2','credit3','credit4','purchase_order1','purchase_order2','purchase_order3','purchase_order4']))
if(stripos($value, 'custom_value') !== false) if(stripos($value, 'custom_value') !== false)
{ {
$parts = explode(".", $value); $parts = explode(".", $value);
if(count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])){ if(count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])){
$entity = "invoice".substr($parts[1], -1); $entity = "invoice".substr($parts[1], -1);
$header[] = "{$prefix}" . $helper->makeCustomField($this->company->custom_fields, $entity); $prefix = ctrans("texts.".$parts[0]);
$fallback = "custom_value".substr($parts[1], -1);
$custom_field_label = $helper->makeCustomField($this->company->custom_fields, $entity);
if(strlen($custom_field_label) > 1)
$header[] = $custom_field_label;
else {
$header[] = $prefix . " ". ctrans("texts.{$fallback}");
}
} }
elseif(count($parts) == 2 && stripos($parts[0], 'contact') !== false) { elseif(count($parts) == 2 && stripos($parts[0], 'contact') !== false) {
nlog("2");
$entity = "contact".substr($parts[1], -1); $entity = "contact".substr($parts[1], -1);
$custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, $entity)) > 1 ? $helper->makeCustomField($this->company->custom_fields, $entity) : ctrans("texts.{$parts[1]}"); $custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, $entity)) > 1 ? $helper->makeCustomField($this->company->custom_fields, $entity) : ctrans("texts.{$parts[1]}");
$header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string; $header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string;
} }
elseif(count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice'])){
nlog("3");
$custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, "product".substr($original_key,-1))) > 1 ? $helper->makeCustomField($this->company->custom_fields, "product".substr($original_key,-1)) : ctrans("texts.{$parts[1]}");
nlog(ctrans("texts.{$parts[0]}") . " " . $custom_field_string);
$header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string;
}
else{ else{
nlog("else".$key); nlog("else".$key);
$header[] = "{$prefix}" . ctrans("texts.{$key}"); $header[] = "{$prefix}" . ctrans("texts.{$key}");

View File

@ -996,7 +996,7 @@ nlog($csv);
$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 Invoice 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'));
@ -1406,14 +1406,14 @@ nlog($csv);
$response->assertStatus(200); $response->assertStatus(200);
$csv = $response->streamedContent(); $csv = $response->streamedContent();
nlog($csv);
$this->assertEquals('100', $this->getFirstValueByColumn($csv, 'Amount')); $this->assertEquals('100', $this->getFirstValueByColumn($csv, 'Credit Amount'));
$this->assertEquals('50', $this->getFirstValueByColumn($csv, 'Balance')); $this->assertEquals('50', $this->getFirstValueByColumn($csv, 'Credit Balance'));
$this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Discount')); $this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Credit Discount'));
$this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'PO Number')); $this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Credit PO Number'));
$this->assertEquals('Public', $this->getFirstValueByColumn($csv, 'Public Notes')); $this->assertEquals('Public', $this->getFirstValueByColumn($csv, 'Credit Public Notes'));
$this->assertEquals('Private', $this->getFirstValueByColumn($csv, 'Private Notes')); $this->assertEquals('Private', $this->getFirstValueByColumn($csv, 'Credit Private Notes'));
$this->assertEquals('Terms', $this->getFirstValueByColumn($csv, 'Terms')); $this->assertEquals('Terms', $this->getFirstValueByColumn($csv, 'Credit Terms'));
$data = [ $data = [