mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
🤖 Auto commit for release 'develop' on 2025-08-01
This commit is contained in:
@@ -172,22 +172,22 @@ 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, false);
|
||||
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
|
||||
$spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency, false);
|
||||
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
|
||||
$array['pc_spent'] = $this->convertToPrimary && $entry->transaction_currency_id !== $this->primaryCurrency->id ? $converter->convert($entry->transactionCurrency, $this->primaryCurrency, $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['pc_budgeted'] = $this->convertToPrimary && $entry->transaction_currency_id !== $this->primaryCurrency->id ? $converter->convert($entry->transactionCurrency, $this->primaryCurrency, $entry->start_date, $budgeted) : null;
|
||||
// this time, because of complex sums, use the currency converter.
|
||||
|
||||
|
||||
$availableBudgets[] = $array;
|
||||
$availableBudgets[] = $array;
|
||||
unset($spentArr);
|
||||
}
|
||||
|
||||
|
@@ -450,10 +450,10 @@ class BudgetController 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->convertToPrimary);
|
||||
@@ -462,15 +462,15 @@ class BudgetController extends Controller
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
Log::debug('Regenerate frontpage chart from scratch.');
|
||||
$chartGenerator = app(FrontpageChartGenerator::class);
|
||||
$chartGenerator = app(FrontpageChartGenerator::class);
|
||||
$chartGenerator->setUser(auth()->user());
|
||||
$chartGenerator->setStart($start);
|
||||
$chartGenerator->setEnd($end);
|
||||
$chartGenerator->convertToPrimary = $this->convertToPrimary;
|
||||
$chartGenerator->default = $this->primaryCurrency;
|
||||
$chartGenerator->default = $this->primaryCurrency;
|
||||
|
||||
$chartData = $chartGenerator->generate();
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$chartData = $chartGenerator->generate();
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
|
@@ -70,7 +70,7 @@ 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->convertToPrimary);
|
||||
@@ -79,18 +79,18 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/** @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 = app(WholePeriodChartGenerator::class);
|
||||
$chartGenerator->convertToPrimary = $this->convertToPrimary;
|
||||
|
||||
$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);
|
||||
|
@@ -60,7 +60,7 @@ abstract class Controller extends BaseController
|
||||
protected ?TransactionCurrency $primaryCurrency;
|
||||
protected string $monthAndDayFormat;
|
||||
protected string $monthFormat;
|
||||
protected string $redirectUrl = '/';
|
||||
protected string $redirectUrl = '/';
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
@@ -128,13 +128,13 @@ abstract class Controller extends BaseController
|
||||
$this->primaryCurrency = null;
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||
$language = Steam::getLanguage();
|
||||
$locale = Steam::getLocale();
|
||||
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
||||
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||
$language = Steam::getLanguage();
|
||||
$locale = Steam::getLocale();
|
||||
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
||||
$this->convertToPrimary = Amount::convertToPrimary();
|
||||
$page = $this->getPageName();
|
||||
$shownDemo = $this->hasSeenDemo();
|
||||
$page = $this->getPageName();
|
||||
$shownDemo = $this->hasSeenDemo();
|
||||
View::share('language', $language);
|
||||
View::share('locale', $locale);
|
||||
View::share('convertToPrimary', $this->convertToPrimary);
|
||||
|
@@ -281,16 +281,16 @@ class DebugController extends Controller
|
||||
setlocale(LC_ALL, (string) $original);
|
||||
|
||||
return [
|
||||
'user_id' => auth()->user()->id,
|
||||
'user_count' => User::count(),
|
||||
'user_flags' => $userFlags,
|
||||
'user_agent' => $userAgent,
|
||||
'user_id' => auth()->user()->id,
|
||||
'user_count' => User::count(),
|
||||
'user_flags' => $userFlags,
|
||||
'user_agent' => $userAgent,
|
||||
'primary' => Amount::getPrimaryCurrency(),
|
||||
'convert_to_primary' => Amount::convertToPrimary(),
|
||||
'locale_attempts' => $localeAttempts,
|
||||
'locale' => Steam::getLocale(),
|
||||
'language' => Steam::getLanguage(),
|
||||
'view_range' => Preferences::get('viewRange', '1M')->data,
|
||||
'locale_attempts' => $localeAttempts,
|
||||
'locale' => Steam::getLocale(),
|
||||
'language' => Steam::getLanguage(),
|
||||
'view_range' => Preferences::get('viewRange', '1M')->data,
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,6 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
@@ -43,13 +42,13 @@ class FrontpageController extends Controller
|
||||
*/
|
||||
public function piggyBanks(PiggyBankRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
$set = $repository->getPiggyBanks();
|
||||
$info = [];
|
||||
$set = $repository->getPiggyBanks();
|
||||
$info = [];
|
||||
|
||||
|
||||
/** @var PiggyBank $piggyBank */
|
||||
foreach ($set as $piggyBank) {
|
||||
$amount = $repository->getCurrentAmount($piggyBank);
|
||||
$amount = $repository->getCurrentAmount($piggyBank);
|
||||
$pcAmount = $repository->getCurrentPrimaryCurrencyAmount($piggyBank);
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
// percentage!
|
||||
@@ -59,16 +58,16 @@ class FrontpageController extends Controller
|
||||
}
|
||||
|
||||
$entry = [
|
||||
'id' => $piggyBank->id,
|
||||
'name' => $piggyBank->name,
|
||||
'amount' => $amount,
|
||||
'pc_amount' => $pcAmount,
|
||||
'target' => $piggyBank->target_amount,
|
||||
'pc_target' => $piggyBank->native_target_amount,
|
||||
'percentage' => $pct,
|
||||
'id' => $piggyBank->id,
|
||||
'name' => $piggyBank->name,
|
||||
'amount' => $amount,
|
||||
'pc_amount' => $pcAmount,
|
||||
'target' => $piggyBank->target_amount,
|
||||
'pc_target' => $piggyBank->native_target_amount,
|
||||
'percentage' => $pct,
|
||||
// currency:
|
||||
'currency_symbol' => $piggyBank->transactionCurrency->symbol,
|
||||
'currency_decimal_places' => $piggyBank->transactionCurrency->decimal_places,
|
||||
'currency_symbol' => $piggyBank->transactionCurrency->symbol,
|
||||
'currency_decimal_places' => $piggyBank->transactionCurrency->decimal_places,
|
||||
'primary_currency_symbol' => $this->primaryCurrency->symbol,
|
||||
'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places,
|
||||
|
||||
@@ -84,12 +83,12 @@ class FrontpageController extends Controller
|
||||
static fn (array $a, array $b) => $a['percentage'] <=> $b['percentage']
|
||||
);
|
||||
|
||||
$html = '';
|
||||
$html = '';
|
||||
if (0 !== count($info)) {
|
||||
try {
|
||||
$convertToPrimary = $this->convertToPrimary;
|
||||
$primary = $this->primaryCurrency;
|
||||
$html = view('json.piggy-banks', compact('info', 'convertToPrimary', 'primary'))->render();
|
||||
$primary = $this->primaryCurrency;
|
||||
$html = view('json.piggy-banks', compact('info', 'convertToPrimary', 'primary'))->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
|
@@ -112,7 +112,7 @@ class PreferencesController extends Controller
|
||||
$darkMode = Preferences::get('darkMode', 'browser')->data;
|
||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
||||
$convertToPrimary = $this->convertToPrimary;
|
||||
$convertToPrimary = $this->convertToPrimary;
|
||||
if (is_array($fiscalYearStartStr)) {
|
||||
$fiscalYearStartStr = '01-01';
|
||||
}
|
||||
@@ -266,7 +266,7 @@ class PreferencesController extends Controller
|
||||
}
|
||||
|
||||
// convert primary
|
||||
$convertToPrimary = 1 === (int) $request->get('convertToPrimary');
|
||||
$convertToPrimary = 1 === (int) $request->get('convertToPrimary');
|
||||
if ($convertToPrimary && !$this->convertToPrimary) {
|
||||
// set to true!
|
||||
Log::debug('User sets convertToPrimary to true.');
|
||||
|
@@ -74,7 +74,7 @@ class IndexController extends Controller
|
||||
// order so default and enabled are on top:
|
||||
$collection = $collection->sortBy(
|
||||
static function (TransactionCurrency $currency) {
|
||||
$primary = true === $currency->userGroupNative ? 0 : 1;
|
||||
$primary = true === $currency->userGroupNative ? 0 : 1;
|
||||
$enabled = true === $currency->userGroupEnabled ? 0 : 1;
|
||||
|
||||
return sprintf('%s-%s-%s', $primary, $enabled, $currency->code);
|
||||
|
Reference in New Issue
Block a user