From c3a28fc69814c4ada62ea4081915e011d0eb54f3 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 10 Aug 2025 07:31:10 +0200 Subject: [PATCH] Fix three years ago. --- app/Http/Controllers/Account/ShowController.php | 7 +++++-- .../JsonApi/Enrichments/SubscriptionEnrichment.php | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index ec1e1ab986..7471e1ebc1 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -119,8 +119,11 @@ class ShowController extends Controller $firstTransaction = $this->repository->oldestJournalDate($account) ?? $start; // go back max 3 years. - $threeYearsAgo = $start->subYears(3); - $firstTransaction = $firstTransaction->lt($threeYearsAgo) ? $threeYearsAgo : $firstTransaction; + $threeYearsAgo = clone $start; + $threeYearsAgo->startOfYear()->subYears(3); + if($firstTransaction->lt($threeYearsAgo)) { + $firstTransaction = clone $threeYearsAgo; + } Log::debug('Start period overview'); $timer = Timer::getInstance(); diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index e143208f54..d008c76a91 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -345,7 +345,7 @@ class SubscriptionEnrichment implements EnrichmentInterface private function getLastPaidDate(array $paidData): ?Carbon { - Log::debug('getLastPaidDate()'); + //Log::debug('getLastPaidDate()'); $return = null; foreach ($paidData as $entry) { if (null !== $return) { @@ -354,15 +354,15 @@ class SubscriptionEnrichment implements EnrichmentInterface if ($current->gt($return)) { $return = clone $current; } - Log::debug(sprintf('Last paid date is: %s', $return->format('Y-m-d'))); + Log::debug(sprintf('[a] Last paid date is: %s', $return->format('Y-m-d'))); } if (null === $return) { /** @var Carbon $return */ $return = $entry['date_object']; - Log::debug(sprintf('Last paid date is: %s', $return->format('Y-m-d'))); + Log::debug(sprintf('[b] Last paid date is: %s', $return->format('Y-m-d'))); } } - Log::debug(sprintf('Last paid date is: "%s"', $return?->format('Y-m-d'))); + Log::debug(sprintf('[c] Last paid date is: "%s"', $return?->format('Y-m-d'))); return $return; }