mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
Auto commit for release 'develop' on 2024-12-27
This commit is contained in:
@@ -426,7 +426,7 @@ class AccountController extends Controller
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
||||
// collect and filter balances for the entire period.
|
||||
|
||||
@@ -111,7 +111,7 @@ class BillController extends Controller
|
||||
$cache->addProperty($bill->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($budget->id);
|
||||
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
|
||||
$collection = new Collection([$budget]);
|
||||
@@ -164,15 +164,15 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($budget->id);
|
||||
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
$entries = [];
|
||||
$amount = $budgetLimit->amount;
|
||||
$budgetCollection = new Collection([$budget]);
|
||||
$currency = $budgetLimit->transactionCurrency;
|
||||
if($this->convertToNative) {
|
||||
$amount = $budgetLimit->native_amount;
|
||||
if ($this->convertToNative) {
|
||||
$amount = $budgetLimit->native_amount;
|
||||
$currency = $this->defaultCurrency;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($end);
|
||||
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$collector->setRange($start, $end);
|
||||
$collector->setBudget($budget);
|
||||
@@ -232,22 +232,22 @@ class BudgetController extends Controller
|
||||
// group by asset account ID:
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $journal['currency_id']);
|
||||
$amount = $journal['amount'];
|
||||
$amount = $journal['amount'];
|
||||
|
||||
// if convert to native, use the native things, unless it's the foreign amount which is in the native currency.
|
||||
if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['native_amount'];
|
||||
}
|
||||
|
||||
if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
@@ -312,26 +312,26 @@ class BudgetController extends Controller
|
||||
$chartData = [];
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
|
||||
$symbol = $journal['currency_symbol'];
|
||||
$code = $journal['currency_code'];
|
||||
$name = $journal['currency_name'];
|
||||
$amount = $journal['amount'];
|
||||
$symbol = $journal['currency_symbol'];
|
||||
$code = $journal['currency_code'];
|
||||
$name = $journal['currency_name'];
|
||||
$amount = $journal['amount'];
|
||||
// if convert to native, use the native things, unless it's the foreign amount which is in the native currency.
|
||||
if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id
|
||||
) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id);
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['native_amount'];
|
||||
}
|
||||
|
||||
if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id
|
||||
) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id);
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($end);
|
||||
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$collector->setRange($start, $end);
|
||||
$collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();
|
||||
@@ -396,22 +396,22 @@ class BudgetController extends Controller
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']);
|
||||
$amount = $journal['amount'];
|
||||
$amount = $journal['amount'];
|
||||
|
||||
// if convert to native, use the native things, unless it's the foreign amount which is in the native currency.
|
||||
if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['native_amount'];
|
||||
}
|
||||
|
||||
if($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ class BudgetController extends Controller
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $symbol,
|
||||
'currency_code' => $code,
|
||||
'currency_name' => $name
|
||||
'currency_name' => $name,
|
||||
];
|
||||
$result[$key]['amount'] = bcadd($amount, $result[$key]['amount']);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty('chart.budget.frontpage');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
Log::debug('Regenerate frontpage chart from scratch.');
|
||||
$chartGenerator = app(FrontpageChartGenerator::class);
|
||||
|
||||
@@ -70,27 +70,27 @@ class CategoryController extends Controller
|
||||
public function all(Category $category): JsonResponse
|
||||
{
|
||||
// cache results:
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('chart.category.all');
|
||||
$cache->addProperty($category->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
||||
/** @var CategoryRepositoryInterface $repository */
|
||||
$repository = app(CategoryRepositoryInterface::class);
|
||||
$start = $repository->firstUseDate($category) ?? $this->getDate();
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
$start = app('navigation')->startOfPeriod($start, $range);
|
||||
$end = $this->getDate();
|
||||
$repository = app(CategoryRepositoryInterface::class);
|
||||
$start = $repository->firstUseDate($category) ?? $this->getDate();
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
$start = app('navigation')->startOfPeriod($start, $range);
|
||||
$end = $this->getDate();
|
||||
|
||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||
$chartGenerator->convertToNative = $this->convertToNative;
|
||||
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
@@ -107,16 +107,16 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function frontPage(): JsonResponse
|
||||
{
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty('chart.category.frontpage');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
||||
$frontpageGenerator = new FrontpageChartGenerator($start, $end);
|
||||
@@ -141,9 +141,9 @@ class CategoryController extends Controller
|
||||
$cache->addProperty($category);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$data = $this->reportPeriodChart($accounts, $start, $end, $category);
|
||||
$data = $this->reportPeriodChart($accounts, $start, $end, $category);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
@@ -164,8 +164,8 @@ class CategoryController extends Controller
|
||||
$noCatRepository = app(NoCategoryRepositoryInterface::class);
|
||||
|
||||
// this gives us all currencies
|
||||
$expenses = $noCatRepository->listExpenses($start, $end, $accounts);
|
||||
$income = $noCatRepository->listIncome($start, $end, $accounts);
|
||||
$expenses = $noCatRepository->listExpenses($start, $end, $accounts);
|
||||
$income = $noCatRepository->listIncome($start, $end, $accounts);
|
||||
}
|
||||
|
||||
if (null !== $category) {
|
||||
@@ -173,9 +173,9 @@ class CategoryController extends Controller
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$categoryId = $category->id;
|
||||
// this gives us all currencies
|
||||
$collection = new Collection([$category]);
|
||||
$expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection);
|
||||
$income = $opsRepository->listIncome($start, $end, $accounts, $collection);
|
||||
$collection = new Collection([$category]);
|
||||
$expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection);
|
||||
$income = $opsRepository->listIncome($start, $end, $accounts, $collection);
|
||||
}
|
||||
$currencies = array_unique(array_merge(array_keys($income), array_keys($expenses)));
|
||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||
@@ -189,19 +189,19 @@ class CategoryController extends Controller
|
||||
$inKey = sprintf('%d-in', $currencyId);
|
||||
$chartData[$outKey]
|
||||
= [
|
||||
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||
];
|
||||
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||
];
|
||||
|
||||
$chartData[$inKey]
|
||||
= [
|
||||
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||
];
|
||||
= [
|
||||
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||
];
|
||||
// loop empty periods:
|
||||
foreach (array_keys($periods) as $period) {
|
||||
$label = $periods[$period];
|
||||
@@ -209,7 +209,7 @@ class CategoryController extends Controller
|
||||
$chartData[$inKey]['entries'][$label] = '0';
|
||||
}
|
||||
// loop income and expenses for this category.:
|
||||
$outSet = $expenses[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []];
|
||||
$outSet = $expenses[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []];
|
||||
foreach ($outSet['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$date = $journal['date']->isoFormat($format);
|
||||
@@ -218,7 +218,7 @@ class CategoryController extends Controller
|
||||
$chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]);
|
||||
}
|
||||
|
||||
$inSet = $income[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []];
|
||||
$inSet = $income[$currencyId]['categories'][$categoryId] ?? ['transaction_journals' => []];
|
||||
foreach ($inSet['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$date = $journal['date']->isoFormat($format);
|
||||
@@ -244,7 +244,7 @@ class CategoryController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$data = $this->reportPeriodChart($accounts, $start, $end, null);
|
||||
$data = $this->reportPeriodChart($accounts, $start, $end, null);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
@@ -259,14 +259,14 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function specificPeriod(Category $category, Carbon $date): JsonResponse
|
||||
{
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
$start = app('navigation')->startOfPeriod($date, $range);
|
||||
$end = session()->get('end');
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
$start = app('navigation')->startOfPeriod($date, $range);
|
||||
$end = session()->get('end');
|
||||
if ($end < $start) {
|
||||
[$end, $start] = [$start, $end];
|
||||
}
|
||||
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($category->id);
|
||||
|
||||
@@ -145,7 +145,7 @@ class ReportController extends Controller
|
||||
$cache->addProperty($accounts);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
||||
Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());
|
||||
|
||||
Reference in New Issue
Block a user