mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-17 15:18:05 +00:00
Code cleanup that (hopefully) matches style CI
This commit is contained in:
@@ -118,7 +118,8 @@ class BudgetController extends Controller
|
||||
= $report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']]
|
||||
?? '0';
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']],
|
||||
$journal['amount']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +173,8 @@ class BudgetController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
|
||||
}
|
||||
@@ -214,8 +216,8 @@ class BudgetController extends Controller
|
||||
];
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -295,11 +297,11 @@ class BudgetController extends Controller
|
||||
$pct = '0';
|
||||
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
|
||||
$pct = round(bcmul(bcdiv($sum, $total), '100'));
|
||||
|
||||
}
|
||||
$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;
|
||||
}
|
||||
}
|
||||
|
||||
return view('reports.budget.partials.budgets', compact('sums', 'report'));
|
||||
}
|
||||
|
||||
@@ -323,7 +325,7 @@ class BudgetController extends Controller
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$budgetId = (int)$budget->id;
|
||||
$budgetId = (int) $budget->id;
|
||||
$report['budgets'][$budgetId] = $report['budgets'][$budgetId] ?? [
|
||||
'budget_id' => $budgetId,
|
||||
'budget_name' => $budget->name,
|
||||
@@ -335,9 +337,9 @@ class BudgetController extends Controller
|
||||
$limits = $this->blRepository->getBudgetLimits($budget, $start, $end);
|
||||
/** @var BudgetLimit $limit */
|
||||
foreach ($limits as $limit) {
|
||||
$limitId = (int)$limit->id;
|
||||
$limitId = (int) $limit->id;
|
||||
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||
$currencyId = (int)$currency->id;
|
||||
$currencyId = (int) $currency->id;
|
||||
$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $accounts, new Collection([$budget]));
|
||||
$spent = $expenses[$currencyId]['sum'] ?? '0';
|
||||
$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);
|
||||
@@ -392,7 +394,7 @@ class BudgetController extends Controller
|
||||
foreach ($noBudget as $noBudgetEntry) {
|
||||
|
||||
// currency information:
|
||||
$nbCurrencyId = (int)($noBudgetEntry['currency_id'] ?? $defaultCurrency->id);
|
||||
$nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $defaultCurrency->id);
|
||||
$nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $defaultCurrency->code;
|
||||
$nbCurrencyName = $noBudgetEntry['currency_name'] ?? $defaultCurrency->name;
|
||||
$nbCurrencySymbol = $noBudgetEntry['currency_symbol'] ?? $defaultCurrency->symbol;
|
||||
@@ -426,14 +428,13 @@ class BudgetController extends Controller
|
||||
$report['sums'][$nbCurrencyId]['overspent'] = $report['sums'][$nbCurrencyId]['overspent'] ?? '0';
|
||||
$report['sums'][$nbCurrencyId]['left'] = $report['sums'][$nbCurrencyId]['left'] ?? '0';
|
||||
$report['sums'][$nbCurrencyId]['budgeted'] = $report['sums'][$nbCurrencyId]['budgeted'] ?? '0';
|
||||
|
||||
}
|
||||
// make percentages based on total amount.
|
||||
foreach ($report['budgets'] as $budgetId => $data) {
|
||||
foreach ($data['budget_limits'] as $limitId => $entry) {
|
||||
$budgetId = (int)$budgetId;
|
||||
$limitId = (int)$limitId;
|
||||
$currencyId = (int)$entry['currency_id'];
|
||||
$budgetId = (int) $budgetId;
|
||||
$limitId = (int) $limitId;
|
||||
$currencyId = (int) $entry['currency_id'];
|
||||
$spent = $entry['spent'];
|
||||
$totalSpent = $report['sums'][$currencyId]['spent'] ?? '0';
|
||||
$spentPct = '0';
|
||||
@@ -504,8 +505,8 @@ class BudgetController extends Controller
|
||||
];
|
||||
$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';
|
||||
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
|
||||
$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
|
||||
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)$count);
|
||||
$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
|
||||
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string) $count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,7 +542,7 @@ class BudgetController 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']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
@@ -571,5 +572,4 @@ class BudgetController extends Controller
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,10 +114,12 @@ class CategoryController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['sum'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['sum'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -152,10 +154,12 @@ class CategoryController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'] = bcadd(
|
||||
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'], $journal['amount']
|
||||
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['sum'] = bcadd(
|
||||
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['sum'], $journal['amount']
|
||||
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -214,10 +218,12 @@ class CategoryController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['spent'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['spent'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['spent'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
$sums[$currencyId]['spent_sum'] = bcadd($sums[$currencyId]['spent_sum'], $journal['amount']);
|
||||
$sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);
|
||||
@@ -250,10 +256,12 @@ class CategoryController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['earned'] = bcadd(
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['earned'], $journal['amount']
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['earned'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
$sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);
|
||||
$sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);
|
||||
@@ -296,8 +304,8 @@ class CategoryController extends Controller
|
||||
];
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,8 +357,8 @@ class CategoryController extends Controller
|
||||
];
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -420,10 +428,12 @@ class CategoryController extends Controller
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$report[$categoryId]['currencies'][$currencyId]['spent'] = bcadd(
|
||||
$report[$categoryId]['currencies'][$currencyId]['spent'], $journal['amount']
|
||||
$report[$categoryId]['currencies'][$currencyId]['spent'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$categoryId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$categoryId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$categoryId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
|
||||
$sums[$currencyId]['spent_sum'] = bcadd($sums[$currencyId]['spent_sum'], $journal['amount']);
|
||||
@@ -459,10 +469,12 @@ class CategoryController extends Controller
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$report[$categoryId]['currencies'][$currencyId]['earned'] = bcadd(
|
||||
$report[$categoryId]['currencies'][$currencyId]['earned'], $journal['amount']
|
||||
$report[$categoryId]['currencies'][$currencyId]['earned'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$categoryId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$categoryId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$categoryId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
|
||||
$sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);
|
||||
@@ -517,31 +529,31 @@ class CategoryController extends Controller
|
||||
$data = [];
|
||||
$with = $opsRepository->listExpenses($start, $end, $accounts);
|
||||
$without = $noCatRepos->listExpenses($start, $end, $accounts);
|
||||
foreach([$with, $without] as $set) {
|
||||
foreach ($set as $currencyId => $currencyRow) {
|
||||
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
|
||||
$key = sprintf('%d-%d', $currencyId, $categoryId);
|
||||
$data[$key] = $data[$key] ?? [
|
||||
'id' => $categoryRow['id'],
|
||||
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
|
||||
'currency_id' => $currencyRow['currency_id'],
|
||||
'currency_symbol' => $currencyRow['currency_symbol'],
|
||||
'currency_name' => $currencyRow['currency_name'],
|
||||
'currency_code' => $currencyRow['currency_code'],
|
||||
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
|
||||
'sum' => '0',
|
||||
'entries' => [],
|
||||
foreach ([$with, $without] as $set) {
|
||||
foreach ($set as $currencyId => $currencyRow) {
|
||||
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
|
||||
$key = sprintf('%d-%d', $currencyId, $categoryId);
|
||||
$data[$key] = $data[$key] ?? [
|
||||
'id' => $categoryRow['id'],
|
||||
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
|
||||
'currency_id' => $currencyRow['currency_id'],
|
||||
'currency_symbol' => $currencyRow['currency_symbol'],
|
||||
'currency_name' => $currencyRow['currency_name'],
|
||||
'currency_code' => $currencyRow['currency_code'],
|
||||
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
|
||||
'sum' => '0',
|
||||
'entries' => [],
|
||||
|
||||
];
|
||||
foreach ($categoryRow['transaction_journals'] as $journalId => $journal) {
|
||||
$date = $journal['date']->format($format);
|
||||
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';
|
||||
$data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']);
|
||||
$data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']);
|
||||
];
|
||||
foreach ($categoryRow['transaction_journals'] as $journalId => $journal) {
|
||||
$date = $journal['date']->format($format);
|
||||
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';
|
||||
$data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']);
|
||||
$data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
@@ -603,7 +615,7 @@ class CategoryController extends Controller
|
||||
$data = [];
|
||||
$with = $opsRepository->listIncome($start, $end, $accounts);
|
||||
$without = $noCatRepos->listIncome($start, $end, $accounts);
|
||||
foreach([$with, $without] as $set) {
|
||||
foreach ([$with, $without] as $set) {
|
||||
foreach ($set as $currencyId => $currencyRow) {
|
||||
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
|
||||
$key = sprintf('%d-%d', $currencyId, $categoryId);
|
||||
@@ -722,22 +734,26 @@ class CategoryController extends Controller
|
||||
$report['sums'][$currencyId]['sum'] = bcadd($report['sums'][$currencyId]['sum'], $journal['amount']);
|
||||
// sum of spent:
|
||||
$report['sums'][$currencyId]['spent'] = -1 === bccomp($journal['amount'], '0') ? bcadd(
|
||||
$report['sums'][$currencyId]['spent'], $journal['amount']
|
||||
$report['sums'][$currencyId]['spent'],
|
||||
$journal['amount']
|
||||
) : $report['sums'][$currencyId]['spent'];
|
||||
// sum of earned
|
||||
$report['sums'][$currencyId]['earned'] = 1 === bccomp($journal['amount'], '0') ? bcadd(
|
||||
$report['sums'][$currencyId]['earned'], $journal['amount']
|
||||
$report['sums'][$currencyId]['earned'],
|
||||
$journal['amount']
|
||||
) : $report['sums'][$currencyId]['earned'];
|
||||
|
||||
// sum of category
|
||||
$report['categories'][$key]['sum'] = bcadd($report['categories'][$key]['sum'], $journal['amount']);
|
||||
// total spent in category
|
||||
$report['categories'][$key]['spent'] = -1 === bccomp($journal['amount'], '0') ? bcadd(
|
||||
$report['categories'][$key]['spent'], $journal['amount']
|
||||
$report['categories'][$key]['spent'],
|
||||
$journal['amount']
|
||||
) : $report['categories'][$key]['spent'];
|
||||
// total earned in category
|
||||
$report['categories'][$key]['earned'] = 1 === bccomp($journal['amount'], '0') ? bcadd(
|
||||
$report['categories'][$key]['earned'], $journal['amount']
|
||||
$report['categories'][$key]['earned'],
|
||||
$journal['amount']
|
||||
) : $report['categories'][$key]['earned'];
|
||||
}
|
||||
}
|
||||
@@ -777,7 +793,7 @@ class CategoryController 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']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
@@ -827,7 +843,7 @@ class CategoryController 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']->formatLocalized($this->monthAndDayFormat),
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
@@ -871,6 +887,4 @@ class CategoryController extends Controller
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ class DoubleController extends Controller
|
||||
];
|
||||
$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
|
||||
@@ -152,8 +152,8 @@ class DoubleController extends Controller
|
||||
];
|
||||
$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
|
||||
@@ -410,7 +410,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']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
@@ -459,7 +459,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']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
@@ -773,10 +773,10 @@ class DoubleController extends Controller
|
||||
/**
|
||||
* TODO this method is double.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Report;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -112,10 +111,12 @@ class TagController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['sum'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['sum'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -150,10 +151,12 @@ class TagController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'] = bcadd(
|
||||
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'], $journal['amount']
|
||||
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['sum'] = bcadd(
|
||||
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['sum'], $journal['amount']
|
||||
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -212,10 +215,12 @@ class TagController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['spent'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['spent'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['spent'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$sourceAccountId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
$sums[$currencyId]['spent_sum'] = bcadd($sums[$currencyId]['spent_sum'], $journal['amount']);
|
||||
$sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);
|
||||
@@ -248,10 +253,12 @@ class TagController extends Controller
|
||||
'sum' => '0',
|
||||
];
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['earned'] = bcadd(
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['earned'], $journal['amount']
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['earned'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$destinationAccountId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
$sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);
|
||||
$sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);
|
||||
@@ -294,8 +301,8 @@ class TagController extends Controller
|
||||
];
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,8 +354,8 @@ class TagController extends Controller
|
||||
];
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,10 +425,12 @@ class TagController extends Controller
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$report[$tagId]['currencies'][$currencyId]['spent'] = bcadd(
|
||||
$report[$tagId]['currencies'][$currencyId]['spent'], $journal['amount']
|
||||
$report[$tagId]['currencies'][$currencyId]['spent'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$tagId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$tagId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$tagId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
|
||||
$sums[$currencyId]['spent_sum'] = bcadd($sums[$currencyId]['spent_sum'], $journal['amount']);
|
||||
@@ -457,10 +466,12 @@ class TagController extends Controller
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
];
|
||||
$report[$tagId]['currencies'][$currencyId]['earned'] = bcadd(
|
||||
$report[$tagId]['currencies'][$currencyId]['earned'], $journal['amount']
|
||||
$report[$tagId]['currencies'][$currencyId]['earned'],
|
||||
$journal['amount']
|
||||
);
|
||||
$report[$tagId]['currencies'][$currencyId]['sum'] = bcadd(
|
||||
$report[$tagId]['currencies'][$currencyId]['sum'], $journal['amount']
|
||||
$report[$tagId]['currencies'][$currencyId]['sum'],
|
||||
$journal['amount']
|
||||
);
|
||||
|
||||
$sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);
|
||||
@@ -491,7 +502,7 @@ class TagController 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']->formatLocalized($this->monthAndDayFormat),
|
||||
'destination_account_name' => $journal['destination_account_name'],
|
||||
@@ -541,7 +552,7 @@ class TagController 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']->formatLocalized($this->monthAndDayFormat),
|
||||
'source_account_name' => $journal['source_account_name'],
|
||||
@@ -571,5 +582,4 @@ class TagController extends Controller
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user