Code cleanup

This commit is contained in:
James Cole
2023-10-28 15:03:33 +02:00
parent fa920fed4e
commit 0133a7c5db
77 changed files with 575 additions and 594 deletions

View File

@@ -226,16 +226,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.35.1", "version": "v3.36.0",
"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": "ec1ccc264994b6764882669973ca435cf05bab08" "reference": "e889301f276c6ce2c391d6aafae9a162e785b064"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/ec1ccc264994b6764882669973ca435cf05bab08", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/e889301f276c6ce2c391d6aafae9a162e785b064",
"reference": "ec1ccc264994b6764882669973ca435cf05bab08", "reference": "e889301f276c6ce2c391d6aafae9a162e785b064",
"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.35.1" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.36.0"
}, },
"funding": [ "funding": [
{ {
@@ -315,7 +315,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-10-12T13:47:26+00:00" "time": "2023-10-27T10:12:29+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",

View File

@@ -27,8 +27,8 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Validator; use Validator;

View File

@@ -87,7 +87,7 @@ class ShowController extends Controller
$currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page')); $paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.index') . $this->buildParams()); $paginator->setPath(route('api.v1.currencies.index') . $this->buildParams());
$manager = $this->getManager(); $manager = $this->getManager();
/** @var CurrencyTransformer $transformer */ /** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class); $transformer = app(CurrencyTransformer::class);
@@ -144,7 +144,7 @@ class ShowController extends Controller
public function showDefault(): JsonResponse public function showDefault(): JsonResponse
{ {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$manager = $this->getManager(); $manager = $this->getManager();
$currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup); $currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);

View File

@@ -83,7 +83,7 @@ class StoreController extends Controller
$this->repository->makeDefault($currency); $this->repository->makeDefault($currency);
app('preferences')->mark(); app('preferences')->mark();
} }
$manager = $this->getManager(); $manager = $this->getManager();
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();

View File

@@ -183,11 +183,11 @@ class UpdateController extends Controller
$data = $request->getAll(); $data = $request->getAll();
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
// safety catch on currency disablement. // safety catch on currency disablement.
$set = $this->repository->get(); $set = $this->repository->get();
if(array_key_exists('enabled', $data) && false === $data['enabled'] && 1 === count($set) && $set->first()->id === $currency->id){ if (array_key_exists('enabled', $data) && false === $data['enabled'] && 1 === count($set) && $set->first()->id === $currency->id) {
return response()->json([], 409); return response()->json([], 409);
} }

View File

@@ -71,9 +71,9 @@ class CreateRequest extends FormRequest
*/ */
public function rules(): array public function rules(): array
{ {
$triggers = implode(',', array_keys(Webhook::getTriggersForValidation())); $triggers = implode(',', array_keys(Webhook::getTriggersForValidation()));
$responses = implode(',', array_keys(Webhook::getResponsesForValidation())); $responses = implode(',', array_keys(Webhook::getResponsesForValidation()));
$deliveries = implode(',', array_keys(Webhook::getDeliveriesForValidation())); $deliveries = implode(',', array_keys(Webhook::getDeliveriesForValidation()));
$validProtocols = config('firefly.valid_url_protocols'); $validProtocols = config('firefly.valid_url_protocols');
return [ return [
'title' => 'required|between:1,512|uniqueObjectForUser:webhooks,title', 'title' => 'required|between:1,512|uniqueObjectForUser:webhooks,title',

View File

@@ -32,7 +32,6 @@ use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface as AdminAccountRepositoryInterface; use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface as AdminAccountRepositoryInterface;
use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Http\Api\AccountFilter;
use http\Env\Response;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**

View File

@@ -32,13 +32,12 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\UserGroups\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Budget\OperationsRepositoryInterface; use FireflyIII\Repositories\UserGroups\Budget\OperationsRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
use FireflyIII\Support\Http\Api\CleansChartData; use FireflyIII\Support\Http\Api\CleansChartData;
use FireflyIII\Support\Http\Api\ExchangeRateConverter; use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@@ -26,11 +26,9 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Model\Bill; namespace FireflyIII\Api\V2\Controllers\Model\Bill;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface; use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\AccountTransformer;
use FireflyIII\Transformers\V2\BillTransformer; use FireflyIII\Transformers\V2\BillTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Api\V2\Controllers\Model\Bill;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Generic\DateRequest; use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface; use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Api\V2\Controllers\Model\Budget;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Generic\DateRequest; use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\Http\Api\ConvertsExchangeRates; use FireflyIII\Support\Http\Api\ConvertsExchangeRates;

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Api\V2\Controllers\Model\Budget;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Generic\DateRequest; use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\Http\Api\ConvertsExchangeRates; use FireflyIII\Support\Http\Api\ConvertsExchangeRates;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;

View File

@@ -26,7 +26,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Model\PiggyBank; namespace FireflyIII\Api\V2\Controllers\Model\PiggyBank;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\PiggyBankTransformer; use FireflyIII\Transformers\V2\PiggyBankTransformer;

View File

@@ -30,7 +30,6 @@ use FireflyIII\Api\V2\Request\Model\Transaction\StoreRequest;
use FireflyIII\Events\StoredTransactionGroup; use FireflyIII\Events\StoredTransactionGroup;
use FireflyIII\Exceptions\DuplicateTransactionException; use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use Illuminate\Validation\ValidationException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Rules\IsDuplicateTransaction; use FireflyIII\Rules\IsDuplicateTransaction;
@@ -38,6 +37,7 @@ use FireflyIII\Transformers\V2\TransactionGroupTransformer;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
/** /**
* Class StoreController * Class StoreController

View File

@@ -28,9 +28,7 @@ use FireflyIII\Models\AccountType;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User; use FireflyIII\User;
use FireflyIII\Validation\Administration\ValidatesAdministrationAccess;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
/** /**
* Class AutocompleteRequest * Class AutocompleteRequest

View File

@@ -57,6 +57,7 @@ class StoreRequest extends FormRequest
use GroupValidation; use GroupValidation;
use CurrencyValidation; use CurrencyValidation;
use AppendsLocationData; use AppendsLocationData;
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS]; protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
/** /**

View File

@@ -37,6 +37,7 @@ class StoreRequest extends FormRequest
{ {
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL]; protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
/** /**

View File

@@ -37,6 +37,7 @@ class UpdateMembershipRequest extends FormRequest
{ {
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL]; protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
/** /**

View File

@@ -38,6 +38,7 @@ class UpdateRequest extends FormRequest
{ {
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL]; protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
/** /**

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Correction; namespace FireflyIII\Console\Commands\Correction;
use Artisan;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Schema; use Schema;

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Integrity; namespace FireflyIII\Console\Commands\Integrity;
use Artisan;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Schema; use Schema;

View File

@@ -34,7 +34,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;

View File

@@ -45,8 +45,8 @@ class OtherCurrenciesCorrections extends Command
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const CONFIG_NAME = '480_other_currencies'; public const CONFIG_NAME = '480_other_currencies';
protected $description = 'Update all journal currency information.'; protected $description = 'Update all journal currency information.';
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}'; protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies; private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos; private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos; private JournalCLIRepositoryInterface $cliRepos;

View File

@@ -68,30 +68,6 @@ class UpgradeCurrencyPreferences extends Command
return false; return false;
} }
/**
* @param User $user
*
* @return string
*/
private function getPreference(User $user): string
{
$preference = Preference::where('user_id', $user->id)->where('name', 'currencyPreference')->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
if (null !== $preference) {
return (string)$preference->data;
}
return 'EUR';
}
/**
*
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
private function runUpgrade(): void private function runUpgrade(): void
{ {
$groups = UserGroup::get(); $groups = UserGroup::get();
@@ -107,6 +83,24 @@ class UpgradeCurrencyPreferences extends Command
} }
} }
/**
* @param UserGroup $group
*
* @return void
*/
private function upgradeGroupPreferences(UserGroup $group)
{
$currencies = TransactionCurrency::get();
$enabled = new Collection();
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
if ($currency->enabled) {
$enabled->push($currency);
}
}
$group->currencies()->sync($enabled->pluck('id')->toArray());
}
/** /**
* @param User $user * @param User $user
* *
@@ -136,20 +130,25 @@ class UpgradeCurrencyPreferences extends Command
} }
/** /**
* @param UserGroup $group * @param User $user
* *
* @return void * @return string
*/ */
private function upgradeGroupPreferences(UserGroup $group) private function getPreference(User $user): string
{ {
$currencies = TransactionCurrency::get(); $preference = Preference::where('user_id', $user->id)->where('name', 'currencyPreference')->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
$enabled = new Collection();
/** @var TransactionCurrency $currency */ if (null !== $preference) {
foreach ($currencies as $currency) { return (string)$preference->data;
if ($currency->enabled) {
$enabled->push($currency);
}
} }
$group->currencies()->sync($enabled->pluck('id')->toArray()); return 'EUR';
}
/**
*
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
} }
} }

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
set_time_limit(0); set_time_limit(0);
use Artisan;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@@ -72,7 +71,7 @@ class UpgradeDatabase extends Command
// also just in case, some integrity commands: // also just in case, some integrity commands:
'firefly-iii:create-group-memberships', 'firefly-iii:create-group-memberships',
'firefly-iii:upgrade-group-information', 'firefly-iii:upgrade-group-information',
'firefly-iii:upgrade-currency-preferences' 'firefly-iii:upgrade-currency-preferences',
]; ];
$args = []; $args = [];
if ($this->option('force')) { if ($this->option('force')) {

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Factory;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountMeta;
use Illuminate\Support\Facades\Log;
/** /**
* Class AccountMetaFactory * Class AccountMetaFactory

View File

@@ -39,9 +39,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface; use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\JournalDestroyService; use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
use FireflyIII\Services\Internal\Support\JournalServiceTrait; use FireflyIII\Services\Internal\Support\JournalServiceTrait;
use FireflyIII\Support\NullArrayObject; use FireflyIII\Support\NullArrayObject;

View File

@@ -34,29 +34,29 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
trait CollectorProperties trait CollectorProperties
{ {
public const TEST = 'Test'; public const TEST = 'Test';
private bool $expandGroupSearch; private bool $expandGroupSearch;
private array $fields; private array $fields;
private bool $hasAccountInfo; private bool $hasAccountInfo;
private bool $hasBillInformation; private bool $hasBillInformation;
private bool $hasBudgetInformation; private bool $hasBudgetInformation;
private bool $hasCatInformation; private bool $hasCatInformation;
private bool $hasJoinedAttTables; private bool $hasJoinedAttTables;
private bool $hasJoinedMetaTables; private bool $hasJoinedMetaTables;
private bool $hasJoinedTagTables; private bool $hasJoinedTagTables;
private bool $hasNotesInformation; private bool $hasNotesInformation;
private array $integerFields; private array $integerFields;
private ?int $limit; private ?int $limit;
private ?int $page; private ?int $page;
private array $postFilters; private array $postFilters;
private HasMany $query; private HasMany $query;
private array $stringFields; private array $stringFields;
/* /*
* This array is used to collect ALL tags the user may search for (using 'setTags'). * This array is used to collect ALL tags the user may search for (using 'setTags').
* This way the user can call 'setTags' multiple times and get a joined result. * This way the user can call 'setTags' multiple times and get a joined result.
* *
*/ */
private array $tags; private array $tags;
private int $total; private int $total;
private ?User $user; private ?User $user;
private ?UserGroup $userGroup; private ?UserGroup $userGroup;
} }

View File

@@ -29,8 +29,8 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\UserGroup; use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface as AdminAccountRepositoryInterface; use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface as AdminAccountRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Http\Api\ExchangeRateConverter; use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use FireflyIII\User; use FireflyIII\User;

View File

@@ -29,8 +29,8 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**

View File

@@ -89,7 +89,7 @@ class CreateController extends Controller
session()->flash('success', trans('firefly.stored_journal', ['description' => $title])); session()->flash('success', trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success_url', $link); session()->flash('success_url', $link);
if('edit' === $request->get('redirect')) { if ('edit' === $request->get('redirect')) {
return response()->json(['redirect' => route('transactions.edit', [$newGroup->id])]); return response()->json(['redirect' => route('transactions.edit', [$newGroup->id])]);
} }

View File

@@ -63,17 +63,6 @@ class EditController extends Controller
); );
} }
/**
* @param TransactionJournal $journal
*
* @return JsonResponse
*/
public function unreconcile(TransactionJournal $journal): JsonResponse
{
$this->repository->unreconcileById($journal->id);
return response()->json([], 204);
}
/** /**
* @param TransactionGroup $transactionGroup * @param TransactionGroup $transactionGroup
* *
@@ -116,4 +105,15 @@ class EditController extends Controller
) )
); );
} }
/**
* @param TransactionJournal $journal
*
* @return JsonResponse
*/
public function unreconcile(TransactionJournal $journal): JsonResponse
{
$this->repository->unreconcileById($journal->id);
return response()->json([], 204);
}
} }

