mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
🤖 Auto commit for release 'develop' on 2025-08-05
This commit is contained in:
@@ -87,7 +87,7 @@ class ShowController extends Controller
|
||||
$enrichment->setUser($admin);
|
||||
$enrichment->setStart($this->parameters->get('start'));
|
||||
$enrichment->setEnd($this->parameters->get('end'));
|
||||
$categories = $enrichment->enrich($categories);
|
||||
$categories = $enrichment->enrich($categories);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));
|
||||
@@ -123,7 +123,7 @@ class ShowController extends Controller
|
||||
$enrichment->setUser($admin);
|
||||
$enrichment->setStart($this->parameters->get('start'));
|
||||
$enrichment->setEnd($this->parameters->get('end'));
|
||||
$category = $enrichment->enrichSingle($category);
|
||||
$category = $enrichment->enrichSingle($category);
|
||||
|
||||
$resource = new Item($category, $transformer, 'categories');
|
||||
|
||||
|
||||
@@ -285,6 +285,7 @@ class CategoryReportController extends Controller
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay()->startOfDay();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ use Illuminate\View\View;
|
||||
|
||||
use function Safe\json_decode;
|
||||
use function Safe\file_get_contents;
|
||||
use function Safe\strtotime;
|
||||
|
||||
/**
|
||||
* Class PreferencesController.
|
||||
@@ -278,8 +277,8 @@ class PreferencesController extends Controller
|
||||
// custom fiscal year
|
||||
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
|
||||
Preferences::set('customFiscalYear', $customFiscalYear);
|
||||
$fiscalYearString = (string) $request->get('fiscalYearStart');
|
||||
if('' !== $fiscalYearString) {
|
||||
$fiscalYearString = (string) $request->get('fiscalYearStart');
|
||||
if ('' !== $fiscalYearString) {
|
||||
$fiscalYearStart = Carbon::parse($fiscalYearString, config('app.timezone'))->format('m-d');
|
||||
Preferences::set('fiscalYearStart', $fiscalYearStart);
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
public function collectExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
||||
|
||||
if ($accounts instanceof Collection && $accounts->count() > 0) {
|
||||
@@ -460,15 +460,16 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
}
|
||||
$collector->setCategories($categories);
|
||||
$collector->withCategoryInformation();
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
public function collectIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)
|
||||
->setTypes([TransactionTypeEnum::DEPOSIT->value])
|
||||
->setTypes([TransactionTypeEnum::DEPOSIT->value])
|
||||
;
|
||||
|
||||
if ($accounts instanceof Collection && $accounts->count() > 0) {
|
||||
@@ -478,6 +479,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$categories = $this->getCategories();
|
||||
}
|
||||
$collector->setCategories($categories);
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
@@ -486,7 +488,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user)->setRange($start, $end)
|
||||
->setTypes([TransactionTypeEnum::TRANSFER->value])
|
||||
->setTypes([TransactionTypeEnum::TRANSFER->value])
|
||||
;
|
||||
|
||||
if ($accounts instanceof Collection && $accounts->count() > 0) {
|
||||
@@ -496,6 +498,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$categories = $this->getCategories();
|
||||
}
|
||||
$collector->setCategories($categories);
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace FireflyIII\Repositories\Category;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
@@ -81,8 +80,11 @@ interface OperationsRepositoryInterface
|
||||
public function sumExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array;
|
||||
|
||||
public function collectExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array;
|
||||
|
||||
public function collectIncome(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array;
|
||||
|
||||
public function collectTransfers(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $categories = null): array;
|
||||
|
||||
public function sumCollectedTransactionsByCategory(array $expenses, Category $category, string $method, bool $convertToPrimary = false): array;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\JsonApi\Enrichments;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -39,7 +41,7 @@ class CategoryEnrichment implements EnrichmentInterface
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function enrichSingle(Model|array $model): array|Model
|
||||
public function enrichSingle(array|Model $model): array|Model
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$collection = new Collection([$model]);
|
||||
@@ -100,9 +102,10 @@ class CategoryEnrichment implements EnrichmentInterface
|
||||
private function collectNotes(): void
|
||||
{
|
||||
$notes = Note::query()->whereIn('noteable_id', $this->ids)
|
||||
->whereNotNull('notes.text')
|
||||
->where('notes.text', '!=', '')
|
||||
->where('noteable_type', Category::class)->get(['notes.noteable_id', 'notes.text'])->toArray();
|
||||
->whereNotNull('notes.text')
|
||||
->where('notes.text', '!=', '')
|
||||
->where('noteable_type', Category::class)->get(['notes.noteable_id', 'notes.text'])->toArray()
|
||||
;
|
||||
foreach ($notes as $note) {
|
||||
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
|
||||
}
|
||||
@@ -116,9 +119,9 @@ class CategoryEnrichment implements EnrichmentInterface
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$opsRepository->setUser($this->user);
|
||||
$opsRepository->setUserGroup($this->userGroup);
|
||||
$expenses = $opsRepository->collectExpenses($this->start, $this->end, null, $this->collection);
|
||||
$income = $opsRepository->collectIncome($this->start, $this->end, null, $this->collection);
|
||||
$transfers = $opsRepository->collectTransfers($this->start, $this->end, null, $this->collection);
|
||||
$expenses = $opsRepository->collectExpenses($this->start, $this->end, null, $this->collection);
|
||||
$income = $opsRepository->collectIncome($this->start, $this->end, null, $this->collection);
|
||||
$transfers = $opsRepository->collectTransfers($this->start, $this->end, null, $this->collection);
|
||||
foreach ($this->collection as $item) {
|
||||
$id = (int)$item->id;
|
||||
$this->spent[$id] = array_values($opsRepository->sumCollectedTransactionsByCategory($expenses, $item, 'negative', false));
|
||||
@@ -130,5 +133,4 @@ class CategoryEnrichment implements EnrichmentInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ class Navigation
|
||||
*/
|
||||
public function preferredEndOfPeriod(Carbon $start, Carbon $end): string
|
||||
{
|
||||
$diff = $start->diffInMonths($end, true);
|
||||
$diff = $start->diffInMonths($end, true);
|
||||
if ($diff >= 1.001) {
|
||||
return 'endOfMonth';
|
||||
}
|
||||
@@ -601,7 +601,7 @@ class Navigation
|
||||
*/
|
||||
public function preferredRangeFormat(Carbon $start, Carbon $end): string
|
||||
{
|
||||
$diff = $start->diffInMonths($end, true);
|
||||
$diff = $start->diffInMonths($end, true);
|
||||
if ($diff >= 1.001) {
|
||||
return '1M';
|
||||
}
|
||||
@@ -619,7 +619,7 @@ class Navigation
|
||||
*/
|
||||
public function preferredSqlFormat(Carbon $start, Carbon $end): string
|
||||
{
|
||||
$diff = $start->diffInMonths($end, true);
|
||||
$diff = $start->diffInMonths($end, true);
|
||||
if ($diff >= 1.001) {
|
||||
return '%Y-%m';
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ class CategoryTransformer extends AbstractTransformer
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $category->id,
|
||||
'created_at' => $category->created_at->toAtomString(),
|
||||
'updated_at' => $category->updated_at->toAtomString(),
|
||||
'name' => $category->name,
|
||||
'notes' => $category->meta['notes'],
|
||||
'id' => $category->id,
|
||||
'created_at' => $category->created_at->toAtomString(),
|
||||
'updated_at' => $category->updated_at->toAtomString(),
|
||||
'name' => $category->name,
|
||||
'notes' => $category->meta['notes'],
|
||||
|
||||
// category never has currency settings.
|
||||
'object_has_currency_setting' => false,
|
||||
'object_has_currency_setting' => false,
|
||||
|
||||
|
||||
'primary_currency_id' => (string)$this->primaryCurrency->id,
|
||||
@@ -74,7 +74,7 @@ class CategoryTransformer extends AbstractTransformer
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/categories/' . $category->id,
|
||||
'uri' => '/categories/'.$category->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -36,9 +36,9 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Safe\json_decode;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user