mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix some charts.
This commit is contained in:
parent
6f78735bc5
commit
7f887e294a
@ -81,7 +81,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('chart.category.all');
|
||||
$cache->addProperty($category->id);
|
||||
if ($cache->has()) {
|
||||
//return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
$start = $repository->firstUseDate($category) ?? $this->getDate();
|
||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||
@ -216,7 +216,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($category);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());// @codeCoverageIgnore
|
||||
return response()->json($cache->get());// @codeCoverageIgnore
|
||||
}
|
||||
$repository = app(CategoryRepositoryInterface::class);
|
||||
$expenses = $repository->periodExpenses(new Collection([$category]), $accounts, $start, $end);
|
||||
@ -248,7 +248,7 @@ class CategoryController extends Controller
|
||||
$spent = $expenses[$category->id]['entries'][$period] ?? '0';
|
||||
$earned = $income[$category->id]['entries'][$period] ?? '0';
|
||||
$sum = bcadd($spent, $earned);
|
||||
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
|
||||
$chartData[0]['entries'][$label] = round($spent, 12);
|
||||
$chartData[1]['entries'][$label] = round($earned, 12);
|
||||
$chartData[2]['entries'][$label] = round($sum, 12);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ class CategoryReportController extends Controller
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
//return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
@ -262,7 +262,7 @@ class CategoryReportController extends Controller
|
||||
$labelOut = $category->id . '-out';
|
||||
$labelSumIn = $category->id . '-total-in';
|
||||
$labelSumOut = $category->id . '-total-out';
|
||||
$currentIncome = bcmul($income[$category->id] ?? '0','-1');
|
||||
$currentIncome = $income[$category->id] ?? '0';
|
||||
$currentExpense = $expenses[$category->id] ?? '0';
|
||||
|
||||
// add to sum:
|
||||
|
@ -86,7 +86,7 @@ class ReportController extends Controller
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$filtered = $accounts->filter(
|
||||
function (Account $account) use ($accountRepository) {
|
||||
static function (Account $account) use ($accountRepository) {
|
||||
$includeNetWorth = $accountRepository->getMetaValue($account, 'include_net_worth');
|
||||
$result = null === $includeNetWorth ? true : '1' === $includeNetWorth;
|
||||
if (false === $result) {
|
||||
@ -97,6 +97,7 @@ class ReportController extends Controller
|
||||
}
|
||||
);
|
||||
|
||||
// TODO get liabilities and include those as well?
|
||||
|
||||
while ($current < $end) {
|
||||
// get balances by date, grouped by currency.
|
||||
|
@ -201,7 +201,7 @@ class TagReportController extends Controller
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
//return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
|
@ -48,7 +48,7 @@ class BillController extends Controller
|
||||
$cache->addProperty('bill-report');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
//return $cache->get(); // @codeCoverageIgnore
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
@ -57,13 +57,13 @@ class BillController extends Controller
|
||||
$report = $helper->getBillReport($accounts, $start, $end);
|
||||
|
||||
|
||||
// try {
|
||||
try {
|
||||
$result = view('reports.partials.bills', compact('report'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::debug(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage()));
|
||||
// $result = 'Could not render view.';
|
||||
// }
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
|
@ -475,6 +475,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
|
||||
|
||||
/**
|
||||
* TODO not multi currency aware.
|
||||
* @param Collection $categories
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
@ -510,7 +511,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
foreach ($journals as $journal) {
|
||||
$categoryId = (int)$journal['category_id'];
|
||||
$date = $journal['date']->format($carbonFormat);
|
||||
$data[$categoryId]['entries'][$date] = bcadd($data[$categoryId]['entries'][$date] ?? '0', $journal['amount']);
|
||||
$data[$categoryId]['entries'][$date] = bcadd($data[$categoryId]['entries'][$date] ?? '0', bcmul($journal['amount'],'-1'));
|
||||
}
|
||||
|
||||
return $data;
|
||||
@ -548,7 +549,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
if (!isset($result['entries'][$date])) {
|
||||
$result['entries'][$date] = '0';
|
||||
}
|
||||
$result['entries'][$date] = bcadd($result['entries'][$date], $journal['amount']);
|
||||
$result['entries'][$date] = bcadd($result['entries'][$date], bcmul($journal['amount'],'-1'));
|
||||
}
|
||||
Log::debug('Done looping transactions..');
|
||||
Log::debug('Finished periodIncomeNoCategory()');
|
||||
|
@ -137,6 +137,7 @@ interface CategoryRepositoryInterface
|
||||
public function lastUseDate(Category $category, Collection $accounts): ?Carbon;
|
||||
|
||||
/**
|
||||
* TODO not multi-currency
|
||||
* @param Collection $categories
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
@ -149,6 +150,7 @@ interface CategoryRepositoryInterface
|
||||
|
||||
|
||||
/**
|
||||
* TODO not multi-currency
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
@ -158,6 +160,7 @@ interface CategoryRepositoryInterface
|
||||
public function periodExpensesNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* TODO not multi-currency
|
||||
* @param Collection $categories
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
@ -168,6 +171,7 @@ interface CategoryRepositoryInterface
|
||||
public function periodIncome(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* TODO not multi-currency
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -375,7 +375,7 @@ trait PeriodOverview
|
||||
$cache->addProperty('tag-period-entries');
|
||||
$cache->addProperty($tag->id);
|
||||
if ($cache->has()) {
|
||||
// return $cache->get(); // @codeCoverageIgnore
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
/** @var array $dates */
|
||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||
|
Loading…
Reference in New Issue
Block a user