Skip to content

Firefly III: a personal finances manager

Fix #12468

James Cole04198ff4da70
diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php
index 110ea3d5bd..18819476e5 100644
--- a/app/Http/Controllers/Bill/IndexController.php
+++ b/app/Http/Controllers/Bill/IndexController.php
@@ -253,7 +253,9 @@ final class IndexController extends Controller
// only fill in total_left_to_pay when bill is not yet paid.
// #11474 and when it is expected in the current period
if (count($bill['paid_dates']) < count($bill['pay_dates'])) {
- $count = count($bill['pay_dates']) - count($bill['paid_dates']);
+ // #12468 the count does not need to subtract paid_dates, that is already accounted for.
+ //$count = count($bill['pay_dates']) - count($bill['paid_dates']);
+ $count = count($bill['pay_dates']);
if ($count > 0) {
$avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2');
$avg = bcmul($avg, (string) $count);
diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php
index 037e115c1b..4b350960b9 100644
--- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php
+++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php
@@ -76,6 +76,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
$this->collectPaidDates();
$this->collectPayDates();
+
// TODO clean me up.
$notes = $this->notes;
diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php
index f6c391ce35..08669a5693 100644
--- a/app/Support/Navigation.php
+++ b/app/Support/Navigation.php
@@ -140,6 +140,7 @@ class Navigation
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
{
+ [$beginning, $end] = $beginning->lt($end) ? [$beginning, $end] : [$end, $beginning];
Log::debug(sprintf('diffInPeriods: %s (skip: %d), between %s and %s.', $period, $skip, $beginning->format('Y-m-d'), $end->format('Y-m-d')));
$map = [
'daily' => 'diffInDays',
diff --git a/resources/views/components/lists/subscriptions.blade.php b/resources/views/components/lists/subscriptions.blade.php
index b72ebf95b1..e312f759a4 100644
--- a/resources/views/components/lists/subscriptions.blade.php
+++ b/resources/views/components/lists/subscriptions.blade.php
@@ -77,7 +77,7 @@
</td>
<td class="expected_in_period hidden-sm hidden-xs">
@if($entry['next_expected_match'])
- {{ new \Carbon\Carbon($entry['next_expected_match'])->isoFormat($monthAndDayFormat) }}
+ {{ new \Carbon\Carbon($entry['next_expected_match'])->isoFormat($monthAndDayFormat) }}
@endif
</td>
@endif
@@ -101,7 +101,7 @@
@endif
<td class="expected_in_period hidden-sm hidden-xs">
@foreach($entry['pay_dates'] as $date)
- {{ new \Carbon\Carbon($date)->isoFormat($monthAndDayFormat) }}<br>
+ {{ new \Carbon\Carbon($date)->isoFormat($monthAndDayFormat) }}<br>
@endforeach
</td>
@@ -113,17 +113,19 @@
--}}
@if(count($entry['paid_dates']) > 0 && $entry['active'])
- <td class="paid_in_period text-success">
- @foreach($entry['paid_dates'] as $currentPaid)
- <a href="{{ route('transactions.show', $currentPaid['transaction_group_id']) }}">
- {{ new \Carbon\Carbon($currentPaid['date'])->isoFormat($monthAndDayFormat) }}
- </a>
- <br/>
- @endforeach
+ <td class="paid_in_period text-success">
+ @foreach($entry['paid_dates'] as $currentPaid)
+ <a href="{{ route('transactions.show', $currentPaid['transaction_group_id']) }}">{{ new \Carbon\Carbon($currentPaid['date'])->isoFormat($monthAndDayFormat) }}</a><br/>
+ @endforeach
</td>
<td class="expected_in_period hidden-sm hidden-xs">
- @if($entry['next_expected_match'])
- {{ new \Carbon\Carbon($entry['next_expected_match'])->isoFormat($monthAndDayFormat) }}
+ <!-- not just show next expected match, loop all pay_dates. -->
+ @if($entry['next_expected_match'] && 1 === count($entry['pay_dates']))
+ {{ new \Carbon\Carbon($entry['next_expected_match'])->isoFormat($monthAndDayFormat) }}
+ @elseif($entry['next_expected_match'] && count($entry['pay_dates']) > 0)
+ @foreach($entry['pay_dates'] as $date)
+ {{ new \Carbon\Carbon($date)->isoFormat($monthAndDayFormat) }}<br>
+ @endforeach
@else
<span class="text-muted">{{ $entry['next_expected_match_diff'] }}</span>
@endif
@@ -139,7 +141,7 @@
<td class="hidden-sm hidden-xs">
{{ __('firefly.repeat_freq_' . $entry['repeat_freq']) }}
@if($entry['skip'] > 0)
- {{ __('firefly.skips_over') }} {{ $entry['skip'] }}
+ {{ __('firefly.skips_over') }} {{ $entry['skip'] }}
@endif
@if(null !== $entry['end_date'])
<br>