include project name in invoice name (#1672)
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Invoice;
|
namespace App\Invoice;
|
||||||
|
|
||||||
|
use App\Entity\Project;
|
||||||
use Symfony\Component\String\UnicodeString;
|
use Symfony\Component\String\UnicodeString;
|
||||||
|
|
||||||
final class InvoiceFilename
|
final class InvoiceFilename
|
||||||
@@ -34,6 +35,17 @@ final class InvoiceFilename
|
|||||||
$filename .= '-' . $uCompany->ascii()->snake();
|
$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;
|
$this->filename = $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ namespace App\Tests\Invoice;
|
|||||||
|
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
use App\Entity\InvoiceTemplate;
|
use App\Entity\InvoiceTemplate;
|
||||||
|
use App\Entity\Project;
|
||||||
use App\Invoice\InvoiceFilename;
|
use App\Invoice\InvoiceFilename;
|
||||||
use App\Invoice\InvoiceModel;
|
use App\Invoice\InvoiceModel;
|
||||||
use App\Invoice\NumberGenerator\DateNumberGenerator;
|
use App\Invoice\NumberGenerator\DateNumberGenerator;
|
||||||
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,5 +59,16 @@ class InvoiceFilenameTest extends TestCase
|
|||||||
$customer->setCompany('\"#+ß.!$%&/()=?\\n=/*-+´_<>@' . "\n");
|
$customer->setCompany('\"#+ß.!$%&/()=?\\n=/*-+´_<>@' . "\n");
|
||||||
$sut = new InvoiceFilename($model);
|
$sut = new InvoiceFilename($model);
|
||||||
self::assertEquals($datePrefix . '-ss_n', $sut->getFilename());
|
self::assertEquals($datePrefix . '-ss_n', $sut->getFilename());
|
||||||
|
|
||||||
|
$project = new Project();
|
||||||
|
$project->setName('Demo ProjecT1');
|
||||||
|
|
||||||
|
$query = new InvoiceQuery();
|
||||||
|
$query->addProject($project);
|
||||||
|
$model->setQuery($query);
|
||||||
|
|
||||||
|
$customer->setCompany('\"#+ß.!$%&/()=?\\n=/*-+´_<>@' . "\n");
|
||||||
|
$sut = new InvoiceFilename($model);
|
||||||
|
self::assertEquals($datePrefix . '-ss_n-demo_projec_t1', $sut->getFilename());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user