mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-02 20:25:28 +00:00
Better chart for bills.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
use App;
|
use App;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Crypt;
|
||||||
use DB;
|
use DB;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Helpers\Report\ReportQueryInterface;
|
use FireflyIII\Helpers\Report\ReportQueryInterface;
|
||||||
@@ -26,7 +27,6 @@ use Preferences;
|
|||||||
use Response;
|
use Response;
|
||||||
use Session;
|
use Session;
|
||||||
use Steam;
|
use Steam;
|
||||||
use Crypt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GoogleChartController
|
* Class GoogleChartController
|
||||||
@@ -256,12 +256,12 @@ class GoogleChartController extends Controller
|
|||||||
->where('transaction_types.type', 'Withdrawal')
|
->where('transaction_types.type', 'Withdrawal')
|
||||||
->groupBy('categories.id')
|
->groupBy('categories.id')
|
||||||
->orderBy('sum', 'DESC')
|
->orderBy('sum', 'DESC')
|
||||||
->get(['categories.id','categories.encrypted', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]);
|
->get(['categories.id', 'categories.encrypted', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]);
|
||||||
|
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$isEncrypted = intval($entry->encrypted) == 1 ? true : false;
|
$isEncrypted = intval($entry->encrypted) == 1 ? true : false;
|
||||||
$name = strlen($entry->name) == 0 ? '(no category)' : $entry->name;
|
$name = strlen($entry->name) == 0 ? '(no category)' : $entry->name;
|
||||||
$name = $isEncrypted ? Crypt::decrypt($name) : $name;
|
$name = $isEncrypted ? Crypt::decrypt($name) : $name;
|
||||||
$chart->addRow($name, floatval($entry->sum));
|
$chart->addRow($name, floatval($entry->sum));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,22 +291,18 @@ class GoogleChartController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
}
|
}
|
||||||
$end = new Carbon;
|
|
||||||
while ($start <= $end) {
|
$results = $bill->transactionjournals()->after($start)->get();
|
||||||
$result = $bill->transactionjournals()->before($end)->after($start)->first();
|
/** @var TransactionJournal $result */
|
||||||
if ($result) {
|
foreach ($results as $result) {
|
||||||
/** @var Transaction $tr */
|
$amount = 0;
|
||||||
foreach ($result->transactions()->get() as $tr) {
|
/** @var Transaction $tr */
|
||||||
if (floatval($tr->amount) > 0) {
|
foreach ($result->transactions()->get() as $tr) {
|
||||||
$amount = floatval($tr->amount);
|
if (floatval($tr->amount) > 0) {
|
||||||
}
|
$amount = floatval($tr->amount);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$amount = 0;
|
|
||||||
}
|
}
|
||||||
unset($result);
|
$chart->addRow(clone $result->date, $bill->amount_max, $bill->amount_min, $amount);
|
||||||
$chart->addRow(clone $start, $bill->amount_max, $bill->amount_min, $amount);
|
|
||||||
$start = Navigation::addPeriod($start, $bill->repeat_freq, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$chart->generate();
|
$chart->generate();
|
||||||
|
|||||||
Reference in New Issue
Block a user