Auto commit for release 'develop' on 2024-12-27

This commit is contained in:
github-actions
2024-12-27 22:03:16 +01:00
parent 2dddaa36d5
commit 23c4352c18
18 changed files with 316 additions and 310 deletions

View File

@@ -162,7 +162,7 @@ class IndexController extends Controller
private function getAllAvailableBudgets(Carbon $start, Carbon $end): array
{
$converter = new ExchangeRateConverter();
$converter = new ExchangeRateConverter();
// get all available budgets.
$ab = $this->abRepository->get($start, $end);
$availableBudgets = [];
@@ -170,24 +170,25 @@ class IndexController extends Controller
// for each, complement with spent amount:
/** @var AvailableBudget $entry */
foreach ($ab as $entry) {
$array = $entry->toArray();
$array['start_date'] = $entry->start_date;
$array['end_date'] = $entry->end_date;
$array = $entry->toArray();
$array['start_date'] = $entry->start_date;
$array['end_date'] = $entry->end_date;
// spent in period:
$spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency);
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
$array['native_spent'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $array['spent']) : null;
$spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency);
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
$array['native_spent'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $array['spent']) : null;
// budgeted in period:
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency);
$array['budgeted'] = $budgeted;
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency);
$array['budgeted'] = $budgeted;
$array['native_budgeted'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $budgeted) : null;
// this time, because of complex sums, use the currency converter.
$availableBudgets[] = $array;
$availableBudgets[] = $array;
unset($spentArr);
}
return $availableBudgets;
}

View File

@@ -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.

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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());

View File

@@ -95,7 +95,7 @@ class JavascriptController extends Controller
public function variables(Request $request, AccountRepositoryInterface $repository): Response
{
$account = $repository->find((int) $request->get('account'));
$currency = $this->defaultCurrency;
$currency = $this->defaultCurrency;
if (null !== $account) {
$currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency;
}