Auto commit for release 'develop' on 2024-05-13

This commit is contained in:
github-actions
2024-05-13 05:10:16 +02:00
parent 04fe5d1fc4
commit cb5d856769
48 changed files with 271 additions and 398 deletions

View File

@@ -226,16 +226,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.56.0", "version": "v3.56.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "4429303e62a4ce583ddfe64ff5c34c76bcf74931" "reference": "69c6168ae8bc96dc656c7f6c7271120a68ae5903"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/4429303e62a4ce583ddfe64ff5c34c76bcf74931", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/69c6168ae8bc96dc656c7f6c7271120a68ae5903",
"reference": "4429303e62a4ce583ddfe64ff5c34c76bcf74931", "reference": "69c6168ae8bc96dc656c7f6c7271120a68ae5903",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -307,7 +307,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.56.0" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.56.1"
}, },
"funding": [ "funding": [
{ {
@@ -315,7 +315,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-05-07T15:50:05+00:00" "time": "2024-05-10T11:31:15+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Autocomplete; namespace FireflyIII\Api\V2\Controllers\Autocomplete;
use Carbon\Carbon;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Autocomplete\AutocompleteRequest; use FireflyIII\Api\V2\Request\Autocomplete\AutocompleteRequest;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@@ -41,7 +40,6 @@ use Illuminate\Http\JsonResponse;
*/ */
class AccountController extends Controller class AccountController extends Controller
{ {
// use AccountFilter; // use AccountFilter;
private AdminAccountRepositoryInterface $adminRepository; private AdminAccountRepositoryInterface $adminRepository;
private TransactionCurrency $default; private TransactionCurrency $default;
@@ -102,6 +100,7 @@ class AccountController extends Controller
private function parseAccount(Account $account): array private function parseAccount(Account $account): array
{ {
$currency = $this->adminRepository->getAccountCurrency($account); $currency = $this->adminRepository->getAccountCurrency($account);
return [ return [
'id' => (string) $account->id, 'id' => (string) $account->id,
'title' => $account->name, 'title' => $account->name,
@@ -120,21 +119,19 @@ class AccountController extends Controller
{ {
$return = []; $return = [];
$balances = $this->adminRepository->getAccountBalances($account); $balances = $this->adminRepository->getAccountBalances($account);
/** @var AccountBalance $balance */ /** @var AccountBalance $balance */
foreach ($balances as $balance) { foreach ($balances as $balance) {
$return[] = $this->parseAccountBalance($balance); $return[] = $this->parseAccountBalance($balance);
} }
return $return; return $return;
} }
/**
* @param AccountBalance $balance
*
* @return array
*/
private function parseAccountBalance(AccountBalance $balance): array private function parseAccountBalance(AccountBalance $balance): array
{ {
$currency = $balance->transactionCurrency; $currency = $balance->transactionCurrency;
return [ return [
'title' => $balance->title, 'title' => $balance->title,
'native_amount' => $this->converter->convert($currency, $this->default, today(), $balance->balance), 'native_amount' => $this->converter->convert($currency, $this->default, today(), $balance->balance),
@@ -147,8 +144,6 @@ class AccountController extends Controller
'native_currency_code' => $this->default->code, 'native_currency_code' => $this->default->code,
'native_currency_symbol' => $this->default->symbol, 'native_currency_symbol' => $this->default->symbol,
'native_currency_decimal' => $this->default->decimal_places, 'native_currency_decimal' => $this->default->decimal_places,
]; ];
} }
} }

View File

@@ -35,26 +35,26 @@ use Illuminate\Foundation\Http\FormRequest;
use LaravelJsonApi\Core\Query\QueryParameters; use LaravelJsonApi\Core\Query\QueryParameters;
use LaravelJsonApi\Validation\Rule as JsonApiRule; use LaravelJsonApi\Validation\Rule as JsonApiRule;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
/** /**
* Class AutocompleteRequest * Class AutocompleteRequest
*/ */
class AutocompleteRequest extends FormRequest class AutocompleteRequest extends FormRequest
{ {
use AccountFilter;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
use AccountFilter;
/** /**
* Loops over all possible query parameters (these are shared over ALL auto complete requests) * Loops over all possible query parameters (these are shared over ALL auto complete requests)
* and returns a validated array of parameters. * and returns a validated array of parameters.
* *
* The advantage is a single class. But you may also submit "account types" to an endpoint that doesn't use these. * The advantage is a single class. But you may also submit "account types" to an endpoint that doesn't use these.
*
* @return array
*/ */
public function getParameters(): array public function getParameters(): array
{ {
$queryParameters = QueryParameters::cast($this->all()); $queryParameters = QueryParameters::cast($this->all());
try { try {
$date = Carbon::createFromFormat('Y-m-d', $queryParameters->filter()?->value('date', date('Y-m-d')), config('app.timezone')); $date = Carbon::createFromFormat('Y-m-d', $queryParameters->filter()?->value('date', date('Y-m-d')), config('app.timezone'));
} catch (InvalidFormatException $e) { } catch (InvalidFormatException $e) {
@@ -65,20 +65,16 @@ class AutocompleteRequest extends FormRequest
$size = (int) ($queryParameters->page()['size'] ?? 50); $size = (int) ($queryParameters->page()['size'] ?? 50);
$accountTypes = $this->getAccountTypeParameter($queryParameters->filter()?->value('account_types', '') ?? ''); $accountTypes = $this->getAccountTypeParameter($queryParameters->filter()?->value('account_types', '') ?? '');
return [ return [
'date' => $date, 'date' => $date,
'query' => $query, 'query' => $query,
'size' => $size, 'size' => $size,
'account_types' => $accountTypes, 'account_types' => $accountTypes,
]; ];
} }
public function getData(): array public function getData(): array
{ {
return []; return [];
$types = $this->convertString('types'); $types = $this->convertString('types');
$array = []; $array = [];
@@ -101,12 +97,11 @@ class AutocompleteRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'fields' => JsonApiRule::notSupported(), 'fields' => JsonApiRule::notSupported(),
'filter' => ['nullable', 'array', new IsValidFilter(['query', 'date', 'account_types']),], 'filter' => ['nullable', 'array', new IsValidFilter(['query', 'date', 'account_types'])],
'include' => JsonApiRule::notSupported(), 'include' => JsonApiRule::notSupported(),
'page' => ['nullable', 'array', new IsValidPage(['size']),], 'page' => ['nullable', 'array', new IsValidPage(['size'])],
'sort' => JsonApiRule::notSupported(), 'sort' => JsonApiRule::notSupported(),
]; ];
} }
@@ -123,6 +118,7 @@ class AutocompleteRequest extends FormRequest
foreach ($types as $type) { foreach ($types as $type) {
$return = array_merge($return, $this->mapAccountTypes($type)); $return = array_merge($return, $this->mapAccountTypes($type));
} }
return array_unique($return); return array_unique($return);
} }
} }

View File

@@ -1,35 +1,29 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\Console\Commands\Correction; namespace FireflyIII\Console\Commands\Correction;
use DB;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\AccountBalance;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\Models\AccountBalanceCalculator; use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use stdClass;
/** /**
* Class CorrectionSkeleton * Class CorrectionSkeleton
*/ */
class CorrectAccountBalance extends Command class CorrectAccountBalance extends Command
{ {
use ShowsFriendlyMessages;
protected $description = 'Recalculate all account balance amounts'; protected $description = 'Recalculate all account balance amounts';
protected $signature = 'firefly-iii:correct-account-balance'; protected $signature = 'firefly-iii:correct-account-balance';
use ShowsFriendlyMessages;
/**
* @return int
*/
public function handle(): int public function handle(): int
{ {
$this->correctBalanceAmounts(); $this->correctBalanceAmounts();
return 0; return 0;
} }

View File

@@ -33,7 +33,7 @@ class AccountBalance
public static function fromArray(): self public static function fromArray(): self
{ {
$balance = new self; $balance = new self();
$balance->id = (string) random_int(1, 1000); $balance->id = (string) random_int(1, 1000);
$balance->name = (string) random_int(1, 1000); $balance->name = (string) random_int(1, 1000);
$balance->amount = (string) random_int(1, 1000); $balance->amount = (string) random_int(1, 1000);
@@ -42,8 +42,8 @@ class AccountBalance
return $balance; return $balance;
} }
public function getAccount():Account { public function getAccount(): Account
{
return Account::inRandomOrder()->first(); return Account::inRandomOrder()->first();
} }
} }

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer; namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Facades\Log;
/** /**
* Class TransactionJournalObserver * Class TransactionJournalObserver
@@ -49,5 +48,4 @@ class TransactionJournalObserver
$transactionJournal->destJournalLinks()->delete(); $transactionJournal->destJournalLinks()->delete();
$transactionJournal->auditLogEntries()->delete(); $transactionJournal->auditLogEntries()->delete();
} }
} }

View File

@@ -23,11 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer; namespace FireflyIII\Handlers\Observer;
use DB;
use FireflyIII\Models\AccountBalance;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Support\Models\AccountBalanceCalculator; use FireflyIII\Support\Models\AccountBalanceCalculator;
use stdClass;
/** /**
* Class TransactionObserver * Class TransactionObserver
@@ -48,6 +45,7 @@ class TransactionObserver
AccountBalanceCalculator::recalculateByJournal($transaction->transactionJournal); AccountBalanceCalculator::recalculateByJournal($transaction->transactionJournal);
} }
} }
public function created(Transaction $transaction): void public function created(Transaction $transaction): void
{ {
app('log')->debug('Observe "created" of a transaction.'); app('log')->debug('Observe "created" of a transaction.');

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Api\V3\Controllers; namespace FireflyIII\Http\Controllers\Api\V3\Controllers;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -13,17 +15,16 @@ use LaravelJsonApi\Laravel\Http\Requests\AnonymousQuery;
class AccountController extends Controller class AccountController extends Controller
{ {
use Actions\AttachRelationship;
use Actions\Destroy;
use Actions\DetachRelationship;
use Actions\FetchMany; use Actions\FetchMany;
use Actions\FetchOne; use Actions\FetchOne;
use Actions\Store;
use Actions\Update;
use Actions\Destroy;
use Actions\FetchRelated; use Actions\FetchRelated;
use Actions\FetchRelationship; use Actions\FetchRelationship;
use Actions\Store;
use Actions\Update;
use Actions\UpdateRelationship; use Actions\UpdateRelationship;
use Actions\AttachRelationship;
use Actions\DetachRelationship;
public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable
{ {
@@ -34,7 +35,8 @@ class AccountController extends Controller
->queryAll() ->queryAll()
->withRequest($query) ->withRequest($query)
->withAccount($account) ->withAccount($account)
->get(); ->get()
;
return DataResponse::make($models); return DataResponse::make($models);
} }

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\JsonApi\Rules; namespace FireflyIII\JsonApi\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Contracts\Validation\ValidationRule;
class IsValidFilter implements ValidationRule class IsValidFilter implements ValidationRule
@@ -35,10 +34,8 @@ class IsValidFilter implements ValidationRule
$this->allowed = $keys; $this->allowed = $keys;
} }
/** #[\Override]
* @inheritDoc public function validate(string $attribute, mixed $value, \Closure $fail): void
*/
#[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void
{ {
if ('filter' !== $attribute) { if ('filter' !== $attribute) {
$fail('validation.bad_api_filter')->translate(); $fail('validation.bad_api_filter')->translate();

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\JsonApi\Rules; namespace FireflyIII\JsonApi\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Contracts\Validation\ValidationRule;
class IsValidPage implements ValidationRule class IsValidPage implements ValidationRule
@@ -35,10 +34,8 @@ class IsValidPage implements ValidationRule
$this->allowed = $keys; $this->allowed = $keys;
} }
/** #[\Override]
* @inheritDoc public function validate(string $attribute, mixed $value, \Closure $fail): void
*/
#[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void
{ {
if ('page' !== $attribute) { if ('page' !== $attribute) {
$fail('validation.bad_api_filter')->translate(); $fail('validation.bad_api_filter')->translate();

View File

@@ -29,23 +29,17 @@ use LaravelJsonApi\NonEloquent\AbstractRepository;
class AccountBalanceRepository extends AbstractRepository implements QueriesAll class AccountBalanceRepository extends AbstractRepository implements QueriesAll
{ {
#[\Override]
/** public function find(string $resourceId): ?object
* @inheritDoc
*/
#[\Override] public function find(string $resourceId): ?object
{ {
return AccountBalance::fromArray(); return AccountBalance::fromArray();
} }
/**
* @inheritDoc
*/
public function queryAll(): Capabilities\AccountBalanceQuery public function queryAll(): Capabilities\AccountBalanceQuery
{ {
return Capabilities\AccountBalanceQuery::make() return Capabilities\AccountBalanceQuery::make()
->withServer($this->server) ->withServer($this->server)
->withSchema($this->schema); ->withSchema($this->schema)
;
} }
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3\AccountBalances; namespace FireflyIII\JsonApi\V3\AccountBalances;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -9,8 +11,6 @@ class AccountBalanceResource extends JsonApiResource
{ {
/** /**
* Get the resource id. * Get the resource id.
*
* @return string
*/ */
public function id(): string public function id(): string
{ {
@@ -20,9 +20,7 @@ class AccountBalanceResource extends JsonApiResource
/** /**
* Get the resource's attributes. * Get the resource's attributes.
* *
* @param Request|null $request * @param null|Request $request
*
* @return iterable
*/ */
public function attributes($request): iterable public function attributes($request): iterable
{ {
@@ -35,9 +33,7 @@ class AccountBalanceResource extends JsonApiResource
/** /**
* Get the resource's relationships. * Get the resource's relationships.
* *
* @param Request|null $request * @param null|Request $request
*
* @return iterable
*/ */
public function relationships($request): iterable public function relationships($request): iterable
{ {
@@ -45,5 +41,4 @@ class AccountBalanceResource extends JsonApiResource
$this->relation('account')->withData($this->resource->getAccount()), $this->relation('account')->withData($this->resource->getAccount()),
]; ];
} }
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3\AccountBalances; namespace FireflyIII\JsonApi\V3\AccountBalances;
use FireflyIII\Entities\AccountBalance; use FireflyIII\Entities\AccountBalance;
@@ -10,18 +12,13 @@ use LaravelJsonApi\NonEloquent\Fields\ID;
class AccountBalanceSchema extends Schema class AccountBalanceSchema extends Schema
{ {
/** /**
* The model the schema corresponds to. * The model the schema corresponds to.
*
* @var string
*/ */
public static string $model = AccountBalance::class; public static string $model = AccountBalance::class;
/** /**
* Get the resource fields. * Get the resource fields.
*
* @return array
*/ */
public function fields(): array public function fields(): array
{ {
@@ -35,8 +32,6 @@ class AccountBalanceSchema extends Schema
/** /**
* Get the resource filters. * Get the resource filters.
*
* @return array
*/ */
public function filters(): array public function filters(): array
{ {
@@ -49,6 +44,7 @@ class AccountBalanceSchema extends Schema
{ {
return AccountBalanceRepository::make() return AccountBalanceRepository::make()
->withServer($this->server) ->withServer($this->server)
->withSchema($this); ->withSchema($this)
;
} }
} }

View File

@@ -39,9 +39,6 @@ class AccountBalanceQuery extends QueryAll
parent::__construct(); parent::__construct();
} }
/**
* @inheritDoc
*/
public function get(): iterable public function get(): iterable
{ {
return [ return [
@@ -55,7 +52,7 @@ class AccountBalanceQuery extends QueryAll
public function withAccount(Account $account): self public function withAccount(Account $account): self
{ {
$this->account = $account; $this->account = $account;
return $this; return $this;
} }
} }

View File

@@ -27,8 +27,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Support\JsonApi\Concerns\UsergroupAware; use FireflyIII\Support\JsonApi\Concerns\UsergroupAware;
use LaravelJsonApi\Contracts\Store\QueriesAll; use LaravelJsonApi\Contracts\Store\QueriesAll;
use LaravelJsonApi\NonEloquent\AbstractRepository; use LaravelJsonApi\NonEloquent\AbstractRepository;
use LaravelJsonApi\NonEloquent\Concerns\HasCrudCapability;
class AccountRepository extends AbstractRepository implements QueriesAll class AccountRepository extends AbstractRepository implements QueriesAll
{ {
@@ -36,16 +34,11 @@ class AccountRepository extends AbstractRepository implements QueriesAll
/** /**
* SiteRepository constructor. * SiteRepository constructor.
*
*/ */
public function __construct() {} public function __construct() {}
/**
* @inheritDoc
*/
public function find(string $resourceId): ?object public function find(string $resourceId): ?object
{ {
return Account::find((int) $resourceId); return Account::find((int) $resourceId);
} }
@@ -54,7 +47,7 @@ class AccountRepository extends AbstractRepository implements QueriesAll
return Capabilities\AccountQuery::make() return Capabilities\AccountQuery::make()
->withUserGroup($this->userGroup) ->withUserGroup($this->userGroup)
->withServer($this->server) ->withServer($this->server)
->withSchema($this->schema); ->withSchema($this->schema)
;
} }
} }

View File

@@ -1,10 +1,11 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3\Accounts; namespace FireflyIII\JsonApi\V3\Accounts;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use LaravelJsonApi\Core\Resources\JsonApiResource; use LaravelJsonApi\Core\Resources\JsonApiResource;
/** /**
@@ -12,13 +13,10 @@ use LaravelJsonApi\Core\Resources\JsonApiResource;
*/ */
class AccountResource extends JsonApiResource class AccountResource extends JsonApiResource
{ {
/** /**
* Get the resource's attributes. * Get the resource's attributes.
* *
* @param Request|null $request * @param null|Request $request
*
* @return iterable
*/ */
public function attributes($request): iterable public function attributes($request): iterable
{ {
@@ -32,11 +30,6 @@ class AccountResource extends JsonApiResource
'type' => $this->resource->type, 'type' => $this->resource->type,
'account_role' => $this->resource->account_role, 'account_role' => $this->resource->account_role,
// 'virtual_balance' => $this->resource->virtual_balance, // 'virtual_balance' => $this->resource->virtual_balance,
// 'native_balance' => $this->resource->native_balance, // 'native_balance' => $this->resource->native_balance,
// 'user' => $this->resource->user_array, // 'user' => $this->resource->user_array,
@@ -51,7 +44,6 @@ class AccountResource extends JsonApiResource
// balance (in currency, on date) // balance (in currency, on date)
// 'current_balance' => $this->resource->current_balance, // 'current_balance' => $this->resource->current_balance,
// 'current_balance' => app('steam')->bcround(app('steam')->balance($account, $date), $decimalPlaces), // 'current_balance' => app('steam')->bcround(app('steam')->balance($account, $date), $decimalPlaces),
// 'current_balance_date' => $date->toAtomString(), // 'current_balance_date' => $date->toAtomString(),
// 'notes' => $this->repository->getNoteText($account), // 'notes' => $this->repository->getNoteText($account),
@@ -125,9 +117,7 @@ class AccountResource extends JsonApiResource
/** /**
* Get the resource's relationships. * Get the resource's relationships.
* *
* @param Request|null $request * @param null|Request $request
*
* @return iterable
*/ */
public function relationships($request): iterable public function relationships($request): iterable
{ {
@@ -136,5 +126,4 @@ class AccountResource extends JsonApiResource
$this->relation('account_balances')->withData($this->resource->balances), $this->relation('account_balances')->withData($this->resource->balances),
]; ];
} }
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3\Accounts; namespace FireflyIII\JsonApi\V3\Accounts;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
@@ -17,18 +19,13 @@ use LaravelJsonApi\Eloquent\Schema;
class AccountSchema extends Schema class AccountSchema extends Schema
{ {
/** /**
* The model the schema corresponds to. * The model the schema corresponds to.
*
* @var string
*/ */
public static string $model = Account::class; public static string $model = Account::class;
/** /**
* Get the resource fields. * Get the resource fields.
*
* @return array
*/ */
public function fields(): array public function fields(): array
{ {
@@ -49,8 +46,6 @@ class AccountSchema extends Schema
/** /**
* Get the resource filters. * Get the resource filters.
*
* @return array
*/ */
public function filters(): array public function filters(): array
{ {
@@ -61,12 +56,9 @@ class AccountSchema extends Schema
/** /**
* Get the resource paginator. * Get the resource paginator.
*
* @return Paginator|null
*/ */
public function pagination(): ?Paginator public function pagination(): ?Paginator
{ {
return PagePagination::make(); return PagePagination::make();
} }
} }

View File

@@ -35,19 +35,16 @@ use LaravelJsonApi\NonEloquent\Concerns\PaginatesEnumerables;
class AccountQuery extends QueryAll implements HasPagination class AccountQuery extends QueryAll implements HasPagination
{ {
use PaginatesEnumerables;
use FiltersPagination;
use ValidateSortParameters;
use UsergroupAware;
use ExpandsQuery; use ExpandsQuery;
use FiltersPagination;
use PaginatesEnumerables;
use SortsCollection; use SortsCollection;
use UsergroupAware;
use ValidateSortParameters;
/** #[\Override]
* @inheritDoc public function get(): iterable
*/
#[\Override] public function get(): iterable
{ {
$filters = $this->queryParameters->filter(); $filters = $this->queryParameters->filter();
$sort = $this->queryParameters->sortFields(); $sort = $this->queryParameters->sortFields();
$pagination = $this->filtersPagination($this->queryParameters->page()); $pagination = $this->filtersPagination($this->queryParameters->page());
@@ -66,15 +63,10 @@ class AccountQuery extends QueryAll implements HasPagination
$enrichment = new AccountEnrichment(); $enrichment = new AccountEnrichment();
$collection = $enrichment->enrich($collection); $collection = $enrichment->enrich($collection);
// add filters after the query // add filters after the query
// add sort after the query // add sort after the query
$collection = $this->sortCollection($collection, $sort); return $this->sortCollection($collection, $sort);
return $collection;
// var_dump($filters->value('name')); // var_dump($filters->value('name'));
// exit; // exit;
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3; namespace FireflyIII\JsonApi\V3;
use FireflyIII\JsonApi\V3\Accounts\AccountSchema; use FireflyIII\JsonApi\V3\Accounts\AccountSchema;
@@ -9,18 +11,13 @@ use LaravelJsonApi\Core\Server\Server as BaseServer;
class Server extends BaseServer class Server extends BaseServer
{ {
/** /**
* The base URI namespace for this server. * The base URI namespace for this server.
*
* @var string
*/ */
protected string $baseUri = '/api/v3'; protected string $baseUri = '/api/v3';
/** /**
* Bootstrap the server when it is handling an HTTP request. * Bootstrap the server when it is handling an HTTP request.
*
* @return void
*/ */
public function serving(): void public function serving(): void
{ {
@@ -29,8 +26,6 @@ class Server extends BaseServer
/** /**
* Get the server's list of schemas. * Get the server's list of schemas.
*
* @return array
*/ */
protected function allSchemas(): array protected function allSchemas(): array
{ {
@@ -40,5 +35,4 @@ class Server extends BaseServer
AccountBalanceSchema::class, AccountBalanceSchema::class,
]; ];
} }
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3\Users; namespace FireflyIII\JsonApi\V3\Users;
use FireflyIII\Models\User; use FireflyIII\Models\User;
@@ -11,12 +13,10 @@ use LaravelJsonApi\Core\Resources\JsonApiResource;
*/ */
class UserResource extends JsonApiResource class UserResource extends JsonApiResource
{ {
/** /**
* Get the resource's attributes. * Get the resource's attributes.
* *
* @param Request|null $request * @param null|Request $request
* @return iterable
*/ */
public function attributes($request): iterable public function attributes($request): iterable
{ {
@@ -30,8 +30,7 @@ class UserResource extends JsonApiResource
/** /**
* Get the resource's relationships. * Get the resource's relationships.
* *
* @param Request|null $request * @param null|Request $request
* @return iterable
*/ */
public function relationships($request): iterable public function relationships($request): iterable
{ {
@@ -39,5 +38,4 @@ class UserResource extends JsonApiResource
// @TODO // @TODO
]; ];
} }
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\JsonApi\V3\Users; namespace FireflyIII\JsonApi\V3\Users;
use FireflyIII\User; use FireflyIII\User;
@@ -14,18 +16,13 @@ use LaravelJsonApi\Eloquent\Schema;
class UserSchema extends Schema class UserSchema extends Schema
{ {
/** /**
* The model the schema corresponds to. * The model the schema corresponds to.
*
* @var string
*/ */
public static string $model = User::class; public static string $model = User::class;
/** /**
* Get the resource fields. * Get the resource fields.
*
* @return array
*/ */
public function fields(): array public function fields(): array
{ {
@@ -40,8 +37,6 @@ class UserSchema extends Schema
/** /**
* Get the resource filters. * Get the resource filters.
*
* @return array
*/ */
public function filters(): array public function filters(): array
{ {
@@ -52,8 +47,6 @@ class UserSchema extends Schema
/** /**
* Get the resource paginator. * Get the resource paginator.
*
* @return Paginator|null
*/ */
public function pagination(): ?Paginator public function pagination(): ?Paginator
{ {

View File

@@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\Models; namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -8,9 +10,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class AccountBalance extends Model class AccountBalance extends Model
{ {
protected $fillable = ['account_id', 'title', 'transaction_currency_id', 'balance'];
use HasFactory; use HasFactory;
protected $fillable = ['account_id', 'title', 'transaction_currency_id', 'balance'];
public function account(): BelongsTo public function account(): BelongsTo
{ {

View File

@@ -24,27 +24,18 @@ declare(strict_types=1);
namespace FireflyIII\Policies; namespace FireflyIII\Policies;
use FireflyIII\Entities\AccountBalance; use FireflyIII\Entities\AccountBalance;
use FireflyIII\Models\Account;
use FireflyIII\User; use FireflyIII\User;
class AccountBalancePolicy class AccountBalancePolicy
{ {
/** /**
* TODO needs better authentication. * TODO needs better authentication.
*
* @param User $user
* @param Account $account
*
* @return bool
*/ */
public function view(User $user, AccountBalance $accountBalance): bool public function view(User $user, AccountBalance $accountBalance): bool
{ {
return true; return true;
} }
/** /**
* Everybody can do this, but selection should limit to user. * Everybody can do this, but selection should limit to user.
* *
@@ -54,6 +45,4 @@ class AccountBalancePolicy
{ {
return true; return true;
} }
} }

View File

@@ -28,23 +28,16 @@ use FireflyIII\User;
class AccountPolicy class AccountPolicy
{ {
/** /**
* TODO needs better authentication. * TODO needs better authentication.
*
* @param User $user
* @param Account $account
*
* @return bool
*/ */
public function view(User $user, Account $account): bool public function view(User $user, Account $account): bool
{ {
return true; return true;
return auth()->check() && $user->id === $account->user_id; return auth()->check() && $user->id === $account->user_id;
} }
/** /**
* Everybody can do this, but selection should limit to user. * Everybody can do this, but selection should limit to user.
* *
@@ -53,6 +46,7 @@ class AccountPolicy
public function viewAny(): bool public function viewAny(): bool
{ {
return true; return true;
return auth()->check(); return auth()->check();
} }

View File

@@ -30,11 +30,6 @@ class BalancePolicy
{ {
/** /**
* TODO needs better authentication. * TODO needs better authentication.
*
* @param User $user
* @param Account $account
*
* @return bool
*/ */
public function view(User $user, Account $account): bool public function view(User $user, Account $account): bool
{ {

View File

@@ -23,22 +23,17 @@ declare(strict_types=1);
namespace FireflyIII\Policies; namespace FireflyIII\Policies;
use FireflyIII\Models\Account;
use FireflyIII\User; use FireflyIII\User;
class UserPolicy class UserPolicy
{ {
/** /**
* TODO needs better authentication. * TODO needs better authentication.
*
* @param User $user
* @param Account $account
*
* @return bool
*/ */
public function view(User $user, User $user1): bool public function view(User $user, User $user1): bool
{ {
return true; return true;
return auth()->check() && $user->id === $account->user_id; return auth()->check() && $user->id === $account->user_id;
} }
@@ -50,11 +45,14 @@ class UserPolicy
public function viewAny(): bool public function viewAny(): bool
{ {
return true; return true;
return auth()->check(); return auth()->check();
} }
public function viewAccounts(User $user): bool public function viewAccounts(User $user): bool
{ {
return true; return true;
return auth()->check(); return auth()->check();
} }
} }

View File

@@ -386,7 +386,8 @@ class AccountRepository implements AccountRepositoryInterface
return $return; return $return;
} }
#[\Override] public function getAccountBalances(Account $account): Collection #[\Override]
public function getAccountBalances(Account $account): Collection
{ {
return $account->accountBalances; return $account->accountBalances;
} }

View File

@@ -27,7 +27,6 @@ use FireflyIII\Models\UserGroup;
trait UsergroupAware trait UsergroupAware
{ {
protected UserGroup $userGroup; protected UserGroup $userGroup;
public function getUserGroup(): UserGroup public function getUserGroup(): UserGroup
@@ -40,9 +39,10 @@ trait UsergroupAware
$this->userGroup = $userGroup; $this->userGroup = $userGroup;
} }
public function withUserGroup(UserGroup $userGroup): self { public function withUserGroup(UserGroup $userGroup): self
{
$this->userGroup = $userGroup; $this->userGroup = $userGroup;
return $this; return $this;
} }
} }

View File

@@ -34,12 +34,11 @@ use Illuminate\Support\Facades\Log;
class AccountEnrichment implements EnrichmentInterface class AccountEnrichment implements EnrichmentInterface
{ {
private Collection $collection; private Collection $collection;
private array $currencies; private array $currencies;
#[\Override]
#[\Override] public function enrich(Collection $collection): Collection public function enrich(Collection $collection): Collection
{ {
$this->collection = $collection; $this->collection = $collection;
$this->currencies = []; $this->currencies = [];
@@ -56,6 +55,7 @@ class AccountEnrichment implements EnrichmentInterface
['balance_id' => 2, 'balance' => 5], ['balance_id' => 2, 'balance' => 5],
['balance_id' => 3, 'balance' => 5], ['balance_id' => 3, 'balance' => 5],
]); ]);
return $account; return $account;
}); });
@@ -64,8 +64,6 @@ class AccountEnrichment implements EnrichmentInterface
/** /**
* TODO this method refers to a single-use method inside Steam that could be moved here. * TODO this method refers to a single-use method inside Steam that could be moved here.
*
* @return void
*/ */
private function getLastActivity(): void private function getLastActivity(): void
{ {
@@ -74,14 +72,11 @@ class AccountEnrichment implements EnrichmentInterface
$lastActivity = $accountRepository->getLastActivity($this->collection); $lastActivity = $accountRepository->getLastActivity($this->collection);
foreach ($lastActivity as $row) { foreach ($lastActivity as $row) {
$this->collection->where('id', $row['account_id'])->first()->last_activity = Carbon::parse($row['date_max'], config('app.timezone')); $this->collection->where('id', $row['account_id'])->first()->last_activity = Carbon::parse($row['date_max'], config('app.timezone'));
} }
} }
/** /**
* TODO this method refers to a single-use method inside Steam that could be moved here. * TODO this method refers to a single-use method inside Steam that could be moved here.
*
* @return void
*/ */
private function getMetaBalances(): void private function getMetaBalances(): void
{ {
@@ -89,6 +84,7 @@ class AccountEnrichment implements EnrichmentInterface
$array = app('steam')->balancesByAccountsConverted($this->collection, today()); $array = app('steam')->balancesByAccountsConverted($this->collection, today());
} catch (FireflyException $e) { } catch (FireflyException $e) {
Log::error(sprintf('Could not load balances: %s', $e->getMessage())); Log::error(sprintf('Could not load balances: %s', $e->getMessage()));
return; return;
} }
foreach ($array as $accountId => $row) { foreach ($array as $accountId => $row) {
@@ -99,8 +95,6 @@ class AccountEnrichment implements EnrichmentInterface
/** /**
* TODO this method refers to a single-use method inside Steam that could be moved here. * TODO this method refers to a single-use method inside Steam that could be moved here.
*
* @return void
*/ */
private function collectAccountTypes(): void private function collectAccountTypes(): void
{ {
@@ -115,6 +109,7 @@ class AccountEnrichment implements EnrichmentInterface
} }
$this->collection->transform(function (Account $account) use ($types) { $this->collection->transform(function (Account $account) use ($types) {
$account->type = $types[$account->id]; $account->type = $types[$account->id];
return $account; return $account;
}); });
} }
@@ -123,6 +118,7 @@ class AccountEnrichment implements EnrichmentInterface
{ {
/** @var AccountRepositoryInterface $accountRepository */ /** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class); $accountRepository = app(AccountRepositoryInterface::class);
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
@@ -135,7 +131,6 @@ class AccountEnrichment implements EnrichmentInterface
$currencies[$id] = $currency; $currencies[$id] = $currency;
} }
$this->collection->transform(function (Account $account) use ($metaFields, $currencies) { $this->collection->transform(function (Account $account) use ($metaFields, $currencies) {
$set = $metaFields->where('account_id', $account->id); $set = $metaFields->where('account_id', $account->id);
foreach ($set as $entry) { foreach ($set as $entry) {
@@ -147,6 +142,7 @@ class AccountEnrichment implements EnrichmentInterface
$account->currency_decimal_places = $currencies[$id]?->decimal_places; $account->currency_decimal_places = $currencies[$id]?->decimal_places;
} }
} }
return $account; return $account;
}); });
} }

View File

@@ -28,5 +28,4 @@ use Illuminate\Support\Collection;
interface EnrichmentInterface interface EnrichmentInterface
{ {
public function enrich(Collection $collection): Collection; public function enrich(Collection $collection): Collection;
} }

View File

@@ -35,6 +35,7 @@ trait ExpandsQuery
final protected function addPagination(Builder $query, array $pagination): Builder final protected function addPagination(Builder $query, array $pagination): Builder
{ {
$skip = ($pagination['number'] - 1) * $pagination['size']; $skip = ($pagination['number'] - 1) * $pagination['size'];
return $query->skip($skip)->take($pagination['size']); return $query->skip($skip)->take($pagination['size']);
} }
@@ -46,6 +47,7 @@ trait ExpandsQuery
foreach ($sort->all() as $sortField) { foreach ($sort->all() as $sortField) {
$query->orderBy($sortField->name(), $sortField->isAscending() ? 'ASC' : 'DESC'); $query->orderBy($sortField->name(), $sortField->isAscending() ? 'ASC' : 'DESC');
} }
return $query; return $query;
} }
@@ -55,10 +57,10 @@ trait ExpandsQuery
return $query; return $query;
} }
$config = config(sprintf('firefly.valid_query_filters.%s', $class)) ?? []; $config = config(sprintf('firefly.valid_query_filters.%s', $class)) ?? [];
if (count($filters->all()) === 0) { if (0 === count($filters->all())) {
return $query; return $query;
} }
$query->where(function (Builder $q) use ($config, $filters) { $query->where(function (Builder $q) use ($config, $filters): void {
foreach ($filters->all() as $filter) { foreach ($filters->all() as $filter) {
if (in_array($filter->key(), $config, true)) { if (in_array($filter->key(), $config, true)) {
foreach ($filter->value() as $value) { foreach ($filter->value() as $value) {
@@ -80,5 +82,4 @@ trait ExpandsQuery
return $query; return $query;
} }
} }

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Support\JsonApi;
trait FiltersPagination trait FiltersPagination
{ {
protected function filtersPagination(?array $pagination): array protected function filtersPagination(?array $pagination): array
{ {
if (null === $pagination) { if (null === $pagination) {
@@ -50,6 +49,7 @@ trait FiltersPagination
if (auth()->check()) { if (auth()->check()) {
return (int) app('preferences')->get('listPageSize', 50)->data; return (int) app('preferences')->get('listPageSize', 50)->data;
} }
return 50; return 50;
} }
} }

View File

@@ -28,8 +28,8 @@ use LaravelJsonApi\Core\Query\SortFields;
trait SortsCollection trait SortsCollection
{ {
protected function sortCollection(Collection $collection, ?SortFields $sortFields): Collection { protected function sortCollection(Collection $collection, ?SortFields $sortFields): Collection
{
if (null === $sortFields) { if (null === $sortFields) {
return $collection; return $collection;
} }
@@ -39,5 +39,4 @@ trait SortsCollection
return $collection; return $collection;
} }
} }

View File

@@ -27,7 +27,7 @@ use LaravelJsonApi\Core\Query\SortFields;
trait ValidateSortParameters trait ValidateSortParameters
{ {
function validateParams(string $class, ?SortFields $params): bool public function validateParams(string $class, ?SortFields $params): bool
{ {
if (null === $params) { if (null === $params) {
return false; return false;
@@ -35,13 +35,12 @@ trait ValidateSortParameters
$config = config(sprintf('firefly.full_data_set.%s', $class)) ?? []; $config = config(sprintf('firefly.full_data_set.%s', $class)) ?? [];
foreach ($params->all() as $field) { foreach ($params->all() as $field) {
if (in_array($field->name(), $config, true)) { if (in_array($field->name(), $config, true)) {
return true; return true;
} }
} }
return false; return false;
} }
} }

View File

@@ -23,13 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Support\Models; namespace FireflyIII\Support\Models;
use DB;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountBalance; use FireflyIII\Models\AccountBalance;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use stdClass;
class AccountBalanceCalculator class AccountBalanceCalculator
{ {
@@ -49,12 +47,12 @@ class AccountBalanceCalculator
$title = 'balance_after_journal'; $title = 'balance_after_journal';
} }
$result = $query->get(['transactions.account_id', 'transactions.transaction_currency_id', 'transactions.foreign_currency_id', DB::raw('SUM(transactions.amount) as sum_amount'), DB::raw('SUM(transactions.foreign_amount) as sum_foreign_amount')]); $result = $query->get(['transactions.account_id', 'transactions.transaction_currency_id', 'transactions.foreign_currency_id', \DB::raw('SUM(transactions.amount) as sum_amount'), \DB::raw('SUM(transactions.foreign_amount) as sum_foreign_amount')]);
// reset account balances: // reset account balances:
self::resetAccountBalances($title, $account, $transactionJournal); self::resetAccountBalances($title, $account, $transactionJournal);
/** @var stdClass $row */ /** @var \stdClass $row */
foreach ($result as $row) { foreach ($result as $row) {
$account = (int) $row->account_id; $account = (int) $row->account_id;
$transactionCurrency = (int) $row->transaction_currency_id; $transactionCurrency = (int) $row->transaction_currency_id;
@@ -78,7 +76,6 @@ class AccountBalanceCalculator
Log::debug(sprintf('Set balance entry "%s" #%d to amount %s', $title, $entry->id, $entry->balance)); Log::debug(sprintf('Set balance entry "%s" #%d to amount %s', $title, $entry->id, $entry->balance));
} }
} }
return;
} }
private static function getBalance(string $title, int $account, int $currency, ?int $journal): AccountBalance private static function getBalance(string $title, int $account, int $currency, ?int $journal): AccountBalance
@@ -92,9 +89,10 @@ class AccountBalanceCalculator
$entry = $query->first(); $entry = $query->first();
if (null !== $entry) { if (null !== $entry) {
Log::debug(sprintf('Found account balance "%s" for account #%d and currency #%d: %s', $title, $account, $currency, $entry->balance)); Log::debug(sprintf('Found account balance "%s" for account #%d and currency #%d: %s', $title, $account, $currency, $entry->balance));
return $entry; return $entry;
} }
$entry = new AccountBalance; $entry = new AccountBalance();
$entry->title = $title; $entry->title = $title;
$entry->account_id = $account; $entry->account_id = $account;
$entry->transaction_currency_id = $currency; $entry->transaction_currency_id = $currency;
@@ -102,6 +100,7 @@ class AccountBalanceCalculator
$entry->balance = '0'; $entry->balance = '0';
$entry->save(); $entry->save();
Log::debug(sprintf('Created new account balance for account #%d and currency #%d: %s', $account, $currency, $entry->balance)); Log::debug(sprintf('Created new account balance for account #%d and currency #%d: %s', $account, $currency, $entry->balance));
return $entry; return $entry;
} }
@@ -110,20 +109,20 @@ class AccountBalanceCalculator
if (null === $account && null === $transactionJournal) { if (null === $account && null === $transactionJournal) {
AccountBalance::whereNotNull('updated_at')->where('title', $title)->update(['balance' => '0']); AccountBalance::whereNotNull('updated_at')->where('title', $title)->update(['balance' => '0']);
Log::debug('Set ALL balances to zero.'); Log::debug('Set ALL balances to zero.');
return; return;
} }
if (null !== $account && null === $transactionJournal) { if (null !== $account && null === $transactionJournal) {
AccountBalance::where('account_id', $account->id)->where('title', $title)->update(['balance' => '0']); AccountBalance::where('account_id', $account->id)->where('title', $title)->update(['balance' => '0']);
Log::debug(sprintf('Set balances of account #%d to zero.', $account->id)); Log::debug(sprintf('Set balances of account #%d to zero.', $account->id));
return; return;
} }
AccountBalance::where('account_id', $account->id)->where('transaction_journal_id', $transactionJournal->id)->where('title', $title)->update(['balance' => '0']); AccountBalance::where('account_id', $account->id)->where('transaction_journal_id', $transactionJournal->id)->where('title', $title)->update(['balance' => '0']);
Log::debug(sprintf('Set balances of account #%d + journal #%d to zero.', $account->id, $transactionJournal->id)); Log::debug(sprintf('Set balances of account #%d + journal #%d to zero.', $account->id, $transactionJournal->id));
} }
public static function recalculateByJournal(TransactionJournal $transactionJournal) public static function recalculateByJournal(TransactionJournal $transactionJournal): void
{ {
Log::debug(sprintf('Recalculate balance after journal #%d', $transactionJournal->id)); Log::debug(sprintf('Recalculate balance after journal #%d', $transactionJournal->id));
// update both account balances, but limit to this transaction or earlier. // update both account balances, but limit to this transaction or earlier.
@@ -131,6 +130,4 @@ class AccountBalanceCalculator
self::recalculate($transaction->account, $transactionJournal); self::recalculate($transaction->account, $transactionJournal);
} }
} }
} }

16
composer.lock generated
View File

@@ -5296,20 +5296,20 @@
}, },
{ {
"name": "psr/http-factory", "name": "psr/http-factory",
"version": "1.0.2", "version": "1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-factory.git", "url": "https://github.com/php-fig/http-factory.git",
"reference": "e616d01114759c4c489f93b099585439f795fe35" "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "e616d01114759c4c489f93b099585439f795fe35", "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0" "psr/http-message": "^1.0 || ^2.0"
}, },
"type": "library", "type": "library",
@@ -5333,7 +5333,7 @@
"homepage": "https://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"description": "Common interfaces for PSR-7 HTTP message factories", "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [ "keywords": [
"factory", "factory",
"http", "http",
@@ -5345,9 +5345,9 @@
"response" "response"
], ],
"support": { "support": {
"source": "https://github.com/php-fig/http-factory/tree/1.0.2" "source": "https://github.com/php-fig/http-factory"
}, },
"time": "2023-04-10T20:10:41+00:00" "time": "2024-04-15T12:06:14+00:00"
}, },
{ {
"name": "psr/http-message", "name": "psr/http-message",

View File

@@ -117,7 +117,7 @@ return [
'expression_engine' => false, 'expression_engine' => false,
// see cer.php for exchange rates feature flag. // see cer.php for exchange rates feature flag.
], ],
'version' => 'develop/2024-05-09', 'version' => 'develop/2024-05-13',
'api_version' => '2.0.14', 'api_version' => '2.0.14',
'db_version' => 24, 'db_version' => 24,

View File

@@ -1,9 +1,10 @@
<?php <?php
declare(strict_types=1);
use FireflyIII\JsonApi\V3\Server; use FireflyIII\JsonApi\V3\Server;
return [ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Root Namespace | Root Namespace

View File

@@ -1,17 +1,19 @@
<?php <?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration { return new class () extends Migration {
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('account_balances')) { if (!Schema::hasTable('account_balances')) {
Schema::create('account_balances', function (Blueprint $table) { Schema::create('account_balances', function (Blueprint $table): void {
$table->id(); $table->id();
$table->timestamps(); $table->timestamps();
$table->string('title', 100)->nullable(); $table->string('title', 100)->nullable();
@@ -24,7 +26,6 @@ return new class extends Migration {
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade'); $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->unique(['account_id', 'transaction_currency_id', 'transaction_journal_id', 'date', 'title'], 'unique_account_currency'); $table->unique(['account_id', 'transaction_currency_id', 'transaction_journal_id', 'date', 'title'], 'unique_account_currency');
}); });
} }

30
package-lock.json generated
View File

@@ -4163,9 +4163,9 @@
} }
}, },
"node_modules/cli-table3": { "node_modules/cli-table3": {
"version": "0.6.4", "version": "0.6.5",
"resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.4.tgz", "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.5.tgz",
"integrity": "sha512-Lm3L0p+/npIQWNIiyF/nAn7T5dnOwR3xNTHXYEBFBFVPXzCVNZ5lqEC/1eo/EVfpDsQ1I+TX4ORPQgp+UI0CRw==", "integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"string-width": "^4.2.0" "string-width": "^4.2.0"
@@ -5095,9 +5095,9 @@
"dev": true "dev": true
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.760", "version": "1.4.763",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.760.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.763.tgz",
"integrity": "sha512-xF6AWMVM/QGQseTPgXjUewfNjCW2fgUcV/z5cSG0r+SiYcgtvcmRAL3oH/MSZwHBBD+fyKTXdQ4qGENJMSedEQ==", "integrity": "sha512-k4J8NrtJ9QrvHLRo8Q18OncqBCB7tIUyqxRcJnlonQ0ioHKYB988GcDFF3ZePmnb8eHEopDs/wPHR/iGAFgoUQ==",
"dev": true "dev": true
}, },
"node_modules/elliptic": { "node_modules/elliptic": {
@@ -6275,9 +6275,9 @@
} }
}, },
"node_modules/i18next": { "node_modules/i18next": {
"version": "23.11.3", "version": "23.11.4",
"resolved": "https://registry.npmjs.org/i18next/-/i18next-23.11.3.tgz", "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.11.4.tgz",
"integrity": "sha512-Pq/aSKowir7JM0rj+Wa23Kb6KKDUGno/HjG+wRQu0PxoTbpQ4N89MAT0rFGvXmLkRLNMb1BbBOKGozl01dabzg==", "integrity": "sha512-CCUjtd5TfaCl+mLUzAA0uPSN+AVn4fP/kWCYt/hocPUwusTpMVczdrRyOBUwk6N05iH40qiKx6q1DoNJtBIwdg==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@@ -9074,9 +9074,9 @@
"dev": true "dev": true
}, },
"node_modules/sass": { "node_modules/sass": {
"version": "1.77.0", "version": "1.77.1",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.77.0.tgz", "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.1.tgz",
"integrity": "sha512-eGj4HNfXqBWtSnvItNkn7B6icqH14i3CiCGbzMKs3BAPTq62pp9NBYsBgyN4cA+qssqo9r26lW4JSvlaUUWbgw==", "integrity": "sha512-OMEyfirt9XEfyvocduUIOlUSkWOXS/LAt6oblR/ISXCTukyavjex+zQNm51pPCOiFKY1QpWvEH1EeCkgyV3I6w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"chokidar": ">=3.0.0 <4.0.0", "chokidar": ">=3.0.0 <4.0.0",
@@ -9128,9 +9128,9 @@
} }
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.6.1", "version": "7.6.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz",
"integrity": "sha512-f/vbBsu+fOiYt+lmwZV0rVwJScl46HppnOA1ZvIuBWKOTlllpyJ3bfVax76/OrhCH38dyxoDIA8K7uB963IYgA==", "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==",
"dev": true, "dev": true,
"bin": { "bin": {
"semver": "bin/semver.js" "semver": "bin/semver.js"

View File

@@ -10,16 +10,16 @@
"title": "T\u00edtulo" "title": "T\u00edtulo"
}, },
"list": { "list": {
"drag_and_drop": "Drag and drop", "drag_and_drop": "Arrastar e soltar",
"active": "Esta ativo?", "active": "Esta ativo?",
"name": "Nome", "name": "Nome",
"type": "Tipo", "type": "Tipo",
"number": "Account number", "number": "N\u00famero de conta",
"liability_type": "Tipo de responsabilidade", "liability_type": "Tipo de responsabilidade",
"current_balance": "Current balance", "current_balance": "Saldo atual",
"last_activity": "Last activity", "last_activity": "\u00daltima atividade",
"amount_due": "Amount due", "amount_due": "Valor a pagar",
"balance_difference": "Balance difference", "balance_difference": "Diferen\u00e7a de saldo",
"menu": "Menu" "menu": "Menu"
}, },
"validation": { "validation": {

View File

@@ -10,16 +10,16 @@
"title": "T\u00edtulo" "title": "T\u00edtulo"
}, },
"list": { "list": {
"drag_and_drop": "Drag and drop", "drag_and_drop": "Arrastar e soltar",
"active": "Esta ativo?", "active": "Esta ativo?",
"name": "Nome", "name": "Nome",
"type": "Tipo", "type": "Tipo",
"number": "Account number", "number": "N\u00famero de conta",
"liability_type": "Tipo de responsabilidade", "liability_type": "Tipo de responsabilidade",
"current_balance": "Current balance", "current_balance": "Saldo atual",
"last_activity": "Last activity", "last_activity": "\u00daltima atividade",
"amount_due": "Amount due", "amount_due": "Valor a pagar",
"balance_difference": "Balance difference", "balance_difference": "Diferen\u00e7a de saldo",
"menu": "Menu" "menu": "Menu"
}, },
"validation": { "validation": {

View File

@@ -138,7 +138,8 @@ return [
'error_ip' => 'O endereço de IP associado a este erro é: :ip', 'error_ip' => 'O endereço de IP associado a este erro é: :ip',
'error_url' => 'O URL é: :url', 'error_url' => 'O URL é: :url',
'error_user_agent' => 'Agente de utilizador: :userAgent', 'error_user_agent' => 'Agente de utilizador: :userAgent',
'error_stacktrace' => 'The full stacktrace is below. If you think this is a bug in Firefly III, you can forward this message to <a href="mailto:james@firefly-iii.org?subject=I%20found%20a%20bug!">james@firefly-iii.org</a>. This can help fix the bug you just encountered.', 'error_stacktrace' => 'O stacktrace completo encontra-se abaixo. Se julga ser um erro no Firefly III, pode reencaminhar este email para <a href="mailto:james@firefly-iii.org?subject=I%20found%20a%20bug!">james@firefly-iii.org</a>.
Isto pode ajudar a corrigir o erro que acabou de encontrar.',
'error_github_html' => 'Se preferir, pode também abrir uma nova questão no <a href="https://github.com/firefly-iii/firefly-iii/issues">GitHub</a>.', 'error_github_html' => 'Se preferir, pode também abrir uma nova questão no <a href="https://github.com/firefly-iii/firefly-iii/issues">GitHub</a>.',
'error_github_text' => 'Se preferir, pode também abrir uma nova questão em https://github.com/firefly-iii/firefly-iii/issues.', 'error_github_text' => 'Se preferir, pode também abrir uma nova questão em https://github.com/firefly-iii/firefly-iii/issues.',
'error_stacktrace_below' => 'O rastreamento da pilha completo é:', 'error_stacktrace_below' => 'O rastreamento da pilha completo é:',

View File

@@ -42,7 +42,7 @@ return [
'fatal_error' => 'Aconteceu um erro fatal. Por favor, verifique os ficheiros de log em "storage/logs" ou use "docker logs -f [container]" para verificar o que se passa.', 'fatal_error' => 'Aconteceu um erro fatal. Por favor, verifique os ficheiros de log em "storage/logs" ou use "docker logs -f [container]" para verificar o que se passa.',
'maintenance_mode' => 'O Firefly III está em modo de manutenção.', 'maintenance_mode' => 'O Firefly III está em modo de manutenção.',
'be_right_back' => 'Volto já!', 'be_right_back' => 'Volto já!',
'check_back' => 'Firefly III is down for some necessary maintenance. Please check back in a second. If you happen to see this message on the demo site, just wait a few minutes. The database is reset every few hours.', 'check_back' => 'Firefly III encontra-se desligado para alguma manutenção necessária. Volte a tentar daqui a uns segundos. Se acontecer de ver esta mensagem no site de demonstração, espere alguns minutos. A base de dados é reiniciada a cada algumas horas.',
'error_occurred' => 'Oops! Ocorreu um erro.', 'error_occurred' => 'Oops! Ocorreu um erro.',
'db_error_occurred' => 'Oops! Ocorreu um erro na base de dados.', 'db_error_occurred' => 'Oops! Ocorreu um erro na base de dados.',
'error_not_recoverable' => 'Infelizmente, este erro não era recuperável :(. Firefly III avariou. O erro é:', 'error_not_recoverable' => 'Infelizmente, este erro não era recuperável :(. Firefly III avariou. O erro é:',

View File

@@ -37,7 +37,7 @@ return [
// new user: // new user:
'bank_name' => 'Nome do banco', 'bank_name' => 'Nome do banco',
'bank_balance' => 'Saldo', 'bank_balance' => 'Saldo',
'current_balance' => 'Current balance', 'current_balance' => 'Saldo atual',
'savings_balance' => 'Saldo nas poupanças', 'savings_balance' => 'Saldo nas poupanças',
'credit_card_limit' => 'Limite do cartão de crédito', 'credit_card_limit' => 'Limite do cartão de crédito',
'automatch' => 'Corresponder automaticamente', 'automatch' => 'Corresponder automaticamente',

View File

@@ -67,12 +67,12 @@ return [
'source' => 'Origem', 'source' => 'Origem',
'next_expected_match' => 'Próxima correspondência esperada', 'next_expected_match' => 'Próxima correspondência esperada',
'automatch' => 'Auto correspondência?', 'automatch' => 'Auto correspondência?',
'drag_and_drop' => 'Drag and drop', 'drag_and_drop' => 'Arrastar e soltar',
'number' => 'Account number', 'number' => 'Número de conta',
'current_balance' => 'Current balance', 'current_balance' => 'Saldo atual',
'last_activity' => 'Last activity', 'last_activity' => 'Última atividade',
'amount_due' => 'Amount due', 'amount_due' => 'Valor a pagar',
'balance_difference' => 'Balance difference', 'balance_difference' => 'Diferença de saldo',
'menu' => 'Menu', 'menu' => 'Menu',
/* /*

View File

@@ -27,7 +27,7 @@ return [
'find_or_create_tag_failed' => 'Não foi possível encontrar ou criar a etiqueta ":tag"', 'find_or_create_tag_failed' => 'Não foi possível encontrar ou criar a etiqueta ":tag"',
'tag_already_added' => 'A etiqueta ":tag" já está vinculada a esta transação', 'tag_already_added' => 'A etiqueta ":tag" já está vinculada a esta transação',
'inspect_transaction' => 'Inspecionar transação ":title" @ Firefly III', 'inspect_transaction' => 'Inspecionar transação ":title" @ Firefly III',
'inspect_rule' => 'Inspect rule ":title" @ Firefly III', 'inspect_rule' => 'Inspecionar regra ":title" @ Firefly III',
'journal_other_user' => 'Esta transação não pertence ao utilizador', 'journal_other_user' => 'Esta transação não pertence ao utilizador',
'no_such_journal' => 'Esta transação não existe', 'no_such_journal' => 'Esta transação não existe',
'journal_already_no_budget' => 'Esta transação não tem orçamento, então não pode ser removido', 'journal_already_no_budget' => 'Esta transação não tem orçamento, então não pode ser removido',
@@ -47,28 +47,28 @@ return [
'unsupported_transaction_type_transfer' => 'Firefly III não pode converter um ":type" para uma transferência', 'unsupported_transaction_type_transfer' => 'Firefly III não pode converter um ":type" para uma transferência',
'already_has_source_asset' => 'Esta transação já tem ":name" como a conta do ativo de origem', 'already_has_source_asset' => 'Esta transação já tem ":name" como a conta do ativo de origem',
'already_has_destination_asset' => 'Esta transação já tem ":name" como a conta de ativo de destino', 'already_has_destination_asset' => 'Esta transação já tem ":name" como a conta de ativo de destino',
'already_has_destination' => 'This transaction already has ":name" as the destination account', 'already_has_destination' => 'Esta transação já tem ":name" como conta de destino',
'already_has_source' => 'This transaction already has ":name" as the source account', 'already_has_source' => 'Esta transação já tem ":name" como a conta de origem',
'already_linked_to_subscription' => 'The transaction is already linked to subscription ":name"', 'already_linked_to_subscription' => 'A transação já está vinculada à subscrição ":name"',
'already_linked_to_category' => 'The transaction is already linked to category ":name"', 'already_linked_to_category' => 'A transação já está vinculada à categoria ":name"',
'already_linked_to_budget' => 'The transaction is already linked to budget ":name"', 'already_linked_to_budget' => 'A transação já está vinculada ao orçamento ":name"',
'cannot_find_subscription' => 'Firefly III can\'t find subscription ":name"', 'cannot_find_subscription' => 'Firefly III não consegue encontrar a subscrição ":name"',
'no_notes_to_move' => 'The transaction has no notes to move to the description field', 'no_notes_to_move' => 'A transação não tem notas para mover para o campo de descrição',
'no_tags_to_remove' => 'The transaction has no tags to remove', 'no_tags_to_remove' => 'A transação não tem etiquetas para remover',
'not_withdrawal' => 'The transaction is not a withdrawal', 'not_withdrawal' => 'A transação não é um levantamento',
'not_deposit' => 'The transaction is not a deposit', 'not_deposit' => 'A transação não é um depósito',
'cannot_find_tag' => 'Firefly III can\'t find tag ":tag"', 'cannot_find_tag' => 'Firefly III não consegue encontrar a etiqueta ":tag"',
'cannot_find_asset' => 'Firefly III can\'t find asset account ":name"', 'cannot_find_asset' => 'Firefly III não consegue encontrar a conta de ativos ":name"',
'cannot_find_accounts' => 'Firefly III can\'t find the source or destination account', 'cannot_find_accounts' => 'Firefly III não conseguiu encontrar a conta de origem ou de destino',
'cannot_find_source_transaction' => 'Firefly III can\'t find the source transaction', 'cannot_find_source_transaction' => 'Firefly III não conseguiu encontrar a transação de origem',
'cannot_find_destination_transaction' => 'Firefly III can\'t find the destination transaction', 'cannot_find_destination_transaction' => 'Firefly III não conseguiu encontrar a transação de destino',
'cannot_find_source_transaction_account' => 'Firefly III can\'t find the source transaction account', 'cannot_find_source_transaction_account' => 'Firefly III não conseguiu encontrar a conta de origem da transação',
'cannot_find_destination_transaction_account' => 'Firefly III can\'t find the destination transaction account', 'cannot_find_destination_transaction_account' => 'Firefly III não conseguiu encontrar a conta de destino da transação',
'cannot_find_piggy' => 'Firefly III can\'t find a piggy bank named ":name"', 'cannot_find_piggy' => 'Firefly III não conseguiu encontrar nenhum mealheiro chamado ":name"',
'no_link_piggy' => 'This transaction\'s accounts are not linked to the piggy bank, so no action will be taken', 'no_link_piggy' => 'As contas desta transação não estão ligadas ao mealheiro, logo nenhuma ação será tomada',
'cannot_unlink_tag' => 'Tag ":tag" isn\'t linked to this transaction', 'cannot_unlink_tag' => 'Etiqueta ":tag" não está vinculada a esta transação',
'cannot_find_budget' => 'Firefly III can\'t find budget ":name"', 'cannot_find_budget' => 'Firefly III não consegue encontrar o orçamento ":name"',
'cannot_find_category' => 'Firefly III can\'t find category ":name"', 'cannot_find_category' => 'Firefly III não consegue encontrar a categoria ":name"',
'cannot_set_budget' => 'Firefly III can\'t set budget ":name" to a transaction of type ":type"', 'cannot_set_budget' => 'Firefly III não pode definir o orçamento ":name" para uma transação do tipo ":type"',
'journal_invalid_amount' => 'Firefly III can\'t set amount ":amount" because it is not a valid number.', 'journal_invalid_amount' => 'Firefly III não pode definir a quantidade ":amount" porque não é um número válido.',
]; ];

View File

@@ -29,9 +29,7 @@ use LaravelJsonApi\Laravel\Routing\ActionRegistrar;
use LaravelJsonApi\Laravel\Routing\Relationships; use LaravelJsonApi\Laravel\Routing\Relationships;
use LaravelJsonApi\Laravel\Routing\ResourceRegistrar; use LaravelJsonApi\Laravel\Routing\ResourceRegistrar;
/** // V2 auto complete controller(s)
* V2 auto complete controller(s)
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Autocomplete', 'namespace' => 'FireflyIII\Api\V2\Controllers\Autocomplete',
@@ -47,10 +45,6 @@ Route::group(
} }
); );
// JsonApiRoute::server('v3') // JsonApiRoute::server('v3')
// ->prefix('v3') // ->prefix('v3')
// ->resources(function (ResourceRegistrar $server) { // ->resources(function (ResourceRegistrar $server) {
@@ -67,8 +61,6 @@ Route::group(
// $server->resource('account-balances', JsonApiController::class); // $server->resource('account-balances', JsonApiController::class);
// }); // });
// V2 API route for Summary boxes // V2 API route for Summary boxes
// BASIC // BASIC
Route::group( Route::group(
@@ -102,7 +94,6 @@ Route::group(
// V2 API routes for auto complete // V2 API routes for auto complete
// V2 API route for net worth endpoint(s); // V2 API route for net worth endpoint(s);
Route::group( Route::group(
[ [