Improve efficiency of PDF generation when encountering custom date fields in product tables

This commit is contained in:
David Bomba 2025-01-28 14:40:36 +11:00
parent 99d2652f89
commit b7c815b048
5 changed files with 14 additions and 9 deletions

View File

@ -49,7 +49,7 @@ class ProjectRepository extends BaseRepository
$body = '<div class="task-time-details">'.$task->description().'</div>';
}
else {
$body = '';
$body = $task->description ?? '';
}
$item = new InvoiceItem();

View File

@ -729,6 +729,7 @@ class PdfBuilder
*/
public function buildTableBody(string $type): array
{
$elements = [];
$items = $this->transformLineItems($this->service->config->entity->line_items, $type);
@ -776,6 +777,9 @@ class PdfBuilder
$table_type = "product_quote_columns";
}
$_type = Str::startsWith($type, '$') ? ltrim($type, '$') : $type;
$column_visibility = $this->getColumnVisibility($this->service->config->entity->line_items, $_type);
foreach ($items as $row) {
$element = ['element' => 'tr', 'elements' => []];
@ -804,9 +808,6 @@ class PdfBuilder
}
}
} else {
$_type = Str::startsWith($type, '$') ? ltrim($type, '$') : $type;
$column_visibility = $this->getColumnVisibility($this->service->config->entity->line_items, $_type);
foreach ($this->service->config->pdf_variables[$table_type] as $key => $cell) {
// We want to keep aliases like these:

View File

@ -981,6 +981,8 @@ class Design extends BaseDesign
$table_type = "product_quote_columns";
}
$column_visibility = $this->getColumnVisibility($this->entity->line_items, $_type);
foreach ($items as $row) {
$element = ['element' => 'tr', 'elements' => []];
@ -1009,8 +1011,6 @@ class Design extends BaseDesign
}
} else {
$column_visibility = $this->getColumnVisibility($this->entity->line_items, $_type);
foreach ($this->context['pdf_variables'][$table_type] as $key => $cell) {
// We want to keep aliases like these:
// $task.cost => $task.rate

View File

@ -222,6 +222,10 @@
{
"type": "vcs",
"url": "https://github.com/turbo124/snappdf"
},
{
"type": "path",
"url": "../admin-api"
}
],
"minimum-stability": "dev",

2
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a8c8a77c6cc5e0b0c046923603c2110a",
"content-hash": "2f0a47c420c857b7fc7a4a71e2f3224d",
"packages": [
{
"name": "adrienrn/php-mimetyper",