mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 14:46:37 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DoubleController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -70,10 +71,10 @@ class DoubleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -88,21 +89,21 @@ class DoubleController extends Controller
|
||||
$sourceId = $journal['source_account_id'];
|
||||
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'transactions' => 0,
|
||||
'sum' => '0',
|
||||
'avg' => '0',
|
||||
'avg_float' => 0,
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
'transactions' => 0,
|
||||
'sum' => '0',
|
||||
'avg' => '0',
|
||||
'avg_float' => 0,
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
'source_account_id' => $journal['source_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$result[$key]['transactions']++;
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
@@ -122,10 +123,10 @@ class DoubleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -140,21 +141,21 @@ class DoubleController extends Controller
|
||||
$destinationId = $journal['destination_account_id'];
|
||||
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'transactions' => 0,
|
||||
'sum' => '0',
|
||||
'avg' => '0',
|
||||
'avg_float' => 0,
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
'transactions' => 0,
|
||||
'sum' => '0',
|
||||
'avg' => '0',
|
||||
'avg_float' => 0,
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
'destination_account_id' => $journal['destination_account_id'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$result[$key]['transactions']++;
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
@@ -174,10 +175,10 @@ class DoubleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $double
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $double
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -197,15 +198,15 @@ class DoubleController extends Controller
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
@@ -215,19 +216,19 @@ class DoubleController extends Controller
|
||||
$genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban);
|
||||
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'dest_name' => '',
|
||||
'dest_iban' => '',
|
||||
'source_name' => '',
|
||||
'source_iban' => '',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
'dest_name' => '',
|
||||
'dest_iban' => '',
|
||||
'source_name' => '',
|
||||
'source_iban' => '',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
// set name
|
||||
$report[$objectName]['dest_name'] = $destName;
|
||||
$report[$objectName]['dest_iban'] = $destIban;
|
||||
@@ -245,15 +246,15 @@ class DoubleController extends Controller
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
@@ -263,19 +264,19 @@ class DoubleController extends Controller
|
||||
$genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban);
|
||||
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'dest_name' => '',
|
||||
'dest_iban' => '',
|
||||
'source_name' => '',
|
||||
'source_iban' => '',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
'dest_name' => '',
|
||||
'dest_iban' => '',
|
||||
'source_name' => '',
|
||||
'source_iban' => '',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
|
||||
// set name
|
||||
$report[$objectName]['source_name'] = $sourceName;
|
||||
@@ -295,10 +296,10 @@ class DoubleController extends Controller
|
||||
/**
|
||||
* TODO this method is duplicated.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string|null $iban
|
||||
* @param Collection $accounts
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param string|null $iban
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -318,10 +319,10 @@ class DoubleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $double
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $double
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -341,31 +342,31 @@ class DoubleController extends Controller
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'account_id' => $journal['source_account_id'],
|
||||
'account_name' => $objectName,
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
'account_id' => $journal['source_account_id'],
|
||||
'account_name' => $objectName,
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
// set name
|
||||
// add amounts:
|
||||
$report[$objectName]['spent'] = bcadd($report[$objectName]['spent'], $journal['amount']);
|
||||
@@ -380,31 +381,31 @@ class DoubleController extends Controller
|
||||
$currencyId = $currency['currency_id'];
|
||||
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? [
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
|
||||
$report[$objectName] = $report[$objectName] ?? [
|
||||
'account_id' => $journal['destination_account_id'],
|
||||
'account_name' => $objectName,
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
'account_id' => $journal['destination_account_id'],
|
||||
'account_name' => $objectName,
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'currency_name' => $currency['currency_name'],
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'sum' => '0',
|
||||
];
|
||||
|
||||
// add amounts:
|
||||
$report[$objectName]['earned'] = bcadd($report[$objectName]['earned'], $journal['amount']);
|
||||
@@ -418,10 +419,10 @@ class DoubleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -436,7 +437,7 @@ class DoubleController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
@@ -468,10 +469,10 @@ class DoubleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $doubles
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -486,7 +487,7 @@ class DoubleController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
|
Reference in New Issue
Block a user