Code cleanup that (hopefully) matches style CI

This commit is contained in:
James Cole
2020-03-17 14:57:04 +01:00
parent b0c9fc0792
commit bd2f064eeb
30 changed files with 318 additions and 298 deletions

View File

@@ -63,7 +63,7 @@ class ChartJsGenerator implements GeneratorInterface
$amounts = array_column($data, 'amount');
$next = next($amounts);
$sortFlag = SORT_ASC;
if (!is_bool($next) && 1 === bccomp((string)$next, '0')) {
if (!is_bool($next) && 1 === bccomp((string) $next, '0')) {
$sortFlag = SORT_DESC;
}
array_multisort($amounts, $sortFlag, $data);
@@ -72,7 +72,7 @@ class ChartJsGenerator implements GeneratorInterface
$index = 0;
foreach ($data as $key => $valueArray) {
// make larger than 0
$chartData['datasets'][0]['data'][] = (float)app('steam')->positive((string)$valueArray['amount']);
$chartData['datasets'][0]['data'][] = (float) app('steam')->positive((string) $valueArray['amount']);
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['datasets'][0]['currency_symbol'][] = $valueArray['currency_symbol'];
$chartData['labels'][] = $key;
@@ -178,7 +178,7 @@ class ChartJsGenerator implements GeneratorInterface
// different sort when values are positive and when they're negative.
asort($data);
$next = next($data);
if (!is_bool($next) && 1 === bccomp((string)$next, '0')) {
if (!is_bool($next) && 1 === bccomp((string) $next, '0')) {
// next is positive, sort other way around.
arsort($data);
}
@@ -187,7 +187,7 @@ class ChartJsGenerator implements GeneratorInterface
$index = 0;
foreach ($data as $key => $value) {
// make larger than 0
$chartData['datasets'][0]['data'][] = (float)app('steam')->positive((string)$value);
$chartData['datasets'][0]['data'][] = (float) app('steam')->positive((string) $value);
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['labels'][] = $key;

View File

@@ -52,14 +52,14 @@ class MonthReportGenerator implements ReportGeneratorInterface
public function generate(): string
{
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$doubleIds = implode(',', $this->expense->pluck('id')->toArray());
$doubleIds = implode(',', $this->expense->pluck('id')->toArray());
$reportType = 'account';
$preferredPeriod = $this->preferredPeriod();
try {
$result = view('reports.double.report', compact('accountIds', 'reportType', 'doubleIds', 'preferredPeriod'))
->with('start', $this->start)->with('end', $this->end)
->with('doubles', $this->expense)
->render();
->with('doubles', $this->expense)
->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage()));
$result = sprintf('Could not render report view: %s', $e->getMessage());

View File

@@ -51,9 +51,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generates the report.
*
* @return string
* @throws FireflyException
* @codeCoverageIgnore
* @return string
*/
public function generate(): string
{
@@ -100,9 +100,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
* @param Account $account
* @param Carbon $date
*
* @throws FireflyException
* @return array
*
* @throws FireflyException
*/
public function getAuditReport(Account $account, Carbon $date): array
{
@@ -117,7 +117,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation()
->withBudgetInformation()->withCategoryInformation()->withBillInformation();
->withBudgetInformation()->withCategoryInformation()->withBillInformation();
$journals = $collector->getExtractedJournals();
$journals = array_reverse($journals, true);
$dayBeforeBalance = app('steam')->balance($account, $date);
@@ -159,9 +159,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
'journals' => $journals,
'currency' => $currency,
'exists' => count($journals) > 0,
'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
'end' => $this->end->formatLocalized((string) trans('config.month_and_day')),
'endBalance' => app('steam')->balance($account, $this->end),
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day')),
'dayBeforeBalance' => $dayBeforeBalance,
];

View File

@@ -76,7 +76,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
// render!
try {
return view('reports.category.month', compact('accountIds', 'categoryIds', 'reportType',))
return view('reports.category.month', compact('accountIds', 'categoryIds', 'reportType', ))
->with('start', $this->start)->with('end', $this->end)
->with('categories', $this->categories)
->with('accounts', $this->accounts)

View File

@@ -39,9 +39,9 @@ class ReportGeneratorFactory
* @param Carbon $start
* @param Carbon $end
*
* @throws FireflyException
* @return ReportGeneratorInterface
*
* @throws FireflyException
*/
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
{

View File

@@ -76,7 +76,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
// render!
try {
$result = view(
'reports.tag.month', compact('accountIds', 'reportType', 'tagIds')
'reports.tag.month',
compact('accountIds', 'reportType', 'tagIds')
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
@@ -177,6 +178,4 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $this;
}
}