mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-01 03:29:33 +00:00
Some expansion on the index of repeated expenses, and the first reference to the show page.
This commit is contained in:
@@ -46,29 +46,35 @@ class RepeatedExpenseController extends BaseController
|
|||||||
throw new FireflyException('Cannot handle "' . $piggyBank->reminder . '" reminders for repeated expenses');
|
throw new FireflyException('Cannot handle "' . $piggyBank->reminder . '" reminders for repeated expenses');
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
$piggyBank->parts = $piggyBank->currentRep->startdate->diffInMonths($piggyBank->currentRep->targetdate);
|
$start = clone $piggyBank->currentRep->startdate;
|
||||||
|
$start->startOfMonth();
|
||||||
|
$end = clone $piggyBank->currentRep->targetdate;
|
||||||
|
$end->endOfMonth();
|
||||||
|
$piggyBank->parts = $start->diffInMonths($end);
|
||||||
|
unset($start, $end);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$piggyBank->parts = 1;
|
$piggyBank->parts = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// number of bars:
|
// number of bars:
|
||||||
$piggyBank->barCount = floor(12 / $piggyBank->parts);
|
$piggyBank->barCount = floor(12 / $piggyBank->parts) == 0 ? 1 : floor(12 / $piggyBank->parts);
|
||||||
$amountPerBar = floatval($piggyBank->targetamount) / $piggyBank->parts;
|
$amountPerBar = floatval($piggyBank->targetamount) / $piggyBank->parts;
|
||||||
$currentAmount = floatval($amountPerBar);
|
$currentAmount = floatval($amountPerBar);
|
||||||
$bars = [];
|
$bars = [];
|
||||||
$currentDate = clone $piggyBank->currentRep->startdate;
|
$currentDate = clone $piggyBank->currentRep->startdate;
|
||||||
for ($i = 0; $i < $piggyBank->parts; $i++) {
|
for ($i = 0; $i < $piggyBank->parts; $i++) {
|
||||||
// niet elke keer een andere dinges pakken? om target te redden?
|
// niet elke keer een andere dinges pakken? om target te redden?
|
||||||
|
if (!is_null($piggyBank->reminder)) {
|
||||||
|
$currentDate = \DateKit::addPeriod($currentDate, $piggyBank->reminder, 0);
|
||||||
|
}
|
||||||
$bars[] = [
|
$bars[] = [
|
||||||
'amount' => $currentAmount,
|
'amount' => $currentAmount,
|
||||||
'date' => $currentDate
|
'date' => $currentDate
|
||||||
];
|
];
|
||||||
if (!is_null($piggyBank->reminder)) {
|
|
||||||
$currentDate = \DateKit::addPeriod($currentDate, $piggyBank->reminder, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentAmount += $amountPerBar;
|
$currentAmount += $amountPerBar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,10 +205,14 @@ class Piggybank
|
|||||||
*/
|
*/
|
||||||
public function validateRepeatedExpenses()
|
public function validateRepeatedExpenses()
|
||||||
{
|
{
|
||||||
|
if(!\Auth::check()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
/** @var \FireflyIII\Database\RepeatedExpense $repository */
|
/** @var \FireflyIII\Database\RepeatedExpense $repository */
|
||||||
$repository = \App::make('FireflyIII\Database\RepeatedExpense');
|
$repository = \App::make('FireflyIII\Database\RepeatedExpense');
|
||||||
|
|
||||||
$list = $repository->get();
|
$list = $repository->get();
|
||||||
|
$today = Carbon::now();
|
||||||
|
|
||||||
/** @var \Piggybank $entry */
|
/** @var \Piggybank $entry */
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
@@ -225,7 +229,7 @@ class Piggybank
|
|||||||
$repetition->save();
|
$repetition->save();
|
||||||
}
|
}
|
||||||
// then continue and do something in the current relevant timeframe.
|
// then continue and do something in the current relevant timeframe.
|
||||||
$today = Carbon::now();
|
|
||||||
$currentTarget = clone $target;
|
$currentTarget = clone $target;
|
||||||
$currentStart = null;
|
$currentStart = null;
|
||||||
while ($currentTarget < $today) {
|
while ($currentTarget < $today) {
|
||||||
@@ -243,7 +247,6 @@ class Piggybank
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class Date
|
|||||||
case 'monthly':
|
case 'monthly':
|
||||||
$date->addMonths($add);
|
$date->addMonths($add);
|
||||||
break;
|
break;
|
||||||
|
case 'quarter':
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$months = $add * 3;
|
$months = $add * 3;
|
||||||
$date->addMonths($months);
|
$date->addMonths($months);
|
||||||
@@ -142,6 +143,7 @@ class Date
|
|||||||
case 'monthly':
|
case 'monthly':
|
||||||
$date->startOfMonth();
|
$date->startOfMonth();
|
||||||
break;
|
break;
|
||||||
|
case 'quarter':
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$date->firstOfQuarter();
|
$date->firstOfQuarter();
|
||||||
break;
|
break;
|
||||||
@@ -184,6 +186,7 @@ class Date
|
|||||||
case 'monthly':
|
case 'monthly':
|
||||||
$date->subMonths($subtract);
|
$date->subMonths($subtract);
|
||||||
break;
|
break;
|
||||||
|
case 'quarter':
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$months = $subtract * 3;
|
$months = $subtract * 3;
|
||||||
$date->subMonths($months);
|
$date->subMonths($months);
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ Route::group(
|
|||||||
// repeated expenses controller:
|
// repeated expenses controller:
|
||||||
Route::get('/repeatedexpenses', ['uses' => 'RepeatedExpenseController@index', 'as' => 'repeated.index']);
|
Route::get('/repeatedexpenses', ['uses' => 'RepeatedExpenseController@index', 'as' => 'repeated.index']);
|
||||||
Route::get('/repeatedexpenses/create', ['uses' => 'RepeatedExpenseController@create', 'as' => 'repeated.create']);
|
Route::get('/repeatedexpenses/create', ['uses' => 'RepeatedExpenseController@create', 'as' => 'repeated.create']);
|
||||||
|
Route::get('/repeatedexpenses/show/{repeated}', ['uses' => 'RepeatedExpenseController@show', 'as' => 'repeated.show']);
|
||||||
|
|
||||||
// report controller:
|
// report controller:
|
||||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<div class="col-lg-12 col-sm-12 col-md-12">
|
<div class="col-lg-12 col-sm-12 col-md-12">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<a href="#" title="{{{$entry->name}}}">{{{$entry->name}}}</a> ({{mf($entry->currentRep->currentamount)}})
|
<a href="{{route('repeated.show',$entry->id)}}" title="{{{$entry->name}}}">{{{$entry->name}}}</a> ({{mf($entry->currentRep->currentamount)}})
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
Reference in New Issue
Block a user