diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index d607de6d140b..4fb1342391ae 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -39,7 +39,11 @@ class TriggeredActions extends AbstractService public function run() { if ($this->request->has('auto_bill') && $this->request->input('auto_bill') == 'true') { - $this->invoice->service()->autoBill(); //update notification sends automatically for this. + try { + $this->invoice->service()->autoBill(); + } catch(\Exception $e) { + + } //update notification sends automatically for this. } if ($this->request->has('paid') && $this->request->input('paid') == 'true') { diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index ccf8694c18d0..71b83284438f 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -743,8 +743,6 @@ class Design extends BaseDesign */ public function buildTableHeader(string $type): array { - $this->processTaxColumns($type); - // $this->processCustomColumns($type); $elements = []; @@ -757,10 +755,16 @@ class Design extends BaseDesign $table_type = "{$type}_columns"; + $column_type = $type; + if ($type == 'product' && $this->entity instanceof Quote && !$this->settings_object->getSetting('sync_invoice_quote_columns')) { $table_type = "product_quote_columns"; + $column_type = 'product_quote'; } - + + $this->processTaxColumns($column_type); + + foreach ($this->context['pdf_variables'][$table_type] as $column) { if (array_key_exists($column, $aliases)) { $elements[] = ['element' => 'th', 'content' => $aliases[$column] . '_label', 'properties' => ['data-ref' => "{$type}_table-" . substr($aliases[$column], 1) . '-th', 'hidden' => $this->settings_object->getSetting('hide_empty_columns_on_pdf')]]; diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 1e9a4ccab5d1..183c4de8df35 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -150,8 +150,11 @@ trait DesignHelpers */ public function processTaxColumns(string $type): void { - if ($type == 'product') { + $column_type = $type; + if ($type == 'product' || $type == 'product_quote') { $type_id = 1; + $column_type = 'product_quote'; + $type = 'product'; } if ($type == 'task') { @@ -163,7 +166,7 @@ trait DesignHelpers // This sprintf() will help us convert "task" or "product" into "$task" or "$product" without // evaluating the variable. - if (in_array(sprintf('%s%s.tax', '$', $type), (array) $this->context['pdf_variables']["{$type}_columns"])) { + if (in_array(sprintf('%s%s.tax', '$', $type), (array) $this->context['pdf_variables']["{$column_type}_columns"])) { $line_items = collect($this->entity->line_items)->filter(function ($item) use ($type_id) { return $item->type_id = $type_id; }); @@ -186,10 +189,10 @@ trait DesignHelpers array_push($taxes, sprintf('%s%s.tax_rate3', '$', $type)); } - $key = array_search(sprintf('%s%s.tax', '$', $type), $this->context['pdf_variables']["{$type}_columns"], true); + $key = array_search(sprintf('%s%s.tax', '$', $type), $this->context['pdf_variables']["{$column_type}_columns"], true); if ($key !== false) { - array_splice($this->context['pdf_variables']["{$type}_columns"], $key, 1, $taxes); + array_splice($this->context['pdf_variables']["{$column_type}_columns"], $key, 1, $taxes); } } }