added new invoice fields, improved invoice templates (#1258)

This commit is contained in:
Kevin Papst
2019-11-18 12:01:26 +01:00
committed by GitHub
parent 2287c9951c
commit 47bd8b0ce7
50 changed files with 1530 additions and 1222 deletions

View File

@@ -114,6 +114,9 @@ trait RendererTrait
'template.title' => $model->getTemplate()->getTitle(),
'template.payment_terms' => $model->getTemplate()->getPaymentTerms(),
'template.due_days' => $model->getTemplate()->getDueDays(),
'template.vat_id' => $model->getTemplate()->getVatId(),
'template.contact' => $model->getTemplate()->getContact(),
'template.payment_details' => $model->getTemplate()->getPaymentDetails(),
'query.begin' => $this->getFormattedDateTime($model->getQuery()->getBegin()),
'query.day' => $model->getQuery()->getBegin()->format('d'),
@@ -164,6 +167,7 @@ trait RendererTrait
'customer.name' => $customer->getName(),
'customer.contact' => $customer->getContact(),
'customer.company' => $customer->getCompany(),
'customer.vat' => $customer->getVatId(),
'customer.number' => $customer->getNumber(),
'customer.country' => $customer->getCountry(),
'customer.homepage' => $customer->getHomepage(),

View File

@@ -15,35 +15,23 @@ use App\Invoice\RendererInterface;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
class TwigRenderer implements RendererInterface
final class TwigRenderer implements RendererInterface
{
/**
* @var Environment
*/
protected $twig;
private $twig;
/**
* @param Environment $twig
*/
public function __construct(Environment $twig)
{
$this->twig = $twig;
}
/**
* @param InvoiceDocument $document
* @return bool
*/
public function supports(InvoiceDocument $document): bool
{
return stripos($document->getFilename(), '.twig') !== false;
return stripos($document->getFilename(), '.html.twig') !== false;
}
/**
* @param InvoiceDocument $document
* @param InvoiceModel $model
* @return Response
*/
public function render(InvoiceDocument $document, InvoiceModel $model): Response
{
$content = $this->twig->render('@invoice/' . basename($document->getFilename()), [