mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
Fixed some duplication.
This commit is contained in:
parent
3fb14b4708
commit
a4cc25175a
@ -64,32 +64,7 @@ class GoogleAccountChartGenerator implements AccountChartGenerator
|
|||||||
*/
|
*/
|
||||||
public function frontpage(Collection $accounts, Carbon $start, Carbon $end)
|
public function frontpage(Collection $accounts, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$chart = new GChart;
|
return $this->all($accounts, $start, $end);
|
||||||
$chart->addColumn(trans('firefly.dayOfMonth'), 'date');
|
|
||||||
|
|
||||||
$index = 1;
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$chart->addColumn(trans('firefly.balanceFor', ['name' => $account->name]), 'number');
|
|
||||||
$chart->addCertainty($index);
|
|
||||||
$index++;
|
|
||||||
}
|
|
||||||
$current = clone $start;
|
|
||||||
$current->subDay();
|
|
||||||
$today = Carbon::now();
|
|
||||||
while ($end >= $current) {
|
|
||||||
$row = [clone $current];
|
|
||||||
$certain = $current < $today;
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$row[] = Steam::balance($account, $current);
|
|
||||||
$row[] = $certain;
|
|
||||||
}
|
|
||||||
$chart->addRowArray($row);
|
|
||||||
$current->addDay();
|
|
||||||
}
|
|
||||||
$chart->generate();
|
|
||||||
|
|
||||||
return $chart->getData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,12 +31,13 @@ class ChartJsBillChartGenerator implements BillChartGenerator
|
|||||||
$unpaidDescriptions = [];
|
$unpaidDescriptions = [];
|
||||||
$unpaidAmount = 0;
|
$unpaidAmount = 0;
|
||||||
|
|
||||||
|
bcscale(2);
|
||||||
|
|
||||||
/** @var TransactionJournal $entry */
|
/** @var TransactionJournal $entry */
|
||||||
foreach ($paid as $entry) {
|
foreach ($paid as $entry) {
|
||||||
|
|
||||||
$paidDescriptions[] = $entry->description;
|
$paidDescriptions[] = $entry->description;
|
||||||
$paidAmount += floatval($entry->amount);
|
$paidAmount = bcadd($paidAmount, $entry->amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop unpaid:
|
// loop unpaid:
|
||||||
@ -45,7 +46,7 @@ class ChartJsBillChartGenerator implements BillChartGenerator
|
|||||||
$description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
|
$description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
|
||||||
$amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
$amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
||||||
$unpaidDescriptions[] = $description;
|
$unpaidDescriptions[] = $description;
|
||||||
$unpaidAmount += $amount;
|
$unpaidAmount = bcadd($unpaidAmount, $amount);
|
||||||
unset($amount, $description);
|
unset($amount, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,14 @@ class GoogleBillChartGenerator implements BillChartGenerator
|
|||||||
$unpaidDescriptions = [];
|
$unpaidDescriptions = [];
|
||||||
$unpaidAmount = 0;
|
$unpaidAmount = 0;
|
||||||
|
|
||||||
|
bcscale(2);
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionJournal $entry */
|
/** @var TransactionJournal $entry */
|
||||||
foreach ($paid as $entry) {
|
foreach ($paid as $entry) {
|
||||||
|
|
||||||
$paidDescriptions[] = $entry->description;
|
$paidDescriptions[] = $entry->description;
|
||||||
$paidAmount += floatval($entry->amount);
|
$paidAmount = bcadd($paidAmount, $entry->amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop unpaid:
|
// loop unpaid:
|
||||||
@ -44,7 +46,7 @@ class GoogleBillChartGenerator implements BillChartGenerator
|
|||||||
$description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
|
$description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')';
|
||||||
$amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
$amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
||||||
$unpaidDescriptions[] = $description;
|
$unpaidDescriptions[] = $description;
|
||||||
$unpaidAmount += $amount;
|
$unpaidAmount = bcadd($unpaidAmount, $amount);
|
||||||
unset($amount, $description);
|
unset($amount, $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +79,11 @@ class GoogleBillChartGenerator implements BillChartGenerator
|
|||||||
|
|
||||||
/** @var TransactionJournal $result */
|
/** @var TransactionJournal $result */
|
||||||
foreach ($entries as $result) {
|
foreach ($entries as $result) {
|
||||||
$chart->addRow(clone $result->date, floatval($bill->amount_max), floatval($bill->amount_min), floatval($result->amount));
|
$chart->addRow(
|
||||||
|
clone $result->date,
|
||||||
|
floatval($bill->amount_max),
|
||||||
|
floatval($bill->amount_min),
|
||||||
|
floatval($result->amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
$chart->generate();
|
$chart->generate();
|
||||||
|
@ -28,7 +28,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
|||||||
$format = Config::get('firefly.' . $dateFormat . '.' . $language);
|
$format = Config::get('firefly.' . $dateFormat . '.' . $language);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'count' => 1,
|
|
||||||
'labels' => [],
|
'labels' => [],
|
||||||
'datasets' => [
|
'datasets' => [
|
||||||
[
|
[
|
||||||
@ -45,6 +44,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['count'] = count($data['datasets']);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +119,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
|||||||
$format = Config::get('firefly.month.' . $language);
|
$format = Config::get('firefly.month.' . $language);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'count' => 0,
|
|
||||||
'labels' => [],
|
'labels' => [],
|
||||||
'datasets' => [],
|
'datasets' => [],
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user