This commit is contained in:
James Cole
2025-08-09 06:59:55 +02:00
parent 4b0597d19a
commit 6aab5fab05
6 changed files with 67 additions and 39 deletions

View File

@@ -79,7 +79,6 @@ class IndexController extends Controller
$total = $collection->count(); $total = $collection->count();
$parameters = new ParameterBag(); $parameters = new ParameterBag();
// sub one day from temp start so the last paid date is one day before it should be. // sub one day from temp start so the last paid date is one day before it should be.
$tempStart = clone $start; $tempStart = clone $start;
@@ -173,6 +172,7 @@ class IndexController extends Controller
'currency_symbol' => $bill['currency_symbol'], 'currency_symbol' => $bill['currency_symbol'],
'currency_decimal_places' => $bill['currency_decimal_places'], 'currency_decimal_places' => $bill['currency_decimal_places'],
'avg' => '0', 'avg' => '0',
'total_left_to_pay' => '0',
'period' => $range, 'period' => $range,
'per_period' => '0', 'per_period' => '0',
]; ];
@@ -183,6 +183,17 @@ class IndexController extends Controller
$avg = bcmul($avg, (string)count($bill['pay_dates'])); $avg = bcmul($avg, (string)count($bill['pay_dates']));
$sums[$groupOrder][$currencyId]['avg'] = bcadd($sums[$groupOrder][$currencyId]['avg'], $avg); $sums[$groupOrder][$currencyId]['avg'] = bcadd($sums[$groupOrder][$currencyId]['avg'], $avg);
} }
// only fill in total_left_to_pay when bill is not yet paid.
if (count($bill['paid_dates']) < count($bill['pay_dates'])) {
$count = count($bill['pay_dates']) - count($bill['paid_dates']);
if ($count > 0) {
$avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2');
$avg = bcmul($avg, (string)$count);
$sums[$groupOrder][$currencyId]['total_left_to_pay'] = bcadd($sums[$groupOrder][$currencyId]['total_left_to_pay'], $avg);
}
}
// fill in per period regardless: // fill in per period regardless:
$sums[$groupOrder][$currencyId]['per_period'] = bcadd($sums[$groupOrder][$currencyId]['per_period'], $this->amountPerPeriod($bill, $range)); $sums[$groupOrder][$currencyId]['per_period'] = bcadd($sums[$groupOrder][$currencyId]['per_period'], $this->amountPerPeriod($bill, $range));
} }

View File

@@ -56,6 +56,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
$this->collectPaidDates(); $this->collectPaidDates();
$this->collectPayDates(); $this->collectPayDates();
// TODO clean me up. // TODO clean me up.
$notes = $this->notes; $notes = $this->notes;

View File

@@ -110,8 +110,8 @@ class BillDateCalculator
$currentStart = clone $nextExpectedMatch; $currentStart = clone $nextExpectedMatch;
++$loop; ++$loop;
if ($loop > 12) { if ($loop > 31) {
Log::debug('Loop is more than 12, so we break.'); Log::debug('Loop is more than 31, so we break.');
break; break;
} }

View File

@@ -1864,6 +1864,7 @@ return [
'remove_budgeted_amount' => 'Remove budgeted amount in :currency', 'remove_budgeted_amount' => 'Remove budgeted amount in :currency',
// bills: // bills:
'left_to_pay_active_bills' => 'active, expected and not yet paid subscriptions',
'left_to_pay_lc' => 'left to pay', 'left_to_pay_lc' => 'left to pay',
'less_than_expected' => 'less than expected', 'less_than_expected' => 'less than expected',
'more_than_expected' => 'more than expected', 'more_than_expected' => 'more than expected',

View File

@@ -158,8 +158,8 @@
<td style="width:33%;">{{ 'amount'|_ }}</td> <td style="width:33%;">{{ 'amount'|_ }}</td>
<td> <td>
{{ formatAmountBySymbol(limit.amount, limit.transactionCurrency.symbol, limit.transactionCurrency.decimal_places) }} {{ formatAmountBySymbol(limit.amount, limit.transactionCurrency.symbol, limit.transactionCurrency.decimal_places) }}
{% if convertToPrimary and 0 != limit.pc_amount %} {% if convertToPrimary and null != limit.native_amount %}
({{ formatAmountBySymbol(limit.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }}) ({{ formatAmountBySymbol(limit.native_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
{% endif %} {% endif %}
</td> </td>
</tr> </tr>

View File

@@ -189,6 +189,21 @@
<td class="hidden-sm hidden-xs">&nbsp;</td><!-- repeats --> <td class="hidden-sm hidden-xs">&nbsp;</td><!-- repeats -->
</tr> </tr>
{% endif %} {% endif %}
{% if '0' != sum.total_left_to_pay %}
<tr>
<td class="hidden-sm hidden-xs">&nbsp;</td> <!-- handle -->
<td class="hidden-sm hidden-xs">&nbsp;</td> <!-- buttons -->
<td colspan="2" style="text-align: right;"> <!-- title -->
<small>{{ 'sum'|_ }} ({{ sum.currency_name }}) ({{ 'left_to_pay_active_bills'|_ }})</small>
</td>
<td style="text-align: right;"> <!-- amount -->
{{ formatAmountBySymbol(sum.total_left_to_pay, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
<td>&nbsp;</td> <!-- paid in period -->
<td class="hidden-sm hidden-xs">&nbsp;</td> <!-- next expected match -->
<td class="hidden-sm hidden-xs">&nbsp;</td><!-- repeats -->
</tr>
{% endif %}
{% if '0' != sum.per_period %} {% if '0' != sum.per_period %}
<tr> <tr>
<td class="hidden-sm hidden-xs">&nbsp;</td> <!-- handle --> <td class="hidden-sm hidden-xs">&nbsp;</td> <!-- handle -->