View File

@@ -7,8 +7,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\CurrencyFormRequest; use FireflyIII\Http\Requests\CurrencyFormRequest;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@@ -45,6 +45,7 @@ class CreateController extends Controller
} }
); );
} }
/** /**
* Create a currency. * Create a currency.
* *

View File

@@ -6,8 +6,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@@ -46,7 +46,6 @@ class DeleteController extends Controller
} }
/** /**
* Deletes a currency. * Deletes a currency.
* *

View File

@@ -7,8 +7,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\CurrencyFormRequest; use FireflyIII\Http\Requests\CurrencyFormRequest;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@@ -68,7 +68,7 @@ class EditController extends Controller
// is currently enabled (for this user?) // is currently enabled (for this user?)
$userCurrencies = $this->repository->get()->pluck('id')->toArray(); $userCurrencies = $this->repository->get()->pluck('id')->toArray();
$enabled = in_array($currency->id, $userCurrencies, true); $enabled = in_array($currency->id, $userCurrencies, true);
// code to handle active-checkboxes // code to handle active-checkboxes
$hasOldInput = null !== $request->old('_token'); $hasOldInput = null !== $request->old('_token');

View File

@@ -6,8 +6,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request; use Illuminate\Http\Request;

View File

@@ -232,6 +232,32 @@ class InterestingMessage
return null !== $webhookId && null !== $message; return null !== $webhookId && null !== $message;
} }
/**
* @param Request $request
*/
private function handleWebhookMessage(Request $request): void
{
// get parameters from request.
$webhookId = $request->get('webhook_id');
$message = $request->get('message');
/** @var Webhook $webhook */
$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);
if (null === $webhook) {
return;
}
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));
}
if ('updated' === $message) {
session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));
}
if ('created' === $message) {
session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
}
}
/** /**
* @param Request $request * @param Request $request
* *
@@ -278,30 +304,4 @@ class InterestingMessage
session()->flash('error', (string)trans('firefly.default_currency_failed', ['name' => $currency->name])); session()->flash('error', (string)trans('firefly.default_currency_failed', ['name' => $currency->name]));
} }
} }
/**
* @param Request $request
*/
private function handleWebhookMessage(Request $request): void
{
// get parameters from request.
$webhookId = $request->get('webhook_id');
$message = $request->get('message');
/** @var Webhook $webhook */
$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);
if (null === $webhook) {
return;
}
if ('deleted' === $message) {
session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));
}
if ('updated' === $message) {
session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));
}
if ('created' === $message) {
session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
}
}
} }

View File

@@ -40,6 +40,7 @@ class AccountFormRequest extends FormRequest
use ConvertsDataTypes; use ConvertsDataTypes;
use AppendsLocationData; use AppendsLocationData;
use ChecksLogin; use ChecksLogin;
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS]; protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
/** /**

View File

@@ -42,36 +42,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class Account * Class Account
* *
* @property int $id * @property int $id
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at * @property \Illuminate\Support\Carbon|null $deleted_at
* @property int $user_id * @property int $user_id
* @property int $account_type_id * @property int $account_type_id
* @property string $name * @property string $name
* @property string|null $virtual_balance * @property string|null $virtual_balance
* @property string|null $iban * @property string|null $iban
* @property bool $active * @property bool $active
* @property bool $encrypted * @property bool $encrypted
* @property int $order * @property int $order
* @property-read Collection|AccountMeta[] $accountMeta * @property-read Collection|AccountMeta[] $accountMeta
* @property-read int|null $account_meta_count * @property-read int|null $account_meta_count
* @property AccountType $accountType * @property AccountType $accountType
* @property-read Collection|Attachment[] $attachments * @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count * @property-read int|null $attachments_count
* @property-read string $account_number * @property-read string $account_number
* @property-read string $edit_name * @property-read string $edit_name
* @property-read Collection|Location[] $locations * @property-read Collection|Location[] $locations
* @property-read int|null $locations_count * @property-read int|null $locations_count
* @property-read Collection|Note[] $notes * @property-read Collection|Note[] $notes
* @property-read int|null $notes_count * @property-read int|null $notes_count
* @property-read Collection|ObjectGroup[] $objectGroups * @property-read Collection|ObjectGroup[] $objectGroups
* @property-read int|null $object_groups_count * @property-read int|null $object_groups_count
* @property-read Collection|PiggyBank[] $piggyBanks * @property-read Collection|PiggyBank[] $piggyBanks
* @property-read int|null $piggy_banks_count * @property-read int|null $piggy_banks_count
* @property-read Collection|Transaction[] $transactions * @property-read Collection|Transaction[] $transactions
* @property-read int|null $transactions_count * @property-read int|null $transactions_count
* @property-read User $user * @property-read User $user
* @method static EloquentBuilder|Account accountTypeIn($types) * @method static EloquentBuilder|Account accountTypeIn($types)
* @method static EloquentBuilder|Account newModelQuery() * @method static EloquentBuilder|Account newModelQuery()
* @method static EloquentBuilder|Account newQuery() * @method static EloquentBuilder|Account newQuery()
@@ -91,19 +91,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static EloquentBuilder|Account whereVirtualBalance($value) * @method static EloquentBuilder|Account whereVirtualBalance($value)
* @method static Builder|Account withTrashed() * @method static Builder|Account withTrashed()
* @method static Builder|Account withoutTrashed() * @method static Builder|Account withoutTrashed()
* @property Carbon $lastActivityDate * @property Carbon $lastActivityDate
* @property string $startBalance * @property string $startBalance
* @property string $endBalance * @property string $endBalance
* @property string $difference * @property string $difference
* @property string $interest * @property string $interest
* @property string $interestPeriod * @property string $interestPeriod
* @property string $accountTypeString * @property string $accountTypeString
* @property Location $location * @property Location $location
* @property string $liability_direction * @property string $liability_direction
* @property string $current_debt * @property string $current_debt
* @property int|null $user_group_id * @property int|null $user_group_id
* @method static EloquentBuilder|Account whereUserGroupId($value) * @method static EloquentBuilder|Account whereUserGroupId($value)
* @property-read \FireflyIII\Models\UserGroup|null $userGroup * @property-read UserGroup|null $userGroup
* @mixin Eloquent * @mixin Eloquent
*/ */
class Account extends Model class Account extends Model

