From a2eec608d9dc5c23fafc786944bc88366d6c4091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 20 Sep 2021 08:47:54 +0200 Subject: [PATCH 1/3] Support for 1:1 columns --- .../PdfMaker/Designs/Utilities/DesignHelpers.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 02fb145f1280..34f21fe8422f 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -272,12 +272,21 @@ document.addEventListener('DOMContentLoaded', function() { return false; } + // Some variables don't map 1:1 to table columns. This gives us support for such cases. + $aliases = [ + '$quote.balance_due' => 'partial', + ]; + try { $_variable = explode('.', $variable)[1]; } catch (Exception $e) { throw new Exception('Company settings seems to be broken. Missing $entity.variable type.'); } + if (\in_array($variable, \array_keys($aliases))) { + $_variable = $aliases[$variable]; + } + if (is_null($this->entity->{$_variable})) { return true; } From c1efcba422b199d932449d7b2123f93b4676d6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 20 Sep 2021 08:50:22 +0200 Subject: [PATCH 2/3] Showing partial due on the quotes --- app/Services/PdfMaker/Design.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 818307c806ef..6164bad7a2e9 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -241,6 +241,10 @@ class Design extends BaseDesign if ($this->entity instanceof Quote) { $variables = $this->context['pdf_variables']['quote_details']; + + if ($this->entity->partial > 0) { + $variables[] = '$quote.balance_due'; + } } if ($this->entity instanceof Credit) { From b62134a5ffb95d26259a6fd4a2f5d3d3c66906da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 20 Sep 2021 15:00:54 +0200 Subject: [PATCH 3/3] Add `partial_due` to quotes in totals table --- app/Services/PdfMaker/Design.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 6164bad7a2e9..8c9c4add12c3 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -631,6 +631,10 @@ class Design extends BaseDesign if (in_array('$outstanding', $variables)) { $variables = \array_diff($variables, ['$outstanding']); } + + if ($this->entity->partial > 0) { + $variables[] = '$partial_due'; + } } foreach (['discount'] as $property) {