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:
@@ -32,17 +32,17 @@ final class DefaultInvoiceFormatter implements InvoiceFormatter
|
||||
return $this->formatter;
|
||||
}
|
||||
|
||||
public function getFormattedDateTime(\DateTime $date): string
|
||||
public function getFormattedDateTime(\DateTimeInterface $date): string
|
||||
{
|
||||
return (string) $this->getFormatter()->dateShort($date);
|
||||
}
|
||||
|
||||
public function getFormattedTime(\DateTime $date): string
|
||||
public function getFormattedTime(\DateTimeInterface $date): string
|
||||
{
|
||||
return (string) $this->getFormatter()->time($date);
|
||||
}
|
||||
|
||||
public function getFormattedMonthName(\DateTime $date): string
|
||||
public function getFormattedMonthName(\DateTimeInterface $date): string
|
||||
{
|
||||
return $this->getFormatter()->monthName($date);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,6 @@ final class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
|
||||
$query = $model->getQuery();
|
||||
if ($query !== null) {
|
||||
$begin = $query->getBegin();
|
||||
$end = $query->getEnd();
|
||||
|
||||
if ($begin !== null) {
|
||||
$values = array_merge($values, [
|
||||
'query.day' => $begin->format('d'),
|
||||
@@ -88,6 +86,12 @@ final class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
|
||||
'query.begin_month' => $formatter->getFormattedMonthName($begin),
|
||||
'query.begin_month_number' => $begin->format('m'),
|
||||
'query.begin_year' => $begin->format('Y'),
|
||||
]);
|
||||
}
|
||||
|
||||
$end = $query->getEnd();
|
||||
if ($end !== null) {
|
||||
$values = array_merge($values, [
|
||||
'query.end' => $formatter->getFormattedDateTime($end),
|
||||
// since 1.9
|
||||
'query.end_day' => $end->format('d'),
|
||||
@@ -97,7 +101,6 @@ final class InvoiceModelDefaultHydrator implements InvoiceModelHydrator
|
||||
'query.end_month_number' => $end->format('m'),
|
||||
// since 1.9
|
||||
'query.end_year' => $end->format('Y'),
|
||||
// since 1.9
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace App\Invoice;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
|
||||
/**
|
||||
* @internal this is subject to change
|
||||
@@ -20,15 +20,15 @@ interface InvoiceFormatter
|
||||
|
||||
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 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;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ final class InvoiceModel
|
||||
private ?InvoiceTemplate $template = null;
|
||||
private ?CalculatorInterface $calculator = null;
|
||||
private ?NumberGeneratorInterface $generator = null;
|
||||
private \DateTime $invoiceDate;
|
||||
private \DateTimeInterface $invoiceDate;
|
||||
private ?User $user = null;
|
||||
private InvoiceFormatter $formatter;
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ final class InvoiceModel
|
||||
*/
|
||||
public function __construct(InvoiceFormatter $formatter, CustomerStatisticService $customerStatistic, ProjectStatisticService $projectStatistic, ActivityStatisticService $activityStatistic)
|
||||
{
|
||||
$this->invoiceDate = new \DateTime();
|
||||
$this->invoiceDate = new \DateTimeImmutable();
|
||||
$this->formatter = $formatter;
|
||||
$this->addModelHydrator(new InvoiceModelDefaultHydrator());
|
||||
$this->addModelHydrator(new InvoiceModelCustomerHydrator($customerStatistic));
|
||||
@@ -73,11 +73,9 @@ final class InvoiceModel
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function setQuery(InvoiceQuery $query): InvoiceModel
|
||||
public function setQuery(InvoiceQuery $query): void
|
||||
{
|
||||
$this->query = $query;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,11 +122,9 @@ final class InvoiceModel
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
public function setTemplate(InvoiceTemplate $template): InvoiceModel
|
||||
public function setTemplate(InvoiceTemplate $template): void
|
||||
{
|
||||
$this->template = $template;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCustomer(): ?Customer
|
||||
@@ -136,32 +132,34 @@ final class InvoiceModel
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
public function setCustomer(?Customer $customer): InvoiceModel
|
||||
public function setCustomer(Customer $customer): void
|
||||
{
|
||||
$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()) {
|
||||
return null;
|
||||
$date = \DateTimeImmutable::createFromInterface($this->getInvoiceDate());
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
public function setInvoiceDate(\DateTime $date): InvoiceModel
|
||||
public function setInvoiceDate(\DateTimeInterface $date): void
|
||||
{
|
||||
$this->invoiceDate = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInvoiceNumber(): string
|
||||
|
||||
@@ -11,7 +11,10 @@ namespace App\Invoice;
|
||||
|
||||
use App\Activity\ActivityStatisticService;
|
||||
use App\Customer\CustomerStatisticService;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\InvoiceTemplate;
|
||||
use App\Project\ProjectStatisticService;
|
||||
use App\Repository\Query\InvoiceQuery;
|
||||
|
||||
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());
|
||||
|
||||
$model = $this->invoiceModelFactory->createModel($formatter);
|
||||
$model
|
||||
->setCustomer($customer)
|
||||
->setTemplate($template)
|
||||
->setQuery($query)
|
||||
;
|
||||
$model = $this->invoiceModelFactory->createModel(
|
||||
$formatter,
|
||||
$customer,
|
||||
$template,
|
||||
$query
|
||||
);
|
||||
|
||||
if ($query->getInvoiceDate() !== null) {
|
||||
$model->setInvoiceDate($query->getInvoiceDate());
|
||||
|
||||
Reference in New Issue
Block a user