mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 14:46:37 +00:00
Auto commit for release 'develop' on 2024-12-27
This commit is contained in:
24
.ci/php-cs-fixer/composer.lock
generated
24
.ci/php-cs-fixer/composer.lock
generated
@@ -1369,12 +1369,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -1517,12 +1517,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -2329,12 +2329,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@@ -74,7 +74,7 @@ class NetWorth implements NetWorthInterface
|
|||||||
$cache->addProperty('net-worth-by-accounts');
|
$cache->addProperty('net-worth-by-accounts');
|
||||||
$cache->addProperty($ids);
|
$cache->addProperty($ids);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));
|
Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));
|
||||||
$default = Amount::getDefaultCurrency();
|
$default = Amount::getDefaultCurrency();
|
||||||
|
@@ -162,7 +162,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
private function getAllAvailableBudgets(Carbon $start, Carbon $end): array
|
private function getAllAvailableBudgets(Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
// get all available budgets.
|
// get all available budgets.
|
||||||
$ab = $this->abRepository->get($start, $end);
|
$ab = $this->abRepository->get($start, $end);
|
||||||
$availableBudgets = [];
|
$availableBudgets = [];
|
||||||
@@ -170,24 +170,25 @@ class IndexController extends Controller
|
|||||||
// for each, complement with spent amount:
|
// for each, complement with spent amount:
|
||||||
/** @var AvailableBudget $entry */
|
/** @var AvailableBudget $entry */
|
||||||
foreach ($ab as $entry) {
|
foreach ($ab as $entry) {
|
||||||
$array = $entry->toArray();
|
$array = $entry->toArray();
|
||||||
$array['start_date'] = $entry->start_date;
|
$array['start_date'] = $entry->start_date;
|
||||||
$array['end_date'] = $entry->end_date;
|
$array['end_date'] = $entry->end_date;
|
||||||
|
|
||||||
// spent in period:
|
// spent in period:
|
||||||
$spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency);
|
$spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency);
|
||||||
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
|
$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;
|
$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 in period:
|
||||||
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency);
|
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency);
|
||||||
$array['budgeted'] = $budgeted;
|
$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;
|
$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.
|
// this time, because of complex sums, use the currency converter.
|
||||||
|
|
||||||
|
|
||||||
$availableBudgets[] = $array;
|
$availableBudgets[] = $array;
|
||||||
unset($spentArr);
|
unset($spentArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $availableBudgets;
|
return $availableBudgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -426,7 +426,7 @@ class AccountController extends Controller
|
|||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect and filter balances for the entire period.
|
// collect and filter balances for the entire period.
|
||||||
|
@@ -111,7 +111,7 @@ class BillController extends Controller
|
|||||||
$cache->addProperty($bill->id);
|
$cache->addProperty($bill->id);
|
||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($budget->id);
|
$cache->addProperty($budget->id);
|
||||||
|
|
||||||
if ($cache->has()) {
|
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.
|
$step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart.
|
||||||
$collection = new Collection([$budget]);
|
$collection = new Collection([$budget]);
|
||||||
@@ -164,15 +164,15 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($budget->id);
|
$cache->addProperty($budget->id);
|
||||||
|
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
$entries = [];
|
$entries = [];
|
||||||
$amount = $budgetLimit->amount;
|
$amount = $budgetLimit->amount;
|
||||||
$budgetCollection = new Collection([$budget]);
|
$budgetCollection = new Collection([$budget]);
|
||||||
$currency = $budgetLimit->transactionCurrency;
|
$currency = $budgetLimit->transactionCurrency;
|
||||||
if($this->convertToNative) {
|
if ($this->convertToNative) {
|
||||||
$amount = $budgetLimit->native_amount;
|
$amount = $budgetLimit->native_amount;
|
||||||
$currency = $this->defaultCurrency;
|
$currency = $this->defaultCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
|
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setBudget($budget);
|
$collector->setBudget($budget);
|
||||||
@@ -232,22 +232,22 @@ class BudgetController extends Controller
|
|||||||
// group by asset account ID:
|
// group by asset account ID:
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$key = sprintf('%d-%d', $journal['source_account_id'], $journal['currency_id']);
|
$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 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['source_account_id'], $this->defaultCurrency->id);
|
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||||
$symbol = $this->defaultCurrency->symbol;
|
$symbol = $this->defaultCurrency->symbol;
|
||||||
$code = $this->defaultCurrency->code;
|
$code = $this->defaultCurrency->code;
|
||||||
$name = $this->defaultCurrency->name;
|
$name = $this->defaultCurrency->name;
|
||||||
$amount = $journal['native_amount'];
|
$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['source_account_id'], $this->defaultCurrency->id);
|
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||||
$symbol = $this->defaultCurrency->symbol;
|
$symbol = $this->defaultCurrency->symbol;
|
||||||
$code = $this->defaultCurrency->code;
|
$code = $this->defaultCurrency->code;
|
||||||
$name = $this->defaultCurrency->name;
|
$name = $this->defaultCurrency->name;
|
||||||
$amount = $journal['foreign_amount'];
|
$amount = $journal['foreign_amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,26 +312,26 @@ class BudgetController extends Controller
|
|||||||
$chartData = [];
|
$chartData = [];
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
|
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
|
||||||
$symbol = $journal['currency_symbol'];
|
$symbol = $journal['currency_symbol'];
|
||||||
$code = $journal['currency_code'];
|
$code = $journal['currency_code'];
|
||||||
$name = $journal['currency_name'];
|
$name = $journal['currency_name'];
|
||||||
$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 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;
|
$symbol = $this->defaultCurrency->symbol;
|
||||||
$code = $this->defaultCurrency->code;
|
$code = $this->defaultCurrency->code;
|
||||||
$name = $this->defaultCurrency->name;
|
$name = $this->defaultCurrency->name;
|
||||||
$amount = $journal['native_amount'];
|
$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;
|
$symbol = $this->defaultCurrency->symbol;
|
||||||
$code = $this->defaultCurrency->code;
|
$code = $this->defaultCurrency->code;
|
||||||
$name = $this->defaultCurrency->name;
|
$name = $this->defaultCurrency->name;
|
||||||
$amount = $journal['foreign_amount'];
|
$amount = $journal['foreign_amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
|
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();
|
$collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();
|
||||||
@@ -396,22 +396,22 @@ class BudgetController extends Controller
|
|||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']);
|
$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 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['destination_account_id'], $this->defaultCurrency->id);
|
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||||
$symbol = $this->defaultCurrency->symbol;
|
$symbol = $this->defaultCurrency->symbol;
|
||||||
$code = $this->defaultCurrency->code;
|
$code = $this->defaultCurrency->code;
|
||||||
$name = $this->defaultCurrency->name;
|
$name = $this->defaultCurrency->name;
|
||||||
$amount = $journal['native_amount'];
|
$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['destination_account_id'], $this->defaultCurrency->id);
|
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||||
$symbol = $this->defaultCurrency->symbol;
|
$symbol = $this->defaultCurrency->symbol;
|
||||||
$code = $this->defaultCurrency->code;
|
$code = $this->defaultCurrency->code;
|
||||||
$name = $this->defaultCurrency->name;
|
$name = $this->defaultCurrency->name;
|
||||||
$amount = $journal['foreign_amount'];
|
$amount = $journal['foreign_amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ class BudgetController extends Controller
|
|||||||
'amount' => '0',
|
'amount' => '0',
|
||||||
'currency_symbol' => $symbol,
|
'currency_symbol' => $symbol,
|
||||||
'currency_code' => $code,
|
'currency_code' => $code,
|
||||||
'currency_name' => $name
|
'currency_name' => $name,
|
||||||
];
|
];
|
||||||
$result[$key]['amount'] = bcadd($amount, $result[$key]['amount']);
|
$result[$key]['amount'] = bcadd($amount, $result[$key]['amount']);
|
||||||
}
|
}
|
||||||
@@ -457,7 +457,7 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
$cache->addProperty('chart.budget.frontpage');
|
$cache->addProperty('chart.budget.frontpage');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
Log::debug('Regenerate frontpage chart from scratch.');
|
Log::debug('Regenerate frontpage chart from scratch.');
|
||||||
$chartGenerator = app(FrontpageChartGenerator::class);
|
$chartGenerator = app(FrontpageChartGenerator::class);
|
||||||
|
@@ -70,27 +70,27 @@ class CategoryController extends Controller
|
|||||||
public function all(Category $category): JsonResponse
|
public function all(Category $category): JsonResponse
|
||||||
{
|
{
|
||||||
// cache results:
|
// cache results:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty('chart.category.all');
|
$cache->addProperty('chart.category.all');
|
||||||
$cache->addProperty($category->id);
|
$cache->addProperty($category->id);
|
||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var CategoryRepositoryInterface $repository */
|
/** @var CategoryRepositoryInterface $repository */
|
||||||
$repository = app(CategoryRepositoryInterface::class);
|
$repository = app(CategoryRepositoryInterface::class);
|
||||||
$start = $repository->firstUseDate($category) ?? $this->getDate();
|
$start = $repository->firstUseDate($category) ?? $this->getDate();
|
||||||
$range = app('navigation')->getViewRange(false);
|
$range = app('navigation')->getViewRange(false);
|
||||||
$start = app('navigation')->startOfPeriod($start, $range);
|
$start = app('navigation')->startOfPeriod($start, $range);
|
||||||
$end = $this->getDate();
|
$end = $this->getDate();
|
||||||
|
|
||||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||||
$chartGenerator->convertToNative = $this->convertToNative;
|
$chartGenerator->convertToNative = $this->convertToNative;
|
||||||
|
|
||||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||||
$data = $this->generator->multiSet($chartData);
|
$data = $this->generator->multiSet($chartData);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
@@ -107,16 +107,16 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function frontPage(): JsonResponse
|
public function frontPage(): JsonResponse
|
||||||
{
|
{
|
||||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
$cache->addProperty('chart.category.frontpage');
|
$cache->addProperty('chart.category.frontpage');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
$frontpageGenerator = new FrontpageChartGenerator($start, $end);
|
$frontpageGenerator = new FrontpageChartGenerator($start, $end);
|
||||||
@@ -141,9 +141,9 @@ class CategoryController extends Controller
|
|||||||
$cache->addProperty($category);
|
$cache->addProperty($category);
|
||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
if ($cache->has()) {
|
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);
|
$cache->store($data);
|
||||||
|
|
||||||
@@ -164,8 +164,8 @@ class CategoryController extends Controller
|
|||||||
$noCatRepository = app(NoCategoryRepositoryInterface::class);
|
$noCatRepository = app(NoCategoryRepositoryInterface::class);
|
||||||
|
|
||||||
// this gives us all currencies
|
// this gives us all currencies
|
||||||
$expenses = $noCatRepository->listExpenses($start, $end, $accounts);
|
$expenses = $noCatRepository->listExpenses($start, $end, $accounts);
|
||||||
$income = $noCatRepository->listIncome($start, $end, $accounts);
|
$income = $noCatRepository->listIncome($start, $end, $accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $category) {
|
if (null !== $category) {
|
||||||
@@ -173,9 +173,9 @@ class CategoryController extends Controller
|
|||||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
$categoryId = $category->id;
|
$categoryId = $category->id;
|
||||||
// this gives us all currencies
|
// this gives us all currencies
|
||||||
$collection = new Collection([$category]);
|
$collection = new Collection([$category]);
|
||||||
$expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection);
|
$expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection);
|
||||||
$income = $opsRepository->listIncome($start, $end, $accounts, $collection);
|
$income = $opsRepository->listIncome($start, $end, $accounts, $collection);
|
||||||
}
|
}
|
||||||
$currencies = array_unique(array_merge(array_keys($income), array_keys($expenses)));
|
$currencies = array_unique(array_merge(array_keys($income), array_keys($expenses)));
|
||||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||||
@@ -189,19 +189,19 @@ class CategoryController extends Controller
|
|||||||
$inKey = sprintf('%d-in', $currencyId);
|
$inKey = sprintf('%d-in', $currencyId);
|
||||||
$chartData[$outKey]
|
$chartData[$outKey]
|
||||||
= [
|
= [
|
||||||
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
|
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||||
];
|
];
|
||||||
|
|
||||||
$chartData[$inKey]
|
$chartData[$inKey]
|
||||||
= [
|
= [
|
||||||
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||||
];
|
];
|
||||||
// loop empty periods:
|
// loop empty periods:
|
||||||
foreach (array_keys($periods) as $period) {
|
foreach (array_keys($periods) as $period) {
|
||||||
$label = $periods[$period];
|
$label = $periods[$period];
|
||||||
@@ -209,7 +209,7 @@ class CategoryController extends Controller
|
|||||||
$chartData[$inKey]['entries'][$label] = '0';
|
$chartData[$inKey]['entries'][$label] = '0';
|
||||||
}
|
}
|
||||||
// loop income and expenses for this category.:
|
// 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) {
|
foreach ($outSet['transaction_journals'] as $journal) {
|
||||||
$amount = app('steam')->positive($journal['amount']);
|
$amount = app('steam')->positive($journal['amount']);
|
||||||
$date = $journal['date']->isoFormat($format);
|
$date = $journal['date']->isoFormat($format);
|
||||||
@@ -218,7 +218,7 @@ class CategoryController extends Controller
|
|||||||
$chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]);
|
$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) {
|
foreach ($inSet['transaction_journals'] as $journal) {
|
||||||
$amount = app('steam')->positive($journal['amount']);
|
$amount = app('steam')->positive($journal['amount']);
|
||||||
$date = $journal['date']->isoFormat($format);
|
$date = $journal['date']->isoFormat($format);
|
||||||
@@ -244,7 +244,7 @@ class CategoryController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get());
|
return response()->json($cache->get());
|
||||||
}
|
}
|
||||||
$data = $this->reportPeriodChart($accounts, $start, $end, null);
|
$data = $this->reportPeriodChart($accounts, $start, $end, null);
|
||||||
|
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
@@ -259,14 +259,14 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function specificPeriod(Category $category, Carbon $date): JsonResponse
|
public function specificPeriod(Category $category, Carbon $date): JsonResponse
|
||||||
{
|
{
|
||||||
$range = app('navigation')->getViewRange(false);
|
$range = app('navigation')->getViewRange(false);
|
||||||
$start = app('navigation')->startOfPeriod($date, $range);
|
$start = app('navigation')->startOfPeriod($date, $range);
|
||||||
$end = session()->get('end');
|
$end = session()->get('end');
|
||||||
if ($end < $start) {
|
if ($end < $start) {
|
||||||
[$end, $start] = [$start, $end];
|
[$end, $start] = [$start, $end];
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty($category->id);
|
$cache->addProperty($category->id);
|
||||||
|
@@ -145,7 +145,7 @@ class ReportController extends Controller
|
|||||||
$cache->addProperty($accounts);
|
$cache->addProperty($accounts);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
if ($cache->has()) {
|
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());
|
Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());
|
||||||
|
@@ -95,7 +95,7 @@ class JavascriptController extends Controller
|
|||||||
public function variables(Request $request, AccountRepositoryInterface $repository): Response
|
public function variables(Request $request, AccountRepositoryInterface $repository): Response
|
||||||
{
|
{
|
||||||
$account = $repository->find((int) $request->get('account'));
|
$account = $repository->find((int) $request->get('account'));
|
||||||
$currency = $this->defaultCurrency;
|
$currency = $this->defaultCurrency;
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
$currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||||
}
|
}
|
||||||
|
@@ -63,13 +63,13 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$collector->setCategories($this->getCategories());
|
$collector->setCategories($this->getCategories());
|
||||||
}
|
}
|
||||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$categoryId = (int) $journal['category_id'];
|
$categoryId = (int) $journal['category_id'];
|
||||||
$categoryName = (string) $journal['category_name'];
|
$categoryName = (string) $journal['category_name'];
|
||||||
|
|
||||||
// catch "no category" entries.
|
// catch "no category" entries.
|
||||||
if (0 === $categoryId) {
|
if (0 === $categoryId) {
|
||||||
@@ -77,7 +77,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// info about the currency:
|
// info about the currency:
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'categories' => [],
|
'categories' => [],
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
@@ -112,7 +112,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUser(null | Authenticatable | User $user): void
|
public function setUser(null|Authenticatable|User $user): void
|
||||||
{
|
{
|
||||||
if ($user instanceof User) {
|
if ($user instanceof User) {
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
@@ -147,13 +147,13 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$collector->setCategories($this->getCategories());
|
$collector->setCategories($this->getCategories());
|
||||||
}
|
}
|
||||||
$collector->withCategoryInformation()->withAccountInformation();
|
$collector->withCategoryInformation()->withAccountInformation();
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$categoryId = (int) $journal['category_id'];
|
$categoryId = (int) $journal['category_id'];
|
||||||
$categoryName = (string) $journal['category_name'];
|
$categoryName = (string) $journal['category_name'];
|
||||||
|
|
||||||
// catch "no category" entries.
|
// catch "no category" entries.
|
||||||
if (0 === $categoryId) {
|
if (0 === $categoryId) {
|
||||||
@@ -161,7 +161,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// info about the currency:
|
// info about the currency:
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'categories' => [],
|
'categories' => [],
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
@@ -200,7 +200,8 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER])
|
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER])
|
||||||
->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts);
|
->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts)
|
||||||
|
;
|
||||||
if (null !== $categories && $categories->count() > 0) {
|
if (null !== $categories && $categories->count() > 0) {
|
||||||
$collector->setCategories($categories);
|
$collector->setCategories($categories);
|
||||||
}
|
}
|
||||||
@@ -208,13 +209,13 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$collector->setCategories($this->getCategories());
|
$collector->setCategories($this->getCategories());
|
||||||
}
|
}
|
||||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$categoryId = (int) $journal['category_id'];
|
$categoryId = (int) $journal['category_id'];
|
||||||
$categoryName = (string) $journal['category_name'];
|
$categoryName = (string) $journal['category_name'];
|
||||||
|
|
||||||
// catch "no category" entries.
|
// catch "no category" entries.
|
||||||
if (0 === $categoryId) {
|
if (0 === $categoryId) {
|
||||||
@@ -222,7 +223,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// info about the currency:
|
// info about the currency:
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'categories' => [],
|
'categories' => [],
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
@@ -262,7 +263,8 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER])
|
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER])
|
||||||
->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts);
|
->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts)
|
||||||
|
;
|
||||||
if (null !== $categories && $categories->count() > 0) {
|
if (null !== $categories && $categories->count() > 0) {
|
||||||
$collector->setCategories($categories);
|
$collector->setCategories($categories);
|
||||||
}
|
}
|
||||||
@@ -270,13 +272,13 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$collector->setCategories($this->getCategories());
|
$collector->setCategories($this->getCategories());
|
||||||
}
|
}
|
||||||
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
$collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$categoryId = (int) $journal['category_id'];
|
$categoryId = (int) $journal['category_id'];
|
||||||
$categoryName = (string) $journal['category_name'];
|
$categoryName = (string) $journal['category_name'];
|
||||||
|
|
||||||
// catch "no category" entries.
|
// catch "no category" entries.
|
||||||
if (0 === $categoryId) {
|
if (0 === $categoryId) {
|
||||||
@@ -284,7 +286,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// info about the currency:
|
// info about the currency:
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'categories' => [],
|
'categories' => [],
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
@@ -325,7 +327,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array
|
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array
|
||||||
{
|
{
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
||||||
|
|
||||||
// default currency information for native stuff.
|
// default currency information for native stuff.
|
||||||
@@ -339,19 +341,19 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
}
|
}
|
||||||
$collector->setCategories($categories);
|
$collector->setCategories($categories);
|
||||||
$collector->withCategoryInformation();
|
$collector->withCategoryInformation();
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
Log::debug(sprintf('Collected %d journals', count($journals)));
|
Log::debug(sprintf('Collected %d journals', count($journals)));
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
// Almost the same as in \FireflyIII\Repositories\Budget\OperationsRepository::sumExpenses
|
// Almost the same as in \FireflyIII\Repositories\Budget\OperationsRepository::sumExpenses
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$currencyName = $journal['currency_name'];
|
$currencyName = $journal['currency_name'];
|
||||||
$currencySymbol = $journal['currency_symbol'];
|
$currencySymbol = $journal['currency_symbol'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||||
if ($convertToNative) {
|
if ($convertToNative) {
|
||||||
$amount = Amount::getAmountFromJournal($journal);
|
$amount = Amount::getAmountFromJournal($journal);
|
||||||
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
||||||
@@ -376,7 +378,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$amount = $journal['amount'];
|
$amount = $journal['amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $currencyName,
|
'currency_name' => $currencyName,
|
||||||
@@ -396,9 +398,10 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array
|
public function sumIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array
|
||||||
{
|
{
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($this->user)->setRange($start, $end)
|
$collector->setUser($this->user)->setRange($start, $end)
|
||||||
->setTypes([TransactionTypeEnum::DEPOSIT->value]);
|
->setTypes([TransactionTypeEnum::DEPOSIT->value])
|
||||||
|
;
|
||||||
|
|
||||||
if (null !== $accounts && $accounts->count() > 0) {
|
if (null !== $accounts && $accounts->count() > 0) {
|
||||||
$collector->setAccounts($accounts);
|
$collector->setAccounts($accounts);
|
||||||
@@ -407,19 +410,19 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$categories = $this->getCategories();
|
$categories = $this->getCategories();
|
||||||
}
|
}
|
||||||
$collector->setCategories($categories);
|
$collector->setCategories($categories);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$convertToNative = app('preferences')->get('convert_to_native', false)->data;
|
$convertToNative = app('preferences')->get('convert_to_native', false)->data;
|
||||||
$default = app('amount')->getDefaultCurrency();
|
$default = app('amount')->getDefaultCurrency();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
// Almost the same as in \FireflyIII\Repositories\Budget\OperationsRepository::sumExpenses
|
// Almost the same as in \FireflyIII\Repositories\Budget\OperationsRepository::sumExpenses
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$currencyName = $journal['currency_name'];
|
$currencyName = $journal['currency_name'];
|
||||||
$currencySymbol = $journal['currency_symbol'];
|
$currencySymbol = $journal['currency_symbol'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||||
if ($convertToNative) {
|
if ($convertToNative) {
|
||||||
$amount = Amount::getAmountFromJournal($journal);
|
$amount = Amount::getAmountFromJournal($journal);
|
||||||
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
||||||
@@ -444,7 +447,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$amount = $journal['amount'];
|
$amount = $journal['amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $currencyName,
|
'currency_name' => $currencyName,
|
||||||
@@ -466,7 +469,8 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($this->user)->setRange($start, $end)
|
$collector->setUser($this->user)->setRange($start, $end)
|
||||||
->setTypes([TransactionType::TRANSFER]);
|
->setTypes([TransactionType::TRANSFER])
|
||||||
|
;
|
||||||
|
|
||||||
if (null !== $accounts && $accounts->count() > 0) {
|
if (null !== $accounts && $accounts->count() > 0) {
|
||||||
$collector->setAccounts($accounts);
|
$collector->setAccounts($accounts);
|
||||||
@@ -475,12 +479,12 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$categories = $this->getCategories();
|
$categories = $this->getCategories();
|
||||||
}
|
}
|
||||||
$collector->setCategories($categories);
|
$collector->setCategories($categories);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$array[$currencyId] ??= [
|
$array[$currencyId] ??= [
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
'currency_id' => (string) $currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Support\Chart\Category;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Enums\AccountTypeEnum;
|
use FireflyIII\Enums\AccountTypeEnum;
|
||||||
use FireflyIII\Models\AccountType;
|
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||||
|
@@ -183,7 +183,7 @@ trait AugumentData
|
|||||||
$cache->addProperty('get-limits');
|
$cache->addProperty('get-limits');
|
||||||
|
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$set = $blRepository->getBudgetLimits($budget, $start, $end);
|
$set = $blRepository->getBudgetLimits($budget, $start, $end);
|
||||||
@@ -191,12 +191,12 @@ trait AugumentData
|
|||||||
$budgetCollection = new Collection([$budget]);
|
$budgetCollection = new Collection([$budget]);
|
||||||
|
|
||||||
// merge sets based on a key, in case of convert to native
|
// merge sets based on a key, in case of convert to native
|
||||||
$limits = new Collection();
|
$limits = new Collection();
|
||||||
|
|
||||||
/** @var BudgetLimit $entry */
|
/** @var BudgetLimit $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$currency = $entry->transactionCurrency;
|
$currency = $entry->transactionCurrency;
|
||||||
if($this->convertToNative) {
|
if ($this->convertToNative) {
|
||||||
// the sumExpenses method already handles this.
|
// the sumExpenses method already handles this.
|
||||||
$currency = $this->defaultCurrency;
|
$currency = $this->defaultCurrency;
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,7 @@ trait ChartGeneration
|
|||||||
$cache->addProperty($accounts);
|
$cache->addProperty($accounts);
|
||||||
$cache->addProperty($convertToNative);
|
$cache->addProperty($convertToNative);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
app('log')->debug('Regenerate chart.account.account-balance-chart from scratch.');
|
app('log')->debug('Regenerate chart.account.account-balance-chart from scratch.');
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
|
@@ -75,11 +75,11 @@ trait PeriodOverview
|
|||||||
*/
|
*/
|
||||||
protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array
|
protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||||
|
|
||||||
// properties for cache
|
// properties for cache
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('account-show-period-entries');
|
$cache->addProperty('account-show-period-entries');
|
||||||
@@ -89,32 +89,32 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $dates */
|
/** @var array $dates */
|
||||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
// collect all expenses in this period:
|
// collect all expenses in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]));
|
$collector->setAccounts(new Collection([$account]));
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
$earnedSet = $collector->getExtractedJournals();
|
$earnedSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all income in this period:
|
// collect all income in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]));
|
$collector->setAccounts(new Collection([$account]));
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$spentSet = $collector->getExtractedJournals();
|
$spentSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all transfers in this period:
|
// collect all transfers in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]));
|
$collector->setAccounts(new Collection([$account]));
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
$transferSet = $collector->getExtractedJournals();
|
$transferSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// loop dates
|
// loop dates
|
||||||
foreach ($dates as $currentDate) {
|
foreach ($dates as $currentDate) {
|
||||||
@@ -125,15 +125,15 @@ trait PeriodOverview
|
|||||||
$transferredIn = $this->filterTransferredIn($account, $this->filterJournalsByDate($transferSet, $currentDate['start'], $currentDate['end']));
|
$transferredIn = $this->filterTransferredIn($account, $this->filterJournalsByDate($transferSet, $currentDate['start'], $currentDate['end']));
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route('accounts.show', [$account->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
'route' => route('accounts.show', [$account->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
||||||
|
|
||||||
'total_transactions' => count($spent) + count($earned) + count($transferredAway) + count($transferredIn),
|
'total_transactions' => count($spent) + count($earned) + count($transferredAway) + count($transferredIn),
|
||||||
'spent' => $this->groupByCurrency($spent),
|
'spent' => $this->groupByCurrency($spent),
|
||||||
'earned' => $this->groupByCurrency($earned),
|
'earned' => $this->groupByCurrency($earned),
|
||||||
'transferred_away' => $this->groupByCurrency($transferredAway),
|
'transferred_away' => $this->groupByCurrency($transferredAway),
|
||||||
'transferred_in' => $this->groupByCurrency($transferredIn),
|
'transferred_in' => $this->groupByCurrency($transferredIn),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$cache->store($entries);
|
$cache->store($entries);
|
||||||
|
|
||||||
@@ -197,13 +197,13 @@ trait PeriodOverview
|
|||||||
|
|
||||||
/** @var array $journal */
|
/** @var array $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$currencyName = $journal['currency_name'];
|
$currencyName = $journal['currency_name'];
|
||||||
$currencySymbol = $journal['currency_symbol'];
|
$currencySymbol = $journal['currency_symbol'];
|
||||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||||
$foreignCurrencyId = $journal['foreign_currency_id'];
|
$foreignCurrencyId = $journal['foreign_currency_id'];
|
||||||
$amount = $journal['amount'];
|
$amount = $journal['amount'];
|
||||||
|
|
||||||
|
|
||||||
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId !== $this->defaultCurrency->id) {
|
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId !== $this->defaultCurrency->id) {
|
||||||
@@ -215,7 +215,7 @@ trait PeriodOverview
|
|||||||
$currencyDecimalPlaces = $this->defaultCurrency->decimal_places;
|
$currencyDecimalPlaces = $this->defaultCurrency->decimal_places;
|
||||||
}
|
}
|
||||||
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId === $this->defaultCurrency->id) {
|
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId === $this->defaultCurrency->id) {
|
||||||
$currencyId = (int) $foreignCurrencyId;
|
$currencyId = (int) $foreignCurrencyId;
|
||||||
$currencyCode = $journal['foreign_currency_code'];
|
$currencyCode = $journal['foreign_currency_code'];
|
||||||
$currencyName = $journal['foreign_currency_name'];
|
$currencyName = $journal['foreign_currency_name'];
|
||||||
$currencySymbol = $journal['foreign_currency_symbol'];
|
$currencySymbol = $journal['foreign_currency_symbol'];
|
||||||
@@ -247,11 +247,11 @@ trait PeriodOverview
|
|||||||
*/
|
*/
|
||||||
protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array
|
protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||||
|
|
||||||
// properties for entries with their amounts.
|
// properties for entries with their amounts.
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty($range);
|
$cache->addProperty($range);
|
||||||
@@ -263,32 +263,32 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $dates */
|
/** @var array $dates */
|
||||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
// collect all expenses in this period:
|
// collect all expenses in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setCategory($category);
|
$collector->setCategory($category);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
$earnedSet = $collector->getExtractedJournals();
|
$earnedSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all income in this period:
|
// collect all income in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setCategory($category);
|
$collector->setCategory($category);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$spentSet = $collector->getExtractedJournals();
|
$spentSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all transfers in this period:
|
// collect all transfers in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setCategory($category);
|
$collector->setCategory($category);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
$transferSet = $collector->getExtractedJournals();
|
$transferSet = $collector->getExtractedJournals();
|
||||||
foreach ($dates as $currentDate) {
|
foreach ($dates as $currentDate) {
|
||||||
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
||||||
$earned = $this->filterJournalsByDate($earnedSet, $currentDate['start'], $currentDate['end']);
|
$earned = $this->filterJournalsByDate($earnedSet, $currentDate['start'], $currentDate['end']);
|
||||||
@@ -296,17 +296,17 @@ trait PeriodOverview
|
|||||||
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'transactions' => 0,
|
'transactions' => 0,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route(
|
'route' => route(
|
||||||
'categories.show',
|
'categories.show',
|
||||||
[$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]
|
[$category->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]
|
||||||
),
|
),
|
||||||
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
||||||
'spent' => $this->groupByCurrency($spent),
|
'spent' => $this->groupByCurrency($spent),
|
||||||
'earned' => $this->groupByCurrency($earned),
|
'earned' => $this->groupByCurrency($earned),
|
||||||
'transferred' => $this->groupByCurrency($transferred),
|
'transferred' => $this->groupByCurrency($transferred),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$cache->store($entries);
|
$cache->store($entries);
|
||||||
|
|
||||||
@@ -322,43 +322,43 @@ trait PeriodOverview
|
|||||||
*/
|
*/
|
||||||
protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array
|
protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
|
|
||||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||||
|
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty($this->convertToNative);
|
$cache->addProperty($this->convertToNative);
|
||||||
$cache->addProperty('no-budget-period-entries');
|
$cache->addProperty('no-budget-period-entries');
|
||||||
|
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $dates */
|
/** @var array $dates */
|
||||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
// get all expenses without a budget.
|
// get all expenses without a budget.
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setRange($start, $end)->withoutBudget()->withAccountInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setRange($start, $end)->withoutBudget()->withAccountInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
|
|
||||||
foreach ($dates as $currentDate) {
|
foreach ($dates as $currentDate) {
|
||||||
$set = $this->filterJournalsByDate($journals, $currentDate['start'], $currentDate['end']);
|
$set = $this->filterJournalsByDate($journals, $currentDate['start'], $currentDate['end']);
|
||||||
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route('budgets.no-budget', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
'route' => route('budgets.no-budget', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
||||||
'total_transactions' => count($set),
|
'total_transactions' => count($set),
|
||||||
'spent' => $this->groupByCurrency($set),
|
'spent' => $this->groupByCurrency($set),
|
||||||
'earned' => [],
|
'earned' => [],
|
||||||
'transferred_away' => [],
|
'transferred_away' => [],
|
||||||
'transferred_in' => [],
|
'transferred_in' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$cache->store($entries);
|
$cache->store($entries);
|
||||||
|
|
||||||
@@ -375,38 +375,38 @@ trait PeriodOverview
|
|||||||
protected function getNoCategoryPeriodOverview(Carbon $theDate): array
|
protected function getNoCategoryPeriodOverview(Carbon $theDate): array
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d')));
|
app('log')->debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d')));
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
$first = $this->journalRepos->firstNull();
|
$first = $this->journalRepos->firstNull();
|
||||||
$start = null === $first ? new Carbon() : $first->date;
|
$start = null === $first ? new Carbon() : $first->date;
|
||||||
$end = clone $theDate;
|
$end = clone $theDate;
|
||||||
$end = app('navigation')->endOfPeriod($end, $range);
|
$end = app('navigation')->endOfPeriod($end, $range);
|
||||||
|
|
||||||
app('log')->debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d')));
|
app('log')->debug(sprintf('Start for getNoCategoryPeriodOverview() is %s', $start->format('Y-m-d')));
|
||||||
app('log')->debug(sprintf('End for getNoCategoryPeriodOverview() is %s', $end->format('Y-m-d')));
|
app('log')->debug(sprintf('End for getNoCategoryPeriodOverview() is %s', $end->format('Y-m-d')));
|
||||||
|
|
||||||
// properties for cache
|
// properties for cache
|
||||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
// collect all expenses in this period:
|
// collect all expenses in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->withoutCategory();
|
$collector->withoutCategory();
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
$earnedSet = $collector->getExtractedJournals();
|
$earnedSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all income in this period:
|
// collect all income in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->withoutCategory();
|
$collector->withoutCategory();
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$spentSet = $collector->getExtractedJournals();
|
$spentSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all transfers in this period:
|
// collect all transfers in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->withoutCategory();
|
$collector->withoutCategory();
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
@@ -420,13 +420,13 @@ trait PeriodOverview
|
|||||||
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route('categories.no-category', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
'route' => route('categories.no-category', [$currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
||||||
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
||||||
'spent' => $this->groupByCurrency($spent),
|
'spent' => $this->groupByCurrency($spent),
|
||||||
'earned' => $this->groupByCurrency($earned),
|
'earned' => $this->groupByCurrency($earned),
|
||||||
'transferred' => $this->groupByCurrency($transferred),
|
'transferred' => $this->groupByCurrency($transferred),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
app('log')->debug('End of loops');
|
app('log')->debug('End of loops');
|
||||||
|
|
||||||
@@ -440,11 +440,11 @@ trait PeriodOverview
|
|||||||
*/
|
*/
|
||||||
protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.
|
protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.
|
||||||
{
|
{
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||||
|
|
||||||
// properties for cache
|
// properties for cache
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('tag-period-entries');
|
$cache->addProperty('tag-period-entries');
|
||||||
@@ -454,37 +454,37 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $dates */
|
/** @var array $dates */
|
||||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
// collect all expenses in this period:
|
// collect all expenses in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setTag($tag);
|
$collector->setTag($tag);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||||
$earnedSet = $collector->getExtractedJournals();
|
$earnedSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all income in this period:
|
// collect all income in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setTag($tag);
|
$collector->setTag($tag);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
$collector->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
$spentSet = $collector->getExtractedJournals();
|
$spentSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// collect all transfers in this period:
|
// collect all transfers in this period:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setTag($tag);
|
$collector->setTag($tag);
|
||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
$collector->setTypes([TransactionType::TRANSFER]);
|
$collector->setTypes([TransactionType::TRANSFER]);
|
||||||
$transferSet = $collector->getExtractedJournals();
|
$transferSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
// filer all of them:
|
// filer all of them:
|
||||||
$earnedSet = $this->filterJournalsByTag($earnedSet, $tag);
|
$earnedSet = $this->filterJournalsByTag($earnedSet, $tag);
|
||||||
$spentSet = $this->filterJournalsByTag($spentSet, $tag);
|
$spentSet = $this->filterJournalsByTag($spentSet, $tag);
|
||||||
$transferSet = $this->filterJournalsByTag($transferSet, $tag);
|
$transferSet = $this->filterJournalsByTag($transferSet, $tag);
|
||||||
|
|
||||||
foreach ($dates as $currentDate) {
|
foreach ($dates as $currentDate) {
|
||||||
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
|
||||||
@@ -493,17 +493,17 @@ trait PeriodOverview
|
|||||||
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'transactions' => 0,
|
'transactions' => 0,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route(
|
'route' => route(
|
||||||
'tags.show',
|
'tags.show',
|
||||||
[$tag->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]
|
[$tag->id, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]
|
||||||
),
|
),
|
||||||
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
||||||
'spent' => $this->groupByCurrency($spent),
|
'spent' => $this->groupByCurrency($spent),
|
||||||
'earned' => $this->groupByCurrency($earned),
|
'earned' => $this->groupByCurrency($earned),
|
||||||
'transferred' => $this->groupByCurrency($transferred),
|
'transferred' => $this->groupByCurrency($transferred),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entries;
|
return $entries;
|
||||||
@@ -513,7 +513,7 @@ trait PeriodOverview
|
|||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
/** @var array $localTag */
|
/** @var array $localTag */
|
||||||
foreach ($entry['tags'] as $localTag) {
|
foreach ($entry['tags'] as $localTag) {
|
||||||
@@ -535,12 +535,12 @@ trait PeriodOverview
|
|||||||
*/
|
*/
|
||||||
protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array
|
protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
$types = config(sprintf('firefly.transactionTypesByType.%s', $transactionType));
|
$types = config(sprintf('firefly.transactionTypesByType.%s', $transactionType));
|
||||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||||
|
|
||||||
// properties for cache
|
// properties for cache
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('transactions-period-entries');
|
$cache->addProperty('transactions-period-entries');
|
||||||
@@ -550,13 +550,13 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var array $dates */
|
/** @var array $dates */
|
||||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
// collect all journals in this period (regardless of type)
|
// collect all journals in this period (regardless of type)
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setTypes($types)->setRange($start, $end);
|
$collector->setTypes($types)->setRange($start, $end);
|
||||||
$genericSet = $collector->getExtractedJournals();
|
$genericSet = $collector->getExtractedJournals();
|
||||||
|
|
||||||
foreach ($dates as $currentDate) {
|
foreach ($dates as $currentDate) {
|
||||||
$spent = [];
|
$spent = [];
|
||||||
@@ -575,14 +575,14 @@ trait PeriodOverview
|
|||||||
$transferred = $this->filterJournalsByDate($genericSet, $currentDate['start'], $currentDate['end']);
|
$transferred = $this->filterJournalsByDate($genericSet, $currentDate['start'], $currentDate['end']);
|
||||||
}
|
}
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route('transactions.index', [$transactionType, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
'route' => route('transactions.index', [$transactionType, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
||||||
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
||||||
'spent' => $this->groupByCurrency($spent),
|
'spent' => $this->groupByCurrency($spent),
|
||||||
'earned' => $this->groupByCurrency($earned),
|
'earned' => $this->groupByCurrency($earned),
|
||||||
'transferred' => $this->groupByCurrency($transferred),
|
'transferred' => $this->groupByCurrency($transferred),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entries;
|
return $entries;
|
||||||
|
@@ -84,7 +84,7 @@ class Steam
|
|||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$balances = [];
|
$balances = [];
|
||||||
|
40
composer.lock
generated
40
composer.lock
generated
@@ -7330,12 +7330,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -7637,12 +7637,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -7860,12 +7860,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -9670,12 +9670,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -9930,12 +9930,12 @@
|
|||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "3.5-dev"
|
"dev-main": "3.5-dev"
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/contracts",
|
|
||||||
"url": "https://github.com/symfony/contracts"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@@ -81,7 +81,7 @@ return [
|
|||||||
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
||||||
// see cer.php for exchange rates feature flag.
|
// see cer.php for exchange rates feature flag.
|
||||||
],
|
],
|
||||||
'version' => 'branch-v6.2',
|
'version' => 'develop/2024-12-27',
|
||||||
'api_version' => '2.1.0', // field is no longer used.
|
'api_version' => '2.1.0', // field is no longer used.
|
||||||
'db_version' => 25,
|
'db_version' => 25,
|
||||||
|
|
||||||
|
16
package-lock.json
generated
16
package-lock.json
generated
@@ -5663,9 +5663,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/electron-to-chromium": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.5.75",
|
"version": "1.5.76",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.76.tgz",
|
||||||
"integrity": "sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q==",
|
"integrity": "sha512-CjVQyG7n7Sr+eBXE86HIulnL5N8xZY1sgmOPGuq/F0Rr0FJq63lg0kEtOIDfZBk44FnDLf6FUJ+dsJcuiUDdDQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
@@ -6967,6 +6967,7 @@
|
|||||||
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
|
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.23.2"
|
"@babel/runtime": "^7.23.2"
|
||||||
},
|
},
|
||||||
@@ -11272,12 +11273,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "6.0.5",
|
"version": "6.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-6.0.6.tgz",
|
||||||
"integrity": "sha512-akD5IAH/ID5imgue2DYhzsEwCi0/4VKY31uhMLEYJwPP4TiUp8pL5PIK+Wo7H8qT8JY9i+pVfPydcFPYD1EL7g==",
|
"integrity": "sha512-NSjmUuckPmDU18bHz7QZ+bTYhRR0iA72cs2QAxCqDpafJ0S6qetco0LB3WW2OxlMHS0JmAv+yZ/R3uPmMyGTjQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "0.24.0",
|
"esbuild": "^0.24.2",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
"rollup": "^4.23.0"
|
"rollup": "^4.23.0"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user