Minor Fixes for templates

This commit is contained in:
David Bomba 2023-10-13 13:43:59 +11:00
parent 1cf829b137
commit 9294e2c347
4 changed files with 24 additions and 13 deletions

View File

@ -144,8 +144,8 @@ class Statement
'variables' => collect([$variables]), 'variables' => collect([$variables]),
'invoices' => $this->getInvoices()->get(), 'invoices' => $this->getInvoices()->get(),
'payments' => $this->options['show_payments_table'] ? $this->getPayments()->get() : collect([]), 'payments' => $this->options['show_payments_table'] ? $this->getPayments()->get() : collect([]),
'credits' => $this->options['show_credits_table'] ? $this->getCredits()->get() : [], 'credits' => $this->options['show_credits_table'] ? $this->getCredits()->get() : collect([]),
'aging' => $this->options['show_aging_table'] ? $this->getAging() : [], 'aging' => $this->options['show_aging_table'] ? $this->getAging() : collect([]),
]); ]);
$html = $ts->getHtml(); $html = $ts->getHtml();

View File

@ -195,7 +195,6 @@ class PdfMock
{ {
return ['values' => return ['values' =>
[ [
'$client.shipping_postal_code' => '46420', '$client.shipping_postal_code' => '46420',
'$client.billing_postal_code' => '11243', '$client.billing_postal_code' => '11243',
'$company.city_state_postal' => 'Beveley Hills, CA, 90210', '$company.city_state_postal' => 'Beveley Hills, CA, 90210',
@ -496,6 +495,8 @@ class PdfMock
'$show_shipping_address' => $this->settings->show_shipping_address ? 'flex' : 'none', '$show_shipping_address' => $this->settings->show_shipping_address ? 'flex' : 'none',
'$show_shipping_address_block' => $this->settings->show_shipping_address ? 'block' : 'none', '$show_shipping_address_block' => $this->settings->show_shipping_address ? 'block' : 'none',
'$show_shipping_address_visibility' => $this->settings->show_shipping_address ? 'visible' : 'hidden', '$show_shipping_address_visibility' => $this->settings->show_shipping_address ? 'visible' : 'hidden',
'$start_date' => '31/01/2023',
'$end_date' => '31/12/2023',
], ],
'labels' => $this->mockTranslatedLabels(), 'labels' => $this->mockTranslatedLabels(),
]; ];
@ -811,6 +812,8 @@ class PdfMock
'$tax_label' => ctrans('texts.tax'), '$tax_label' => ctrans('texts.tax'),
'$dir_label' => '', '$dir_label' => '',
'$to_label' => ctrans('texts.to'), '$to_label' => ctrans('texts.to'),
'$start_date_label' => ctrans('texts.start_date'),
'$end_date_label' => ctrans('texts.end_date'),
]; ];
} }

View File

@ -84,6 +84,12 @@ class TemplateService
}); });
$this->twig->addFunction($function); $this->twig->addFunction($function);
$filter = new \Twig\TwigFilter('sum', function (array $array, string $column) {
return array_sum(array_column($array, $column));
});
$this->twig->addFilter($filter);
return $this; return $this;
} }

View File

@ -5163,6 +5163,8 @@ $LANG = array(
'click_or_drop_files_here' => 'Click or drop files here', 'click_or_drop_files_here' => 'Click or drop files here',
'payment_refund_receipt' => 'Payment Refund Receipt # :number', 'payment_refund_receipt' => 'Payment Refund Receipt # :number',
'payment_receipt' => 'Payment Receipt # :number', 'payment_receipt' => 'Payment Receipt # :number',
'load_template_description' => 'The template will be applied to following:',
'run_template' => 'Run template',
); );
return $LANG; return $LANG;