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]),
'invoices' => $this->getInvoices()->get(),
'payments' => $this->options['show_payments_table'] ? $this->getPayments()->get() : collect([]),
'credits' => $this->options['show_credits_table'] ? $this->getCredits()->get() : [],
'aging' => $this->options['show_aging_table'] ? $this->getAging() : [],
'credits' => $this->options['show_credits_table'] ? $this->getCredits()->get() : collect([]),
'aging' => $this->options['show_aging_table'] ? $this->getAging() : collect([]),
]);
$html = $ts->getHtml();

View File

@ -195,7 +195,6 @@ class PdfMock
{
return ['values' =>
[
'$client.shipping_postal_code' => '46420',
'$client.billing_postal_code' => '11243',
'$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_block' => $this->settings->show_shipping_address ? 'block' : 'none',
'$show_shipping_address_visibility' => $this->settings->show_shipping_address ? 'visible' : 'hidden',
'$start_date' => '31/01/2023',
'$end_date' => '31/12/2023',
],
'labels' => $this->mockTranslatedLabels(),
];
@ -811,21 +812,23 @@ class PdfMock
'$tax_label' => ctrans('texts.tax'),
'$dir_label' => '',
'$to_label' => ctrans('texts.to'),
'$start_date_label' => ctrans('texts.start_date'),
'$end_date_label' => ctrans('texts.end_date'),
];
}
private function getVendorStubVariables()
{
return ['values' => [
'$vendor.billing_postal_code' => '06270-5526',
'$company.postal_city_state' => '29359 New Loy, Delaware',
'$company.city_state_postal' => 'New Loy, Delaware 29359',
'$product.gross_line_total' => '',
'$purchase_order.po_number' => 'PO12345',
'$vendor.postal_city_state' => '06270-5526 Jameyhaven, West Virginia',
'$vendor.city_state_postal' => 'Jameyhaven, West Virginia 06270-5526',
'$purchase_order.due_date' => '02-12-2021',
'$vendor.billing_address1' => '589',
'$vendor.billing_postal_code' => '06270-5526',
'$company.postal_city_state' => '29359 New Loy, Delaware',
'$company.city_state_postal' => 'New Loy, Delaware 29359',
'$product.gross_line_total' => '',
'$purchase_order.po_number' => 'PO12345',
'$vendor.postal_city_state' => '06270-5526 Jameyhaven, West Virginia',
'$vendor.city_state_postal' => 'Jameyhaven, West Virginia 06270-5526',
'$purchase_order.due_date' => '02-12-2021',
'$vendor.billing_address1' => '589',
'$vendor.billing_address2' => '761 Odessa Centers Suite 673',
'$invoiceninja.whitelabel' => 'https://invoicing.co/images/new_logo.png',
'$purchase_order.custom1' => 'Custom 1',

View File

@ -84,6 +84,12 @@ class TemplateService
});
$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;
}

View File

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