new invoice template variables for budgets (#3005)

This commit is contained in:
Kevin Papst
2021-12-08 22:15:07 +01:00
committed by GitHub
parent 82525f382d
commit 22ce6b047a
31 changed files with 389 additions and 188 deletions

View File

@@ -131,12 +131,20 @@ class DebugRendererTest extends TestCase
'customer.email',
'customer.fax',
'customer.phone',
'customer.budget_open',
'customer.budget_open_plain',
'customer.time_budget_open',
'customer.time_budget_open_plain',
'customer.mobile',
'customer.meta.foo-customer',
'activity.id',
'activity.name',
'activity.comment',
'activity.meta.foo-activity',
'activity.budget_open',
'activity.budget_open_plain',
'activity.time_budget_open',
'activity.time_budget_open_plain',
'user.alias',
'user.email',
'user.name',
@@ -146,8 +154,18 @@ class DebugRendererTest extends TestCase
'testFromModelHydrator',
];
if ($activityCounter === 1) {
$keys = array_merge($keys, [
'activity',
]);
}
if ($activityCounter > 1) {
$keys = array_merge($keys, [
'activity.1.budget_open',
'activity.1.budget_open_plain',
'activity.1.time_budget_open',
'activity.1.time_budget_open_plain',
'activity.1.id',
'activity.1.name',
'activity.1.comment',
@@ -171,7 +189,16 @@ class DebugRendererTest extends TestCase
'project.budget_time',
'project.budget_time_decimal',
'project.budget_time_minutes',
'project.budget_open',
'project.budget_open_plain',
'project.time_budget_open',
'project.time_budget_open_plain',
]);
if ($projectCounter === 1) {
$keys = array_merge($keys, [
'project',
]);
}
if ($projectCounter > 1) {
$keys = array_merge($keys, [
'project.1.id',
@@ -188,6 +215,10 @@ class DebugRendererTest extends TestCase
'project.1.budget_time',
'project.1.budget_time_decimal',
'project.1.budget_time_minutes',
'project.1.budget_open',
'project.1.budget_open_plain',
'project.1.time_budget_open',
'project.1.time_budget_open_plain',
]);
}
}

View File

@@ -30,6 +30,7 @@ use App\Invoice\NumberGenerator\DateNumberGenerator;
use App\Invoice\Renderer\AbstractRenderer;
use App\Repository\InvoiceRepository;
use App\Repository\Query\InvoiceQuery;
use App\Tests\Mocks\InvoiceModelFactoryFactory;
trait RendererTestTrait
{
@@ -217,7 +218,7 @@ trait RendererTestTrait
$query->setEnd(new \DateTime());
$query->setProjects([$project, $project2]);
$model = new InvoiceModel($this->getFormatter());
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter());
$model->setCustomer($customer);
$model->setTemplate($template);
$model->addEntries($entries);
@@ -301,7 +302,7 @@ trait RendererTestTrait
$query->setBegin(new \DateTime());
$query->setEnd(new \DateTime());
$model = new InvoiceModel($this->getFormatter());
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter());
$model->setCustomer($customer);
$model->setTemplate($template);
$model->addEntries($entries);

View File

@@ -66,10 +66,8 @@ class TwigRendererTest extends KernelTestCase
$filename = $model->getInvoiceNumber() . '-customer_with_special_name';
$this->assertStringContainsString('<title>' . $filename . '</title>', $content);
$this->assertStringContainsString('<h2 class="page-header">
<span contenteditable="true">a very *long* test invoice / template title with [ßpecial] chäracter</span>
</h2>', $content);
$this->assertEquals(2, substr_count($content, 'activity description'));
$this->assertStringContainsString('<span contenteditable="true">a very *long* test invoice / template title with [ßpecial] chäracter</span>', $content);
$this->assertEquals(3, substr_count($content, 'activity description'));
$this->assertStringContainsString(nl2br("foo\n" .
"foo\r\n" .
'foo' . PHP_EOL .