View File

@@ -61,7 +61,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|ObjectGroup whereTitle($value) * @method static Builder|ObjectGroup whereTitle($value)
* @method static Builder|ObjectGroup whereUpdatedAt($value) * @method static Builder|ObjectGroup whereUpdatedAt($value)
* @method static Builder|ObjectGroup whereUserId($value) * @method static Builder|ObjectGroup whereUserId($value)
* @property int|null $user_group_id * @property int|null $user_group_id
* @method static Builder|ObjectGroup whereUserGroupId($value) * @method static Builder|ObjectGroup whereUserGroupId($value)
* @mixin Eloquent * @mixin Eloquent
*/ */

View File

@@ -125,6 +125,14 @@ class Rule extends Model
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
/**
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/** /**
* @return HasMany * @return HasMany
*/ */
@@ -159,14 +167,6 @@ class Rule extends Model
$this->attributes['description'] = e($value); $this->attributes['description'] = e($value);
} }
/**
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/** /**
* @return BelongsTo * @return BelongsTo
*/ */

View File

@@ -37,23 +37,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* FireflyIII\Models\TransactionCurrency * FireflyIII\Models\TransactionCurrency
* *
* @property int $id * @property int $id
* @property Carbon|null $created_at * @property Carbon|null $created_at
* @property Carbon|null $updated_at * @property Carbon|null $updated_at
* @property Carbon|null $deleted_at * @property Carbon|null $deleted_at
* @property bool $enabled * @property bool $enabled
* @property bool $userDefault * @property bool $userDefault
* @property bool $userEnabled * @property bool $userEnabled
* @property string $code * @property string $code
* @property string $name * @property string $name
* @property string $symbol * @property string $symbol
* @property int $decimal_places * @property int $decimal_places
* @property-read Collection|BudgetLimit[] $budgetLimits * @property-read Collection|BudgetLimit[] $budgetLimits
* @property-read int|null $budget_limits_count * @property-read int|null $budget_limits_count
* @property-read Collection|TransactionJournal[] $transactionJournals * @property-read Collection|TransactionJournal[] $transactionJournals
* @property-read int|null $transaction_journals_count * @property-read int|null $transaction_journals_count
* @property-read Collection|Transaction[] $transactions * @property-read Collection|Transaction[] $transactions
* @property-read int|null $transactions_count * @property-read int|null $transactions_count
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newQuery() * @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newQuery()
* @method static Builder|TransactionCurrency onlyTrashed() * @method static Builder|TransactionCurrency onlyTrashed()
@@ -69,10 +69,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency whereUpdatedAt($value)
* @method static Builder|TransactionCurrency withTrashed() * @method static Builder|TransactionCurrency withTrashed()
* @method static Builder|TransactionCurrency withoutTrashed() * @method static Builder|TransactionCurrency withoutTrashed()
* @property-read Collection<int, \FireflyIII\Models\UserGroup> $userGroups * @property-read Collection<int, UserGroup> $userGroups
* @property-read int|null $user_groups_count * @property-read int|null $user_groups_count
* @property-read Collection<int, User> $users * @property-read Collection<int, User> $users
* @property-read int|null $users_count * @property-read int|null $users_count
* @mixin Eloquent * @mixin Eloquent
*/ */
class TransactionCurrency extends Model class TransactionCurrency extends Model
@@ -115,6 +115,14 @@ class TransactionCurrency extends Model
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
/**
* @return HasMany
*/
public function budgetLimits(): HasMany
{
return $this->hasMany(BudgetLimit::class);
}
/** /**
* @param User $user * @param User $user
* *
@@ -122,40 +130,12 @@ class TransactionCurrency extends Model
*/ */
public function refreshForUser(User $user) public function refreshForUser(User $user)
{ {
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first(); $current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
$default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup); $default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
$this->userDefault = (int)$default->id === (int)$this->id; $this->userDefault = (int)$default->id === (int)$this->id;
$this->userEnabled = null !== $current; $this->userEnabled = null !== $current;
} }
/**
* Link to users
*
* @return BelongsToMany
*/
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)->withTimestamps()->withPivot('user_default');
}
/**
* Link to user groups
*
* @return BelongsToMany
*/
public function userGroups(): BelongsToMany
{
return $this->belongsToMany(UserGroup::class)->withTimestamps()->withPivot('group_default');
}
/**
* @return HasMany
*/
public function budgetLimits(): HasMany
{
return $this->hasMany(BudgetLimit::class);
}
/** /**
* @return HasMany * @return HasMany
*/ */
@@ -171,4 +151,24 @@ class TransactionCurrency extends Model
{ {
return $this->hasMany(Transaction::class); return $this->hasMany(Transaction::class);
} }
/**
* Link to user groups
*
* @return BelongsToMany
*/
public function userGroups(): BelongsToMany
{
return $this->belongsToMany(UserGroup::class)->withTimestamps()->withPivot('group_default');
}
/**
* Link to users
*
* @return BelongsToMany
*/
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)->withTimestamps()->withPivot('user_default');
}
} }

View File

@@ -41,50 +41,50 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* FireflyIII\Models\TransactionJournal * FireflyIII\Models\TransactionJournal
* *
* @property int $id * @property int $id
* @property Carbon|null $created_at * @property Carbon|null $created_at
* @property Carbon|null $updated_at * @property Carbon|null $updated_at
* @property Carbon|null $deleted_at * @property Carbon|null $deleted_at
* @property int $user_id * @property int $user_id
* @property int $transaction_type_id * @property int $transaction_type_id
* @property int|null $transaction_group_id * @property int|null $transaction_group_id
* @property int|null $bill_id * @property int|null $bill_id
* @property int|null $transaction_currency_id * @property int|null $transaction_currency_id
* @property string $description * @property string $description
* @property Carbon $date * @property Carbon $date
* @property Carbon|null $interest_date * @property Carbon|null $interest_date
* @property Carbon|null $book_date * @property Carbon|null $book_date
* @property Carbon|null $process_date * @property Carbon|null $process_date
* @property int $order * @property int $order
* @property int $tag_count * @property int $tag_count
* @property string $transaction_type_type * @property string $transaction_type_type
* @property bool $encrypted * @property bool $encrypted
* @property bool $completed * @property bool $completed
* @property-read Collection|Attachment[] $attachments * @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count * @property-read int|null $attachments_count
* @property-read Bill|null $bill * @property-read Bill|null $bill
* @property-read Collection|Budget[] $budgets * @property-read Collection|Budget[] $budgets
* @property-read int|null $budgets_count * @property-read int|null $budgets_count
* @property-read Collection|Category[] $categories * @property-read Collection|Category[] $categories
* @property-read int|null $categories_count * @property-read int|null $categories_count
* @property-read Collection|TransactionJournalLink[] $destJournalLinks * @property-read Collection|TransactionJournalLink[] $destJournalLinks
* @property-read int|null $dest_journal_links_count * @property-read int|null $dest_journal_links_count
* @property-read Collection|Note[] $notes * @property-read Collection|Note[] $notes
* @property-read int|null $notes_count * @property-read int|null $notes_count
* @property-read Collection|PiggyBankEvent[] $piggyBankEvents * @property-read Collection|PiggyBankEvent[] $piggyBankEvents
* @property-read int|null $piggy_bank_events_count * @property-read int|null $piggy_bank_events_count
* @property-read Collection|TransactionJournalLink[] $sourceJournalLinks * @property-read Collection|TransactionJournalLink[] $sourceJournalLinks
* @property-read int|null $source_journal_links_count * @property-read int|null $source_journal_links_count
* @property-read Collection|Tag[] $tags * @property-read Collection|Tag[] $tags
* @property-read int|null $tags_count * @property-read int|null $tags_count
* @property-read TransactionCurrency|null $transactionCurrency * @property-read TransactionCurrency|null $transactionCurrency
* @property-read TransactionGroup|null $transactionGroup * @property-read TransactionGroup|null $transactionGroup
* @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta * @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta
* @property-read int|null $transaction_journal_meta_count * @property-read int|null $transaction_journal_meta_count
* @property-read TransactionType $transactionType * @property-read TransactionType $transactionType
* @property-read Collection|Transaction[] $transactions * @property-read Collection|Transaction[] $transactions
* @property-read int|null $transactions_count * @property-read int|null $transactions_count
* @property-read User $user * @property-read User $user
* @method static EloquentBuilder|TransactionJournal after(Carbon $date) * @method static EloquentBuilder|TransactionJournal after(Carbon $date)
* @method static EloquentBuilder|TransactionJournal before(Carbon $date) * @method static EloquentBuilder|TransactionJournal before(Carbon $date)
* @method static EloquentBuilder|TransactionJournal newModelQuery() * @method static EloquentBuilder|TransactionJournal newModelQuery()
@@ -112,13 +112,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static EloquentBuilder|TransactionJournal whereUserId($value) * @method static EloquentBuilder|TransactionJournal whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed() * @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed() * @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
* @property-read Collection|Location[] $locations * @property-read Collection|Location[] $locations
* @property-read int|null $locations_count * @property-read int|null $locations_count
* @property int $the_count * @property int $the_count
* @property int|null $user_group_id * @property int|null $user_group_id
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value) * @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
* @property-read Collection<int, \FireflyIII\Models\AuditLogEntry> $auditLogEntries * @property-read Collection<int, AuditLogEntry> $auditLogEntries
* @property-read int|null $audit_log_entries_count * @property-read int|null $audit_log_entries_count
* @mixin Eloquent * @mixin Eloquent
*/ */
class TransactionJournal extends Model class TransactionJournal extends Model

