mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 14:58:40 +00:00
Fix some things in recurring transactions.
This commit is contained in:
@@ -111,11 +111,17 @@ class IndexController extends Controller
|
|||||||
$array['first_date'] = new Carbon($array['first_date']);
|
$array['first_date'] = new Carbon($array['first_date']);
|
||||||
$array['repeat_until'] = null === $array['repeat_until'] ? null : new Carbon($array['repeat_until']);
|
$array['repeat_until'] = null === $array['repeat_until'] ? null : new Carbon($array['repeat_until']);
|
||||||
$array['latest_date'] = null === $array['latest_date'] ? null : new Carbon($array['latest_date']);
|
$array['latest_date'] = null === $array['latest_date'] ? null : new Carbon($array['latest_date']);
|
||||||
$array['occurrences'] = [];
|
|
||||||
|
|
||||||
if (0 !== $recurrence->recurrenceRepetitions->count()) {
|
// make carbon objects out of occurrences
|
||||||
$array['ocurrences'] = array_slice($this->recurring->getOccurrencesInRange($recurrence->recurrenceRepetitions->first(), $today, $year), 0, 1);
|
foreach ($array['repetitions'] as $repIndex => $repetition) {
|
||||||
|
foreach ($repetition['occurrences'] as $occIndex => $occurrence) {
|
||||||
|
$array['repetitions'][$repIndex]['occurrences'][$occIndex] = new Carbon($occurrence);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (0 !== $recurrence->recurrenceRepetitions->count()) {
|
||||||
|
//$array['ocurrences'] = array_slice($this->recurring->getOccurrencesInRange($recurrence->recurrenceRepetitions->first(), $today, $year), 0, 1);
|
||||||
|
//}
|
||||||
|
|
||||||
$recurring[] = $array;
|
$recurring[] = $array;
|
||||||
}
|
}
|
||||||
|
@@ -84,6 +84,8 @@ class ShowController extends Controller
|
|||||||
|
|
||||||
$array = $transformer->transform($recurrence);
|
$array = $transformer->transform($recurrence);
|
||||||
$groups = $this->recurring->getTransactions($recurrence);
|
$groups = $this->recurring->getTransactions($recurrence);
|
||||||
|
$today = new Carbon;
|
||||||
|
$array['repeat_until'] = null !== $array['repeat_until'] ? new Carbon($array['repeat_until']) : null;
|
||||||
|
|
||||||
// transform dates back to Carbon objects:
|
// transform dates back to Carbon objects:
|
||||||
foreach ($array['repetitions'] as $index => $repetition) {
|
foreach ($array['repetitions'] as $index => $repetition) {
|
||||||
@@ -94,6 +96,6 @@ class ShowController extends Controller
|
|||||||
|
|
||||||
$subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
|
$subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
|
||||||
|
|
||||||
return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups'));
|
return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups','today'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -535,6 +535,31 @@ class RecurringRepository implements RecurringRepositoryInterface
|
|||||||
// filter out all the weekend days:
|
// filter out all the weekend days:
|
||||||
$occurrences = $this->filterWeekends($repetition, $occurrences);
|
$occurrences = $this->filterWeekends($repetition, $occurrences);
|
||||||
|
|
||||||
|
// filter out everything if "repeat_until" is set.
|
||||||
|
$repeatUntil = $repetition->recurrence->repeat_until;
|
||||||
|
$occurrences = $this->filterMaxDate($repeatUntil, $occurrences);
|
||||||
|
|
||||||
return $occurrences;
|
return $occurrences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon|null $max
|
||||||
|
* @param array $occurrences
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function filterMaxDate(?Carbon $max, array $occurrences): array
|
||||||
|
{
|
||||||
|
if (null === $max) {
|
||||||
|
return $occurrences;
|
||||||
|
}
|
||||||
|
$filtered = [];
|
||||||
|
foreach ($occurrences as $date) {
|
||||||
|
if ($date->lte($max)) {
|
||||||
|
$filtered[] = $date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filtered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -100,13 +100,13 @@
|
|||||||
({{ trans('firefly.recurring_skips_more', {count: rep.repetition_skip})|lower }}).
|
({{ trans('firefly.recurring_skips_more', {count: rep.repetition_skip})|lower }}).
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rep.weekend == 3 %}
|
{% if rep.weekend == 3 %}
|
||||||
{{ 'will_jump_friday'|_ }}
|
<br>{{ 'will_jump_friday'|_ }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rep.weekend == 4 %}
|
{% if rep.weekend == 4 %}
|
||||||
{{ 'will_jump_monday'|_ }}
|
<br>{{ 'will_jump_monday'|_ }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rep.weekend == 2 %}
|
{% if rep.weekend == 2 %}
|
||||||
{{ 'except_weekends'|_ }}
|
<br>{{ 'except_weekends'|_ }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -123,11 +123,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
{% if rt.occurrences|length == 0 %}
|
<td>
|
||||||
<td> </td>
|
<ul>
|
||||||
{% else %}
|
{% for rep in rt.repetitions %}
|
||||||
<td>{{ rt.occurrences[0].formatLocalized(monthAndDayFormat) }}</td>
|
{% for occ in rep.occurrences %}
|
||||||
{% endif %}
|
<li>{{ occ.formatLocalized(monthAndDayFormat) }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@@ -52,7 +52,11 @@
|
|||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
|
{% if null != array.repeat_until and today > array.repeat_until %}
|
||||||
|
<span class="text-danger">
|
||||||
|
{{ trans('firefly.repeat_until_in_past', {date: array.repeat_until.formatLocalized(monthAndDayFormat) }) }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for rep in array.repetitions %}
|
{% for rep in array.repetitions %}
|
||||||
<li>
|
<li>
|
||||||
|
Reference in New Issue
Block a user