Release 2.0.29 (#4178)
- show button title if delete is used in page actions - fix invoice due date depends on invoice date, replace DateTime with DateTimeI… - lowercase all font names in PDFs, otherwise they fail loading - hide empty fieldset (work-contract page) - activate contract_other_profile by default for admin and super-admin - deactivate rule to check "maximum duration of entries" by default - allow to deactivate presets in DateRange Picker (for Devs)
This commit is contained in:
@@ -36,3 +36,7 @@
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
border-radius: var(--tblr-border-radius);
|
border-radius: var(--tblr-border-radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset:empty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@@ -107,7 +107,7 @@ kimai:
|
|||||||
REPORTING: ['view_reporting','view_other_reporting','project_reporting','customer_reporting']
|
REPORTING: ['view_reporting','view_other_reporting','project_reporting','customer_reporting']
|
||||||
# permissions which are deactivated, as these features are hidden for now
|
# permissions which are deactivated, as these features are hidden for now
|
||||||
# brave users can try to activate them and be surprised what happens
|
# brave users can try to activate them and be surprised what happens
|
||||||
REGISTER_BETA: ['contract_other_profile']
|
REGISTER_BETA: []
|
||||||
# mapping a "role name" to an array of "set names"
|
# mapping a "role name" to an array of "set names"
|
||||||
maps:
|
maps:
|
||||||
ROLE_USER: ['TIMESHEET','PROFILE']
|
ROLE_USER: ['TIMESHEET','PROFILE']
|
||||||
@@ -118,10 +118,8 @@ kimai:
|
|||||||
roles:
|
roles:
|
||||||
ROLE_USER: ['view_team_member','time_team_project','create_tag','view_reporting']
|
ROLE_USER: ['view_team_member','time_team_project','create_tag','view_reporting']
|
||||||
ROLE_TEAMLEAD: ['view_rate_own_timesheet','view_rate_other_timesheet','hourly-rate_own_profile','view_team_member']
|
ROLE_TEAMLEAD: ['view_rate_own_timesheet','view_rate_other_timesheet','hourly-rate_own_profile','view_team_member']
|
||||||
# TODO contract_other_profile
|
ROLE_ADMIN: ['hourly-rate_own_profile','edit_exported_timesheet','teams_own_profile','view_team_member','view_all_data','contract_other_profile']
|
||||||
ROLE_ADMIN: ['hourly-rate_own_profile','edit_exported_timesheet','teams_own_profile','view_team_member','view_all_data']
|
ROLE_SUPER_ADMIN: ['hourly-rate_own_profile','hourly-rate_other_profile','roles_own_profile','system_information','system_configuration','plugins','edit_exported_timesheet','teams_own_profile','view_team_member','upload_invoice_template','view_all_data','contract_other_profile']
|
||||||
# TODO contract_other_profile
|
|
||||||
ROLE_SUPER_ADMIN: ['hourly-rate_own_profile','hourly-rate_other_profile','roles_own_profile','system_information','system_configuration','plugins','edit_exported_timesheet','teams_own_profile','view_team_member','upload_invoice_template','view_all_data']
|
|
||||||
# --------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
18
phpstan.neon
18
phpstan.neon
@@ -4002,12 +4002,12 @@ parameters:
|
|||||||
path: src/Invoice/Hydrator/InvoiceItemDefaultHydrator.php
|
path: src/Invoice/Hydrator/InvoiceItemDefaultHydrator.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedDateTime\\(\\) expects DateTime, DateTime\\|null given\\.$#"
|
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedDateTime\\(\\) expects DateTimeInterface, DateTime\\|null given\\.$#"
|
||||||
count: 3
|
count: 3
|
||||||
path: src/Invoice/Hydrator/InvoiceItemDefaultHydrator.php
|
path: src/Invoice/Hydrator/InvoiceItemDefaultHydrator.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedTime\\(\\) expects DateTime, DateTime\\|null given\\.$#"
|
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedTime\\(\\) expects DateTimeInterface, DateTime\\|null given\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
path: src/Invoice/Hydrator/InvoiceItemDefaultHydrator.php
|
path: src/Invoice/Hydrator/InvoiceItemDefaultHydrator.php
|
||||||
|
|
||||||
@@ -4046,11 +4046,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Invoice/Hydrator/InvoiceModelCustomerHydrator.php
|
path: src/Invoice/Hydrator/InvoiceModelCustomerHydrator.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method format\\(\\) on DateTime\\|null\\.$#"
|
|
||||||
count: 3
|
|
||||||
path: src/Invoice/Hydrator/InvoiceModelDefaultHydrator.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot call method getAddress\\(\\) on App\\\\Entity\\\\InvoiceTemplate\\|null\\.$#"
|
message: "#^Cannot call method getAddress\\(\\) on App\\\\Entity\\\\InvoiceTemplate\\|null\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@@ -4137,13 +4132,8 @@ parameters:
|
|||||||
path: src/Invoice/Hydrator/InvoiceModelDefaultHydrator.php
|
path: src/Invoice/Hydrator/InvoiceModelDefaultHydrator.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedDateTime\\(\\) expects DateTime, DateTime\\|null given\\.$#"
|
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedDateTime\\(\\) expects DateTimeInterface, DateTime\\|null given\\.$#"
|
||||||
count: 4
|
count: 2
|
||||||
path: src/Invoice/Hydrator/InvoiceModelDefaultHydrator.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$date of method App\\\\Invoice\\\\InvoiceFormatter\\:\\:getFormattedMonthName\\(\\) expects DateTime, DateTime\\|null given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Invoice/Hydrator/InvoiceModelDefaultHydrator.php
|
path: src/Invoice/Hydrator/InvoiceModelDefaultHydrator.php
|
||||||
|
|
||||||
-
|
-
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
|||||||
"/build/app.99c7b6b4.js"
|
"/build/app.99c7b6b4.js"
|
||||||
],
|
],
|
||||||
"css": [
|
"css": [
|
||||||
"/build/app.f82609fb.css"
|
"/build/app.eb575c90.css"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"export-pdf": {
|
"export-pdf": {
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
"integrity": {
|
"integrity": {
|
||||||
"/build/runtime.f0079159.js": "sha384-H22sAW1aTvyIPqvHOvGXWSWTxf0y6mptp+MsVmyXCfjx/WJjBbhX9gbUZ+qIuihV",
|
"/build/runtime.f0079159.js": "sha384-H22sAW1aTvyIPqvHOvGXWSWTxf0y6mptp+MsVmyXCfjx/WJjBbhX9gbUZ+qIuihV",
|
||||||
"/build/app.99c7b6b4.js": "sha384-bPAdOMl3I6Ia3clnHgDiwoNKKe/bKnAdHUJdl7BXbsFNMg2wHsUDrGH+uNCQowqM",
|
"/build/app.99c7b6b4.js": "sha384-bPAdOMl3I6Ia3clnHgDiwoNKKe/bKnAdHUJdl7BXbsFNMg2wHsUDrGH+uNCQowqM",
|
||||||
"/build/app.f82609fb.css": "sha384-X848pib0qXUB72LdaVSupYXnYPE/lNXHXNkJdlh4FRj534BVHyupi+ly3cfCkDRS",
|
"/build/app.eb575c90.css": "sha384-CT92SMS+AjbulH+hT+pOq4jicscpVYpl/acq388EdqruZe26icGl9sNq9xaYXH8l",
|
||||||
"/build/export-pdf.d367a32e.js": "sha384-Z5baqnzjI636nYFs4g63ViIKBZKRW4Jhv/7PQmTEQlqhfA7eK0vUMUtiyy0R5A9u",
|
"/build/export-pdf.d367a32e.js": "sha384-Z5baqnzjI636nYFs4g63ViIKBZKRW4Jhv/7PQmTEQlqhfA7eK0vUMUtiyy0R5A9u",
|
||||||
"/build/export-pdf.d8a6c23b.css": "sha384-ztepocHE4rnGE9eKZ4kL6jTKaePUyiwiB9TjJjstjpf/ckcKg1HedrEOOk/8ElJg",
|
"/build/export-pdf.d8a6c23b.css": "sha384-ztepocHE4rnGE9eKZ4kL6jTKaePUyiwiB9TjJjstjpf/ckcKg1HedrEOOk/8ElJg",
|
||||||
"/build/invoice.2604495e.js": "sha384-D6JvhGSqlx7z72b/qD3nF3QDXPy+XsCSRGtWfs1icjDKOcd2UzuXwuSa/E1Fg2TJ",
|
"/build/invoice.2604495e.js": "sha384-D6JvhGSqlx7z72b/qD3nF3QDXPy+XsCSRGtWfs1icjDKOcd2UzuXwuSa/E1Fg2TJ",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"build/app.css": "/build/app.f82609fb.css",
|
"build/app.css": "/build/app.eb575c90.css",
|
||||||
"build/app.js": "/build/app.99c7b6b4.js",
|
"build/app.js": "/build/app.99c7b6b4.js",
|
||||||
"build/export-pdf.css": "/build/export-pdf.d8a6c23b.css",
|
"build/export-pdf.css": "/build/export-pdf.d8a6c23b.css",
|
||||||
"build/export-pdf.js": "/build/export-pdf.d367a32e.js",
|
"build/export-pdf.js": "/build/export-pdf.d367a32e.js",
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ class Constants
|
|||||||
/**
|
/**
|
||||||
* The current release version
|
* The current release version
|
||||||
*/
|
*/
|
||||||
public const VERSION = '2.0.28';
|
public const VERSION = '2.0.29';
|
||||||
/**
|
/**
|
||||||
* The current release: major * 10000 + minor * 100 + patch
|
* The current release: major * 10000 + minor * 100 + patch
|
||||||
*/
|
*/
|
||||||
public const VERSION_ID = 20028;
|
public const VERSION_ID = 20029;
|
||||||
/**
|
/**
|
||||||
* The software name
|
* The software name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ final class Configuration implements ConfigurationInterface
|
|||||||
->defaultValue(0)
|
->defaultValue(0)
|
||||||
->end()
|
->end()
|
||||||
->integerNode('long_running_duration')
|
->integerNode('long_running_duration')
|
||||||
->defaultValue(600)
|
->defaultValue(0)
|
||||||
->end()
|
->end()
|
||||||
->booleanNode('require_activity')
|
->booleanNode('require_activity')
|
||||||
->defaultTrue()
|
->defaultTrue()
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ class Invoice implements EntityWithMetaFields
|
|||||||
$this->currency = $model->getCurrency();
|
$this->currency = $model->getCurrency();
|
||||||
|
|
||||||
$createdAt = $model->getInvoiceDate();
|
$createdAt = $model->getInvoiceDate();
|
||||||
$this->createdAt = $createdAt;
|
$this->createdAt = \DateTime::createFromInterface($createdAt);
|
||||||
$this->timezone = $createdAt->getTimezone()->getName();
|
$this->timezone = $createdAt->getTimezone()->getName();
|
||||||
|
|
||||||
$this->dueDays = $template->getDueDays();
|
$this->dueDays = $template->getDueDays();
|
||||||
|
|||||||
@@ -175,9 +175,9 @@ class PageActionsEvent extends ThemeEvent
|
|||||||
public function addDelete(string $url, bool $remoteConfirm = true): void
|
public function addDelete(string $url, bool $remoteConfirm = true): void
|
||||||
{
|
{
|
||||||
if ($remoteConfirm) {
|
if ($remoteConfirm) {
|
||||||
$this->addAction('trash', ['url' => $url, 'class' => 'modal-ajax-form text-red', 'translation_domain' => 'actions']);
|
$this->addAction('trash', ['url' => $url, 'class' => 'modal-ajax-form text-red', 'translation_domain' => 'actions', 'title' => 'trash']);
|
||||||
} else {
|
} else {
|
||||||
$this->addAction('trash', ['url' => $url, 'class' => 'confirmation-link text-red', 'attr' => ['data-question' => 'confirm.delete'], 'translation_domain' => 'actions']);
|
$this->addAction('trash', ['url' => $url, 'class' => 'confirmation-link text-red', 'attr' => ['data-question' => 'confirm.delete'], 'translation_domain' => 'actions', 'title' => 'trash']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ final class DateRangeType extends AbstractType
|
|||||||
'format' => $formFormat,
|
'format' => $formFormat,
|
||||||
'separator' => self::DATE_SPACER,
|
'separator' => self::DATE_SPACER,
|
||||||
'allow_empty' => true,
|
'allow_empty' => true,
|
||||||
|
'with_presets' => true,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'pattern' => $pattern . self::DATE_SPACER . $pattern
|
'pattern' => $pattern . self::DATE_SPACER . $pattern
|
||||||
],
|
],
|
||||||
@@ -61,6 +62,7 @@ final class DateRangeType extends AbstractType
|
|||||||
$user = $options['user'];
|
$user = $options['user'];
|
||||||
$factory = DateTimeFactory::createByUser($user);
|
$factory = DateTimeFactory::createByUser($user);
|
||||||
|
|
||||||
|
if ($options['with_presets']) {
|
||||||
$ranges = [
|
$ranges = [
|
||||||
'daterangepicker.allTime' => [null, null],
|
'daterangepicker.allTime' => [null, null],
|
||||||
'daterangepicker.today' => [$factory->createDateTime('00:00:00'), $factory->createDateTime('23:59:59')],
|
'daterangepicker.today' => [$factory->createDateTime('00:00:00'), $factory->createDateTime('23:59:59')],
|
||||||
@@ -80,6 +82,7 @@ final class DateRangeType extends AbstractType
|
|||||||
|
|
||||||
$view->vars['ranges'] = $ranges;
|
$view->vars['ranges'] = $ranges;
|
||||||
$view->vars['rangeFormat'] = $options['format'];
|
$view->vars['rangeFormat'] = $options['format'];
|
||||||
|
}
|
||||||
|
|
||||||
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
||||||
'data-separator' => $options['separator'],
|
'data-separator' => $options['separator'],
|
||||||
|
|||||||
@@ -32,17 +32,17 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
|||||||
return $this->formatter;
|
return $this->formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormattedDateTime(\DateTime $date): string
|
public function getFormattedDateTime(\DateTimeInterface $date): string
|
||||||
{
|
{
|
||||||
return (string) $this->getFormatter()->dateShort($date);
|
return (string) $this->getFormatter()->dateShort($date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormattedTime(\DateTime $date): string
|
public function getFormattedTime(\DateTimeInterface $date): string
|
||||||
{
|
{
|
||||||
return (string) $this->getFormatter()->time($date);
|
return (string) $this->getFormatter()->time($date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormattedMonthName(\DateTime $date): string
|
public function getFormattedMonthName(\DateTimeInterface $date): string
|
||||||
{
|
{
|
||||||
return $this->getFormatter()->monthName($date);
|
return $this->getFormatter()->monthName($date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ final class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
|
|||||||
$query = $model->getQuery();
|
$query = $model->getQuery();
|
||||||
if ($query !== null) {
|
if ($query !== null) {
|
||||||
$begin = $query->getBegin();
|
$begin = $query->getBegin();
|
||||||
$end = $query->getEnd();
|
|
||||||
|
|
||||||
if ($begin !== null) {
|
if ($begin !== null) {
|
||||||
$values = array_merge($values, [
|
$values = array_merge($values, [
|
||||||
'query.day' => $begin->format('d'),
|
'query.day' => $begin->format('d'),
|
||||||
@@ -88,6 +86,12 @@ final class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
|
|||||||
'query.begin_month' => $formatter->getFormattedMonthName($begin),
|
'query.begin_month' => $formatter->getFormattedMonthName($begin),
|
||||||
'query.begin_month_number' => $begin->format('m'),
|
'query.begin_month_number' => $begin->format('m'),
|
||||||
'query.begin_year' => $begin->format('Y'),
|
'query.begin_year' => $begin->format('Y'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$end = $query->getEnd();
|
||||||
|
if ($end !== null) {
|
||||||
|
$values = array_merge($values, [
|
||||||
'query.end' => $formatter->getFormattedDateTime($end),
|
'query.end' => $formatter->getFormattedDateTime($end),
|
||||||
// since 1.9
|
// since 1.9
|
||||||
'query.end_day' => $end->format('d'),
|
'query.end_day' => $end->format('d'),
|
||||||
@@ -97,7 +101,6 @@ final class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
|
|||||||
'query.end_month_number' => $end->format('m'),
|
'query.end_month_number' => $end->format('m'),
|
||||||
// since 1.9
|
// since 1.9
|
||||||
'query.end_year' => $end->format('Y'),
|
'query.end_year' => $end->format('Y'),
|
||||||
// since 1.9
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Invoice;
|
namespace App\Invoice;
|
||||||
|
|
||||||
use DateTime;
|
use DateTimeInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal this is subject to change
|
* @internal this is subject to change
|
||||||
@@ -20,15 +20,15 @@ interface InvoiceFormatter
|
|||||||
|
|
||||||
public function setLocale(string $locale): void;
|
public function setLocale(string $locale): void;
|
||||||
|
|
||||||
public function getFormattedDateTime(DateTime $date): string;
|
public function getFormattedDateTime(DateTimeInterface $date): string;
|
||||||
|
|
||||||
public function getFormattedTime(DateTime $date): string;
|
public function getFormattedTime(DateTimeInterface $date): string;
|
||||||
|
|
||||||
public function getFormattedAmount(float $amount): string;
|
public function getFormattedAmount(float $amount): string;
|
||||||
|
|
||||||
public function getFormattedMoney(float $amount, ?string $currency, bool $withCurrency = true): string;
|
public function getFormattedMoney(float $amount, ?string $currency, bool $withCurrency = true): string;
|
||||||
|
|
||||||
public function getFormattedMonthName(DateTime $date): string;
|
public function getFormattedMonthName(DateTimeInterface $date): string;
|
||||||
|
|
||||||
public function getFormattedDuration(int $seconds): string;
|
public function getFormattedDuration(int $seconds): string;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ final class InvoiceModel
|
|||||||
private ?InvoiceTemplate $template = null;
|
private ?InvoiceTemplate $template = null;
|
||||||
private ?CalculatorInterface $calculator = null;
|
private ?CalculatorInterface $calculator = null;
|
||||||
private ?NumberGeneratorInterface $generator = null;
|
private ?NumberGeneratorInterface $generator = null;
|
||||||
private \DateTime $invoiceDate;
|
private \DateTimeInterface $invoiceDate;
|
||||||
private ?User $user = null;
|
private ?User $user = null;
|
||||||
private InvoiceFormatter $formatter;
|
private InvoiceFormatter $formatter;
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +58,7 @@ final class InvoiceModel
|
|||||||
*/
|
*/
|
||||||
public function __construct(InvoiceFormatter $formatter, CustomerStatisticService $customerStatistic, ProjectStatisticService $projectStatistic, ActivityStatisticService $activityStatistic)
|
public function __construct(InvoiceFormatter $formatter, CustomerStatisticService $customerStatistic, ProjectStatisticService $projectStatistic, ActivityStatisticService $activityStatistic)
|
||||||
{
|
{
|
||||||
$this->invoiceDate = new \DateTime();
|
$this->invoiceDate = new \DateTimeImmutable();
|
||||||
$this->formatter = $formatter;
|
$this->formatter = $formatter;
|
||||||
$this->addModelHydrator(new InvoiceModelDefaultHydrator());
|
$this->addModelHydrator(new InvoiceModelDefaultHydrator());
|
||||||
$this->addModelHydrator(new InvoiceModelCustomerHydrator($customerStatistic));
|
$this->addModelHydrator(new InvoiceModelCustomerHydrator($customerStatistic));
|
||||||
@@ -73,11 +73,9 @@ final class InvoiceModel
|
|||||||
return $this->query;
|
return $this->query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setQuery(InvoiceQuery $query): InvoiceModel
|
public function setQuery(InvoiceQuery $query): void
|
||||||
{
|
{
|
||||||
$this->query = $query;
|
$this->query = $query;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,11 +122,9 @@ final class InvoiceModel
|
|||||||
return $this->template;
|
return $this->template;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTemplate(InvoiceTemplate $template): InvoiceModel
|
public function setTemplate(InvoiceTemplate $template): void
|
||||||
{
|
{
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCustomer(): ?Customer
|
public function getCustomer(): ?Customer
|
||||||
@@ -136,32 +132,34 @@ final class InvoiceModel
|
|||||||
return $this->customer;
|
return $this->customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCustomer(?Customer $customer): InvoiceModel
|
public function setCustomer(Customer $customer): void
|
||||||
{
|
{
|
||||||
$this->customer = $customer;
|
$this->customer = $customer;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDueDate(): ?\DateTime
|
/**
|
||||||
|
* Requires the template and invoice date to be set
|
||||||
|
*/
|
||||||
|
public function getDueDate(): \DateTimeInterface
|
||||||
{
|
{
|
||||||
if (null === $this->getTemplate()) {
|
$date = \DateTimeImmutable::createFromInterface($this->getInvoiceDate());
|
||||||
return null;
|
|
||||||
|
$dueDays = 14;
|
||||||
|
if ($this->getTemplate() !== null) {
|
||||||
|
$dueDays = $this->getTemplate()->getDueDays();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new \DateTime('+' . $this->getTemplate()->getDueDays() . ' days');
|
return $date->add(new \DateInterval('P' . $dueDays . 'D'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoiceDate(): \DateTime
|
public function getInvoiceDate(): \DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->invoiceDate;
|
return $this->invoiceDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setInvoiceDate(\DateTime $date): InvoiceModel
|
public function setInvoiceDate(\DateTimeInterface $date): void
|
||||||
{
|
{
|
||||||
$this->invoiceDate = $date;
|
$this->invoiceDate = $date;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoiceNumber(): string
|
public function getInvoiceNumber(): string
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ namespace App\Invoice;
|
|||||||
|
|
||||||
use App\Activity\ActivityStatisticService;
|
use App\Activity\ActivityStatisticService;
|
||||||
use App\Customer\CustomerStatisticService;
|
use App\Customer\CustomerStatisticService;
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Project\ProjectStatisticService;
|
use App\Project\ProjectStatisticService;
|
||||||
|
use App\Repository\Query\InvoiceQuery;
|
||||||
|
|
||||||
final class InvoiceModelFactory
|
final class InvoiceModelFactory
|
||||||
{
|
{
|
||||||
@@ -22,8 +25,14 @@ final class InvoiceModelFactory
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createModel(InvoiceFormatter $formatter): InvoiceModel
|
public function createModel(InvoiceFormatter $formatter, Customer $customer, InvoiceTemplate $template, InvoiceQuery $query): InvoiceModel
|
||||||
{
|
{
|
||||||
return new InvoiceModel($formatter, $this->customerStatisticService, $this->projectStatisticService, $this->activityStatisticService);
|
$model = new InvoiceModel($formatter, $this->customerStatisticService, $this->projectStatisticService, $this->activityStatisticService);
|
||||||
|
|
||||||
|
$model->setCustomer($customer);
|
||||||
|
$model->setTemplate($template);
|
||||||
|
$model->setQuery($query);
|
||||||
|
|
||||||
|
return $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,12 +410,12 @@ final class ServiceInvoice
|
|||||||
|
|
||||||
$formatter = new DefaultInvoiceFormatter($this->formatter, $template->getLanguage());
|
$formatter = new DefaultInvoiceFormatter($this->formatter, $template->getLanguage());
|
||||||
|
|
||||||
$model = $this->invoiceModelFactory->createModel($formatter);
|
$model = $this->invoiceModelFactory->createModel(
|
||||||
$model
|
$formatter,
|
||||||
->setCustomer($customer)
|
$customer,
|
||||||
->setTemplate($template)
|
$template,
|
||||||
->setQuery($query)
|
$query
|
||||||
;
|
);
|
||||||
|
|
||||||
if ($query->getInvoiceDate() !== null) {
|
if ($query->getInvoiceDate() !== null) {
|
||||||
$model->setInvoiceDate($query->getInvoiceDate());
|
$model->setInvoiceDate($query->getInvoiceDate());
|
||||||
|
|||||||
@@ -128,8 +128,14 @@ final class MPdfConverter implements HtmlToPdfConverter
|
|||||||
$defaultFontConfig = (new FontVariables())->getDefaults();
|
$defaultFontConfig = (new FontVariables())->getDefaults();
|
||||||
$fontData = $defaultFontConfig['fontdata'];
|
$fontData = $defaultFontConfig['fontdata'];
|
||||||
|
|
||||||
|
// lowercase all font names, otherwise they cannot be loaded
|
||||||
|
// see https://github.com/kimai/www.kimai.org/issues/280
|
||||||
if (\array_key_exists('fonts', $options)) {
|
if (\array_key_exists('fonts', $options)) {
|
||||||
$fontData = array_merge($fontData, $options['fonts']);
|
$fonts = [];
|
||||||
|
foreach ($options['fonts'] as $name => $values) {
|
||||||
|
$fonts[strtolower($name)] = $values;
|
||||||
|
}
|
||||||
|
$fontData = array_merge($fontData, $fonts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fontData;
|
return $fontData;
|
||||||
|
|||||||
@@ -91,24 +91,27 @@ class InvoiceRepository extends EntityRepository
|
|||||||
return $result['counter'];
|
return $result['counter'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCounterForDay(\DateTime $date, ?Customer $customer = null, ?User $user = null): int
|
public function getCounterForDay(\DateTimeInterface $date, ?Customer $customer = null, ?User $user = null): int
|
||||||
{
|
{
|
||||||
|
$date = \DateTime::createFromInterface($date);
|
||||||
$start = (clone $date)->setTime(0, 0, 0);
|
$start = (clone $date)->setTime(0, 0, 0);
|
||||||
$end = (clone $date)->setTime(23, 59, 59);
|
$end = (clone $date)->setTime(23, 59, 59);
|
||||||
|
|
||||||
return $this->getCounterFor($start, $end, $customer, $user);
|
return $this->getCounterFor($start, $end, $customer, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCounterForMonth(\DateTime $date, ?Customer $customer = null, ?User $user = null): int
|
public function getCounterForMonth(\DateTimeInterface $date, ?Customer $customer = null, ?User $user = null): int
|
||||||
{
|
{
|
||||||
|
$date = \DateTime::createFromInterface($date);
|
||||||
$start = (clone $date)->setDate((int) $date->format('Y'), (int) $date->format('n'), 1)->setTime(0, 0, 0);
|
$start = (clone $date)->setDate((int) $date->format('Y'), (int) $date->format('n'), 1)->setTime(0, 0, 0);
|
||||||
$end = (clone $date)->setDate((int) $date->format('Y'), (int) $date->format('n'), (int) $date->format('t'))->setTime(23, 59, 59);
|
$end = (clone $date)->setDate((int) $date->format('Y'), (int) $date->format('n'), (int) $date->format('t'))->setTime(23, 59, 59);
|
||||||
|
|
||||||
return $this->getCounterFor($start, $end, $customer, $user);
|
return $this->getCounterFor($start, $end, $customer, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCounterForYear(\DateTime $date, ?Customer $customer = null, ?User $user = null): int
|
public function getCounterForYear(\DateTimeInterface $date, ?Customer $customer = null, ?User $user = null): int
|
||||||
{
|
{
|
||||||
|
$date = \DateTime::createFromInterface($date);
|
||||||
$start = (clone $date)->setDate((int) $date->format('Y'), 1, 1)->setTime(0, 0, 0);
|
$start = (clone $date)->setDate((int) $date->format('Y'), 1, 1)->setTime(0, 0, 0);
|
||||||
$end = (clone $date)->setDate((int) $date->format('Y'), 12, 31)->setTime(23, 59, 59);
|
$end = (clone $date)->setDate((int) $date->format('Y'), 12, 31)->setTime(23, 59, 59);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
{% form_theme form 'form/horizontal.html.twig' %}
|
{% form_theme form 'form/horizontal.html.twig' %}
|
||||||
|
|
||||||
|
{{ form_row(form._token) }}
|
||||||
|
|
||||||
<fieldset class="form-fieldset">
|
<fieldset class="form-fieldset">
|
||||||
<legend>{{ 'work_times_should'|trans }}</legend>
|
<legend>{{ 'work_times_should'|trans }}</legend>
|
||||||
<div class="form-text mb-3 help-text">{{ 'work_times_should.help'|trans }}</div>
|
<div class="form-text mb-3 help-text">{{ 'work_times_should.help'|trans }}</div>
|
||||||
@@ -17,7 +19,7 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="form-fieldset">
|
<fieldset class="form-fieldset">
|
||||||
{{ form_rest(form) }}
|
{{- form_rest(form) -}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class ConfigurationTest extends TestCase
|
|||||||
'allow_overbooking_budget' => true,
|
'allow_overbooking_budget' => true,
|
||||||
'lockdown_period_timezone' => null,
|
'lockdown_period_timezone' => null,
|
||||||
'break_warning_duration' => 0,
|
'break_warning_duration' => 0,
|
||||||
'long_running_duration' => 600,
|
'long_running_duration' => 0,
|
||||||
'require_activity' => true,
|
'require_activity' => true,
|
||||||
],
|
],
|
||||||
'duration_increment' => 15,
|
'duration_increment' => 15,
|
||||||
|
|||||||
@@ -190,11 +190,8 @@ class InvoiceTest extends TestCase
|
|||||||
$query->setBegin(new \DateTime());
|
$query->setBegin(new \DateTime());
|
||||||
$query->setEnd(new \DateTime());
|
$query->setEnd(new \DateTime());
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
$model->setUser($user);
|
$model->setUser($user);
|
||||||
$model->setInvoiceDate($created);
|
$model->setInvoiceDate($created);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
|
|
||||||
namespace App\Tests\Event;
|
namespace App\Tests\Event;
|
||||||
|
|
||||||
|
use App\Entity\Customer;
|
||||||
use App\Entity\Invoice;
|
use App\Entity\Invoice;
|
||||||
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Event\InvoiceCreatedEvent;
|
use App\Event\InvoiceCreatedEvent;
|
||||||
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -23,7 +26,7 @@ class InvoiceCreatedEventTest extends TestCase
|
|||||||
public function testDefaultValues()
|
public function testDefaultValues()
|
||||||
{
|
{
|
||||||
$invoice = new Invoice();
|
$invoice = new Invoice();
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||||
|
|
||||||
$sut = new InvoiceCreatedEvent($invoice, $model);
|
$sut = new InvoiceCreatedEvent($invoice, $model);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
|
|
||||||
namespace App\Tests\Event;
|
namespace App\Tests\Event;
|
||||||
|
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Event\InvoicePostRenderEvent;
|
use App\Event\InvoicePostRenderEvent;
|
||||||
use App\Model\InvoiceDocument;
|
use App\Model\InvoiceDocument;
|
||||||
|
use App\Repository\Query\InvoiceQuery;
|
||||||
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 App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
@@ -24,7 +27,7 @@ class InvoicePostRenderEventTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testDefaultValues()
|
public function testDefaultValues()
|
||||||
{
|
{
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||||
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
||||||
$renderer = new DebugRenderer();
|
$renderer = new DebugRenderer();
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
|
|
||||||
namespace App\Tests\Event;
|
namespace App\Tests\Event;
|
||||||
|
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Event\InvoicePreRenderEvent;
|
use App\Event\InvoicePreRenderEvent;
|
||||||
use App\Model\InvoiceDocument;
|
use App\Model\InvoiceDocument;
|
||||||
|
use App\Repository\Query\InvoiceQuery;
|
||||||
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 App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
@@ -23,7 +26,7 @@ class InvoicePreRenderEventTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testDefaultValues()
|
public function testDefaultValues()
|
||||||
{
|
{
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||||
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
$document = new InvoiceDocument(new \SplFileInfo(__FILE__));
|
||||||
$renderer = new DebugRenderer();
|
$renderer = new DebugRenderer();
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class PageActionsEventTest extends TestCase
|
|||||||
'create' => ['url' => 'foo5', 'class' => 'modal-ajax-form', 'title' => 'create', 'accesskey' => 'a'],
|
'create' => ['url' => 'foo5', 'class' => 'modal-ajax-form', 'title' => 'create', 'accesskey' => 'a'],
|
||||||
'download' => ['url' => 'foo7', 'class' => 'toolbar-action', 'title' => 'export'],
|
'download' => ['url' => 'foo7', 'class' => 'toolbar-action', 'title' => 'export'],
|
||||||
'edit' => ['url' => 'trölölö', 'class' => 'modal-ajax-form', 'translation_domain' => 'actions', 'title' => 'edit'],
|
'edit' => ['url' => 'trölölö', 'class' => 'modal-ajax-form', 'translation_domain' => 'actions', 'title' => 'edit'],
|
||||||
'trash' => ['url' => 'foo3', 'class' => 'modal-ajax-form text-red', 'translation_domain' => 'actions'],
|
'trash' => ['url' => 'foo3', 'class' => 'modal-ajax-form text-red', 'translation_domain' => 'actions', 'title' => 'trash'],
|
||||||
];
|
];
|
||||||
$this->assertEquals(\count($expected), $sut->countActions());
|
$this->assertEquals(\count($expected), $sut->countActions());
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,7 @@ abstract class AbstractCalculatorTest extends TestCase
|
|||||||
$template = new InvoiceTemplate();
|
$template = new InvoiceTemplate();
|
||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
return (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
return $model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertDescription(CalculatorInterface $sut, $addProject = false, $addActivity = false): void
|
protected function assertDescription(CalculatorInterface $sut, $addProject = false, $addActivity = false): void
|
||||||
@@ -100,11 +95,8 @@ abstract class AbstractCalculatorTest extends TestCase
|
|||||||
->setActivity($activity)
|
->setActivity($activity)
|
||||||
->setProject($project);
|
->setProject($project);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries([$timesheet]);
|
$model->addEntries([$timesheet]);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
$this->assertEquals(1, \count($sut->getEntries()));
|
$this->assertEquals(1, \count($sut->getEntries()));
|
||||||
|
|||||||
@@ -135,11 +135,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->addActivity($activity1);
|
$query->addActivity($activity1);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -148,11 +148,8 @@ class ActivityUserInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->addActivity($activity1);
|
$query->addActivity($activity1);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -108,11 +108,8 @@ class DateInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -111,11 +111,8 @@ class DateUserInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -64,11 +64,8 @@ class DefaultCalculatorTest extends AbstractCalculatorTest
|
|||||||
|
|
||||||
$entries = [$timesheet, $timesheet2, $timesheet3];
|
$entries = [$timesheet, $timesheet2, $timesheet3];
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, new InvoiceQuery());
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery(new InvoiceQuery());
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -112,11 +112,8 @@ class PriceInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -108,11 +108,8 @@ class ProjectInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -111,11 +111,8 @@ class ProjectUserInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -92,11 +92,8 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->addActivity($activity);
|
$query->addActivity($activity);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
@@ -174,11 +171,8 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->addActivity($activity);
|
$query->addActivity($activity);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
@@ -253,11 +247,8 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->addActivity($activity);
|
$query->addActivity($activity);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -106,11 +106,8 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->addActivity($activity);
|
$query->addActivity($activity);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -111,11 +111,8 @@ class WeeklyInvoiceCalculatorTest extends AbstractCalculatorTest
|
|||||||
$query = new InvoiceQuery();
|
$query = new InvoiceQuery();
|
||||||
$query->setProjects([$project1]);
|
$query->setProjects([$project1]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$sut = $this->getCalculator();
|
$sut = $this->getCalculator();
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ use App\Invoice\InvoiceFormatter;
|
|||||||
|
|
||||||
class DebugFormatter implements InvoiceFormatter
|
class DebugFormatter implements InvoiceFormatter
|
||||||
{
|
{
|
||||||
public function getFormattedDateTime(\DateTime $date): string
|
public function getFormattedDateTime(\DateTimeInterface $date): string
|
||||||
{
|
{
|
||||||
return $date->format('d.m.Y');
|
return $date->format('d.m.Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormattedTime(\DateTime $date): string
|
public function getFormattedTime(\DateTimeInterface $date): string
|
||||||
{
|
{
|
||||||
return $date->format('H:i');
|
return $date->format('H:i');
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class DebugFormatter implements InvoiceFormatter
|
|||||||
return (string) $amount;
|
return (string) $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormattedMonthName(\DateTime $date): string
|
public function getFormattedMonthName(\DateTimeInterface $date): string
|
||||||
{
|
{
|
||||||
return $date->format('m');
|
return $date->format('m');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class InvoiceModelCustomerHydratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
use RendererTestTrait;
|
use RendererTestTrait;
|
||||||
|
|
||||||
public function testHydrate()
|
public function testHydrate(): void
|
||||||
{
|
{
|
||||||
$model = $this->getInvoiceModel();
|
$model = $this->getInvoiceModel();
|
||||||
|
|
||||||
@@ -30,12 +30,36 @@ class InvoiceModelCustomerHydratorTest extends TestCase
|
|||||||
$result = $sut->hydrate($model);
|
$result = $sut->hydrate($model);
|
||||||
$this->assertModelStructure($result);
|
$this->assertModelStructure($result);
|
||||||
|
|
||||||
$model->setCustomer(null);
|
|
||||||
$result = $sut->hydrate($model);
|
$result = $sut->hydrate($model);
|
||||||
self::assertEmpty($result);
|
|
||||||
|
$this->assertModelStructure($result);
|
||||||
|
|
||||||
|
self::assertEquals([
|
||||||
|
'customer.id' => null,
|
||||||
|
'customer.address' => "Foo\nStreet\n1111 City",
|
||||||
|
'customer.name' => 'customer,with/special#name',
|
||||||
|
'customer.contact' => '',
|
||||||
|
'customer.company' => '',
|
||||||
|
'customer.vat' => '',
|
||||||
|
'customer.vat_id' => '',
|
||||||
|
'customer.number' => '',
|
||||||
|
'customer.country' => null,
|
||||||
|
'customer.homepage' => '',
|
||||||
|
'customer.comment' => '',
|
||||||
|
'customer.email' => '',
|
||||||
|
'customer.fax' => '',
|
||||||
|
'customer.phone' => '',
|
||||||
|
'customer.mobile' => '',
|
||||||
|
'customer.invoice_text' => '',
|
||||||
|
'customer.budget_open' => '€0.00',
|
||||||
|
'customer.budget_open_plain' => 0.0,
|
||||||
|
'customer.time_budget_open' => '0.00',
|
||||||
|
'customer.time_budget_open_plain' => 0,
|
||||||
|
'customer.meta.foo-customer' => 'bar-customer',
|
||||||
|
], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertModelStructure(array $model)
|
protected function assertModelStructure(array $model): void
|
||||||
{
|
{
|
||||||
$keys = [
|
$keys = [
|
||||||
'customer.id',
|
'customer.id',
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class InvoiceModelDefaultHydratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
use RendererTestTrait;
|
use RendererTestTrait;
|
||||||
|
|
||||||
public function testHydrate()
|
public function testHydrate(): void
|
||||||
{
|
{
|
||||||
$model = $this->getInvoiceModel();
|
$model = $this->getInvoiceModel();
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ class InvoiceModelDefaultHydratorTest extends TestCase
|
|||||||
$this->assertModelStructure($result);
|
$this->assertModelStructure($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertModelStructure(array $model, $hasProject = true)
|
protected function assertModelStructure(array $model, bool $hasProject = true): void
|
||||||
{
|
{
|
||||||
$keys = [
|
$keys = [
|
||||||
'invoice.due_date',
|
'invoice.due_date',
|
||||||
|
|||||||
@@ -29,39 +29,35 @@ class InvoiceFilenameTest extends TestCase
|
|||||||
{
|
{
|
||||||
$customer = new Customer('foo');
|
$customer = new Customer('foo');
|
||||||
$template = new InvoiceTemplate();
|
$template = new InvoiceTemplate();
|
||||||
|
$query = new InvoiceQuery();
|
||||||
|
$project = new Project();
|
||||||
|
$project->setName('Demo ProjecT1');
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$query->addProject($project);
|
||||||
|
|
||||||
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
$model->setNumberGenerator($this->getNumberGeneratorSut());
|
$model->setNumberGenerator($this->getNumberGeneratorSut());
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->setCustomer($customer);
|
|
||||||
|
|
||||||
$datePrefix = date('ymd');
|
$datePrefix = date('ymd');
|
||||||
|
|
||||||
$sut = new InvoiceFilename($model);
|
$sut = new InvoiceFilename($model);
|
||||||
|
|
||||||
self::assertEquals($datePrefix . '-foo', $sut->getFilename());
|
self::assertEquals($datePrefix . '-foo-Demo_ProjecT1', $sut->getFilename());
|
||||||
self::assertEquals($datePrefix . '-foo', (string) $sut);
|
self::assertEquals($datePrefix . '-foo-Demo_ProjecT1', (string) $sut);
|
||||||
|
|
||||||
$customer->setCompany('barß / laölala # ldksjf 123 MyAwesome GmbH');
|
$customer->setCompany('barß / laölala # ldksjf 123 MyAwesome GmbH');
|
||||||
$sut = new InvoiceFilename($model);
|
$sut = new InvoiceFilename($model);
|
||||||
|
|
||||||
self::assertEquals($datePrefix . '-barss_laolala_ldksjf_123_MyAwesome_GmbH', $sut->getFilename());
|
self::assertEquals($datePrefix . '-barss_laolala_ldksjf_123_MyAwesome_GmbH-Demo_ProjecT1', $sut->getFilename());
|
||||||
self::assertEquals($datePrefix . '-barss_laolala_ldksjf_123_MyAwesome_GmbH', (string) $sut);
|
self::assertEquals($datePrefix . '-barss_laolala_ldksjf_123_MyAwesome_GmbH-Demo_ProjecT1', (string) $sut);
|
||||||
|
|
||||||
$customer->setCompany('까깨꺄꺠꺼께껴꼐꼬꽈sssss');
|
$customer->setCompany('까깨꺄꺠꺼께껴꼐꼬꽈sssss');
|
||||||
$sut = new InvoiceFilename($model);
|
$sut = new InvoiceFilename($model);
|
||||||
self::assertEquals($datePrefix . '-kkakkaekkyakkyaekkeokkekkyeokkyekkokkwasssss', $sut->getFilename());
|
self::assertEquals($datePrefix . '-kkakkaekkyakkyaekkeokkekkyeokkyekkokkwasssss-Demo_ProjecT1', $sut->getFilename());
|
||||||
|
|
||||||
$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_--Demo_ProjecT1', $sut->getFilename());
|
||||||
|
|
||||||
$project = new Project();
|
|
||||||
$project->setName('Demo ProjecT1');
|
|
||||||
|
|
||||||
$query = new InvoiceQuery();
|
|
||||||
$query->addProject($project);
|
|
||||||
$model->setQuery($query);
|
|
||||||
|
|
||||||
$customer->setCompany('\"#+ß.!$%&/()=?\\n=/*-+´_<>@' . "\n");
|
$customer->setCompany('\"#+ß.!$%&/()=?\\n=/*-+´_<>@' . "\n");
|
||||||
$sut = new InvoiceFilename($model);
|
$sut = new InvoiceFilename($model);
|
||||||
|
|||||||
@@ -23,21 +23,19 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class InvoiceModelTest extends TestCase
|
class InvoiceModelTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testEmptyObject()
|
public function testEmptyObject(): void
|
||||||
{
|
{
|
||||||
$formatter = new DebugFormatter();
|
$formatter = new DebugFormatter();
|
||||||
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel($formatter);
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel($formatter, new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||||
|
|
||||||
|
self::assertNotNull($sut->getQuery());
|
||||||
|
self::assertNotNull($sut->getCustomer());
|
||||||
|
self::assertNotNull($sut->getTemplate());
|
||||||
|
|
||||||
self::assertNull($sut->getQuery());
|
|
||||||
self::assertNull($sut->getCustomer());
|
|
||||||
self::assertNull($sut->getDueDate());
|
|
||||||
self::assertNull($sut->getCalculator());
|
self::assertNull($sut->getCalculator());
|
||||||
|
|
||||||
self::assertEmpty($sut->getEntries());
|
self::assertEmpty($sut->getEntries());
|
||||||
self::assertIsArray($sut->getEntries());
|
self::assertIsArray($sut->getEntries());
|
||||||
|
self::assertInstanceOf(\DateTimeInterface::class, $sut->getInvoiceDate());
|
||||||
self::assertNull($sut->getTemplate());
|
|
||||||
self::assertInstanceOf(\DateTime::class, $sut->getInvoiceDate());
|
|
||||||
|
|
||||||
self::assertSame($formatter, $sut->getFormatter());
|
self::assertSame($formatter, $sut->getFormatter());
|
||||||
|
|
||||||
@@ -47,27 +45,24 @@ class InvoiceModelTest extends TestCase
|
|||||||
self::assertSame($newFormatter, $sut->getFormatter());
|
self::assertSame($newFormatter, $sut->getFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyObjectThrowsExceptionOnNumberGenerator()
|
public function testEmptyObjectThrowsExceptionOnNumberGenerator(): void
|
||||||
{
|
{
|
||||||
$formatter = new DebugFormatter();
|
$formatter = new DebugFormatter();
|
||||||
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel($formatter);
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel($formatter, new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||||
|
|
||||||
$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()');
|
||||||
$sut->getInvoiceNumber();
|
$sut->getInvoiceNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetter()
|
public function testSetter(): void
|
||||||
{
|
{
|
||||||
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
|
||||||
|
|
||||||
$query = new InvoiceQuery();
|
|
||||||
self::assertInstanceOf(InvoiceModel::class, $sut->setQuery($query));
|
|
||||||
self::assertSame($query, $sut->getQuery());
|
|
||||||
|
|
||||||
$customer = new Customer('foo');
|
$customer = new Customer('foo');
|
||||||
self::assertInstanceOf(InvoiceModel::class, $sut->setCustomer($customer));
|
$query = new InvoiceQuery();
|
||||||
self::assertSame($customer, $sut->getCustomer());
|
$template = new InvoiceTemplate();
|
||||||
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
|
|
||||||
|
self::assertSame($query, $sut->getQuery());
|
||||||
|
|
||||||
$calculator = new DefaultCalculator();
|
$calculator = new DefaultCalculator();
|
||||||
self::assertInstanceOf(InvoiceModel::class, $sut->setCalculator($calculator));
|
self::assertInstanceOf(InvoiceModel::class, $sut->setCalculator($calculator));
|
||||||
@@ -78,11 +73,28 @@ class InvoiceModelTest extends TestCase
|
|||||||
$number = $sut->getInvoiceNumber();
|
$number = $sut->getInvoiceNumber();
|
||||||
self::assertEquals($number, $sut->getInvoiceNumber());
|
self::assertEquals($number, $sut->getInvoiceNumber());
|
||||||
|
|
||||||
$template = new InvoiceTemplate();
|
|
||||||
self::assertNull($sut->getDueDate());
|
|
||||||
self::assertInstanceOf(InvoiceModel::class, $sut->setTemplate($template));
|
|
||||||
self::assertSame($template, $sut->getTemplate());
|
self::assertSame($template, $sut->getTemplate());
|
||||||
/* @phpstan-ignore-next-line */
|
self::assertInstanceOf(\DateTimeInterface::class, $sut->getDueDate());
|
||||||
self::assertInstanceOf(\DateTime::class, $sut->getDueDate());
|
}
|
||||||
|
|
||||||
|
public function testDueDate(): void
|
||||||
|
{
|
||||||
|
$customer = new Customer('foo');
|
||||||
|
$query = new InvoiceQuery();
|
||||||
|
$template = new InvoiceTemplate();
|
||||||
|
$sut = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, $template, $query);
|
||||||
|
|
||||||
|
$dueDate = $sut->getDueDate();
|
||||||
|
$dueDays = $template->getDueDays();
|
||||||
|
self::assertNotNull($dueDays);
|
||||||
|
$expected = new \DateTimeImmutable('+' . $dueDays . ' days');
|
||||||
|
|
||||||
|
self::assertEquals($expected->format('Y-m-d'), $dueDate->format('Y-m-d'));
|
||||||
|
|
||||||
|
$sut->setInvoiceDate(new \DateTimeImmutable('2022-05-23'));
|
||||||
|
$template->setDueDays(14);
|
||||||
|
$dueDate = $sut->getDueDate();
|
||||||
|
$expected = new \DateTimeImmutable('2022-06-06');
|
||||||
|
self::assertEquals($expected->format('Y-m-d'), $dueDate->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,11 @@
|
|||||||
namespace App\Tests\Invoice\NumberGenerator;
|
namespace App\Tests\Invoice\NumberGenerator;
|
||||||
|
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\InvoiceTemplate;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Invoice\NumberGenerator\ConfigurableNumberGenerator;
|
use App\Invoice\NumberGenerator\ConfigurableNumberGenerator;
|
||||||
use App\Repository\InvoiceRepository;
|
use App\Repository\InvoiceRepository;
|
||||||
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use App\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use App\Tests\Mocks\SystemConfigurationFactory;
|
use App\Tests\Mocks\SystemConfigurationFactory;
|
||||||
@@ -156,9 +158,8 @@ 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 InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, new InvoiceTemplate(), new InvoiceQuery());
|
||||||
$model->setInvoiceDate($invoiceDate);
|
$model->setInvoiceDate($invoiceDate);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setUser($user);
|
$model->setUser($user);
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|
||||||
@@ -200,9 +201,8 @@ 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 InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||||
$model->setInvoiceDate($invoiceDate);
|
$model->setInvoiceDate($invoiceDate);
|
||||||
$model->setCustomer(new Customer('foo'));
|
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|
||||||
$sut->getInvoiceNumber();
|
$sut->getInvoiceNumber();
|
||||||
@@ -235,9 +235,8 @@ class ConfigurableNumberGeneratorTest extends TestCase
|
|||||||
$customer->setName(null);
|
$customer->setName(null);
|
||||||
|
|
||||||
$sut = $this->getSut($format);
|
$sut = $this->getSut($format);
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), $customer, new InvoiceTemplate(), new InvoiceQuery());
|
||||||
$model->setInvoiceDate(new \DateTime());
|
$model->setInvoiceDate(new \DateTime());
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setUser($user);
|
$model->setUser($user);
|
||||||
$sut->setModel($model);
|
$sut->setModel($model);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
|
|
||||||
namespace App\Tests\Invoice\NumberGenerator;
|
namespace App\Tests\Invoice\NumberGenerator;
|
||||||
|
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\InvoiceTemplate;
|
||||||
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\Tests\Invoice\DebugFormatter;
|
use App\Tests\Invoice\DebugFormatter;
|
||||||
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
use App\Tests\Mocks\InvoiceModelFactoryFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -40,7 +43,7 @@ class DateNumberGeneratorTest extends TestCase
|
|||||||
public function testGetInvoiceNumber()
|
public function testGetInvoiceNumber()
|
||||||
{
|
{
|
||||||
$sut = $this->getSut(false, false);
|
$sut = $this->getSut(false, false);
|
||||||
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter()));
|
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery()));
|
||||||
|
|
||||||
$this->assertEquals(date('ymd'), $sut->getInvoiceNumber());
|
$this->assertEquals(date('ymd'), $sut->getInvoiceNumber());
|
||||||
$this->assertEquals('date', $sut->getId());
|
$this->assertEquals('date', $sut->getId());
|
||||||
@@ -49,7 +52,7 @@ class DateNumberGeneratorTest extends TestCase
|
|||||||
public function testGetInvoiceNumberWithExisting()
|
public function testGetInvoiceNumberWithExisting()
|
||||||
{
|
{
|
||||||
$sut = $this->getSut(true, false);
|
$sut = $this->getSut(true, false);
|
||||||
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter()));
|
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery()));
|
||||||
|
|
||||||
$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 +61,7 @@ class DateNumberGeneratorTest extends TestCase
|
|||||||
public function testGetInvoiceNumberWithManyExisting()
|
public function testGetInvoiceNumberWithManyExisting()
|
||||||
{
|
{
|
||||||
$sut = $this->getSut(true, true);
|
$sut = $this->getSut(true, true);
|
||||||
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter()));
|
$sut->setModel((new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery()));
|
||||||
|
|
||||||
$this->assertEquals(date('ymd-99'), $sut->getInvoiceNumber());
|
$this->assertEquals(date('ymd-99'), $sut->getInvoiceNumber());
|
||||||
$this->assertEquals('date', $sut->getId());
|
$this->assertEquals('date', $sut->getId());
|
||||||
|
|||||||
@@ -238,11 +238,8 @@ trait RendererTestTrait
|
|||||||
$query->setEnd(new \DateTime());
|
$query->setEnd(new \DateTime());
|
||||||
$query->setProjects([$project, $project2]);
|
$query->setProjects([$project, $project2]);
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
$model->setUser($user);
|
$model->setUser($user);
|
||||||
|
|
||||||
$calculator = new DefaultCalculator();
|
$calculator = new DefaultCalculator();
|
||||||
@@ -326,11 +323,8 @@ trait RendererTestTrait
|
|||||||
$query->setBegin(new \DateTime());
|
$query->setBegin(new \DateTime());
|
||||||
$query->setEnd(new \DateTime());
|
$query->setEnd(new \DateTime());
|
||||||
|
|
||||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter());
|
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel($this->getFormatter(), $customer, $template, $query);
|
||||||
$model->setCustomer($customer);
|
|
||||||
$model->setTemplate($template);
|
|
||||||
$model->addEntries($entries);
|
$model->addEntries($entries);
|
||||||
$model->setQuery($query);
|
|
||||||
$model->setUser($user);
|
$model->setUser($user);
|
||||||
|
|
||||||
$calculator = new DefaultCalculator();
|
$calculator = new DefaultCalculator();
|
||||||
|
|||||||
@@ -6612,11 +6612,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: Invoice/Hydrator/InvoiceModelActivityHydratorTest.php
|
path: Invoice/Hydrator/InvoiceModelActivityHydratorTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelCustomerHydratorTest\\:\\:assertModelStructure\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/Hydrator/InvoiceModelCustomerHydratorTest.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelCustomerHydratorTest\\:\\:assertModelStructure\\(\\) has parameter \\$model with no value type specified in iterable type array\\.$#"
|
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelCustomerHydratorTest\\:\\:assertModelStructure\\(\\) has parameter \\$model with no value type specified in iterable type array\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@@ -6632,21 +6627,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: Invoice/Hydrator/InvoiceModelCustomerHydratorTest.php
|
path: Invoice/Hydrator/InvoiceModelCustomerHydratorTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelCustomerHydratorTest\\:\\:testHydrate\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/Hydrator/InvoiceModelCustomerHydratorTest.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelDefaultHydratorTest\\:\\:assertModelStructure\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelDefaultHydratorTest\\:\\:assertModelStructure\\(\\) has parameter \\$hasProject with no type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelDefaultHydratorTest\\:\\:assertModelStructure\\(\\) has parameter \\$model with no value type specified in iterable type array\\.$#"
|
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelDefaultHydratorTest\\:\\:assertModelStructure\\(\\) has parameter \\$model with no value type specified in iterable type array\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@@ -6662,11 +6642,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
|
path: Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelDefaultHydratorTest\\:\\:testHydrate\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/Hydrator/InvoiceModelDefaultHydratorTest.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelProjectHydratorTest\\:\\:assertModelStructure\\(\\) has no return type specified\\.$#"
|
message: "#^Method App\\\\Tests\\\\Invoice\\\\Hydrator\\\\InvoiceModelProjectHydratorTest\\:\\:assertModelStructure\\(\\) has no return type specified\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@@ -6722,21 +6697,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: Invoice/InvoiceItemTest.php
|
path: Invoice/InvoiceItemTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\InvoiceModelTest\\:\\:testEmptyObject\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/InvoiceModelTest.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\InvoiceModelTest\\:\\:testEmptyObjectThrowsExceptionOnNumberGenerator\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/InvoiceModelTest.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\InvoiceModelTest\\:\\:testSetter\\(\\) has no return type specified\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: Invoice/InvoiceModelTest.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method App\\\\Tests\\\\Invoice\\\\NumberGenerator\\\\DateNumberGeneratorTest\\:\\:getSut\\(\\) has no return type specified\\.$#"
|
message: "#^Method App\\\\Tests\\\\Invoice\\\\NumberGenerator\\\\DateNumberGeneratorTest\\:\\:getSut\\(\\) has no return type specified\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user