View File

@@ -39,13 +39,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class UserGroup * Class UserGroup
* *
* @property int $id * @property int $id
* @property Carbon|null $created_at * @property Carbon|null $created_at
* @property Carbon|null $updated_at * @property Carbon|null $updated_at
* @property string|null $deleted_at * @property string|null $deleted_at
* @property string $title * @property string $title
* @property-read Collection|GroupMembership[] $groupMemberships * @property-read Collection|GroupMembership[] $groupMemberships
* @property-read int|null $group_memberships_count * @property-read int|null $group_memberships_count
* @method static Builder|UserGroup newModelQuery() * @method static Builder|UserGroup newModelQuery()
* @method static Builder|UserGroup newQuery() * @method static Builder|UserGroup newQuery()
* @method static Builder|UserGroup query() * @method static Builder|UserGroup query()
@@ -54,40 +54,40 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|UserGroup whereId($value) * @method static Builder|UserGroup whereId($value)
* @method static Builder|UserGroup whereTitle($value) * @method static Builder|UserGroup whereTitle($value)
* @method static Builder|UserGroup whereUpdatedAt($value) * @method static Builder|UserGroup whereUpdatedAt($value)
* @property-read Collection<int, Account> $accounts * @property-read Collection<int, Account> $accounts
* @property-read int|null $accounts_count * @property-read int|null $accounts_count
* @property-read Collection<int, AvailableBudget> $availableBudgets * @property-read Collection<int, AvailableBudget> $availableBudgets
* @property-read int|null $available_budgets_count * @property-read int|null $available_budgets_count
* @property-read Collection<int, Bill> $bills * @property-read Collection<int, Bill> $bills
* @property-read int|null $bills_count * @property-read int|null $bills_count
* @property-read Collection<int, Budget> $budgets * @property-read Collection<int, Budget> $budgets
* @property-read int|null $budgets_count * @property-read int|null $budgets_count
* @property-read Collection<int, PiggyBank> $piggyBanks * @property-read Collection<int, PiggyBank> $piggyBanks
* @property-read int|null $piggy_banks_count * @property-read int|null $piggy_banks_count
* @property-read Collection<int, TransactionJournal> $transactionJournals * @property-read Collection<int, TransactionJournal> $transactionJournals
* @property-read int|null $transaction_journals_count * @property-read int|null $transaction_journals_count
* @property-read Collection<int, \FireflyIII\Models\Attachment> $attachments * @property-read Collection<int, Attachment> $attachments
* @property-read int|null $attachments_count * @property-read int|null $attachments_count
* @property-read Collection<int, \FireflyIII\Models\Category> $categories * @property-read Collection<int, Category> $categories
* @property-read int|null $categories_count * @property-read int|null $categories_count
* @property-read Collection<int, \FireflyIII\Models\CurrencyExchangeRate> $currencyExchangeRates * @property-read Collection<int, CurrencyExchangeRate> $currencyExchangeRates
* @property-read int|null $currency_exchange_rates_count * @property-read int|null $currency_exchange_rates_count
* @property-read Collection<int, \FireflyIII\Models\ObjectGroup> $objectGroups * @property-read Collection<int, ObjectGroup> $objectGroups
* @property-read int|null $object_groups_count * @property-read int|null $object_groups_count
* @property-read Collection<int, \FireflyIII\Models\Recurrence> $recurrences * @property-read Collection<int, Recurrence> $recurrences
* @property-read int|null $recurrences_count * @property-read int|null $recurrences_count
* @property-read Collection<int, \FireflyIII\Models\RuleGroup> $ruleGroups * @property-read Collection<int, RuleGroup> $ruleGroups
* @property-read int|null $rule_groups_count * @property-read int|null $rule_groups_count
* @property-read Collection<int, \FireflyIII\Models\Rule> $rules * @property-read Collection<int, Rule> $rules
* @property-read int|null $rules_count * @property-read int|null $rules_count
* @property-read Collection<int, \FireflyIII\Models\Tag> $tags * @property-read Collection<int, Tag> $tags
* @property-read int|null $tags_count * @property-read int|null $tags_count
* @property-read Collection<int, \FireflyIII\Models\TransactionGroup> $transactionGroups * @property-read Collection<int, TransactionGroup> $transactionGroups
* @property-read int|null $transaction_groups_count * @property-read int|null $transaction_groups_count
* @property-read Collection<int, \FireflyIII\Models\Webhook> $webhooks * @property-read Collection<int, Webhook> $webhooks
* @property-read int|null $webhooks_count * @property-read int|null $webhooks_count
* @property-read Collection<int, \FireflyIII\Models\TransactionCurrency> $currencies * @property-read Collection<int, TransactionCurrency> $currencies
* @property-read int|null $currencies_count * @property-read int|null $currencies_count
* @mixin Eloquent * @mixin Eloquent
*/ */
class UserGroup extends Model class UserGroup extends Model
@@ -132,16 +132,6 @@ class UserGroup extends Model
return $this->hasMany(Account::class); return $this->hasMany(Account::class);
} }
/**
* Link to currencies
*
* @return BelongsToMany
*/
public function currencies(): BelongsToMany
{
return $this->belongsToMany(TransactionCurrency::class)->withTimestamps()->withPivot('group_default');
}
/** /**
* Link to attachments. * Link to attachments.
* *
@@ -192,6 +182,16 @@ class UserGroup extends Model
return $this->hasMany(Category::class); return $this->hasMany(Category::class);
} }
/**
* Link to currencies
*
* @return BelongsToMany
*/
public function currencies(): BelongsToMany
{
return $this->belongsToMany(TransactionCurrency::class)->withTimestamps()->withPivot('group_default');
}
/** /**
* Link to exchange rates. * Link to exchange rates.
* *

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Admin; namespace FireflyIII\Notifications\Admin;
use FireflyIII\Support\Notifications\UrlValidator; use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Admin;
use FireflyIII\Models\InvitedUser; use FireflyIII\Models\InvitedUser;
use FireflyIII\Support\Notifications\UrlValidator; use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Notifications\Admin; namespace FireflyIII\Notifications\Admin;
use FireflyIII\Support\Notifications\UrlValidator; use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;

View File

@@ -29,9 +29,9 @@ use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Notifications\Messages\SlackMessage;
/** /**
* Class UserLogin * Class UserLogin

View File

@@ -28,7 +28,6 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Laravel\Sanctum\Sanctum; use Laravel\Sanctum\Sanctum;
use URL;
/** /**
* Class AppServiceProvider * Class AppServiceProvider

View File

@@ -31,10 +31,10 @@ use FireflyIII\Repositories\Journal\JournalCLIRepository;
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface; use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepository; use FireflyIII\Repositories\Journal\JournalRepository;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Journal\JournalRepository as GroupJournalRepository;
use FireflyIII\Repositories\UserGroups\Journal\JournalRepositoryInterface as GroupJournalRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Journal\JournalRepository as GroupJournalRepository;
use FireflyIII\Repositories\UserGroups\Journal\JournalRepositoryInterface as GroupJournalRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;

View File

@@ -25,10 +25,8 @@ namespace FireflyIII\Providers;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepository; use FireflyIII\Repositories\PiggyBank\PiggyBankRepository;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepository as AdminPiggyBankRepository; use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepository as AdminPiggyBankRepository;
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface as AdminPiggyBankRepositoryInterface; use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface as AdminPiggyBankRepositoryInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;

View File

@@ -38,7 +38,6 @@ use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleTrigger; use FireflyIII\Models\RuleTrigger;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepository;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\BudgetDestroyService; use FireflyIII\Services\Internal\Destroy\BudgetDestroyService;
use FireflyIII\User; use FireflyIII\User;

View File

@@ -262,6 +262,16 @@ class JournalRepository implements JournalRepositoryInterface
} }
} }
/**
* @inheritDoc
*/
public function unreconcileById(int $journalId): void
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
$journal?->transactions()->update(['reconciled' => false]);
}
/** /**
* Update budget for a journal. * Update budget for a journal.
* *
@@ -334,14 +344,4 @@ class JournalRepository implements JournalRepositoryInterface
return $journal; return $journal;
} }
/**
* @inheritDoc
*/
public function unreconcileById(int $journalId): void
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
$journal?->transactions()->update(['reconciled' => false]);
}
} }

