Various report updates and code cleanup.

This commit is contained in:
James Cole
2016-12-04 18:02:19 +01:00
parent 905a2432c6
commit f4b9b7ae84
32 changed files with 592 additions and 450 deletions

View File

@@ -44,4 +44,11 @@ interface BudgetChartGeneratorInterface
* @return array
*/
public function period(array $entries): array;
/**
* @param array $entries
*
* @return array
*/
public function periodNoBudget(array $entries): array;
}

View File

@@ -104,7 +104,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
*
* @return array
*/
public function period(array $entries) : array
public function period(array $entries): array
{
$data = [
@@ -133,4 +133,32 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
return $data;
}
/**
* @param array $entries
*
* @return array
*/
public function periodNoBudget(array $entries): array
{
$data = [
'labels' => array_keys($entries),
'datasets' => [
0 => [
'label' => trans('firefly.spent'),
'data' => [],
],
],
'count' => 1,
];
foreach ($entries as $label => $entry) {
// data set 0 is budgeted
// data set 1 is spent:
$data['datasets'][0]['data'][] = round(($entry['spent'] * -1), 2);
}
return $data;
}
}

View File

@@ -78,6 +78,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$auditData[$id]['dayBeforeBalance'] = $dayBeforeBalance;
}
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
$reportType = 'audit';
$accountIds = join(',', $this->accounts->pluck('id')->toArray());
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date',
@@ -87,10 +88,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
'from', 'to', 'budget', 'category', 'bill',
// more new optional fields
'internal_reference', 'notes',
'create_date', 'update_date',
];
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)