Auto commit for release 'develop' on 2025-02-10

This commit is contained in:
github-actions
2025-02-10 04:10:23 +01:00
parent 41ad35880d
commit 57ec9b8e36
22 changed files with 44 additions and 38 deletions

View File

@@ -54,7 +54,7 @@ class TransactionController extends Controller
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);
$this->repository = app(JournalRepositoryInterface::class); $this->repository = app(JournalRepositoryInterface::class);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class); $this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -62,8 +62,8 @@ class StoreController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $admin */ /** @var User $admin */
$admin = auth()->user(); $admin = auth()->user();
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class); $this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin); $this->groupRepository->setUser($admin);
@@ -107,35 +107,36 @@ class StoreController extends Controller
throw new ValidationException($validator); throw new ValidationException($validator);
} }
app('preferences')->mark(); app('preferences')->mark();
$applyRules = $data['apply_rules'] ?? true; $applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true; $fireWebhooks = $data['fire_webhooks'] ?? true;
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks)); event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
$manager = $this->getManager(); $manager = $this->getManager();
/** @var User $admin */ /** @var User $admin */
$admin = auth()->user(); $admin = auth()->user();
// use new group collector: // use new group collector:
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector $collector
->setUser($admin) ->setUser($admin)
->setUserGroup($this->userGroup) ->setUserGroup($this->userGroup)
// filter on transaction group. // filter on transaction group.
->setTransactionGroup($transactionGroup) ->setTransactionGroup($transactionGroup)
// all info needed for the API: // all info needed for the API:
->withAPIInformation(); ->withAPIInformation()
;
$selectedGroup = $collector->getGroups()->first(); $selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) { if (null === $selectedGroup) {
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.'); throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
} }
/** @var TransactionGroupTransformer $transformer */ /** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class); $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters); $transformer->setParameters($this->parameters);
$resource = new Item($selectedGroup, $transformer, 'transactions'); $resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
} }

View File

@@ -32,7 +32,6 @@ use FireflyIII\Models\AccountBalance;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface; use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\ExchangeRateConverter; use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;

View File

@@ -103,7 +103,7 @@ class TagFactory
public function setUser(User $user): void public function setUser(User $user): void
{ {
$this->user = $user; $this->user = $user;
$this->userGroup = $user->userGroup; $this->userGroup = $user->userGroup;
} }

View File

@@ -29,10 +29,8 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\UserGroup;
use FireflyIII\Rules\UniqueIban; use FireflyIII\Rules\UniqueIban;
use FireflyIII\Services\Internal\Update\AccountUpdateService; use FireflyIII\Services\Internal\Update\AccountUpdateService;
use FireflyIII\User;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
/** /**
@@ -164,7 +162,7 @@ class TransactionFactory
} }
app('log')->debug('Will update account with IBAN information.'); app('log')->debug('Will update account with IBAN information.');
$service = app(AccountUpdateService::class); $service = app(AccountUpdateService::class);
$service->update($this->account, ['iban' => $this->accountInformation['iban']]); $service->update($this->account, ['iban' => $this->accountInformation['iban']]);
} }

View File

@@ -96,7 +96,8 @@ class TransactionGroupFactory
$this->user = $user; $this->user = $user;
} }
public function setUserGroup(UserGroup $userGroup): void { public function setUserGroup(UserGroup $userGroup): void
{
$this->userGroup = $userGroup; $this->userGroup = $userGroup;
} }
} }

View File

@@ -178,6 +178,7 @@ class TransactionJournalFactory
if (true === FireflyConfig::get('utc', false)->data) { if (true === FireflyConfig::get('utc', false)->data) {
$carbon->setTimezone('UTC'); $carbon->setTimezone('UTC');
} }
try { try {
// validate source and destination using a new Validator. // validate source and destination using a new Validator.
$this->validateAccounts($row); $this->validateAccounts($row);
@@ -402,7 +403,7 @@ class TransactionJournalFactory
*/ */
public function setUser(User $user): void public function setUser(User $user): void
{ {
$this->user = $user; $this->user = $user;
$this->userGroup = $user->userGroup; $this->userGroup = $user->userGroup;
$this->currencyRepository->setUser($this->user); $this->currencyRepository->setUser($this->user);
$this->tagFactory->setUser($user); $this->tagFactory->setUser($user);
@@ -413,7 +414,8 @@ class TransactionJournalFactory
$this->accountRepository->setUser($this->user); $this->accountRepository->setUser($this->user);
} }
public function setUserGroup(UserGroup $userGroup): void { public function setUserGroup(UserGroup $userGroup): void
{
$this->userGroup = $userGroup; $this->userGroup = $userGroup;
$this->currencyRepository->setUserGroup($userGroup); $this->currencyRepository->setUserGroup($userGroup);
$this->tagFactory->setUserGroup($userGroup); $this->tagFactory->setUserGroup($userGroup);

View File

@@ -54,7 +54,6 @@ class AccountRepository implements AccountRepositoryInterface
{ {
use UserGroupTrait; use UserGroupTrait;
/** /**
* Moved here from account CRUD. * Moved here from account CRUD.
*/ */

View File

@@ -149,6 +149,7 @@ interface AccountRepositoryInterface
public function searchAccountNr(string $query, array $types, int $limit): Collection; public function searchAccountNr(string $query, array $types, int $limit): Collection;
public function setUser(null|Authenticatable|User $user): void; public function setUser(null|Authenticatable|User $user): void;
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
public function store(array $data): Account; public function store(array $data): Account;

View File

@@ -39,8 +39,6 @@ use FireflyIII\Services\Internal\Update\BillUpdateService;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait; use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@@ -40,6 +40,7 @@ interface BillRepositoryInterface
public function billEndsWith(string $query, int $limit): Collection; public function billEndsWith(string $query, int $limit): Collection;
public function billStartsWith(string $query, int $limit): Collection; public function billStartsWith(string $query, int $limit): Collection;
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
/** /**

View File

@@ -42,8 +42,6 @@ use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\BudgetDestroyService; use FireflyIII\Services\Internal\Destroy\BudgetDestroyService;
use FireflyIII\Support\Http\Api\ExchangeRateConverter; use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait; use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;

View File

@@ -40,6 +40,7 @@ interface BudgetRepositoryInterface
public function budgetEndsWith(string $query, int $limit): Collection; public function budgetEndsWith(string $query, int $limit): Collection;
public function budgetStartsWith(string $query, int $limit): Collection; public function budgetStartsWith(string $query, int $limit): Collection;
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
/** /**

View File

@@ -88,6 +88,7 @@ interface CategoryRepositoryInterface
public function searchCategory(string $query, int $limit): Collection; public function searchCategory(string $query, int $limit): Collection;
public function setUser(null|Authenticatable|User $user): void; public function setUser(null|Authenticatable|User $user): void;
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
/** /**

View File

@@ -51,7 +51,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
use UserGroupTrait; use UserGroupTrait;
public function destroyAll(): void public function destroyAll(): void
{ {
Log::channel('audit')->info('Delete all piggy banks through destroyAll'); Log::channel('audit')->info('Delete all piggy banks through destroyAll');

View File

@@ -137,6 +137,7 @@ interface PiggyBankRepositoryInterface
public function setOrder(PiggyBank $piggyBank, int $newOrder): bool; public function setOrder(PiggyBank $piggyBank, int $newOrder): bool;
public function setUser(null|Authenticatable|User $user): void; public function setUser(null|Authenticatable|User $user): void;
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
/** /**

View File

@@ -44,8 +44,6 @@ use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
use FireflyIII\Services\Internal\Update\GroupUpdateService; use FireflyIII\Services\Internal\Update\GroupUpdateService;
use FireflyIII\Support\NullArrayObject; use FireflyIII\Support\NullArrayObject;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait; use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@@ -99,6 +99,7 @@ interface TransactionGroupRepositoryInterface
public function getTags(int $journalId): array; public function getTags(int $journalId): array;
public function setUser(null|Authenticatable|User $user): void; public function setUser(null|Authenticatable|User $user): void;
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
/** /**

View File

@@ -39,6 +39,7 @@ use Illuminate\Support\Facades\Log;
trait ValidatesUserGroupTrait trait ValidatesUserGroupTrait
{ {
protected ?UserGroup $userGroup = null; protected ?UserGroup $userGroup = null;
/** /**
* An "undocumented" filter * An "undocumented" filter
* *
@@ -100,6 +101,7 @@ trait ValidatesUserGroupTrait
if ($user->hasRoleInGroupOrOwner($group, $role)) { if ($user->hasRoleInGroupOrOwner($group, $role)) {
Log::debug(sprintf('validateUserGroup: User has role "%s" in group #%d, return the group.', $role->value, $groupId)); Log::debug(sprintf('validateUserGroup: User has role "%s" in group #%d, return the group.', $role->value, $groupId));
$this->userGroup = $group; $this->userGroup = $group;
return $group; return $group;
} }
Log::debug(sprintf('validateUserGroup: User does NOT have role "%s" in group #%d, continue searching.', $role->value, $groupId)); Log::debug(sprintf('validateUserGroup: User does NOT have role "%s" in group #%d, continue searching.', $role->value, $groupId));

View File

@@ -48,11 +48,13 @@ trait UserGroupTrait
public function checkUserGroupAccess(UserRoleEnum $role): bool public function checkUserGroupAccess(UserRoleEnum $role): bool
{ {
$result = $this->user->hasRoleInGroupOrOwner($this->userGroup, $role); $result = $this->user->hasRoleInGroupOrOwner($this->userGroup, $role);
if($result) { if ($result) {
Log::debug(sprintf('User #%d has role %s in group #%d or is owner/full.', $this->user->id, $role->value, $this->userGroup->id)); Log::debug(sprintf('User #%d has role %s in group #%d or is owner/full.', $this->user->id, $role->value, $this->userGroup->id));
return true; return true;
} }
Log::warning(sprintf('User #%d DOES NOT have role %s in group #%d.', $this->user->id, $role->value, $this->userGroup->id)); Log::warning(sprintf('User #%d DOES NOT have role %s in group #%d.', $this->user->id, $role->value, $this->userGroup->id));
return false; return false;
} }
@@ -62,7 +64,7 @@ trait UserGroupTrait
public function setUserGroup(UserGroup $userGroup): void public function setUserGroup(UserGroup $userGroup): void
{ {
if (null === $this->user) { if (null === $this->user) {
Log::warning(sprintf('User is not set in repository %s', get_class($this))); Log::warning(sprintf('User is not set in repository %s', static::class));
} }
$this->userGroup = $userGroup; $this->userGroup = $userGroup;
} }
@@ -70,16 +72,18 @@ trait UserGroupTrait
/** /**
* @throws FireflyException * @throws FireflyException
*/ */
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;
if (null === $user->userGroup) { if (null === $user->userGroup) {
throw new FireflyException(sprintf('User #%d has no user group.', $user->id)); throw new FireflyException(sprintf('User #%d has no user group.', $user->id));
} }
$this->userGroup = $user->userGroup; $this->userGroup = $user->userGroup;
return; return;
} }
throw new FireflyException(sprintf('Object is of class %s, not User.', get_class($user))); throw new FireflyException(sprintf('Object is of class %s, not User.', get_class($user)));
} }
@@ -89,14 +93,15 @@ trait UserGroupTrait
public function setUserGroupById(int $userGroupId): void public function setUserGroupById(int $userGroupId): void
{ {
$memberships = GroupMembership::where('user_id', $this->user->id) $memberships = GroupMembership::where('user_id', $this->user->id)
->where('user_group_id', $userGroupId) ->where('user_group_id', $userGroupId)
->count(); ->count()
;
if (0 === $memberships) { if (0 === $memberships) {
throw new FireflyException(sprintf('User #%d has no access to administration #%d', $this->user->id, $userGroupId)); throw new FireflyException(sprintf('User #%d has no access to administration #%d', $this->user->id, $userGroupId));
} }
/** @var null|UserGroup $userGroup */ /** @var null|UserGroup $userGroup */
$userGroup = UserGroup::find($userGroupId); $userGroup = UserGroup::find($userGroupId);
if (null === $userGroup) { if (null === $userGroup) {
throw new FireflyException(sprintf('Cannot find administration for user #%d', $this->user->id)); throw new FireflyException(sprintf('Cannot find administration for user #%d', $this->user->id));
} }

View File

@@ -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' => 'develop/2025-02-09', 'version' => 'develop/2025-02-10',
'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,

View File

@@ -18,8 +18,8 @@
"is_reconciled": "Est rapproch\u00e9", "is_reconciled": "Est rapproch\u00e9",
"split": "S\u00e9paration", "split": "S\u00e9paration",
"single_split": "S\u00e9paration unique", "single_split": "S\u00e9paration unique",
"not_enough_currencies": "Not enough currencies", "not_enough_currencies": "Pas assez de devises",
"not_enough_currencies_enabled": "If you have just one currency enabled, there is no need to add exchange rates.", "not_enough_currencies_enabled": "Si vous n'avez qu'une seule devise activ\u00e9e, il n'y a pas besoin d'ajouter des taux de change.",
"transaction_stored_link": "<a href=\"transactions\/show\/{ID}\">L'op\u00e9ration n\u00b0{ID} (\"{title}\")<\/a> a \u00e9t\u00e9 enregistr\u00e9e.", "transaction_stored_link": "<a href=\"transactions\/show\/{ID}\">L'op\u00e9ration n\u00b0{ID} (\"{title}\")<\/a> a \u00e9t\u00e9 enregistr\u00e9e.",
"webhook_stored_link": "<a href=\"webhooks\/show\/{ID}\">Le Webhook #{ID} (\"{title}\")<\/a> a \u00e9t\u00e9 enregistr\u00e9.", "webhook_stored_link": "<a href=\"webhooks\/show\/{ID}\">Le Webhook #{ID} (\"{title}\")<\/a> a \u00e9t\u00e9 enregistr\u00e9.",
"webhook_updated_link": "<a href=\"webhooks\/show\/{ID}\">Le webhook #{ID}<\/a> (\"{title}\") a \u00e9t\u00e9 mis \u00e0 jour.", "webhook_updated_link": "<a href=\"webhooks\/show\/{ID}\">Le webhook #{ID}<\/a> (\"{title}\") a \u00e9t\u00e9 mis \u00e0 jour.",