View File

@@ -133,13 +133,6 @@ interface JournalRepositoryInterface
*/ */
public function reconcileById(int $journalId): void; public function reconcileById(int $journalId): void;
/**
* TODO Maybe to account repository? Do this wen reconcile is API only.
*
* @param int $journalId
*/
public function unreconcileById(int $journalId): void;
/** /**
* Search in journal descriptions. * Search in journal descriptions.
* *
@@ -155,6 +148,13 @@ interface JournalRepositoryInterface
*/ */
public function setUser(User | Authenticatable | null $user): void; public function setUser(User | Authenticatable | null $user): void;
/**
* TODO Maybe to account repository? Do this wen reconcile is API only.
*
* @param int $journalId
*/
public function unreconcileById(int $journalId): void;
/** /**
* Update budget for a journal. * Update budget for a journal.
* *

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait; use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Repositories\UserGroups\Currency; namespace FireflyIII\Repositories\UserGroups\Currency;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Repositories\UserGroups\Currency; namespace FireflyIII\Repositories\UserGroups\Currency;

View File

@@ -31,8 +31,6 @@ use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use NumberFormatter; use NumberFormatter;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/** /**
* Class Amount. * Class Amount.
@@ -140,7 +138,7 @@ class Amount
return $cache->get(); return $cache->get();
} }
$default = $user->currencies()->where('user_default', true)->first(); $default = $user->currencies()->where('user_default', true)->first();
if(null === $default) { if (null === $default) {
$default = $this->getSystemCurrency(); $default = $this->getSystemCurrency();
$user->currencies()->sync([$default->id => ['user_default' => true]]); $user->currencies()->sync([$default->id => ['user_default' => true]]);
} }
@@ -148,6 +146,15 @@ class Amount
return $default; return $default;
} }
/**
* @return TransactionCurrency
*/
public function getSystemCurrency(): TransactionCurrency
{
return TransactionCurrency::where('code', 'EUR')->first();
}
/** /**
* @param User $user * @param User $user
* *
@@ -162,7 +169,7 @@ class Amount
return $cache->get(); return $cache->get();
} }
$default = $userGroup->currencies()->where('group_default', true)->first(); $default = $userGroup->currencies()->where('group_default', true)->first();
if(null === $default) { if (null === $default) {
$default = $this->getSystemCurrency(); $default = $this->getSystemCurrency();
$userGroup->currencies()->sync([$default->id => ['group_default' => true]]); $userGroup->currencies()->sync([$default->id => ['group_default' => true]]);
} }
@@ -171,22 +178,6 @@ class Amount
return $default; return $default;
} }
/**
* @param string $value
*
* @return string
*/
private function tryDecrypt(string $value): string
{
try {
$value = Crypt::decrypt($value); // verified
} catch (DecryptException $e) {
// @ignoreException
}
return $value;
}
/** /**
* This method returns the correct format rules required by accounting.js, * This method returns the correct format rules required by accounting.js,
* the library used to format amounts in charts. * the library used to format amounts in charts.
@@ -328,10 +319,18 @@ class Amount
} }
/** /**
* @return TransactionCurrency * @param string $value
*
* @return string
*/ */
public function getSystemCurrency(): TransactionCurrency private function tryDecrypt(string $value): string
{ {
return TransactionCurrency::where('code', 'EUR')->first(); try {
$value = Crypt::decrypt($value); // verified
} catch (DecryptException $e) {
// @ignoreException
}
return $value;
} }
} }

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Support\Binder;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Routing\Route; use Illuminate\Routing\Route;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Support\Form;
use FireflyIII\Models\RuleGroup; use FireflyIII\Models\RuleGroup;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use Form; use Form;
use Illuminate\Support\HtmlString;
/** /**
* Class RuleForm * Class RuleForm

View File

@@ -26,10 +26,7 @@ namespace FireflyIII\Support\Http\Api;
use Carbon\Carbon; use Carbon\Carbon;
use DateTimeInterface; use DateTimeInterface;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\CacheProperties;
/** /**
* Trait ConvertsExchangeRates * Trait ConvertsExchangeRates

View File

@@ -58,7 +58,7 @@ class Navigation
*/ */
public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip = 0): Carbon public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip = 0): Carbon
{ {
$date = clone $theDate; $date = clone $theDate;
$functionMap = [ $functionMap = [
'1D' => Periodicity::Daily, '1D' => Periodicity::Daily,
'daily' => Periodicity::Daily, 'daily' => Periodicity::Daily,
@@ -351,8 +351,13 @@ class Navigation
*/ */
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
{ {
app('log')->debug(sprintf('diffInPeriods: %s (skip: %d), between %s and %s.', app('log')->debug(sprintf(
$period, $skip, $beginning->format('Y-m-d'), $end->format('Y-m-d'))); 'diffInPeriods: %s (skip: %d), between %s and %s.',
$period,
$skip,
$beginning->format('Y-m-d'),
$end->format('Y-m-d')
));
$map = [ $map = [
'daily' => 'floatDiffInDays', 'daily' => 'floatDiffInDays',
'weekly' => 'floatDiffInWeeks', 'weekly' => 'floatDiffInWeeks',
@@ -370,11 +375,11 @@ class Navigation
$diff = $beginning->$func($end); $diff = $beginning->$func($end);
// then correct for quarterly or half-year // then correct for quarterly or half-year
if('quarterly' === $period) { if ('quarterly' === $period) {
app('log')->debug(sprintf('Q: Corrected %f to %f', $diff, $diff / 3)); app('log')->debug(sprintf('Q: Corrected %f to %f', $diff, $diff / 3));
$diff = $diff / 3; $diff = $diff / 3;
} }
if('half-year' === $period) { if ('half-year' === $period) {
app('log')->debug(sprintf('H: Corrected %f to %f', $diff, $diff / 6)); app('log')->debug(sprintf('H: Corrected %f to %f', $diff, $diff / 6));
$diff = $diff / 6; $diff = $diff / 6;
} }
@@ -384,11 +389,15 @@ class Navigation
app('log')->debug(sprintf('Diff is %f (%d)', $beginning->$func($end), $diff)); app('log')->debug(sprintf('Diff is %f (%d)', $beginning->$func($end), $diff));
if($skip > 0) { if ($skip > 0) {
$parameter = $skip + 1; $parameter = $skip + 1;
$diff = ceil($diff / $parameter) * $parameter; $diff = ceil($diff / $parameter) * $parameter;
app('log')->debug(sprintf('diffInPeriods: skip is %d, so param is %d, and diff becomes %d', app('log')->debug(sprintf(
$skip, $parameter, $diff)); 'diffInPeriods: skip is %d, so param is %d, and diff becomes %d',
$skip,
$parameter,
$diff
));
} }
return (int)$diff; return (int)$diff;

View File

@@ -60,7 +60,7 @@ class Preferences
*/ */
public function get(string $name, $default = null): ?Preference public function get(string $name, $default = null): ?Preference
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
/** @var User|null $user */ /** @var User|null $user */
@@ -85,7 +85,7 @@ class Preferences
*/ */
public function getForUser(User $user, string $name, $default = null): ?Preference public function getForUser(User $user, string $name, $default = null): ?Preference
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
$preference = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']); $preference = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
@@ -114,7 +114,7 @@ class Preferences
*/ */
public function delete(string $name): bool public function delete(string $name): bool
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
$fullName = sprintf('preference%s%s', auth()->user()->id, $name); $fullName = sprintf('preference%s%s', auth()->user()->id, $name);
@@ -132,7 +132,7 @@ class Preferences
*/ */
public function forget(User $user, string $name): void public function forget(User $user, string $name): void
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
$key = sprintf('preference%s%s', $user->id, $name); $key = sprintf('preference%s%s', $user->id, $name);
@@ -150,7 +150,7 @@ class Preferences
*/ */
public function setForUser(User $user, string $name, $value): Preference public function setForUser(User $user, string $name, $value): Preference
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
$fullName = sprintf('preference%s%s', $user->id, $name); $fullName = sprintf('preference%s%s', $user->id, $name);
@@ -200,7 +200,7 @@ class Preferences
*/ */
public function findByName(string $name): Collection public function findByName(string $name): Collection
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
return Preference::where('name', $name)->get(); return Preference::where('name', $name)->get();
@@ -238,7 +238,7 @@ class Preferences
*/ */
public function getFresh(string $name, $default = null): ?Preference public function getFresh(string $name, $default = null): ?Preference
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
/** @var User|null $user */ /** @var User|null $user */
@@ -264,7 +264,7 @@ class Preferences
*/ */
public function getFreshForUser(User $user, string $name, $default = null): ?Preference public function getFreshForUser(User $user, string $name, $default = null): ?Preference
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
return $this->getForUser($user, $name, $default); return $this->getForUser($user, $name, $default);
@@ -307,7 +307,7 @@ class Preferences
*/ */
public function set(string $name, $value): Preference public function set(string $name, $value): Preference
{ {
if('currencyPreference' === $name) { if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.'); throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
} }
$user = auth()->user(); $user = auth()->user();

View File

@@ -34,8 +34,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\ParseDateString; use FireflyIII\Support\ParseDateString;
use FireflyIII\User; use FireflyIII\User;
use Gdbots\QueryParser\Enum\BoolOperator; use Gdbots\QueryParser\Enum\BoolOperator;

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions; namespace FireflyIII\TransactionRules\Actions;
use DB;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;

View File

@@ -60,17 +60,17 @@ class BillTransformer extends AbstractTransformer
$paidData = $this->paidData($bill); $paidData = $this->paidData($bill);
$payDates = $this->payDates($bill); $payDates = $this->payDates($bill);
$currency = $bill->transactionCurrency; $currency = $bill->transactionCurrency;
$notes = $this->repository->getNoteText($bill); $notes = $this->repository->getNoteText($bill);
$notes = '' === $notes ? null : $notes; $notes = '' === $notes ? null : $notes;
$this->repository->setUser($bill->user); $this->repository->setUser($bill->user);
$objectGroupId = null; $objectGroupId = null;
$objectGroupOrder = null; $objectGroupOrder = null;
$objectGroupTitle = null; $objectGroupTitle = null;
/** @var ObjectGroup $objectGroup */ /** @var ObjectGroup $objectGroup */
$objectGroup = $bill->objectGroups->first(); $objectGroup = $bill->objectGroups->first();
if (null !== $objectGroup) { if (null !== $objectGroup) {
$objectGroupId = (int)$objectGroup->id; $objectGroupId = (int)$objectGroup->id;
$objectGroupOrder = (int)$objectGroup->order; $objectGroupOrder = (int)$objectGroup->order;
$objectGroupTitle = $objectGroup->title; $objectGroupTitle = $objectGroup->title;
} }
@@ -78,7 +78,7 @@ class BillTransformer extends AbstractTransformer
$paidDataFormatted = []; $paidDataFormatted = [];
$payDatesFormatted = []; $payDatesFormatted = [];
foreach ($paidData['paid_dates'] as $object) { foreach ($paidData['paid_dates'] as $object) {
$object['date'] = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'))->toAtomString(); $object['date'] = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'))->toAtomString();
$paidDataFormatted[] = $object; $paidDataFormatted[] = $object;
} }
@@ -98,40 +98,40 @@ class BillTransformer extends AbstractTransformer
$current = $payDatesFormatted[0] ?? null; $current = $payDatesFormatted[0] ?? null;
if (null !== $current && !$temp->isToday()) { if (null !== $current && !$temp->isToday()) {
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current); $temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
$nextExpectedMatchDiff = $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW); $nextExpectedMatchDiff = $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW);
} }
unset($temp, $temp2); unset($temp, $temp2);
return [ return [
'id' => (int)$bill->id, 'id' => (int)$bill->id,
'created_at' => $bill->created_at->toAtomString(), 'created_at' => $bill->created_at->toAtomString(),
'updated_at' => $bill->updated_at->toAtomString(), 'updated_at' => $bill->updated_at->toAtomString(),
'currency_id' => (string)$bill->transaction_currency_id, 'currency_id' => (string)$bill->transaction_currency_id,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
'currency_decimal_places' => (int)$currency->decimal_places, 'currency_decimal_places' => (int)$currency->decimal_places,
'name' => $bill->name, 'name' => $bill->name,
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places), 'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places), 'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
'date' => $bill->date->toAtomString(), 'date' => $bill->date->toAtomString(),
'end_date' => $bill->end_date?->toAtomString(), 'end_date' => $bill->end_date?->toAtomString(),
'extension_date' => $bill->extension_date?->toAtomString(), 'extension_date' => $bill->extension_date?->toAtomString(),
'repeat_freq' => $bill->repeat_freq, 'repeat_freq' => $bill->repeat_freq,
'skip' => (int)$bill->skip, 'skip' => (int)$bill->skip,
'active' => $bill->active, 'active' => $bill->active,
'order' => (int)$bill->order, 'order' => (int)$bill->order,
'notes' => $notes, 'notes' => $notes,
'object_group_id' => $objectGroupId ? (string)$objectGroupId : null, 'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
'object_group_order' => $objectGroupOrder, 'object_group_order' => $objectGroupOrder,
'object_group_title' => $objectGroupTitle, 'object_group_title' => $objectGroupTitle,
// these fields need work: // these fields need work:
'next_expected_match' => $nextExpectedMatch, 'next_expected_match' => $nextExpectedMatch,
'next_expected_match_diff' => $nextExpectedMatchDiff, 'next_expected_match_diff' => $nextExpectedMatchDiff,
'pay_dates' => $payDatesFormatted, 'pay_dates' => $payDatesFormatted,
'paid_dates' => $paidDataFormatted, 'paid_dates' => $paidDataFormatted,
'links' => [ 'links' => [
[ [
'rel' => 'self', 'rel' => 'self',
'uri' => '/bills/' . $bill->id, 'uri' => '/bills/' . $bill->id,
@@ -154,7 +154,7 @@ class BillTransformer extends AbstractTransformer
app('log')->debug('parameters are NULL, return empty array'); app('log')->debug('parameters are NULL, return empty array');
return [ return [
'paid_dates' => [], 'paid_dates' => [],
'next_expected_match' => null, 'next_expected_match' => null,
]; ];
} }
@@ -162,7 +162,7 @@ class BillTransformer extends AbstractTransformer
// 2023-07-18 this particular date is used to search for the last paid date. // 2023-07-18 this particular date is used to search for the last paid date.
// 2023-07-18 the cloned $searchDate is used to grab the correct transactions. // 2023-07-18 the cloned $searchDate is used to grab the correct transactions.
/** @var Carbon $start */ /** @var Carbon $start */
$start = clone $this->parameters->get('start'); $start = clone $this->parameters->get('start');
$searchStart = clone $start; $searchStart = clone $start;
$start->subDay(); $start->subDay();
@@ -189,7 +189,7 @@ class BillTransformer extends AbstractTransformer
/* /*
* Diff in months (or other period) between bill start and last paid date or $start. * Diff in months (or other period) between bill start and last paid date or $start.
*/ */
$steps = app('navigation')->diffInPeriods($bill->repeat_freq, $bill->skip, $start, $nextMatch); $steps = app('navigation')->diffInPeriods($bill->repeat_freq, $bill->skip, $start, $nextMatch);
$nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $steps); $nextMatch = app('navigation')->addPeriod($nextMatch, $bill->repeat_freq, $steps);
if ($nextMatch->lt($lastPaidDate)) { if ($nextMatch->lt($lastPaidDate)) {
@@ -213,16 +213,16 @@ class BillTransformer extends AbstractTransformer
$result = []; $result = [];
foreach ($set as $entry) { foreach ($set as $entry) {
$result[] = [ $result[] = [
'transaction_group_id' => (int)$entry->transaction_group_id, 'transaction_group_id' => (int)$entry->transaction_group_id,
'transaction_journal_id' => (int)$entry->id, 'transaction_journal_id' => (int)$entry->id,
'date' => $entry->date->format('Y-m-d'), 'date' => $entry->date->format('Y-m-d'),
]; ];
} }
app('log')->debug(sprintf('Next match: %s', $nextMatch->toIso8601String())); app('log')->debug(sprintf('Next match: %s', $nextMatch->toIso8601String()));
return [ return [
'paid_dates' => $result, 'paid_dates' => $result,
'next_expected_match' => $nextMatch->format('Y-m-d'), 'next_expected_match' => $nextMatch->format('Y-m-d'),
]; ];
} }
@@ -231,7 +231,7 @@ class BillTransformer extends AbstractTransformer
* Returns the latest date in the set, or start when set is empty. * Returns the latest date in the set, or start when set is empty.
* *
* @param Collection $dates * @param Collection $dates
* @param Carbon $default * @param Carbon $default
* *
* @return Carbon * @return Carbon
*/ */
@@ -265,7 +265,7 @@ class BillTransformer extends AbstractTransformer
return []; return [];
} }
app('log')->debug(sprintf('Start: %s, end: %s', $this->parameters->get('start')->format('Y-m-d'), $this->parameters->get('end')->format('Y-m-d'))); app('log')->debug(sprintf('Start: %s, end: %s', $this->parameters->get('start')->format('Y-m-d'), $this->parameters->get('end')->format('Y-m-d')));
$set = new Collection(); $set = new Collection();
$currentStart = clone $this->parameters->get('start'); $currentStart = clone $this->parameters->get('start');
// 2023-06-23 subDay to fix 7655 // 2023-06-23 subDay to fix 7655
$currentStart->subDay(); $currentStart->subDay();
@@ -303,7 +303,7 @@ class BillTransformer extends AbstractTransformer
} }
app('log')->debug(sprintf('Next expected match is %s', $nextExpectedMatch->format('Y-m-d'))); app('log')->debug(sprintf('Next expected match is %s', $nextExpectedMatch->format('Y-m-d')));
// add to set, if the date is ON or after the start parameter // add to set, if the date is ON or after the start parameter
if($nextExpectedMatch->gte($this->parameters->get('start'))) { if ($nextExpectedMatch->gte($this->parameters->get('start'))) {
$set->push(clone $nextExpectedMatch); $set->push(clone $nextExpectedMatch);
} }
@@ -334,7 +334,7 @@ class BillTransformer extends AbstractTransformer
* Given a bill and a date, this method will tell you at which moment this bill expects its next * Given a bill and a date, this method will tell you at which moment this bill expects its next
* transaction. That date must be AFTER $date as a sanity check. * transaction. That date must be AFTER $date as a sanity check.
* *
* @param Bill $bill * @param Bill $bill
* @param Carbon $date * @param Carbon $date
* *
* @return Carbon * @return Carbon
@@ -349,7 +349,7 @@ class BillTransformer extends AbstractTransformer
return clone $start; return clone $start;
} }
$steps = app('navigation')->diffInPeriods($bill->repeat_freq, $bill->skip, $start, $date); $steps = app('navigation')->diffInPeriods($bill->repeat_freq, $bill->skip, $start, $date);
$result = clone $start; $result = clone $start;
if ($steps > 0) { if ($steps > 0) {
$steps = $steps - 1; $steps = $steps - 1;

View File

@@ -34,6 +34,7 @@ class CurrencyTransformer extends AbstractTransformer
* Transform the currency. * Transform the currency.
* *
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
*
* @return array * @return array
*/ */
public function transform(TransactionCurrency $currency): array public function transform(TransactionCurrency $currency): array

View File

@@ -34,7 +34,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface; use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use Illuminate\Support\Facades\Log;
/** /**
* *

View File

@@ -36,7 +36,6 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Support\NullArrayObject; use FireflyIII\Support\NullArrayObject;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
/** /**
* Class TransactionGroupTransformer * Class TransactionGroupTransformer

View File

@@ -58,8 +58,8 @@ class AccountTransformer extends AbstractTransformer
$this->convertedBalances = app('steam')->balancesByAccountsConverted($objects, $this->getDate()); $this->convertedBalances = app('steam')->balancesByAccountsConverted($objects, $this->getDate());
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$this->default = app('amount')->getDefaultCurrency(); $this->default = app('amount')->getDefaultCurrency();
// get currencies: // get currencies:
$accountIds = $objects->pluck('id')->toArray(); $accountIds = $objects->pluck('id')->toArray();

View File

@@ -35,7 +35,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ExchangeRateConverter; use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Log;
/** /**
* Class BillTransformer * Class BillTransformer

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Transformers; namespace FireflyIII\Transformers;
use FireflyIII\Models\WebhookMessage; use FireflyIII\Models\WebhookMessage;
use Illuminate\Support\Facades\Log;
use Jsonexception; use Jsonexception;
/** /**

View File

@@ -80,39 +80,39 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class User. * Class User.
* *
* @property int $id * @property int $id
* @property string $email * @property string $email
* @property bool $isAdmin * @property bool $isAdmin
* @property bool $has2FA * @property bool $has2FA
* @property array $prefs * @property array $prefs
* @property string $password * @property string $password
* @property string $mfa_secret * @property string $mfa_secret
* @property Collection $roles * @property Collection $roles
* @property string $blocked_code * @property string $blocked_code
* @property bool $blocked * @property bool $blocked
* @property Carbon|null $created_at * @property Carbon|null $created_at
* @property Carbon|null $updated_at * @property Carbon|null $updated_at
* @property string|null $remember_token * @property string|null $remember_token
* @property string|null $reset * @property string|null $reset
* @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts * @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts
* @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments * @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments
* @property-read \Illuminate\Database\Eloquent\Collection|AvailableBudget[] $availableBudgets * @property-read \Illuminate\Database\Eloquent\Collection|AvailableBudget[] $availableBudgets
* @property-read \Illuminate\Database\Eloquent\Collection|Bill[] $bills * @property-read \Illuminate\Database\Eloquent\Collection|Bill[] $bills
* @property-read \Illuminate\Database\Eloquent\Collection|Budget[] $budgets * @property-read \Illuminate\Database\Eloquent\Collection|Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|Category[] $categories * @property-read \Illuminate\Database\Eloquent\Collection|Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|Client[] $clients * @property-read \Illuminate\Database\Eloquent\Collection|Client[] $clients
* @property-read \Illuminate\Database\Eloquent\Collection|CurrencyExchangeRate[] $currencyExchangeRates * @property-read \Illuminate\Database\Eloquent\Collection|CurrencyExchangeRate[] $currencyExchangeRates
* @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications * @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
* @property-read \Illuminate\Database\Eloquent\Collection|PiggyBank[] $piggyBanks * @property-read \Illuminate\Database\Eloquent\Collection|PiggyBank[] $piggyBanks
* @property-read \Illuminate\Database\Eloquent\Collection|Preference[] $preferences * @property-read \Illuminate\Database\Eloquent\Collection|Preference[] $preferences
* @property-read \Illuminate\Database\Eloquent\Collection|Recurrence[] $recurrences * @property-read \Illuminate\Database\Eloquent\Collection|Recurrence[] $recurrences
* @property-read \Illuminate\Database\Eloquent\Collection|RuleGroup[] $ruleGroups * @property-read \Illuminate\Database\Eloquent\Collection|RuleGroup[] $ruleGroups
* @property-read \Illuminate\Database\Eloquent\Collection|Rule[] $rules * @property-read \Illuminate\Database\Eloquent\Collection|Rule[] $rules
* @property-read \Illuminate\Database\Eloquent\Collection|Tag[] $tags * @property-read \Illuminate\Database\Eloquent\Collection|Tag[] $tags
* @property-read \Illuminate\Database\Eloquent\Collection|Token[] $tokens * @property-read \Illuminate\Database\Eloquent\Collection|Token[] $tokens
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionGroup[] $transactionGroups * @property-read \Illuminate\Database\Eloquent\Collection|TransactionGroup[] $transactionGroups
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournal[] $transactionJournals * @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournal[] $transactionJournals
* @property-read \Illuminate\Database\Eloquent\Collection|Transaction[] $transactions * @property-read \Illuminate\Database\Eloquent\Collection|Transaction[] $transactions
* @method static Builder|User newModelQuery() * @method static Builder|User newModelQuery()
* @method static Builder|User newQuery() * @method static Builder|User newQuery()
* @method static Builder|User query() * @method static Builder|User query()
@@ -125,50 +125,50 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|User whereRememberToken($value) * @method static Builder|User whereRememberToken($value)
* @method static Builder|User whereReset($value) * @method static Builder|User whereReset($value)
* @method static Builder|User whereUpdatedAt($value) * @method static Builder|User whereUpdatedAt($value)
* @property string|null $objectguid * @property string|null $objectguid
* @property-read int|null $accounts_count * @property-read int|null $accounts_count
* @property-read int|null $attachments_count * @property-read int|null $attachments_count
* @property-read int|null $available_budgets_count * @property-read int|null $available_budgets_count
* @property-read int|null $bills_count * @property-read int|null $bills_count
* @property-read int|null $budgets_count * @property-read int|null $budgets_count
* @property-read int|null $categories_count * @property-read int|null $categories_count
* @property-read int|null $clients_count * @property-read int|null $clients_count
* @property-read int|null $currency_exchange_rates_count * @property-read int|null $currency_exchange_rates_count
* @property-read int|null $notifications_count * @property-read int|null $notifications_count
* @property-read int|null $piggy_banks_count * @property-read int|null $piggy_banks_count
* @property-read int|null $preferences_count * @property-read int|null $preferences_count
* @property-read int|null $recurrences_count * @property-read int|null $recurrences_count
* @property-read int|null $roles_count * @property-read int|null $roles_count
* @property-read int|null $rule_groups_count * @property-read int|null $rule_groups_count
* @property-read int|null $rules_count * @property-read int|null $rules_count
* @property-read int|null $tags_count * @property-read int|null $tags_count
* @property-read int|null $tokens_count * @property-read int|null $tokens_count
* @property-read int|null $transaction_groups_count * @property-read int|null $transaction_groups_count
* @property-read int|null $transaction_journals_count * @property-read int|null $transaction_journals_count
* @property-read int|null $transactions_count * @property-read int|null $transactions_count
* @method static Builder|User whereMfaSecret($value) * @method static Builder|User whereMfaSecret($value)
* @method static Builder|User whereObjectguid($value) * @method static Builder|User whereObjectguid($value)
* @property string|null $provider * @property string|null $provider
* @method static Builder|User whereProvider($value) * @method static Builder|User whereProvider($value)
* @property-read \Illuminate\Database\Eloquent\Collection|ObjectGroup[] $objectGroups * @property-read \Illuminate\Database\Eloquent\Collection|ObjectGroup[] $objectGroups
* @property-read int|null $object_groups_count * @property-read int|null $object_groups_count
* @property-read \Illuminate\Database\Eloquent\Collection|Webhook[] $webhooks * @property-read \Illuminate\Database\Eloquent\Collection|Webhook[] $webhooks
* @property-read int|null $webhooks_count * @property-read int|null $webhooks_count
* @property string|null $two_factor_secret * @property string|null $two_factor_secret
* @property string|null $two_factor_recovery_codes * @property string|null $two_factor_recovery_codes
* @property string|null $guid * @property string|null $guid
* @property string|null $domain * @property string|null $domain
* @method static Builder|User whereDomain($value) * @method static Builder|User whereDomain($value)
* @method static Builder|User whereGuid($value) * @method static Builder|User whereGuid($value)
* @method static Builder|User whereTwoFactorRecoveryCodes($value) * @method static Builder|User whereTwoFactorRecoveryCodes($value)
* @method static Builder|User whereTwoFactorSecret($value) * @method static Builder|User whereTwoFactorSecret($value)
* @property int|null $user_group_id * @property int|null $user_group_id
* @property-read \Illuminate\Database\Eloquent\Collection|GroupMembership[] $groupMemberships * @property-read \Illuminate\Database\Eloquent\Collection|GroupMembership[] $groupMemberships
* @property-read int|null $group_memberships_count * @property-read int|null $group_memberships_count
* @property-read UserGroup|null $userGroup * @property-read UserGroup|null $userGroup
* @method static Builder|User whereUserGroupId($value) * @method static Builder|User whereUserGroupId($value)
* @property-read \Illuminate\Database\Eloquent\Collection<int, TransactionCurrency> $currencies * @property-read \Illuminate\Database\Eloquent\Collection<int, TransactionCurrency> $currencies
* @property-read int|null $currencies_count * @property-read int|null $currencies_count
* @mixin Eloquent * @mixin Eloquent
*/ */
class User extends Authenticatable class User extends Authenticatable
@@ -234,16 +234,6 @@ class User extends Authenticatable
return $this->hasMany(Account::class); return $this->hasMany(Account::class);
} }
/**
* Link to currencies
*
* @return BelongsToMany
*/
public function currencies(): BelongsToMany
{
return $this->belongsToMany(TransactionCurrency::class)->withTimestamps()->withPivot('user_default');
}
/** /**
* Link to attachments * Link to attachments
* *
@@ -294,6 +284,16 @@ class User extends Authenticatable
return $this->hasMany(Category::class); return $this->hasMany(Category::class);
} }
/**
* Link to currencies
*
* @return BelongsToMany
*/
public function currencies(): BelongsToMany
{
return $this->belongsToMany(TransactionCurrency::class)->withTimestamps()->withPivot('user_default');
}
/** /**
* Link to currency exchange rates * Link to currency exchange rates
* *

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Validation;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
@@ -38,44 +37,6 @@ use Illuminate\Validation\Validator;
*/ */
trait GroupValidation trait GroupValidation
{ {
/**
* @param Validator $validator
* @param TransactionGroup $transactionGroup
*
* @return void
*/
protected function preventUpdateReconciled(Validator $validator, TransactionGroup $transactionGroup): void
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
$count = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
->leftJoin('transaction_groups', 'transaction_groups.id', 'transaction_journals.transaction_group_id')
->where('transaction_journals.transaction_group_id', $transactionGroup->id)
->where('transactions.reconciled', 1)->where('transactions.amount', '<', 0)->count(['transactions.id']);
if (0 === $count) {
app('log')->debug(sprintf('Transaction is not reconciled, done with %s', __METHOD__));
return;
}
$data = $validator->getData();
$forbidden = ['amount','foreign_amount','currency_code','currency_id','foreign_currency_code','foreign_currency_id',
'source_id','source_name','source_number','source_iban',
'destination_id','destination_name','destination_number','destination_iban',
];
foreach($data['transactions'] as $index => $row) {
foreach($forbidden as $key) {
if(array_key_exists($key, $row)) {
$validator->errors()->add(
sprintf('transactions.%d.%s', $index, $key),
(string)trans('validation.reconciled_forbidden_field', ['field' => $key])
);
}
}
}
app('log')->debug(sprintf('Done with %s', __METHOD__));
}
/** /**
* A catch when users submit splits with no source or destination info at all. * A catch when users submit splits with no source or destination info at all.
* *
@@ -133,6 +94,43 @@ trait GroupValidation
*/ */
abstract protected function getTransactionsArray(Validator $validator): array; abstract protected function getTransactionsArray(Validator $validator): array;
/**
* @param Validator $validator
* @param TransactionGroup $transactionGroup
*
* @return void
*/
protected function preventUpdateReconciled(Validator $validator, TransactionGroup $transactionGroup): void
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
$count = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
->leftJoin('transaction_groups', 'transaction_groups.id', 'transaction_journals.transaction_group_id')
->where('transaction_journals.transaction_group_id', $transactionGroup->id)
->where('transactions.reconciled', 1)->where('transactions.amount', '<', 0)->count(['transactions.id']);
if (0 === $count) {
app('log')->debug(sprintf('Transaction is not reconciled, done with %s', __METHOD__));
return;
}
$data = $validator->getData();
$forbidden = ['amount', 'foreign_amount', 'currency_code', 'currency_id', 'foreign_currency_code', 'foreign_currency_id',
'source_id', 'source_name', 'source_number', 'source_iban',
'destination_id', 'destination_name', 'destination_number', 'destination_iban',
];
foreach ($data['transactions'] as $index => $row) {
foreach ($forbidden as $key) {
if (array_key_exists($key, $row)) {
$validator->errors()->add(
sprintf('transactions.%d.%s', $index, $key),
(string)trans('validation.reconciled_forbidden_field', ['field' => $key])
);
}
}
}
app('log')->debug(sprintf('Done with %s', __METHOD__));
}
/** /**
* Adds an error to the "description" field when the user has submitted no descriptions and no * Adds an error to the "description" field when the user has submitted no descriptions and no
* journal description. * journal description.

View File

@@ -41,7 +41,8 @@ if (!function_exists('envNonEmpty')) {
* *
* @return mixed|null * @return mixed|null
*/ */
function envNonEmpty(string $key, $default = null) { function envNonEmpty(string $key, $default = null)
{
$result = env($key, $default); $result = env($key, $default);
if (is_string($result) && '' === $result) { if (is_string($result) && '' === $result) {
$result = $default; $result = $default;
@@ -58,7 +59,8 @@ if (!function_exists('stringIsEqual')) {
* *
* @return bool * @return bool
*/ */
function stringIsEqual(string $left, string $right): bool { function stringIsEqual(string $left, string $right): bool
{
return $left === $right; return $left === $right;
} }
} }

View File

@@ -51,17 +51,17 @@ return [
'connections' => [ 'connections' => [
'pusher' => [ 'pusher' => [
'driver' => 'pusher', 'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'), 'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'), 'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'), 'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 443), 'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'), 'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true, 'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
], ],
'client_options' => [ 'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
@@ -70,11 +70,11 @@ return [
'ably' => [ 'ably' => [
'driver' => 'ably', 'driver' => 'ably',
'key' => env('ABLY_KEY'), 'key' => env('ABLY_KEY'),
], ],
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',
], ],

View File

@@ -25,7 +25,6 @@ namespace Database\Seeders;
use FireflyIII\Models\Configuration; use FireflyIII\Models\Configuration;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Log;
/** /**
* Class ConfigSeeder. * Class ConfigSeeder.