mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
More stuffs. Too lazy to explain.
This commit is contained in:
@@ -336,6 +336,34 @@ class GoogleChartController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function budgetLimitSpending(\Budget $budget, \LimitRepetition $repetition)
|
||||
{
|
||||
$start = clone $repetition->startdate;
|
||||
$end = $repetition->enddate;
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Day', 'date');
|
||||
$chart->addColumn('Left', 'number');
|
||||
|
||||
|
||||
$amount = $repetition->amount;
|
||||
|
||||
while ($start <= $end) {
|
||||
/*
|
||||
* Sum of expenses on this day:
|
||||
*/
|
||||
$sum = floatval($budget->transactionjournals()->lessThan(0)->transactionTypes(['Withdrawal'])->onDate($start)->sum('amount'));
|
||||
$amount += $sum;
|
||||
$chart->addRow(clone $start, $amount);
|
||||
$start->addDay();
|
||||
}
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
@@ -445,28 +473,44 @@ class GoogleChartController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function budgetLimitSpending(\Budget $budget, \LimitRepetition $repetition) {
|
||||
$start = clone $repetition->startdate;
|
||||
$end = $repetition->enddate;
|
||||
/**
|
||||
* @param RecurringTransaction $recurring
|
||||
*/
|
||||
public function recurringOverview(RecurringTransaction $recurring)
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
||||
$dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Day', 'date');
|
||||
$chart->addColumn('Left', 'number');
|
||||
$chart->addColumn('Date', 'date');
|
||||
$chart->addColumn('Max amount', 'number');
|
||||
$chart->addColumn('Min amount', 'number');
|
||||
$chart->addColumn('Current entry', 'number');
|
||||
|
||||
|
||||
$amount = $repetition->amount;
|
||||
|
||||
while($start <= $end) {
|
||||
/*
|
||||
* Sum of expenses on this day:
|
||||
*/
|
||||
$sum = floatval($budget->transactionjournals()->lessThan(0)->transactionTypes(['Withdrawal'])->onDate($start)->sum('amount'));
|
||||
$amount += $sum;
|
||||
$chart->addRow(clone $start, $amount);
|
||||
$start->addDay();
|
||||
// get first transaction or today for start:
|
||||
$first = $recurring->transactionjournals()->orderBy('date', 'ASC')->first();
|
||||
if ($first) {
|
||||
$start = $first->date;
|
||||
} else {
|
||||
$start = new Carbon;
|
||||
}
|
||||
$end = new Carbon;
|
||||
while ($start <= $end) {
|
||||
$result = $recurring->transactionjournals()->before($end)->after($start)->first();
|
||||
if($result) {
|
||||
$amount = $result->getAmount();
|
||||
} else {
|
||||
$amount = 0;
|
||||
}
|
||||
unset($result);
|
||||
$chart->addRow(clone $start, $recurring->amount_max, $recurring->amount_min, $amount);
|
||||
$start = $dateKit->addPeriod($start, $recurring->repeat_freq, 0);
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
@@ -551,6 +595,7 @@ class GoogleChartController extends BaseController
|
||||
$chart->addRow('Paid: ' . join(', ', $paid['items']), $paid['amount']);
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class PiggybankController extends BaseController
|
||||
|
||||
/**
|
||||
* Add money to piggy bank
|
||||
*
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return $this
|
||||
@@ -109,7 +110,7 @@ class PiggybankController extends BaseController
|
||||
* Flash some data to fill the form.
|
||||
*/
|
||||
$prefilled = ['name' => $piggybank->name, 'account_id' => $piggybank->account_id, 'targetamount' => $piggybank->targetamount,
|
||||
'targetdate' => $piggybank->targetdate, 'remind_me' => intval($piggybank->remind_me) == 1 ? true : false];
|
||||
'targetdate' => !is_null($piggybank->targetdate) ? $piggybank->targetdate->format('Y-m-d') : null,'reminder' => $piggybank->reminder, 'remind_me' => intval($piggybank->remind_me) == 1 ? true : false];
|
||||
Session::flash('prefilled', $prefilled);
|
||||
|
||||
return View::make('piggybanks.edit', compact('piggybank', 'accounts', 'periods', 'prefilled'))->with('title', 'Piggybanks')->with(
|
||||
@@ -152,6 +153,7 @@ class PiggybankController extends BaseController
|
||||
|
||||
/**
|
||||
* POST add money to piggy bank
|
||||
*
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
@@ -176,7 +178,7 @@ class PiggybankController extends BaseController
|
||||
/*
|
||||
* Create event!
|
||||
*/
|
||||
Event::fire('piggybank.addMoney',[$piggybank, $amount]);
|
||||
Event::fire('piggybank.addMoney', [$piggybank, $amount]);
|
||||
|
||||
Session::flash('success', 'Added ' . mf($amount, false) . ' to "' . e($piggybank->name) . '".');
|
||||
} else {
|
||||
@@ -205,7 +207,7 @@ class PiggybankController extends BaseController
|
||||
/*
|
||||
* Create event!
|
||||
*/
|
||||
Event::fire('piggybank.removeMoney',[$piggybank, $amount]);
|
||||
Event::fire('piggybank.removeMoney', [$piggybank, $amount]);
|
||||
|
||||
Session::flash('success', 'Removed ' . mf($amount, false) . ' from "' . e($piggybank->name) . '".');
|
||||
} else {
|
||||
@@ -228,7 +230,21 @@ class PiggybankController extends BaseController
|
||||
public function show(Piggybank $piggybank)
|
||||
{
|
||||
|
||||
return View::make('piggybanks.show', compact('piggybank'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc')->with(
|
||||
$events = $piggybank->piggybankevents()->orderBy('date', 'DESC')->get();
|
||||
|
||||
/*
|
||||
* Number of reminders:
|
||||
*/
|
||||
$remindersCount = $piggybank->countFutureReminders();
|
||||
if ($remindersCount > 0) {
|
||||
$amountPerReminder = ($piggybank->targetamount - $piggybank->currentRelevantRep()->currentamount) / $remindersCount;
|
||||
} else {
|
||||
$amountPerReminder = ($piggybank->targetamount - $piggybank->currentRelevantRep()->currentamount);
|
||||
}
|
||||
|
||||
return View::make('piggybanks.show', compact('amountPerReminder', 'remindersCount', 'piggybank', 'events'))->with('title', 'Piggy banks')->with(
|
||||
'mainTitleIcon', 'fa-sort-amount-asc'
|
||||
)->with(
|
||||
'subTitle', $piggybank->name
|
||||
);
|
||||
|
||||
@@ -296,7 +312,7 @@ class PiggybankController extends BaseController
|
||||
default:
|
||||
throw new FireflyException('Cannot handle post_submit_action "' . e(Input::get('post_submit_action')) . '"');
|
||||
break;
|
||||
case 'create_another':
|
||||
case 'return_to_edit':
|
||||
case 'update':
|
||||
$messages = $repos->validate($data);
|
||||
/** @var MessageBag $messages ['errors'] */
|
||||
@@ -311,7 +327,7 @@ class PiggybankController extends BaseController
|
||||
$repos->update($piggyBank, $data);
|
||||
Session::flash('success', 'Piggy bank updated!');
|
||||
|
||||
if ($data['post_submit_action'] == 'create_another') {
|
||||
if ($data['post_submit_action'] == 'return_to_edit') {
|
||||
return Redirect::route('piggybanks.edit', $piggyBank->id);
|
||||
} else {
|
||||
return Redirect::route('piggybanks.index');
|
||||
|
||||
Reference in New Issue
Block a user