new invoice template variables for budgets (#3005)
This commit is contained in:
@@ -9,12 +9,20 @@
|
|||||||
|
|
||||||
namespace App\Invoice\Hydrator;
|
namespace App\Invoice\Hydrator;
|
||||||
|
|
||||||
|
use App\Activity\ActivityStatisticService;
|
||||||
use App\Entity\Activity;
|
use App\Entity\Activity;
|
||||||
use App\Invoice\InvoiceModel;
|
use App\Invoice\InvoiceModel;
|
||||||
use App\Invoice\InvoiceModelHydrator;
|
use App\Invoice\InvoiceModelHydrator;
|
||||||
|
|
||||||
class InvoiceModelActivityHydrator implements InvoiceModelHydrator
|
class InvoiceModelActivityHydrator implements InvoiceModelHydrator
|
||||||
{
|
{
|
||||||
|
private $activityStatistic;
|
||||||
|
|
||||||
|
public function __construct(ActivityStatisticService $activityStatistic)
|
||||||
|
{
|
||||||
|
$this->activityStatistic = $activityStatistic;
|
||||||
|
}
|
||||||
|
|
||||||
public function hydrate(InvoiceModel $model): array
|
public function hydrate(InvoiceModel $model): array
|
||||||
{
|
{
|
||||||
if (!$model->getQuery()->hasActivities()) {
|
if (!$model->getQuery()->hasActivities()) {
|
||||||
@@ -24,19 +32,23 @@ class InvoiceModelActivityHydrator implements InvoiceModelHydrator
|
|||||||
$values = [];
|
$values = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
if (\count($model->getQuery()->getActivities()) === 1) {
|
||||||
|
$values['activity'] = $model->getQuery()->getActivities()[0]->getName();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($model->getQuery()->getActivities() as $activity) {
|
foreach ($model->getQuery()->getActivities() as $activity) {
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
$prefix = $i . '.';
|
$prefix = $i . '.';
|
||||||
}
|
}
|
||||||
$values = array_merge($values, $this->getValuesFromActivity($activity, $prefix));
|
$values = array_merge($values, $this->getValuesFromActivity($model, $activity, $prefix));
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getValuesFromActivity(Activity $activity, string $prefix): array
|
private function getValuesFromActivity(InvoiceModel $model, Activity $activity, string $prefix): array
|
||||||
{
|
{
|
||||||
$prefix = 'activity.' . $prefix;
|
$prefix = 'activity.' . $prefix;
|
||||||
|
|
||||||
@@ -46,6 +58,23 @@ class InvoiceModelActivityHydrator implements InvoiceModelHydrator
|
|||||||
$prefix . 'comment' => $activity->getComment(),
|
$prefix . 'comment' => $activity->getComment(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$statistic = $this->activityStatistic->getBudgetStatisticModel($activity, $model->getQuery()->getEnd());
|
||||||
|
$formatter = $model->getFormatter();
|
||||||
|
$currency = $model->getCurrency();
|
||||||
|
|
||||||
|
if ($model->getTemplate()->isDecimalDuration()) {
|
||||||
|
$budgetOpenDuration = $formatter->getFormattedDecimalDuration($statistic->getTimeBudgetOpen());
|
||||||
|
} else {
|
||||||
|
$budgetOpenDuration = $formatter->getFormattedDuration($statistic->getTimeBudgetOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = array_merge($values, [
|
||||||
|
$prefix . 'budget_open' => $formatter->getFormattedMoney($statistic->getBudgetOpen(), $currency),
|
||||||
|
$prefix . 'budget_open_plain' => $statistic->getBudgetOpen(),
|
||||||
|
$prefix . 'time_budget_open' => $budgetOpenDuration,
|
||||||
|
$prefix . 'time_budget_open_plain' => $statistic->getTimeBudgetOpen(),
|
||||||
|
]);
|
||||||
|
|
||||||
foreach ($activity->getVisibleMetaFields() as $metaField) {
|
foreach ($activity->getVisibleMetaFields() as $metaField) {
|
||||||
$values = array_merge($values, [
|
$values = array_merge($values, [
|
||||||
$prefix . 'meta.' . $metaField->getName() => $metaField->getValue(),
|
$prefix . 'meta.' . $metaField->getName() => $metaField->getValue(),
|
||||||
|
|||||||
@@ -9,11 +9,19 @@
|
|||||||
|
|
||||||
namespace App\Invoice\Hydrator;
|
namespace App\Invoice\Hydrator;
|
||||||
|
|
||||||
|
use App\Customer\CustomerStatisticService;
|
||||||
use App\Invoice\InvoiceModel;
|
use App\Invoice\InvoiceModel;
|
||||||
use App\Invoice\InvoiceModelHydrator;
|
use App\Invoice\InvoiceModelHydrator;
|
||||||
|
|
||||||
class InvoiceModelCustomerHydrator implements InvoiceModelHydrator
|
class InvoiceModelCustomerHydrator implements InvoiceModelHydrator
|
||||||
{
|
{
|
||||||
|
private $customerStatistic;
|
||||||
|
|
||||||
|
public function __construct(CustomerStatisticService $customerStatistic)
|
||||||
|
{
|
||||||
|
$this->customerStatistic = $customerStatistic;
|
||||||
|
}
|
||||||
|
|
||||||
public function hydrate(InvoiceModel $model): array
|
public function hydrate(InvoiceModel $model): array
|
||||||
{
|
{
|
||||||
$customer = $model->getCustomer();
|
$customer = $model->getCustomer();
|
||||||
@@ -22,9 +30,6 @@ class InvoiceModelCustomerHydrator implements InvoiceModelHydrator
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$formatter = $model->getFormatter();
|
|
||||||
$currency = $model->getCurrency();
|
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
'customer.id' => $customer->getId(),
|
'customer.id' => $customer->getId(),
|
||||||
'customer.address' => $customer->getAddress(),
|
'customer.address' => $customer->getAddress(),
|
||||||
@@ -40,12 +45,25 @@ class InvoiceModelCustomerHydrator implements InvoiceModelHydrator
|
|||||||
'customer.fax' => $customer->getFax(),
|
'customer.fax' => $customer->getFax(),
|
||||||
'customer.phone' => $customer->getPhone(),
|
'customer.phone' => $customer->getPhone(),
|
||||||
'customer.mobile' => $customer->getMobile(),
|
'customer.mobile' => $customer->getMobile(),
|
||||||
// budget
|
|
||||||
// remaining budget?
|
|
||||||
// time-budget
|
|
||||||
// remaining time-budget?
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$statistic = $this->customerStatistic->getBudgetStatisticModel($customer, $model->getQuery()->getEnd());
|
||||||
|
$currency = $model->getCurrency();
|
||||||
|
$formatter = $model->getFormatter();
|
||||||
|
|
||||||
|
if ($model->getTemplate()->isDecimalDuration()) {
|
||||||
|
$budgetOpenDuration = $formatter->getFormattedDecimalDuration($statistic->getTimeBudgetOpen());
|
||||||
|
} else {
|
||||||
|
$budgetOpenDuration = $formatter->getFormattedDuration($statistic->getTimeBudgetOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = array_merge($values, [
|
||||||
|
'customer.budget_open' => $formatter->getFormattedMoney($statistic->getBudgetOpen(), $currency),
|
||||||
|
'customer.budget_open_plain' => $statistic->getBudgetOpen(),
|
||||||
|
'customer.time_budget_open' => $budgetOpenDuration,
|
||||||
|
'customer.time_budget_open_plain' => $statistic->getTimeBudgetOpen(),
|
||||||
|
]);
|
||||||
|
|
||||||
foreach ($customer->getMetaFields() as $metaField) {
|
foreach ($customer->getMetaFields() as $metaField) {
|
||||||
$values = array_merge($values, [
|
$values = array_merge($values, [
|
||||||
'customer.meta.' . $metaField->getName() => $metaField->getValue(),
|
'customer.meta.' . $metaField->getName() => $metaField->getValue(),
|
||||||
|
|||||||
@@ -10,40 +10,51 @@
|
|||||||
namespace App\Invoice\Hydrator;
|
namespace App\Invoice\Hydrator;
|
||||||
|
|
||||||
use App\Entity\Project;
|
use App\Entity\Project;
|
||||||
use App\Invoice\InvoiceFormatter;
|
|
||||||
use App\Invoice\InvoiceModel;
|
use App\Invoice\InvoiceModel;
|
||||||
use App\Invoice\InvoiceModelHydrator;
|
use App\Invoice\InvoiceModelHydrator;
|
||||||
|
use App\Project\ProjectStatisticService;
|
||||||
|
|
||||||
class InvoiceModelProjectHydrator implements InvoiceModelHydrator
|
class InvoiceModelProjectHydrator implements InvoiceModelHydrator
|
||||||
{
|
{
|
||||||
|
private $projectStatistic;
|
||||||
|
|
||||||
|
public function __construct(ProjectStatisticService $projectStatistic)
|
||||||
|
{
|
||||||
|
$this->projectStatistic = $projectStatistic;
|
||||||
|
}
|
||||||
|
|
||||||
public function hydrate(InvoiceModel $model): array
|
public function hydrate(InvoiceModel $model): array
|
||||||
{
|
{
|
||||||
if (!$model->getQuery()->hasProjects()) {
|
if (!$model->getQuery()->hasProjects()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$formatter = $model->getFormatter();
|
|
||||||
$currency = $model->getCurrency();
|
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
if (\count($model->getQuery()->getProjects()) === 1) {
|
||||||
|
$values['project'] = $model->getQuery()->getProjects()[0]->getName();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($model->getQuery()->getProjects() as $project) {
|
foreach ($model->getQuery()->getProjects() as $project) {
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
$prefix = $i . '.';
|
$prefix = $i . '.';
|
||||||
}
|
}
|
||||||
$values = array_merge($values, $this->getValuesFromProject($project, $formatter, $currency, $prefix));
|
$values = array_merge($values, $this->getValuesFromProject($model, $project, $prefix));
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getValuesFromProject(Project $project, InvoiceFormatter $formatter, string $currency, string $prefix): array
|
private function getValuesFromProject(InvoiceModel $model, Project $project, string $prefix): array
|
||||||
{
|
{
|
||||||
$prefix = 'project.' . $prefix;
|
$prefix = 'project.' . $prefix;
|
||||||
|
|
||||||
|
$formatter = $model->getFormatter();
|
||||||
|
$currency = $model->getCurrency();
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
$prefix . 'id' => $project->getId(),
|
$prefix . 'id' => $project->getId(),
|
||||||
$prefix . 'name' => $project->getName(),
|
$prefix . 'name' => $project->getName(),
|
||||||
@@ -60,6 +71,21 @@ class InvoiceModelProjectHydrator implements InvoiceModelHydrator
|
|||||||
$prefix . 'budget_time_minutes' => (int) ($project->getTimeBudget() / 60),
|
$prefix . 'budget_time_minutes' => (int) ($project->getTimeBudget() / 60),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$statistic = $this->projectStatistic->getBudgetStatisticModel($project, $model->getQuery()->getEnd());
|
||||||
|
|
||||||
|
if ($model->getTemplate()->isDecimalDuration()) {
|
||||||
|
$budgetOpenDuration = $formatter->getFormattedDecimalDuration($statistic->getTimeBudgetOpen());
|
||||||
|
} else {
|
||||||
|
$budgetOpenDuration = $formatter->getFormattedDuration($statistic->getTimeBudgetOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = array_merge($values, [
|
||||||
|
$prefix . 'budget_open' => $formatter->getFormattedMoney($statistic->getBudgetOpen(), $currency),
|
||||||
|
$prefix . 'budget_open_plain' => $statistic->getBudgetOpen(),
|
||||||
|
$prefix . 'time_budget_open' => $budgetOpenDuration,
|
||||||
|
$prefix . 'time_budget_open_plain' => $statistic->getTimeBudgetOpen(),
|
||||||
|
]);
|
||||||
|
|
||||||
foreach ($project->getVisibleMetaFields() as $metaField) {
|
foreach ($project->getVisibleMetaFields() as $metaField) {
|
||||||
$values = array_merge($values, [
|
$values = array_merge($values, [
|
||||||
$prefix . 'meta.' . $metaField->getName() => $metaField->getValue(),
|
$prefix . 'meta.' . $metaField->getName() => $metaField->getValue(),
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
namespace App\Invoice;
|
namespace App\Invoice;
|
||||||
|
|
||||||
|
use App\Activity\ActivityStatisticService;
|
||||||
|
use App\Customer\CustomerStatisticService;
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
use App\Entity\InvoiceTemplate;
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
@@ -18,6 +20,7 @@ use App\Invoice\Hydrator\InvoiceModelCustomerHydrator;
|
|||||||
use App\Invoice\Hydrator\InvoiceModelDefaultHydrator;
|
use App\Invoice\Hydrator\InvoiceModelDefaultHydrator;
|
||||||
use App\Invoice\Hydrator\InvoiceModelProjectHydrator;
|
use App\Invoice\Hydrator\InvoiceModelProjectHydrator;
|
||||||
use App\Invoice\Hydrator\InvoiceModelUserHydrator;
|
use App\Invoice\Hydrator\InvoiceModelUserHydrator;
|
||||||
|
use App\Project\ProjectStatisticService;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,14 +78,14 @@ final class InvoiceModel
|
|||||||
*/
|
*/
|
||||||
private $invoiceNumber;
|
private $invoiceNumber;
|
||||||
|
|
||||||
public function __construct(InvoiceFormatter $formatter)
|
public function __construct(InvoiceFormatter $formatter, CustomerStatisticService $customerStatistic, ProjectStatisticService $projectStatistic, ActivityStatisticService $activityStatistic)
|
||||||
{
|
{
|
||||||
$this->invoiceDate = new \DateTime();
|
$this->invoiceDate = new \DateTime();
|
||||||
$this->formatter = $formatter;
|
$this->formatter = $formatter;
|
||||||
$this->addModelHydrator(new InvoiceModelDefaultHydrator());
|
$this->addModelHydrator(new InvoiceModelDefaultHydrator());
|
||||||
$this->addModelHydrator(new InvoiceModelCustomerHydrator());
|
$this->addModelHydrator(new InvoiceModelCustomerHydrator($customerStatistic));
|
||||||
$this->addModelHydrator(new InvoiceModelProjectHydrator());
|
$this->addModelHydrator(new InvoiceModelProjectHydrator($projectStatistic));
|
||||||
$this->addModelHydrator(new InvoiceModelActivityHydrator());
|
$this->addModelHydrator(new InvoiceModelActivityHydrator($activityStatistic));
|
||||||
$this->addModelHydrator(new InvoiceModelUserHydrator());
|
$this->addModelHydrator(new InvoiceModelUserHydrator());
|
||||||
$this->addItemHydrator(new InvoiceItemDefaultHydrator());
|
$this->addItemHydrator(new InvoiceItemDefaultHydrator());
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/Invoice/InvoiceModelFactory.php
Normal file
33
src/Invoice/InvoiceModelFactory.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Invoice;
|
||||||
|
|
||||||
|
use App\Activity\ActivityStatisticService;
|
||||||
|
use App\Customer\CustomerStatisticService;
|
||||||
|
use App\Project\ProjectStatisticService;
|
||||||
|
|
||||||
|
final class InvoiceModelFactory
|
||||||
|
{
|
||||||
|
private $customerStatisticService;
|
||||||
|
private $projectStatisticService;
|
||||||
|
private $activityStatisticService;
|
||||||
|
|
||||||
|
public function __construct(CustomerStatisticService $customerStatistic, ProjectStatisticService $projectStatistic, ActivityStatisticService $activityStatistic)
|
||||||
|
{
|
||||||
|
$this->customerStatisticService = $customerStatistic;
|
||||||
|
$this->projectStatisticService = $projectStatistic;
|
||||||
|
$this->activityStatisticService = $activityStatistic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createModel(InvoiceFormatter $formatter): InvoiceModel
|
||||||
|
{
|
||||||
|
return new InvoiceModel($formatter, $this->customerStatisticService, $this->projectStatisticService, $this->activityStatisticService);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,7 +37,10 @@ abstract class AbstractTwigRenderer implements RendererInterface
|
|||||||
$previousLocale = $this->changeTwigLocale($this->twig, $model->getTemplate()->getLanguage());
|
$previousLocale = $this->changeTwigLocale($this->twig, $model->getTemplate()->getLanguage());
|
||||||
|
|
||||||
$content = $this->twig->render('@invoice/' . basename($document->getFilename()), [
|
$content = $this->twig->render('@invoice/' . basename($document->getFilename()), [
|
||||||
'model' => $model
|
// model should not be used in the future, but we can likely not remove it
|
||||||
|
'model' => $model,
|
||||||
|
// new since 1.16.7 - templates should only use the pre-generated values
|
||||||
|
'invoice' => $model->toArray(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->changeTwigLocale($this->twig, $previousLocale);
|
$this->changeTwigLocale($this->twig, $previousLocale);
|
||||||
|
|||||||
@@ -46,29 +46,19 @@ final class ServiceInvoice
|
|||||||
* @var array InvoiceItemRepositoryInterface[]
|
* @var array InvoiceItemRepositoryInterface[]
|
||||||
*/
|
*/
|
||||||
private $invoiceItemRepositories = [];
|
private $invoiceItemRepositories = [];
|
||||||
/**
|
|
||||||
* @var InvoiceDocumentRepository
|
|
||||||
*/
|
|
||||||
private $documents;
|
private $documents;
|
||||||
/**
|
|
||||||
* @var FileHelper
|
|
||||||
*/
|
|
||||||
private $fileHelper;
|
private $fileHelper;
|
||||||
/**
|
|
||||||
* @var LanguageFormattings
|
|
||||||
*/
|
|
||||||
private $formatter;
|
private $formatter;
|
||||||
/**
|
|
||||||
* @var InvoiceRepository
|
|
||||||
*/
|
|
||||||
private $invoiceRepository;
|
private $invoiceRepository;
|
||||||
|
private $invoiceModelFactory;
|
||||||
|
|
||||||
public function __construct(InvoiceDocumentRepository $repository, FileHelper $fileHelper, InvoiceRepository $invoiceRepository, LanguageFormattings $formatter)
|
public function __construct(InvoiceDocumentRepository $repository, FileHelper $fileHelper, InvoiceRepository $invoiceRepository, LanguageFormattings $formatter, InvoiceModelFactory $invoiceModelFactory)
|
||||||
{
|
{
|
||||||
$this->documents = $repository;
|
$this->documents = $repository;
|
||||||
$this->fileHelper = $fileHelper;
|
$this->fileHelper = $fileHelper;
|
||||||
$this->invoiceRepository = $invoiceRepository;
|
$this->invoiceRepository = $invoiceRepository;
|
||||||
$this->formatter = $formatter;
|
$this->formatter = $formatter;
|
||||||
|
$this->invoiceModelFactory = $invoiceModelFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addNumberGenerator(NumberGeneratorInterface $generator): ServiceInvoice
|
public function addNumberGenerator(NumberGeneratorInterface $generator): ServiceInvoice
|
||||||
@@ -469,7 +459,9 @@ final class ServiceInvoice
|
|||||||
@trigger_error('Using invoice templates without a language is is deprecated and trigger and will throw an exception with 2.0', E_USER_DEPRECATED);
|
@trigger_error('Using invoice templates without a language is is deprecated and trigger and will throw an exception with 2.0', E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$model = new InvoiceModel(new DefaultInvoiceFormatter($this->formatter, $template->getLanguage()));
|
$formatter = new DefaultInvoiceFormatter($this->formatter, $template->getLanguage());
|
||||||
|
|
||||||
|
$model = $this->invoiceModelFactory->createModel($formatter);
|
||||||
$model
|
$model
|
||||||
->setTemplate($template)
|
->setTemplate($template)
|
||||||
->setInvoiceDate($this->getDateTimeFactory($query)->createDateTime())
|
->setInvoiceDate($this->getDateTimeFactory($query)->createDateTime())
|
||||||
|
|||||||
@@ -2,124 +2,135 @@
|
|||||||
{% extends 'invoice/layout.html.twig' %}
|
{% extends 'invoice/layout.html.twig' %}
|
||||||
|
|
||||||
{% block invoice %}
|
{% block invoice %}
|
||||||
{% set isDecimal = model.template.decimalDuration|default(false) %}
|
{% set isDecimal = model.template.decimalDuration|default(false) %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<h2 class="page-header">
|
<h2 class="page-header">
|
||||||
<span contenteditable="true">{{ model.template.title }}</span>
|
<span contenteditable="true">{{ model.template.title }}</span>
|
||||||
</h2>
|
</h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<table class="table no-border table-condensed">
|
<table class="table no-border table-condensed">
|
||||||
<tr>
|
|
||||||
<th>{{ 'invoice.from'|trans }}</th>
|
|
||||||
<td contenteditable="true">
|
|
||||||
{% if model.query.user is not empty %}
|
|
||||||
{{ widgets.username(model.query.user) }}
|
|
||||||
{% else %}
|
|
||||||
{{ model.template.company }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>{{ 'label.date'|trans }}</th>
|
|
||||||
<td contenteditable="true">
|
|
||||||
{% if model.query.begin|date('m') != model.query.end|date('m') or model.query.begin|date('Y') != model.query.end|date('Y') %}
|
|
||||||
{{ model.query.begin|date_short }} - {{ model.query.end|date_short }}
|
|
||||||
{% else %}
|
|
||||||
{{ model.query.end|month_name }} {{ model.query.end|date('Y') }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>{{ 'label.customer'|trans }}</th>
|
|
||||||
<td contenteditable="true">
|
|
||||||
{% if model.customer.number is not empty %}[{{ model.customer.number }}]{% endif %}
|
|
||||||
{{ model.customer.name }}{% if model.customer.contact is not empty %} / {{ model.customer.contact }}{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ 'label.orderNumber'|trans }}</th>
|
<th>{{ 'invoice.from'|trans }}</th>
|
||||||
<td contenteditable="true">
|
<td contenteditable="true">
|
||||||
{{ model.query.project.orderNumber }}
|
{% if model.query.user is not empty %}
|
||||||
|
{{ widgets.username(model.query.user) }}
|
||||||
|
{% else %}
|
||||||
|
{{ model.template.company }}
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row invoice-items">
|
|
||||||
<div class="col-xs-12 table-responsive">
|
|
||||||
<table class="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>{{ 'label.date'|trans }}</th>
|
|
||||||
{% if model.query.user is empty %}
|
|
||||||
<th>{{ 'label.user'|trans }}</th>
|
|
||||||
{% endif %}
|
|
||||||
<th>{{ 'label.activity'|trans }}</th>
|
|
||||||
<th>{{ 'label.hours'|trans }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for entry in model.calculator.entries %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ entry.begin|date_short }}</td>
|
|
||||||
{% if model.query.user is empty %}
|
|
||||||
<td>{{ widgets.username(entry.user) }}</td>
|
|
||||||
{% endif %}
|
|
||||||
<td contenteditable="true">
|
|
||||||
{% if entry.description is not empty %}
|
|
||||||
{{ entry.description|nl2br }}
|
|
||||||
{% else %}
|
|
||||||
{% if entry.activity is not null %}{{ entry.activity.name }} / {% endif %}{{ entry.project.name }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td class="text-nowrap">{{ entry.duration|duration(isDecimal) }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th></th>
|
|
||||||
{% if model.query.user is empty %}
|
|
||||||
<th></th>
|
|
||||||
{% endif %}
|
|
||||||
<th>{{ 'invoice.total_working_time'|trans }}</th>
|
|
||||||
<th class="text-nowrap">{{ model.calculator.timeWorked|duration(isDecimal) }}</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12">
|
|
||||||
{% if model.template.paymentTerms is not empty %}
|
|
||||||
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
|
|
||||||
|
|
||||||
<p class="text-muted well well-sm no-shadow" contenteditable="true" style="margin-bottom: 100px">
|
|
||||||
{{ model.template.paymentTerms|trim|nl2br }}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th style="padding-bottom: 60px">{{ 'invoice.signature_user'|trans }}</th>
|
<th>{{ 'label.date'|trans }}</th>
|
||||||
|
<td contenteditable="true">
|
||||||
|
{% if model.query.begin|date('m') != model.query.end|date('m') or model.query.begin|date('Y') != model.query.end|date('Y') %}
|
||||||
|
{{ model.query.begin|date_short }} - {{ model.query.end|date_short }}
|
||||||
|
{% else %}
|
||||||
|
{{ model.query.end|month_name }} {{ model.query.end|date('Y') }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ 'invoice.signature_customer'|trans }}</th>
|
<th>{{ 'label.customer'|trans }}</th>
|
||||||
|
<td contenteditable="true">
|
||||||
|
{% if model.customer.number is not empty %}[{{ model.customer.number }}]{% endif %}
|
||||||
|
{{ model.customer.name }}{% if model.customer.contact is not empty %} / {{ model.customer.contact }}{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
{% if model.query.project is not empty %}
|
||||||
|
<tr>
|
||||||
|
<th>{{ 'label.project'|trans }}</th>
|
||||||
|
<td contenteditable="true">
|
||||||
|
{{ model.query.project.name }}
|
||||||
|
{% if model.query.project.orderNumber is not empty %}
|
||||||
|
({{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }})
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% if model.query.activity is not empty %}
|
||||||
|
<tr>
|
||||||
|
<th>{{ 'label.activity'|trans }}</th>
|
||||||
|
<td contenteditable="true">
|
||||||
|
{{ model.query.activity.name }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<div class="row invoice-items">
|
||||||
|
<div class="col-xs-12 table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ 'label.date'|trans }}</th>
|
||||||
|
{% if model.query.user is empty %}
|
||||||
|
<th>{{ 'label.user'|trans }}</th>
|
||||||
|
{% endif %}
|
||||||
|
<th>{{ 'label.activity'|trans }}</th>
|
||||||
|
<th class="text-right">{{ 'label.hours'|trans }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for entry in model.calculator.entries %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ entry.begin|date_short }}</td>
|
||||||
|
{% if model.query.user is empty %}
|
||||||
|
<td>{{ widgets.username(entry.user) }}</td>
|
||||||
|
{% endif %}
|
||||||
|
<td contenteditable="true">
|
||||||
|
{% if entry.description is not empty %}
|
||||||
|
{{ entry.description|nl2br }}
|
||||||
|
{% else %}
|
||||||
|
{% if entry.activity is not null %}{{ entry.activity.name }} / {% endif %}{{ entry.project.name }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="text-right text-nowrap">{{ entry.duration|duration(isDecimal) }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
{% if model.query.user is empty %}
|
||||||
|
<th></th>
|
||||||
|
{% endif %}
|
||||||
|
<th>{{ 'invoice.total_working_time'|trans }}</th>
|
||||||
|
<th class="text-right text-nowrap">{{ model.calculator.timeWorked|duration(isDecimal) }}</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
{% if model.template.paymentTerms is not empty %}
|
||||||
|
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
|
||||||
|
|
||||||
|
<p class="text-muted well well-sm no-shadow" contenteditable="true" style="margin-bottom: 100px">
|
||||||
|
{{ model.template.paymentTerms|trim|nl2br }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th style="padding-bottom: 60px">{{ 'invoice.signature_user'|trans }}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{{ 'invoice.signature_customer'|trans }}</th>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -26,6 +26,7 @@ use App\Invoice\NumberGenerator\DateNumberGenerator;
|
|||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +159,7 @@ class InvoiceTest extends TestCase
|
|||||||
$query->setBegin(new \DateTime());
|
$query->setBegin(new \DateTime());
|
||||||
$query->setEnd(new \DateTime());
|
$query->setEnd(new \DateTime());
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ namespace App\Tests\Event;
|
|||||||
|
|
||||||
use App\Entity\InvoiceDocument;
|
use App\Entity\InvoiceDocument;
|
||||||
use App\Event\InvoicePostRenderEvent;
|
use App\Event\InvoicePostRenderEvent;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
use App\Tests\Invoice\Renderer\DebugRenderer;
|
use App\Tests\Invoice\Renderer\DebugRenderer;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ class InvoicePostRenderEventTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testDefaultValues()
|
public function testDefaultValues()
|
||||||
{
|
{
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
||||||
$renderer = new DebugRenderer();
|
$renderer = new DebugRenderer();
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ namespace App\Tests\Event;
|
|||||||
|
|
||||||
use App\Entity\InvoiceDocument;
|
use App\Entity\InvoiceDocument;
|
||||||
use App\Event\InvoicePreRenderEvent;
|
use App\Event\InvoicePreRenderEvent;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
use App\Tests\Invoice\Renderer\DebugRenderer;
|
use App\Tests\Invoice\Renderer\DebugRenderer;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +23,7 @@ class InvoicePreRenderEventTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testDefaultValues()
|
public function testDefaultValues()
|
||||||
{
|
{
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
||||||
$renderer = new DebugRenderer();
|
$renderer = new DebugRenderer();
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use App\Entity\Project;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\CalculatorInterface;
|
use App\Invoice\CalculatorInterface;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
abstract class AbstractCalculatorTest extends TestCase
|
abstract class AbstractCalculatorTest extends TestCase
|
||||||
@@ -44,7 +44,7 @@ abstract class AbstractCalculatorTest extends TestCase
|
|||||||
$template = new InvoiceTemplate();
|
$template = new InvoiceTemplate();
|
||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->setQuery($query);
|
$model->setQuery($query);
|
||||||
@@ -88,7 +88,7 @@ abstract class AbstractCalculatorTest extends TestCase
|
|||||||
->setActivity($activity)
|
->setActivity($activity)
|
||||||
->setProject($project);
|
->setProject($project);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries([$timesheet]);
|
$model->addEntries([$timesheet]);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use App\Entity\Project;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\Calculator\ActivityInvoiceCalculator;
|
use App\Invoice\Calculator\ActivityInvoiceCalculator;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \App\Invoice\Calculator\ActivityInvoiceCalculator
|
* @covers \App\Invoice\Calculator\ActivityInvoiceCalculator
|
||||||
@@ -134,7 +134,7 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setActivity($activity1);
|
$query->setActivity($activity1);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use App\Entity\Project;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\Calculator\DateInvoiceCalculator;
|
use App\Invoice\Calculator\DateInvoiceCalculator;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ class DateInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ use App\Entity\InvoiceTemplate;
|
|||||||
use App\Entity\Tag;
|
use App\Entity\Tag;
|
||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Invoice\Calculator\DefaultCalculator;
|
use App\Invoice\Calculator\DefaultCalculator;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \App\Invoice\Calculator\DefaultCalculator
|
* @covers \App\Invoice\Calculator\DefaultCalculator
|
||||||
@@ -63,7 +63,7 @@ class DefaultCalculatorTest extends AbstractCalculatorTest
|
|||||||
|
|
||||||
$entries = [$timesheet, $timesheet2, $timesheet3];
|
$entries = [$timesheet, $timesheet2, $timesheet3];
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use App\Entity\Project;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\Calculator\ProjectInvoiceCalculator;
|
use App\Invoice\Calculator\ProjectInvoiceCalculator;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ class ProjectInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ use App\Entity\Timesheet;
|
|||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\Calculator\ShortInvoiceCalculator;
|
use App\Invoice\Calculator\ShortInvoiceCalculator;
|
||||||
use App\Invoice\InvoiceItem;
|
use App\Invoice\InvoiceItem;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \App\Invoice\Calculator\ShortInvoiceCalculator
|
* @covers \App\Invoice\Calculator\ShortInvoiceCalculator
|
||||||
@@ -91,7 +91,7 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setActivity($activity);
|
$query->setActivity($activity);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
@@ -173,7 +173,7 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setActivity($activity);
|
$query->setActivity($activity);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
@@ -252,7 +252,7 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setActivity($activity);
|
$query->setActivity($activity);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use App\Entity\Project;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\Calculator\UserInvoiceCalculator;
|
use App\Invoice\Calculator\UserInvoiceCalculator;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \App\Invoice\Calculator\UserInvoiceCalculator
|
* @covers \App\Invoice\Calculator\UserInvoiceCalculator
|
||||||
@@ -105,7 +105,7 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setActivity($activity);
|
$query->setActivity($activity);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use App\Entity\Project;
|
|||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\Calculator\WeeklyInvoiceCalculator;
|
use App\Invoice\Calculator\WeeklyInvoiceCalculator;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +110,7 @@ class WeeklyInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Tests\Invoice\Hydrator;
|
namespace App\Tests\Invoice\Hydrator;
|
||||||
|
|
||||||
|
use App\Activity\ActivityStatisticService;
|
||||||
use App\Invoice\Hydrator\InvoiceModelActivityHydrator;
|
use App\Invoice\Hydrator\InvoiceModelActivityHydrator;
|
||||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -24,7 +25,7 @@ class InvoiceModelActivityHydratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$model = $this->getInvoiceModel();
|
$model = $this->getInvoiceModel();
|
||||||
|
|
||||||
$sut = new InvoiceModelActivityHydrator();
|
$sut = new InvoiceModelActivityHydrator($this->createMock(ActivityStatisticService::class));
|
||||||
|
|
||||||
$result = $sut->hydrate($model);
|
$result = $sut->hydrate($model);
|
||||||
$this->assertModelStructure($result);
|
$this->assertModelStructure($result);
|
||||||
@@ -41,10 +42,18 @@ class InvoiceModelActivityHydratorTest extends TestCase
|
|||||||
'activity.name',
|
'activity.name',
|
||||||
'activity.comment',
|
'activity.comment',
|
||||||
'activity.meta.foo-activity',
|
'activity.meta.foo-activity',
|
||||||
|
'activity.budget_open',
|
||||||
|
'activity.budget_open_plain',
|
||||||
|
'activity.time_budget_open',
|
||||||
|
'activity.time_budget_open_plain',
|
||||||
'activity.1.id',
|
'activity.1.id',
|
||||||
'activity.1.name',
|
'activity.1.name',
|
||||||
'activity.1.comment',
|
'activity.1.comment',
|
||||||
'activity.1.meta.foo-activity',
|
'activity.1.meta.foo-activity',
|
||||||
|
'activity.1.budget_open',
|
||||||
|
'activity.1.budget_open_plain',
|
||||||
|
'activity.1.time_budget_open',
|
||||||
|
'activity.1.time_budget_open_plain',
|
||||||
];
|
];
|
||||||
|
|
||||||
$givenKeys = array_keys($model);
|
$givenKeys = array_keys($model);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Tests\Invoice\Hydrator;
|
namespace App\Tests\Invoice\Hydrator;
|
||||||
|
|
||||||
|
use App\Customer\CustomerStatisticService;
|
||||||
use App\Invoice\Hydrator\InvoiceModelCustomerHydrator;
|
use App\Invoice\Hydrator\InvoiceModelCustomerHydrator;
|
||||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -24,7 +25,7 @@ class InvoiceModelCustomerHydratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$model = $this->getInvoiceModel();
|
$model = $this->getInvoiceModel();
|
||||||
|
|
||||||
$sut = new InvoiceModelCustomerHydrator();
|
$sut = new InvoiceModelCustomerHydrator($this->createMock(CustomerStatisticService::class));
|
||||||
|
|
||||||
$result = $sut->hydrate($model);
|
$result = $sut->hydrate($model);
|
||||||
$this->assertModelStructure($result);
|
$this->assertModelStructure($result);
|
||||||
@@ -52,6 +53,10 @@ class InvoiceModelCustomerHydratorTest extends TestCase
|
|||||||
'customer.phone',
|
'customer.phone',
|
||||||
'customer.mobile',
|
'customer.mobile',
|
||||||
'customer.meta.foo-customer',
|
'customer.meta.foo-customer',
|
||||||
|
'customer.budget_open',
|
||||||
|
'customer.budget_open_plain',
|
||||||
|
'customer.time_budget_open',
|
||||||
|
'customer.time_budget_open_plain',
|
||||||
];
|
];
|
||||||
|
|
||||||
$givenKeys = array_keys($model);
|
$givenKeys = array_keys($model);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
namespace App\Tests\Invoice\Hydrator;
|
namespace App\Tests\Invoice\Hydrator;
|
||||||
|
|
||||||
use App\Invoice\Hydrator\InvoiceModelProjectHydrator;
|
use App\Invoice\Hydrator\InvoiceModelProjectHydrator;
|
||||||
|
use App\Project\ProjectStatisticService;
|
||||||
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
use App\Tests\Invoice\Renderer\RendererTestTrait;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ class InvoiceModelProjectHydratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$model = $this->getInvoiceModel();
|
$model = $this->getInvoiceModel();
|
||||||
|
|
||||||
$sut = new InvoiceModelProjectHydrator();
|
$sut = new InvoiceModelProjectHydrator($this->createMock(ProjectStatisticService::class));
|
||||||
|
|
||||||
$result = $sut->hydrate($model);
|
$result = $sut->hydrate($model);
|
||||||
$this->assertModelStructure($result);
|
$this->assertModelStructure($result);
|
||||||
@@ -51,6 +52,10 @@ class InvoiceModelProjectHydratorTest extends TestCase
|
|||||||
'project.budget_time',
|
'project.budget_time',
|
||||||
'project.budget_time_decimal',
|
'project.budget_time_decimal',
|
||||||
'project.budget_time_minutes',
|
'project.budget_time_minutes',
|
||||||
|
'project.budget_open',
|
||||||
|
'project.budget_open_plain',
|
||||||
|
'project.time_budget_open',
|
||||||
|
'project.time_budget_open_plain',
|
||||||
'project.1.id',
|
'project.1.id',
|
||||||
'project.1.name',
|
'project.1.name',
|
||||||
'project.1.comment',
|
'project.1.comment',
|
||||||
@@ -65,6 +70,10 @@ class InvoiceModelProjectHydratorTest extends TestCase
|
|||||||
'project.1.budget_time',
|
'project.1.budget_time',
|
||||||
'project.1.budget_time_decimal',
|
'project.1.budget_time_decimal',
|
||||||
'project.1.budget_time_minutes',
|
'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',
|
||||||
];
|
];
|
||||||
|
|
||||||
$givenKeys = array_keys($model);
|
$givenKeys = array_keys($model);
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ use App\Entity\Customer;
|
|||||||
use App\Entity\InvoiceTemplate;
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Entity\Project;
|
use App\Entity\Project;
|
||||||
use App\Invoice\InvoiceFilename;
|
use App\Invoice\InvoiceFilename;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Invoice\NumberGenerator\DateNumberGenerator;
|
use App\Invoice\NumberGenerator\DateNumberGenerator;
|
||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +29,7 @@ class InvoiceFilenameTest extends TestCase
|
|||||||
$customer = new Customer();
|
$customer = new Customer();
|
||||||
$template = new InvoiceTemplate();
|
$template = new InvoiceTemplate();
|
||||||
|
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setNumberGenerator($this->getNumberGeneratorSut());
|
$model->setNumberGenerator($this->getNumberGeneratorSut());
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Invoice\Calculator\DefaultCalculator;
|
|||||||
use App\Invoice\InvoiceModel;
|
use App\Invoice\InvoiceModel;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\NumberGenerator\IncrementingNumberGenerator;
|
use App\Tests\Invoice\NumberGenerator\IncrementingNumberGenerator;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +27,7 @@ class InvoiceModelTest extends TestCase
|
|||||||
public function testEmptyObject()
|
public function testEmptyObject()
|
||||||
{
|
{
|
||||||
$formatter = new DebugFormatter();
|
$formatter = new DebugFormatter();
|
||||||
$sut = new InvoiceModel($formatter);
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel($formatter);
|
||||||
|
|
||||||
self::assertNull($sut->getQuery());
|
self::assertNull($sut->getQuery());
|
||||||
self::assertNull($sut->getCustomer());
|
self::assertNull($sut->getCustomer());
|
||||||
@@ -51,7 +52,7 @@ class InvoiceModelTest extends TestCase
|
|||||||
public function testEmptyObjectThrowsExceptionOnNumberGenerator()
|
public function testEmptyObjectThrowsExceptionOnNumberGenerator()
|
||||||
{
|
{
|
||||||
$formatter = new DebugFormatter();
|
$formatter = new DebugFormatter();
|
||||||
$sut = new InvoiceModel($formatter);
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel($formatter);
|
||||||
|
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessage('InvoiceModel::getInvoiceNumber() cannot be called before calling setNumberGenerator()');
|
$this->expectExceptionMessage('InvoiceModel::getInvoiceNumber() cannot be called before calling setNumberGenerator()');
|
||||||
@@ -60,7 +61,7 @@ class InvoiceModelTest extends TestCase
|
|||||||
|
|
||||||
public function testSetter()
|
public function testSetter()
|
||||||
{
|
{
|
||||||
$sut = new InvoiceModel(new DebugFormatter());
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
|
|
||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
self::assertInstanceOf(InvoiceModel::class, $sut->setQuery($query));
|
self::assertInstanceOf(InvoiceModel::class, $sut->setQuery($query));
|
||||||
@@ -95,7 +96,7 @@ class InvoiceModelTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeprecations()
|
public function testDeprecations()
|
||||||
{
|
{
|
||||||
$sut = new InvoiceModel(new DebugFormatter());
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
|
|
||||||
$entries = [new Timesheet()];
|
$entries = [new Timesheet()];
|
||||||
self::assertInstanceOf(InvoiceModel::class, $sut->setEntries($entries));
|
self::assertInstanceOf(InvoiceModel::class, $sut->setEntries($entries));
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ namespace App\Tests\Invoice\NumberGenerator;
|
|||||||
use App\Configuration\SystemConfiguration;
|
use App\Configuration\SystemConfiguration;
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Invoice\NumberGenerator\ConfigurableNumberGenerator;
|
use App\Invoice\NumberGenerator\ConfigurableNumberGenerator;
|
||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +156,7 @@ class ConfigurableNumberGeneratorTest extends TestCase
|
|||||||
$user->method('getAccountNumber')->willReturn('0815');
|
$user->method('getAccountNumber')->willReturn('0815');
|
||||||
|
|
||||||
$sut = $this->getSut($format, $counter);
|
$sut = $this->getSut($format, $counter);
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setInvoiceDate($invoiceDate);
|
$model->setInvoiceDate($invoiceDate);
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setUser($user);
|
$model->setUser($user);
|
||||||
@@ -197,7 +197,7 @@ class ConfigurableNumberGeneratorTest extends TestCase
|
|||||||
$this->expectExceptionMessage(sprintf('Unknown %s found', $brokenPart));
|
$this->expectExceptionMessage(sprintf('Unknown %s found', $brokenPart));
|
||||||
|
|
||||||
$sut = $this->getSut($format);
|
$sut = $this->getSut($format);
|
||||||
$model = new InvoiceModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
||||||
$model->setInvoiceDate($invoiceDate);
|
$model->setInvoiceDate($invoiceDate);
|
||||||
$model->setCustomer(new Customer());
|
$model->setCustomer(new Customer());
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
namespace App\Tests\Invoice\NumberGenerator;
|
namespace App\Tests\Invoice\NumberGenerator;
|
||||||
|
|
||||||
use App\Invoice\InvoiceModel;
|
|
||||||
use App\Invoice\NumberGenerator\DateNumberGenerator;
|
use App\Invoice\NumberGenerator\DateNumberGenerator;
|
||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +40,7 @@ class DateNumberGeneratorTest extends TestCase
|
|||||||
public function testGetInvoiceNumber()
|
public function testGetInvoiceNumber()
|
||||||
{
|
{
|
||||||
$sut = $this->getSut(false, false);
|
$sut = $this->getSut(false, false);
|
||||||
$sut->setModel(new InvoiceModel(new DebugFormatter()));
|
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter()));
|
||||||
|
|
||||||
$this->assertEquals(date('ymd'), $sut->getInvoiceNumber());
|
$this->assertEquals(date('ymd'), $sut->getInvoiceNumber());
|
||||||
$this->assertEquals('date', $sut->getId());
|
$this->assertEquals('date', $sut->getId());
|
||||||
@@ -49,7 +49,7 @@ class DateNumberGeneratorTest extends TestCase
|
|||||||
public function testGetInvoiceNumberWithExisting()
|
public function testGetInvoiceNumberWithExisting()
|
||||||
{
|
{
|
||||||
$sut = $this->getSut(true, false);
|
$sut = $this->getSut(true, false);
|
||||||
$sut->setModel(new InvoiceModel(new DebugFormatter()));
|
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter()));
|
||||||
|
|
||||||
$this->assertEquals(date('ymd-01'), $sut->getInvoiceNumber());
|
$this->assertEquals(date('ymd-01'), $sut->getInvoiceNumber());
|
||||||
$this->assertEquals('date', $sut->getId());
|
$this->assertEquals('date', $sut->getId());
|
||||||
@@ -58,7 +58,7 @@ class DateNumberGeneratorTest extends TestCase
|
|||||||
public function testGetInvoiceNumberWithManyExisting()
|
public function testGetInvoiceNumberWithManyExisting()
|
||||||
{
|
{
|
||||||
$sut = $this->getSut(true, true);
|
$sut = $this->getSut(true, true);
|
||||||
$sut->setModel(new InvoiceModel(new DebugFormatter()));
|
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter()));
|
||||||
|
|
||||||
$this->assertEquals(date('ymd-99'), $sut->getInvoiceNumber());
|
$this->assertEquals(date('ymd-99'), $sut->getInvoiceNumber());
|
||||||
$this->assertEquals('date', $sut->getId());
|
$this->assertEquals('date', $sut->getId());
|
||||||
|
|||||||
@@ -131,12 +131,20 @@ class DebugRendererTest extends TestCase
|
|||||||
'customer.email',
|
'customer.email',
|
||||||
'customer.fax',
|
'customer.fax',
|
||||||
'customer.phone',
|
'customer.phone',
|
||||||
|
'customer.budget_open',
|
||||||
|
'customer.budget_open_plain',
|
||||||
|
'customer.time_budget_open',
|
||||||
|
'customer.time_budget_open_plain',
|
||||||
'customer.mobile',
|
'customer.mobile',
|
||||||
'customer.meta.foo-customer',
|
'customer.meta.foo-customer',
|
||||||
'activity.id',
|
'activity.id',
|
||||||
'activity.name',
|
'activity.name',
|
||||||
'activity.comment',
|
'activity.comment',
|
||||||
'activity.meta.foo-activity',
|
'activity.meta.foo-activity',
|
||||||
|
'activity.budget_open',
|
||||||
|
'activity.budget_open_plain',
|
||||||
|
'activity.time_budget_open',
|
||||||
|
'activity.time_budget_open_plain',
|
||||||
'user.alias',
|
'user.alias',
|
||||||
'user.email',
|
'user.email',
|
||||||
'user.name',
|
'user.name',
|
||||||
@@ -146,8 +154,18 @@ class DebugRendererTest extends TestCase
|
|||||||
'testFromModelHydrator',
|
'testFromModelHydrator',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($activityCounter === 1) {
|
||||||
|
$keys = array_merge($keys, [
|
||||||
|
'activity',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($activityCounter > 1) {
|
if ($activityCounter > 1) {
|
||||||
$keys = array_merge($keys, [
|
$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.id',
|
||||||
'activity.1.name',
|
'activity.1.name',
|
||||||
'activity.1.comment',
|
'activity.1.comment',
|
||||||
@@ -171,7 +189,16 @@ class DebugRendererTest extends TestCase
|
|||||||
'project.budget_time',
|
'project.budget_time',
|
||||||
'project.budget_time_decimal',
|
'project.budget_time_decimal',
|
||||||
'project.budget_time_minutes',
|
'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) {
|
if ($projectCounter > 1) {
|
||||||
$keys = array_merge($keys, [
|
$keys = array_merge($keys, [
|
||||||
'project.1.id',
|
'project.1.id',
|
||||||
@@ -188,6 +215,10 @@ class DebugRendererTest extends TestCase
|
|||||||
'project.1.budget_time',
|
'project.1.budget_time',
|
||||||
'project.1.budget_time_decimal',
|
'project.1.budget_time_decimal',
|
||||||
'project.1.budget_time_minutes',
|
'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',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ use App\Invoice\NumberGenerator\DateNumberGenerator;
|
|||||||
use App\Invoice\Renderer\AbstractRenderer;
|
use App\Invoice\Renderer\AbstractRenderer;
|
||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
|
|
||||||
trait RendererTestTrait
|
trait RendererTestTrait
|
||||||
{
|
{
|
||||||
@@ -217,7 +218,7 @@ trait RendererTestTrait
|
|||||||
$query->setEnd(new \DateTime());
|
$query->setEnd(new \DateTime());
|
||||||
$query->setProjects([$project, $project2]);
|
$query->setProjects([$project, $project2]);
|
||||||
|
|
||||||
$model = new InvoiceModel($this->getFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
@@ -301,7 +302,7 @@ trait RendererTestTrait
|
|||||||
$query->setBegin(new \DateTime());
|
$query->setBegin(new \DateTime());
|
||||||
$query->setEnd(new \DateTime());
|
$query->setEnd(new \DateTime());
|
||||||
|
|
||||||
$model = new InvoiceModel($this->getFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter());
|
||||||
$model->setCustomer($customer);
|
$model->setCustomer($customer);
|
||||||
$model->setTemplate($template);
|
$model->setTemplate($template);
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
|
|||||||
@@ -66,10 +66,8 @@ class TwigRendererTest extends KernelTestCase
|
|||||||
|
|
||||||
$filename = $model->getInvoiceNumber() . '-customer_with_special_name';
|
$filename = $model->getInvoiceNumber() . '-customer_with_special_name';
|
||||||
$this->assertStringContainsString('<title>' . $filename . '</title>', $content);
|
$this->assertStringContainsString('<title>' . $filename . '</title>', $content);
|
||||||
$this->assertStringContainsString('<h2 class="page-header">
|
$this->assertStringContainsString('<span contenteditable="true">a very *long* test invoice / template title with [ßpecial] chäracter</span>', $content);
|
||||||
<span contenteditable="true">a very *long* test invoice / template title with [ßpecial] chäracter</span>
|
$this->assertEquals(3, substr_count($content, 'activity description'));
|
||||||
</h2>', $content);
|
|
||||||
$this->assertEquals(2, substr_count($content, 'activity description'));
|
|
||||||
$this->assertStringContainsString(nl2br("foo\n" .
|
$this->assertStringContainsString(nl2br("foo\n" .
|
||||||
"foo\r\n" .
|
"foo\r\n" .
|
||||||
'foo' . PHP_EOL .
|
'foo' . PHP_EOL .
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ use App\Invoice\ServiceInvoice;
|
|||||||
use App\Repository\InvoiceDocumentRepository;
|
use App\Repository\InvoiceDocumentRepository;
|
||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use App\Utils\FileHelper;
|
use App\Utils\FileHelper;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
@@ -48,7 +49,7 @@ class ServiceInvoiceTest extends TestCase
|
|||||||
$repo = new InvoiceDocumentRepository($paths);
|
$repo = new InvoiceDocumentRepository($paths);
|
||||||
$invoiceRepo = $this->createMock(InvoiceRepository::class);
|
$invoiceRepo = $this->createMock(InvoiceRepository::class);
|
||||||
|
|
||||||
return new ServiceInvoice($repo, new FileHelper(realpath(__DIR__ . '/../../var/data/')), $invoiceRepo, $formattings);
|
return new ServiceInvoice($repo, new FileHelper(realpath(__DIR__ . '/../../var/data/')), $invoiceRepo, $formattings, (new InvoiceModelFactoryFactory($this))->create());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidExceptionOnChangeState()
|
public function testInvalidExceptionOnChangeState()
|
||||||
|
|||||||
30
tests/Mocks/InvoiceModelFactoryFactory.php
Normal file
30
tests/Mocks/InvoiceModelFactoryFactory.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Mocks;
|
||||||
|
|
||||||
|
use App\Activity\ActivityStatisticService;
|
||||||
|
use App\Customer\CustomerStatisticService;
|
||||||
|
use App\Invoice\InvoiceModelFactory;
|
||||||
|
use App\Project\ProjectStatisticService;
|
||||||
|
|
||||||
|
class InvoiceModelFactoryFactory extends AbstractMockFactory
|
||||||
|
{
|
||||||
|
public function create(): InvoiceModelFactory
|
||||||
|
{
|
||||||
|
/** @var CustomerStatisticService $customerStatistic */
|
||||||
|
$customerStatistic = $this->getMockBuilder(CustomerStatisticService::class)->disableOriginalConstructor()->getMock();
|
||||||
|
/** @var ProjectStatisticService $projectStatistic */
|
||||||
|
$projectStatistic = $this->getMockBuilder(ProjectStatisticService::class)->disableOriginalConstructor()->getMock();
|
||||||
|
/** @var ActivityStatisticService $activityStatistic */
|
||||||
|
$activityStatistic = $this->getMockBuilder(ActivityStatisticService::class)->disableOriginalConstructor()->getMock();
|
||||||
|
|
||||||
|
return new InvoiceModelFactory($customerStatistic, $projectStatistic, $activityStatistic);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user