include project name in invoice name (#1672)

This commit is contained in:
Kevin Papst
2020-04-29 18:51:33 +02:00
committed by GitHub
parent ad2698dae2
commit 35f864256f
2 changed files with 25 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
namespace App\Invoice;
use App\Entity\Project;
use Symfony\Component\String\UnicodeString;
final class InvoiceFilename
@@ -34,6 +35,17 @@ final class InvoiceFilename
$filename .= '-' . $uCompany->ascii()->snake();
}
if (null !== $model->getQuery()) {
$projects = $model->getQuery()->getProjects();
if (\count($projects) === 1) {
$pName = $projects[0];
if ($pName instanceof Project) {
$uProject = new UnicodeString($pName->getName());
$filename .= '-' . $uProject->ascii()->snake();
}
}
}
$this->filename = $filename;
}