From c4a111c16fff80d69b28a45b37ce96b37d10c00c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 19 Nov 2024 19:05:51 +1100 Subject: [PATCH] Store legal entity ids and company key on license --- app/Models/License.php | 11 +++++++---- app/Services/Invoice/GenerateDeliveryNote.php | 2 ++ app/Services/Pdf/PdfBuilder.php | 5 +++++ app/Services/PdfMaker/Design.php | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/Models/License.php b/app/Models/License.php index 64f42a4c59..c1c93520b4 100644 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -89,20 +89,23 @@ class License extends StaticModel public function addEntity(TaxEntity $entity) { + $entities = $this->entities; - if (is_array($this->entities)) { - $this->entities[] = $entity; + if (is_array($entities)) { + $entities[] = $entity; } else { - $this->entities = [$entity]; + $entities = [$entity]; } + $this->entities = $entities; + $this->save(); } public function removeEntity(TaxEntity $entity) { - + if (!is_array($this->entities)) { return; } diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 80a5fd2367..171cf89e78 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -83,6 +83,8 @@ class GenerateDeliveryNote $variables = $html->generateLabelsAndValues(); $variables['labels']['$entity_label'] = ctrans('texts.delivery_note'); + $variables['labels']['$invoice.date_label'] = ctrans('texts.date'); + $variables['labels']['$invoice.number_label'] = ctrans('texts.number'); $state = [ 'template' => $template->elements([ diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 8c19e23e2f..6e9c174d80 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -1478,6 +1478,11 @@ class PdfBuilder { $variables = $this->service->config->pdf_variables['invoice_details']; + // $_v = $this->service->html_variables; + + // $_v['labels']['$invoice.date_label'] = ctrans('text.date'); + // $this->service->html_variables = $_v; + $variables = array_filter($variables, function ($m) { return !in_array($m, ['$invoice.balance_due', '$invoice.total']); }); diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 9db7fb81b4..dfff058d61 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -380,7 +380,7 @@ class Design extends BaseDesign // We don't want to show account balance or invoice total on PDF.. or any amount with currency. if ($this->type == self::DELIVERY_NOTE) { $variables = array_filter($variables, function ($m) { - return !in_array($m, ['$invoice.balance_due', '$invoice.total']); + return !in_array($m, ['$invoice.balance_due', '$invoice.total', '$invoice.amount']); }); }