mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
🤖 Auto commit for release 'develop' on 2025-09-26
This commit is contained in:
@@ -181,7 +181,7 @@ class FrontpageChartGenerator
|
||||
Log::debug(sprintf('Processing limit #%d with %s %s', $limit->id, $limit->transactionCurrency->code, $limit->amount));
|
||||
}
|
||||
|
||||
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
|
||||
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
|
||||
Log::debug(sprintf('Spent array has %d entries.', count($spent)));
|
||||
|
||||
/** @var array $entry */
|
||||
@@ -208,7 +208,7 @@ class FrontpageChartGenerator
|
||||
*/
|
||||
private function processRow(array $data, Budget $budget, BudgetLimit $limit, array $entry): array
|
||||
{
|
||||
$title = sprintf('%s (%s)', $budget->name, $entry['currency_name']);
|
||||
$title = sprintf('%s (%s)', $budget->name, $entry['currency_name']);
|
||||
Log::debug(sprintf('Title is "%s"', $title));
|
||||
if ($limit->start_date->startOfDay()->ne($this->start->startOfDay()) || $limit->end_date->startOfDay()->ne($this->end->startOfDay())) {
|
||||
$title = sprintf(
|
||||
@@ -219,8 +219,8 @@ class FrontpageChartGenerator
|
||||
$limit->end_date->isoFormat($this->monthAndDayFormat)
|
||||
);
|
||||
}
|
||||
$usePrimary = $this->convertToPrimary && $this->default->id !== $limit->transaction_currency_id;
|
||||
$amount = $limit->amount;
|
||||
$usePrimary = $this->convertToPrimary && $this->default->id !== $limit->transaction_currency_id;
|
||||
$amount = $limit->amount;
|
||||
Log::debug(sprintf('Amount is "%s".', $amount));
|
||||
if ($usePrimary && $limit->transaction_currency_id !== $this->default->id) {
|
||||
$amount = $limit->native_amount;
|
||||
|
@@ -65,16 +65,16 @@ class FrontpageChartGenerator
|
||||
public function generate(): array
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$categories = $this->repository->getCategories();
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]);
|
||||
$collection = $this->collectExpensesAll($categories, $accounts);
|
||||
$categories = $this->repository->getCategories();
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]);
|
||||
$collection = $this->collectExpensesAll($categories, $accounts);
|
||||
|
||||
// collect for no-category:
|
||||
$noCategory = $this->collectNoCatExpenses($accounts);
|
||||
$collection = array_merge($collection, $noCategory);
|
||||
$noCategory = $this->collectNoCatExpenses($accounts);
|
||||
$collection = array_merge($collection, $noCategory);
|
||||
|
||||
// sort temp array by amount.
|
||||
$amounts = array_column($collection, 'sum_float');
|
||||
$amounts = array_column($collection, 'sum_float');
|
||||
array_multisort($amounts, SORT_ASC, $collection);
|
||||
|
||||
$currencyData = $this->createCurrencyGroups($collection);
|
||||
|
@@ -40,22 +40,22 @@ class WholePeriodChartGenerator
|
||||
|
||||
public function generate(Category $category, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$collection = new Collection()->push($category);
|
||||
$collection = new Collection()->push($category);
|
||||
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
$types = [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
|
||||
$accounts = $accountRepository->getAccountsByType($types);
|
||||
$step = $this->calculateStep($start, $end);
|
||||
$chartData = [];
|
||||
$spent = [];
|
||||
$earned = [];
|
||||
$types = [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
|
||||
$accounts = $accountRepository->getAccountsByType($types);
|
||||
$step = $this->calculateStep($start, $end);
|
||||
$chartData = [];
|
||||
$spent = [];
|
||||
$earned = [];
|
||||
|
||||
$current = clone $start;
|
||||
$current = clone $start;
|
||||
|
||||
while ($current <= $end) {
|
||||
$key = $current->format('Y-m-d');
|
||||
@@ -65,14 +65,14 @@ class WholePeriodChartGenerator
|
||||
$current = app('navigation')->addPeriod($current, $step, 0);
|
||||
}
|
||||
|
||||
$currencies = $this->extractCurrencies($spent) + $this->extractCurrencies($earned);
|
||||
$currencies = $this->extractCurrencies($spent) + $this->extractCurrencies($earned);
|
||||
|
||||
// generate chart data (for each currency)
|
||||
/** @var array $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
$code = $currency['currency_code'];
|
||||
$name = $currency['currency_name'];
|
||||
$chartData[sprintf('spent-in-%s', $code)] = [
|
||||
$code = $currency['currency_code'];
|
||||
$name = $currency['currency_name'];
|
||||
$chartData[sprintf('spent-in-%s', $code)] = [
|
||||
'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $name]),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
@@ -87,11 +87,11 @@ class WholePeriodChartGenerator
|
||||
];
|
||||
}
|
||||
|
||||
$current = clone $start;
|
||||
$current = clone $start;
|
||||
|
||||
while ($current <= $end) {
|
||||
$key = $current->format('Y-m-d');
|
||||
$label = app('navigation')->periodShow($current, $step);
|
||||
$key = $current->format('Y-m-d');
|
||||
$label = app('navigation')->periodShow($current, $step);
|
||||
|
||||
/** @var array $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
|
@@ -49,7 +49,7 @@ class ChartData
|
||||
if (array_key_exists('primary_currency_id', $data)) {
|
||||
$data['primary_currency_id'] = (string)$data['primary_currency_id'];
|
||||
}
|
||||
$required = ['start', 'date', 'end', 'entries'];
|
||||
$required = ['start', 'date', 'end', 'entries'];
|
||||
foreach ($required as $field) {
|
||||
if (!array_key_exists($field, $data)) {
|
||||
throw new FireflyException(sprintf('Data-set is missing the "%s"-variable.', $field));
|
||||
|
Reference in New Issue
Block a user