Skip to content

Commit

Permalink
1635: Cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Jul 5, 2024
1 parent e33f84f commit db33c0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/Controller/InvoiceEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Service/InvoiceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 9 additions & 5 deletions src/Service/ProjectBillingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}

Expand Down

0 comments on commit db33c0c

Please sign in to comment.