invoices: choose language and duration format (#1438)

This commit is contained in:
Kevin Papst
2020-02-04 20:27:36 +01:00
committed by GitHub
parent 75dcae6fbe
commit 986d922855
64 changed files with 1559 additions and 541 deletions

View File

@@ -10,8 +10,10 @@
namespace App\Invoice\Renderer;
use App\Entity\InvoiceDocument;
use App\Invoice\InvoiceModel;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\String\UnicodeString;
/**
* @internal
@@ -43,6 +45,23 @@ abstract class AbstractRenderer
return false;
}
protected function buildFilename(InvoiceModel $model): string
{
$filename = $model->getNumberGenerator()->getInvoiceNumber();
$company = $model->getCustomer()->getCompany();
if (empty($company)) {
$company = $model->getCustomer()->getName();
}
if (!empty($company)) {
$company = new UnicodeString($company);
$filename .= '-' . $company->snake();
}
return $filename;
}
/**
* @param mixed $file
* @param string $filename

View File

@@ -99,8 +99,9 @@ abstract class AbstractSpreadsheetRenderer extends AbstractRenderer
}
$filename = $this->saveSpreadsheet($spreadsheet);
$userFilename = $this->buildFilename($model) . '.' . $document->getFileExtension();
return $this->getFileResponse($filename, basename($document->getFilename()));
return $this->getFileResponse($filename, $userFilename);
}
/**

View File

@@ -30,8 +30,6 @@ final class DocxRenderer extends AbstractRenderer implements RendererInterface
{
Settings::setOutputEscapingEnabled(false);
$filename = basename($document->getFilename());
$xmlEscaper = new Xml();
$template = new TemplateProcessor($document->getFilename());
@@ -70,6 +68,8 @@ final class DocxRenderer extends AbstractRenderer implements RendererInterface
clearstatcache(true, $cacheFile);
$filename = $this->buildFilename($model) . '.' . $document->getFileExtension();
return $this->getFileResponse(new Stream($cacheFile), $filename);
}