From e50011a5c373a9c98abd8dd6eb19f1a2c8e38218 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 5 Jul 2024 12:40:39 +0200 Subject: [PATCH] 1635: Cleaned up --- config/services.yaml | 1 - src/Controller/InvoiceEntryController.php | 1 - src/Service/InvoiceHelper.php | 2 +- src/Service/ProjectBillingService.php | 14 +++++++++----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/services.yaml b/config/services.yaml index f7a4f264e..6f45f6b20 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -61,7 +61,6 @@ services: $options: accounts: '%env(json:INVOICE_ENTRY_ACCOUNTS)%' one_invoice_per_issue: '%env(bool:INVOICE_ONE_INVOICE_PER_ISSUE)%' - set_invoice_description_from_entries: '%env(bool:SET_INVOICE_DESCRIPTION_FROM_ENTRIES)%' set_invoice_description_from_issue_description: '%env(bool:SET_INVOICE_DESCRIPTION_FROM_ISSUE_DESCRIPTION)%' invoice_description_issue_heading: '%env(INVOICE_DESCRIPTION_ISSUE_HEADING)%' invoice_description_element_replacements: '%env(json:INVOICE_DESCRIPTION_ELEMENT_REPLACEMENTS)%' diff --git a/src/Controller/InvoiceEntryController.php b/src/Controller/InvoiceEntryController.php index de2dc2aea..c087237cd 100644 --- a/src/Controller/InvoiceEntryController.php +++ b/src/Controller/InvoiceEntryController.php @@ -12,7 +12,6 @@ use App\Service\BillingService; use App\Service\ClientHelper; use App\Service\InvoiceHelper; -use App\Service\ViewService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Service/InvoiceHelper.php b/src/Service/InvoiceHelper.php index b39ee05e9..ea0a5c548 100644 --- a/src/Service/InvoiceHelper.php +++ b/src/Service/InvoiceHelper.php @@ -248,7 +248,7 @@ private function resolveOptions(array $options): array ->setAllowedTypes('invoice_issue_far_past_cutoff_date', ['null', 'string']) ->setAllowedValues('invoice_issue_far_past_cutoff_date', static function (?string $value) { try { - new \DateTimeImmutable($value); + new \DateTimeImmutable($value ?: '0000-00-00'); return true; } catch (Exception) { diff --git a/src/Service/ProjectBillingService.php b/src/Service/ProjectBillingService.php index 329b6eb11..2831d5338 100644 --- a/src/Service/ProjectBillingService.php +++ b/src/Service/ProjectBillingService.php @@ -39,15 +39,19 @@ public function __construct( public function getIssuesNotIncludedInProjectBillingFromTheFarPast(ProjectBilling $projectBilling): array { - $cutoffDate = $this->invoiceHelper->getIssueFarPastCutoffDate(); + $issues = null; - $projectBilling = clone $projectBilling; - $projectBilling->setPeriodStart(new \DateTimeImmutable('0001-01-01')); - $projectBilling->setPeriodEnd($cutoffDate); + if ($cutoffDate = $this->invoiceHelper->getIssueFarPastCutoffDate()) { + $projectBilling = clone $projectBilling; + $projectBilling->setPeriodStart(new \DateTimeImmutable('0001-01-01')); + $projectBilling->setPeriodEnd($cutoffDate); + + $issues = $this->getIssuesNotIncludedInProjectBilling($projectBilling); + } return [ 'cutoff_date' => $cutoffDate, - 'issues' => $this->getIssuesNotIncludedInProjectBilling($projectBilling), + 'issues' => $issues, ]; }