mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup
This commit is contained in:
parent
fa920fed4e
commit
0133a7c5db
12
.ci/php-cs-fixer/composer.lock
generated
12
.ci/php-cs-fixer/composer.lock
generated
@ -226,16 +226,16 @@
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.35.1",
|
||||
"version": "v3.36.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "ec1ccc264994b6764882669973ca435cf05bab08"
|
||||
"reference": "e889301f276c6ce2c391d6aafae9a162e785b064"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/ec1ccc264994b6764882669973ca435cf05bab08",
|
||||
"reference": "ec1ccc264994b6764882669973ca435cf05bab08",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/e889301f276c6ce2c391d6aafae9a162e785b064",
|
||||
"reference": "e889301f276c6ce2c391d6aafae9a162e785b064",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -307,7 +307,7 @@
|
||||
],
|
||||
"support": {
|
||||
"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": [
|
||||
{
|
||||
@ -315,7 +315,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-10-12T13:47:26+00:00"
|
||||
"time": "2023-10-27T10:12:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
|
@ -27,8 +27,8 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Validator;
|
||||
|
@ -87,7 +87,7 @@ class ShowController extends Controller
|
||||
$currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));
|
||||
$paginator->setPath(route('api.v1.currencies.index') . $this->buildParams());
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var CurrencyTransformer $transformer */
|
||||
$transformer = app(CurrencyTransformer::class);
|
||||
@ -144,7 +144,7 @@ class ShowController extends Controller
|
||||
public function showDefault(): JsonResponse
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$manager = $this->getManager();
|
||||
$currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||
|
||||
|
@ -83,7 +83,7 @@ class StoreController extends Controller
|
||||
$this->repository->makeDefault($currency);
|
||||
app('preferences')->mark();
|
||||
}
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
@ -183,11 +183,11 @@ class UpdateController extends Controller
|
||||
$data = $request->getAll();
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
|
||||
// safety catch on currency disablement.
|
||||
$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);
|
||||
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ class CreateRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$triggers = implode(',', array_keys(Webhook::getTriggersForValidation()));
|
||||
$responses = implode(',', array_keys(Webhook::getResponsesForValidation()));
|
||||
$deliveries = implode(',', array_keys(Webhook::getDeliveriesForValidation()));
|
||||
$triggers = implode(',', array_keys(Webhook::getTriggersForValidation()));
|
||||
$responses = implode(',', array_keys(Webhook::getResponsesForValidation()));
|
||||
$deliveries = implode(',', array_keys(Webhook::getDeliveriesForValidation()));
|
||||
$validProtocols = config('firefly.valid_url_protocols');
|
||||
return [
|
||||
'title' => 'required|between:1,512|uniqueObjectForUser:webhooks,title',
|
||||
|
@ -32,7 +32,6 @@ use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface as AdminAccountRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use http\Env\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
|
@ -32,13 +32,12 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\CleansChartData;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
@ -26,11 +26,9 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V2\Controllers\Model\Bill;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
use FireflyIII\Transformers\V2\AccountTransformer;
|
||||
use FireflyIII\Transformers\V2\BillTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Api\V2\Controllers\Model\Bill;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\DateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
@ -27,7 +27,6 @@ namespace FireflyIII\Api\V2\Controllers\Model\Budget;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\DateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ConvertsExchangeRates;
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Api\V2\Controllers\Model\Budget;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\DateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ConvertsExchangeRates;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
@ -26,7 +26,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V2\Controllers\Model\PiggyBank;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
|
||||
use FireflyIII\Transformers\V2\PiggyBankTransformer;
|
||||
|
@ -30,7 +30,6 @@ use FireflyIII\Api\V2\Request\Model\Transaction\StoreRequest;
|
||||
use FireflyIII\Events\StoredTransactionGroup;
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||
use FireflyIII\Rules\IsDuplicateTransaction;
|
||||
@ -38,6 +37,7 @@ use FireflyIII\Transformers\V2\TransactionGroupTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Class StoreController
|
||||
|
@ -28,9 +28,7 @@ use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use FireflyIII\User;
|
||||
use FireflyIII\Validation\Administration\ValidatesAdministrationAccess;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Class AutocompleteRequest
|
||||
|
@ -57,6 +57,7 @@ class StoreRequest extends FormRequest
|
||||
use GroupValidation;
|
||||
use CurrencyValidation;
|
||||
use AppendsLocationData;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@ class StoreRequest extends FormRequest
|
||||
{
|
||||
use ChecksLogin;
|
||||
use ConvertsDataTypes;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@ class UpdateMembershipRequest extends FormRequest
|
||||
{
|
||||
use ChecksLogin;
|
||||
use ConvertsDataTypes;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,7 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
use ChecksLogin;
|
||||
use ConvertsDataTypes;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::OWNER, UserRoleEnum::FULL];
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Schema;
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Schema;
|
||||
|
@ -34,7 +34,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
|
@ -45,8 +45,8 @@ class OtherCurrenciesCorrections extends Command
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const CONFIG_NAME = '480_other_currencies';
|
||||
protected $description = 'Update all journal currency information.';
|
||||
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $description = 'Update all journal currency information.';
|
||||
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
||||
private array $accountCurrencies;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
|
@ -68,30 +68,6 @@ class UpgradeCurrencyPreferences extends Command
|
||||
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
|
||||
{
|
||||
$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
|
||||
*
|
||||
@ -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();
|
||||
$enabled = new Collection();
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->enabled) {
|
||||
$enabled->push($currency);
|
||||
}
|
||||
$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;
|
||||
}
|
||||
$group->currencies()->sync($enabled->pluck('id')->toArray());
|
||||
return 'EUR';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@ -72,7 +71,7 @@ class UpgradeDatabase extends Command
|
||||
// also just in case, some integrity commands:
|
||||
'firefly-iii:create-group-memberships',
|
||||
'firefly-iii:upgrade-group-information',
|
||||
'firefly-iii:upgrade-currency-preferences'
|
||||
'firefly-iii:upgrade-currency-preferences',
|
||||
];
|
||||
$args = [];
|
||||
if ($this->option('force')) {
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class AccountMetaFactory
|
||||
|
@ -39,9 +39,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use FireflyIII\Services\Internal\Support\JournalServiceTrait;
|
||||
use FireflyIII\Support\NullArrayObject;
|
||||
|
@ -34,29 +34,29 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
trait CollectorProperties
|
||||
{
|
||||
public const TEST = 'Test';
|
||||
private bool $expandGroupSearch;
|
||||
private array $fields;
|
||||
private bool $hasAccountInfo;
|
||||
private bool $hasBillInformation;
|
||||
private bool $hasBudgetInformation;
|
||||
private bool $hasCatInformation;
|
||||
private bool $hasJoinedAttTables;
|
||||
private bool $hasJoinedMetaTables;
|
||||
private bool $hasJoinedTagTables;
|
||||
private bool $hasNotesInformation;
|
||||
private array $integerFields;
|
||||
private ?int $limit;
|
||||
private ?int $page;
|
||||
private array $postFilters;
|
||||
private bool $expandGroupSearch;
|
||||
private array $fields;
|
||||
private bool $hasAccountInfo;
|
||||
private bool $hasBillInformation;
|
||||
private bool $hasBudgetInformation;
|
||||
private bool $hasCatInformation;
|
||||
private bool $hasJoinedAttTables;
|
||||
private bool $hasJoinedMetaTables;
|
||||
private bool $hasJoinedTagTables;
|
||||
private bool $hasNotesInformation;
|
||||
private array $integerFields;
|
||||
private ?int $limit;
|
||||
private ?int $page;
|
||||
private array $postFilters;
|
||||
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 way the user can call 'setTags' multiple times and get a joined result.
|
||||
*
|
||||
*/
|
||||
private array $tags;
|
||||
private int $total;
|
||||
private ?User $user;
|
||||
private array $tags;
|
||||
private int $total;
|
||||
private ?User $user;
|
||||
private ?UserGroup $userGroup;
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface as AdminAccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use FireflyIII\User;
|
||||
|
@ -29,8 +29,8 @@ use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ class CreateController extends Controller
|
||||
session()->flash('success', trans('firefly.stored_journal', ['description' => $title]));
|
||||
session()->flash('success_url', $link);
|
||||
|
||||
if('edit' === $request->get('redirect')) {
|
||||
if ('edit' === $request->get('redirect')) {
|
||||
return response()->json(['redirect' => route('transactions.edit', [$newGroup->id])]);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\CurrencyFormRequest;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -45,6 +45,7 @@ class CreateController extends Controller
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a currency.
|
||||
*
|
||||
|
@ -6,8 +6,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -46,7 +46,6 @@ class DeleteController extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a currency.
|
||||
*
|
||||
|
@ -7,8 +7,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\CurrencyFormRequest;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -68,7 +68,7 @@ class EditController extends Controller
|
||||
|
||||
// is currently enabled (for this user?)
|
||||
$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
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
|
@ -6,8 +6,8 @@ namespace FireflyIII\Http\Controllers\TransactionCurrency;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -232,6 +232,32 @@ class InterestingMessage
|
||||
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
|
||||
*
|
||||
@ -278,30 +304,4 @@ class InterestingMessage
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class AccountFormRequest extends FormRequest
|
||||
use ConvertsDataTypes;
|
||||
use AppendsLocationData;
|
||||
use ChecksLogin;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
|
||||
|
||||
/**
|
||||
|
@ -42,36 +42,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
* @property int $id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $account_type_id
|
||||
* @property string $name
|
||||
* @property string|null $virtual_balance
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int $order
|
||||
* @property-read Collection|AccountMeta[] $accountMeta
|
||||
* @property-read int|null $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read string $account_number
|
||||
* @property-read string $edit_name
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $account_type_id
|
||||
* @property string $name
|
||||
* @property string|null $virtual_balance
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int $order
|
||||
* @property-read Collection|AccountMeta[] $accountMeta
|
||||
* @property-read int|null $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read string $account_number
|
||||
* @property-read string $edit_name
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @method static EloquentBuilder|Account accountTypeIn($types)
|
||||
* @method static EloquentBuilder|Account newModelQuery()
|
||||
* @method static EloquentBuilder|Account newQuery()
|
||||
@ -91,19 +91,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static EloquentBuilder|Account whereVirtualBalance($value)
|
||||
* @method static Builder|Account withTrashed()
|
||||
* @method static Builder|Account withoutTrashed()
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int|null $user_group_id
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int|null $user_group_id
|
||||
* @method static EloquentBuilder|Account whereUserGroupId($value)
|
||||
* @property-read \FireflyIII\Models\UserGroup|null $userGroup
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Account extends Model
|
||||
|
@ -61,7 +61,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|ObjectGroup whereTitle($value)
|
||||
* @method static Builder|ObjectGroup whereUpdatedAt($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)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
|
@ -125,6 +125,14 @@ class Rule extends Model
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
@ -159,14 +167,6 @@ class Rule extends Model
|
||||
$this->attributes['description'] = e($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
|
@ -37,23 +37,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionCurrency
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $enabled
|
||||
* @property bool $userDefault
|
||||
* @property bool $userEnabled
|
||||
* @property string $code
|
||||
* @property string $name
|
||||
* @property string $symbol
|
||||
* @property int $decimal_places
|
||||
* @property-read Collection|BudgetLimit[] $budgetLimits
|
||||
* @property-read int|null $budget_limits_count
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $enabled
|
||||
* @property bool $userDefault
|
||||
* @property bool $userEnabled
|
||||
* @property string $code
|
||||
* @property string $name
|
||||
* @property string $symbol
|
||||
* @property int $decimal_places
|
||||
* @property-read Collection|BudgetLimit[] $budgetLimits
|
||||
* @property-read int|null $budget_limits_count
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionCurrency newQuery()
|
||||
* @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 Builder|TransactionCurrency withTrashed()
|
||||
* @method static Builder|TransactionCurrency withoutTrashed()
|
||||
* @property-read Collection<int, \FireflyIII\Models\UserGroup> $userGroups
|
||||
* @property-read int|null $user_groups_count
|
||||
* @property-read Collection<int, User> $users
|
||||
* @property-read int|null $users_count
|
||||
* @property-read Collection<int, UserGroup> $userGroups
|
||||
* @property-read int|null $user_groups_count
|
||||
* @property-read Collection<int, User> $users
|
||||
* @property-read int|null $users_count
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionCurrency extends Model
|
||||
@ -115,6 +115,14 @@ class TransactionCurrency extends Model
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function budgetLimits(): HasMany
|
||||
{
|
||||
return $this->hasMany(BudgetLimit::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
@ -122,40 +130,12 @@ class TransactionCurrency extends Model
|
||||
*/
|
||||
public function refreshForUser(User $user)
|
||||
{
|
||||
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
||||
$default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
||||
$default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||
$this->userDefault = (int)$default->id === (int)$this->id;
|
||||
$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
|
||||
*/
|
||||
@ -171,4 +151,24 @@ class TransactionCurrency extends Model
|
||||
{
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
@ -41,50 +41,50 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournal
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property int|null $transaction_group_id
|
||||
* @property int|null $bill_id
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $interest_date
|
||||
* @property Carbon|null $book_date
|
||||
* @property Carbon|null $process_date
|
||||
* @property int $order
|
||||
* @property int $tag_count
|
||||
* @property string $transaction_type_type
|
||||
* @property bool $encrypted
|
||||
* @property bool $completed
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Bill|null $bill
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read Collection|TransactionJournalLink[] $destJournalLinks
|
||||
* @property-read int|null $dest_journal_links_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property-read int|null $piggy_bank_events_count
|
||||
* @property-read Collection|TransactionJournalLink[] $sourceJournalLinks
|
||||
* @property-read int|null $source_journal_links_count
|
||||
* @property-read Collection|Tag[] $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionGroup|null $transactionGroup
|
||||
* @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta
|
||||
* @property-read int|null $transaction_journal_meta_count
|
||||
* @property-read TransactionType $transactionType
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property int|null $transaction_group_id
|
||||
* @property int|null $bill_id
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $interest_date
|
||||
* @property Carbon|null $book_date
|
||||
* @property Carbon|null $process_date
|
||||
* @property int $order
|
||||
* @property int $tag_count
|
||||
* @property string $transaction_type_type
|
||||
* @property bool $encrypted
|
||||
* @property bool $completed
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Bill|null $bill
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read Collection|TransactionJournalLink[] $destJournalLinks
|
||||
* @property-read int|null $dest_journal_links_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|PiggyBankEvent[] $piggyBankEvents
|
||||
* @property-read int|null $piggy_bank_events_count
|
||||
* @property-read Collection|TransactionJournalLink[] $sourceJournalLinks
|
||||
* @property-read int|null $source_journal_links_count
|
||||
* @property-read Collection|Tag[] $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionGroup|null $transactionGroup
|
||||
* @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta
|
||||
* @property-read int|null $transaction_journal_meta_count
|
||||
* @property-read TransactionType $transactionType
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @method static EloquentBuilder|TransactionJournal after(Carbon $date)
|
||||
* @method static EloquentBuilder|TransactionJournal before(Carbon $date)
|
||||
* @method static EloquentBuilder|TransactionJournal newModelQuery()
|
||||
@ -112,13 +112,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property int $the_count
|
||||
* @property int|null $user_group_id
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property int $the_count
|
||||
* @property int|null $user_group_id
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
|
||||
* @property-read Collection<int, \FireflyIII\Models\AuditLogEntry> $auditLogEntries
|
||||
* @property-read int|null $audit_log_entries_count
|
||||
* @property-read Collection<int, AuditLogEntry> $auditLogEntries
|
||||
* @property-read int|null $audit_log_entries_count
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
|
@ -39,13 +39,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class UserGroup
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property string $title
|
||||
* @property-read Collection|GroupMembership[] $groupMemberships
|
||||
* @property-read int|null $group_memberships_count
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property string $title
|
||||
* @property-read Collection|GroupMembership[] $groupMemberships
|
||||
* @property-read int|null $group_memberships_count
|
||||
* @method static Builder|UserGroup newModelQuery()
|
||||
* @method static Builder|UserGroup newQuery()
|
||||
* @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 whereTitle($value)
|
||||
* @method static Builder|UserGroup whereUpdatedAt($value)
|
||||
* @property-read Collection<int, Account> $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Collection<int, AvailableBudget> $availableBudgets
|
||||
* @property-read int|null $available_budgets_count
|
||||
* @property-read Collection<int, Bill> $bills
|
||||
* @property-read int|null $bills_count
|
||||
* @property-read Collection<int, Budget> $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection<int, PiggyBank> $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection<int, TransactionJournal> $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Attachment> $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Category> $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\CurrencyExchangeRate> $currencyExchangeRates
|
||||
* @property-read int|null $currency_exchange_rates_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\ObjectGroup> $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Recurrence> $recurrences
|
||||
* @property-read int|null $recurrences_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\RuleGroup> $ruleGroups
|
||||
* @property-read int|null $rule_groups_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Rule> $rules
|
||||
* @property-read int|null $rules_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Tag> $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\TransactionGroup> $transactionGroups
|
||||
* @property-read int|null $transaction_groups_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\Webhook> $webhooks
|
||||
* @property-read int|null $webhooks_count
|
||||
* @property-read Collection<int, \FireflyIII\Models\TransactionCurrency> $currencies
|
||||
* @property-read int|null $currencies_count
|
||||
* @property-read Collection<int, Account> $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Collection<int, AvailableBudget> $availableBudgets
|
||||
* @property-read int|null $available_budgets_count
|
||||
* @property-read Collection<int, Bill> $bills
|
||||
* @property-read int|null $bills_count
|
||||
* @property-read Collection<int, Budget> $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection<int, PiggyBank> $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection<int, TransactionJournal> $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read Collection<int, Attachment> $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection<int, Category> $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read Collection<int, CurrencyExchangeRate> $currencyExchangeRates
|
||||
* @property-read int|null $currency_exchange_rates_count
|
||||
* @property-read Collection<int, ObjectGroup> $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection<int, Recurrence> $recurrences
|
||||
* @property-read int|null $recurrences_count
|
||||
* @property-read Collection<int, RuleGroup> $ruleGroups
|
||||
* @property-read int|null $rule_groups_count
|
||||
* @property-read Collection<int, Rule> $rules
|
||||
* @property-read int|null $rules_count
|
||||
* @property-read Collection<int, Tag> $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read Collection<int, TransactionGroup> $transactionGroups
|
||||
* @property-read int|null $transaction_groups_count
|
||||
* @property-read Collection<int, Webhook> $webhooks
|
||||
* @property-read int|null $webhooks_count
|
||||
* @property-read Collection<int, TransactionCurrency> $currencies
|
||||
* @property-read int|null $currencies_count
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class UserGroup extends Model
|
||||
@ -132,16 +132,6 @@ class UserGroup extends Model
|
||||
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.
|
||||
*
|
||||
@ -192,6 +182,16 @@ class UserGroup extends Model
|
||||
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.
|
||||
*
|
||||
|
@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
use FireflyIII\Support\Notifications\UrlValidator;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
use FireflyIII\Models\InvitedUser;
|
||||
use FireflyIII\Support\Notifications\UrlValidator;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
|
@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
use FireflyIII\Support\Notifications\UrlValidator;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
|
@ -29,9 +29,9 @@ use FireflyIII\Support\Notifications\UrlValidator;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
|
||||
/**
|
||||
* Class UserLogin
|
||||
|
@ -28,7 +28,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Passport\Passport;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use URL;
|
||||
|
||||
/**
|
||||
* Class AppServiceProvider
|
||||
|
@ -31,10 +31,10 @@ use FireflyIII\Repositories\Journal\JournalCLIRepository;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepository;
|
||||
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\TransactionGroupRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Journal\JournalRepository as GroupJournalRepository;
|
||||
use FireflyIII\Repositories\UserGroups\Journal\JournalRepositoryInterface as GroupJournalRepositoryInterface;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
@ -25,10 +25,8 @@ namespace FireflyIII\Providers;
|
||||
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepository;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
|
||||
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepository as AdminPiggyBankRepository;
|
||||
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface as AdminPiggyBankRepositoryInterface;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
@ -38,7 +38,6 @@ use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepository;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\BudgetDestroyService;
|
||||
use FireflyIII\User;
|
||||
|
@ -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.
|
||||
*
|
||||
@ -334,14 +344,4 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
return $journal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function unreconcileById(int $journalId): void
|
||||
{
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user->transactionJournals()->find($journalId);
|
||||
$journal?->transactions()->update(['reconciled' => false]);
|
||||
}
|
||||
}
|
||||
|
@ -133,13 +133,6 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -155,6 +148,13 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -30,7 +30,6 @@ use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\UserGroups\Currency;
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\UserGroups\Currency;
|
||||
|
@ -31,8 +31,6 @@ use FireflyIII\User;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Collection;
|
||||
use NumberFormatter;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class Amount.
|
||||
@ -140,7 +138,7 @@ class Amount
|
||||
return $cache->get();
|
||||
}
|
||||
$default = $user->currencies()->where('user_default', true)->first();
|
||||
if(null === $default) {
|
||||
if (null === $default) {
|
||||
$default = $this->getSystemCurrency();
|
||||
$user->currencies()->sync([$default->id => ['user_default' => true]]);
|
||||
}
|
||||
@ -148,6 +146,15 @@ class Amount
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function getSystemCurrency(): TransactionCurrency
|
||||
{
|
||||
return TransactionCurrency::where('code', 'EUR')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
@ -162,7 +169,7 @@ class Amount
|
||||
return $cache->get();
|
||||
}
|
||||
$default = $userGroup->currencies()->where('group_default', true)->first();
|
||||
if(null === $default) {
|
||||
if (null === $default) {
|
||||
$default = $this->getSystemCurrency();
|
||||
$userGroup->currencies()->sync([$default->id => ['group_default' => true]]);
|
||||
}
|
||||
@ -171,22 +178,6 @@ class Amount
|
||||
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,
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Support\Binder;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Support\Form;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use Form;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* Class RuleForm
|
||||
|
@ -26,10 +26,7 @@ namespace FireflyIII\Support\Http\Api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DateTimeInterface;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
|
||||
/**
|
||||
* Trait ConvertsExchangeRates
|
||||
|
@ -58,7 +58,7 @@ class Navigation
|
||||
*/
|
||||
public function addPeriod(Carbon $theDate, string $repeatFreq, int $skip = 0): Carbon
|
||||
{
|
||||
$date = clone $theDate;
|
||||
$date = clone $theDate;
|
||||
$functionMap = [
|
||||
'1D' => Periodicity::Daily,
|
||||
'daily' => Periodicity::Daily,
|
||||
@ -351,8 +351,13 @@ class Navigation
|
||||
*/
|
||||
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
|
||||
{
|
||||
app('log')->debug(sprintf('diffInPeriods: %s (skip: %d), between %s and %s.',
|
||||
$period, $skip, $beginning->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
app('log')->debug(sprintf(
|
||||
'diffInPeriods: %s (skip: %d), between %s and %s.',
|
||||
$period,
|
||||
$skip,
|
||||
$beginning->format('Y-m-d'),
|
||||
$end->format('Y-m-d')
|
||||
));
|
||||
$map = [
|
||||
'daily' => 'floatDiffInDays',
|
||||
'weekly' => 'floatDiffInWeeks',
|
||||
@ -370,11 +375,11 @@ class Navigation
|
||||
$diff = $beginning->$func($end);
|
||||
|
||||
// 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));
|
||||
$diff = $diff / 3;
|
||||
}
|
||||
if('half-year' === $period) {
|
||||
if ('half-year' === $period) {
|
||||
app('log')->debug(sprintf('H: Corrected %f to %f', $diff, $diff / 6));
|
||||
$diff = $diff / 6;
|
||||
}
|
||||
@ -384,11 +389,15 @@ class Navigation
|
||||
|
||||
app('log')->debug(sprintf('Diff is %f (%d)', $beginning->$func($end), $diff));
|
||||
|
||||
if($skip > 0) {
|
||||
if ($skip > 0) {
|
||||
$parameter = $skip + 1;
|
||||
$diff = ceil($diff / $parameter) * $parameter;
|
||||
app('log')->debug(sprintf('diffInPeriods: skip is %d, so param is %d, and diff becomes %d',
|
||||
$skip, $parameter, $diff));
|
||||
$diff = ceil($diff / $parameter) * $parameter;
|
||||
app('log')->debug(sprintf(
|
||||
'diffInPeriods: skip is %d, so param is %d, and diff becomes %d',
|
||||
$skip,
|
||||
$parameter,
|
||||
$diff
|
||||
));
|
||||
}
|
||||
|
||||
return (int)$diff;
|
||||
|
@ -60,7 +60,7 @@ class Preferences
|
||||
*/
|
||||
public function get(string $name, $default = null): ?Preference
|
||||
{
|
||||
if('currencyPreference' === $name) {
|
||||
if ('currencyPreference' === $name) {
|
||||
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
|
||||
}
|
||||
/** @var User|null $user */
|
||||
@ -85,7 +85,7 @@ class Preferences
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
$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
|
||||
{
|
||||
if('currencyPreference' === $name) {
|
||||
if ('currencyPreference' === $name) {
|
||||
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
|
||||
}
|
||||
$fullName = sprintf('preference%s%s', auth()->user()->id, $name);
|
||||
@ -132,7 +132,7 @@ class Preferences
|
||||
*/
|
||||
public function forget(User $user, string $name): void
|
||||
{
|
||||
if('currencyPreference' === $name) {
|
||||
if ('currencyPreference' === $name) {
|
||||
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
|
||||
}
|
||||
$key = sprintf('preference%s%s', $user->id, $name);
|
||||
@ -150,7 +150,7 @@ class Preferences
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
$fullName = sprintf('preference%s%s', $user->id, $name);
|
||||
@ -200,7 +200,7 @@ class Preferences
|
||||
*/
|
||||
public function findByName(string $name): Collection
|
||||
{
|
||||
if('currencyPreference' === $name) {
|
||||
if ('currencyPreference' === $name) {
|
||||
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
|
||||
}
|
||||
return Preference::where('name', $name)->get();
|
||||
@ -238,7 +238,7 @@ class Preferences
|
||||
*/
|
||||
public function getFresh(string $name, $default = null): ?Preference
|
||||
{
|
||||
if('currencyPreference' === $name) {
|
||||
if ('currencyPreference' === $name) {
|
||||
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
|
||||
}
|
||||
/** @var User|null $user */
|
||||
@ -264,7 +264,7 @@ class Preferences
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
return $this->getForUser($user, $name, $default);
|
||||
@ -307,7 +307,7 @@ class Preferences
|
||||
*/
|
||||
public function set(string $name, $value): Preference
|
||||
{
|
||||
if('currencyPreference' === $name) {
|
||||
if ('currencyPreference' === $name) {
|
||||
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
|
||||
}
|
||||
$user = auth()->user();
|
||||
|
@ -34,8 +34,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\ParseDateString;
|
||||
use FireflyIII\User;
|
||||
use Gdbots\QueryParser\Enum\BoolOperator;
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
|
@ -60,17 +60,17 @@ class BillTransformer extends AbstractTransformer
|
||||
$paidData = $this->paidData($bill);
|
||||
$payDates = $this->payDates($bill);
|
||||
$currency = $bill->transactionCurrency;
|
||||
$notes = $this->repository->getNoteText($bill);
|
||||
$notes = '' === $notes ? null : $notes;
|
||||
$notes = $this->repository->getNoteText($bill);
|
||||
$notes = '' === $notes ? null : $notes;
|
||||
$this->repository->setUser($bill->user);
|
||||
|
||||
$objectGroupId = null;
|
||||
$objectGroupId = null;
|
||||
$objectGroupOrder = null;
|
||||
$objectGroupTitle = null;
|
||||
/** @var ObjectGroup $objectGroup */
|
||||
$objectGroup = $bill->objectGroups->first();
|
||||
if (null !== $objectGroup) {
|
||||
$objectGroupId = (int)$objectGroup->id;
|
||||
$objectGroupId = (int)$objectGroup->id;
|
||||
$objectGroupOrder = (int)$objectGroup->order;
|
||||
$objectGroupTitle = $objectGroup->title;
|
||||
}
|
||||
@ -78,7 +78,7 @@ class BillTransformer extends AbstractTransformer
|
||||
$paidDataFormatted = [];
|
||||
$payDatesFormatted = [];
|
||||
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;
|
||||
}
|
||||
|
||||
@ -98,40 +98,40 @@ class BillTransformer extends AbstractTransformer
|
||||
|
||||
$current = $payDatesFormatted[0] ?? null;
|
||||
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);
|
||||
}
|
||||
unset($temp, $temp2);
|
||||
|
||||
return [
|
||||
'id' => (int)$bill->id,
|
||||
'created_at' => $bill->created_at->toAtomString(),
|
||||
'updated_at' => $bill->updated_at->toAtomString(),
|
||||
'currency_id' => (string)$bill->transaction_currency_id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'name' => $bill->name,
|
||||
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
|
||||
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
|
||||
'date' => $bill->date->toAtomString(),
|
||||
'end_date' => $bill->end_date?->toAtomString(),
|
||||
'extension_date' => $bill->extension_date?->toAtomString(),
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => (int)$bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => (int)$bill->order,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
'id' => (int)$bill->id,
|
||||
'created_at' => $bill->created_at->toAtomString(),
|
||||
'updated_at' => $bill->updated_at->toAtomString(),
|
||||
'currency_id' => (string)$bill->transaction_currency_id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'name' => $bill->name,
|
||||
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
|
||||
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
|
||||
'date' => $bill->date->toAtomString(),
|
||||
'end_date' => $bill->end_date?->toAtomString(),
|
||||
'extension_date' => $bill->extension_date?->toAtomString(),
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => (int)$bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => (int)$bill->order,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
|
||||
// these fields need work:
|
||||
'next_expected_match' => $nextExpectedMatch,
|
||||
'next_expected_match' => $nextExpectedMatch,
|
||||
'next_expected_match_diff' => $nextExpectedMatchDiff,
|
||||
'pay_dates' => $payDatesFormatted,
|
||||
'paid_dates' => $paidDataFormatted,
|
||||
'links' => [
|
||||
'pay_dates' => $payDatesFormatted,
|
||||
'paid_dates' => $paidDataFormatted,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/bills/' . $bill->id,
|
||||
@ -154,7 +154,7 @@ class BillTransformer extends AbstractTransformer
|
||||
app('log')->debug('parameters are NULL, return empty array');
|
||||
|
||||
return [
|
||||
'paid_dates' => [],
|
||||
'paid_dates' => [],
|
||||
'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 the cloned $searchDate is used to grab the correct transactions.
|
||||
/** @var Carbon $start */
|
||||
$start = clone $this->parameters->get('start');
|
||||
$start = clone $this->parameters->get('start');
|
||||
$searchStart = clone $start;
|
||||
$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.
|
||||
*/
|
||||
$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);
|
||||
|
||||
if ($nextMatch->lt($lastPaidDate)) {
|
||||
@ -213,16 +213,16 @@ class BillTransformer extends AbstractTransformer
|
||||
$result = [];
|
||||
foreach ($set as $entry) {
|
||||
$result[] = [
|
||||
'transaction_group_id' => (int)$entry->transaction_group_id,
|
||||
'transaction_group_id' => (int)$entry->transaction_group_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()));
|
||||
|
||||
return [
|
||||
'paid_dates' => $result,
|
||||
'paid_dates' => $result,
|
||||
'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.
|
||||
*
|
||||
* @param Collection $dates
|
||||
* @param Carbon $default
|
||||
* @param Carbon $default
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
@ -265,7 +265,7 @@ class BillTransformer extends AbstractTransformer
|
||||
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')));
|
||||
$set = new Collection();
|
||||
$set = new Collection();
|
||||
$currentStart = clone $this->parameters->get('start');
|
||||
// 2023-06-23 subDay to fix 7655
|
||||
$currentStart->subDay();
|
||||
@ -303,7 +303,7 @@ class BillTransformer extends AbstractTransformer
|
||||
}
|
||||
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
|
||||
if($nextExpectedMatch->gte($this->parameters->get('start'))) {
|
||||
if ($nextExpectedMatch->gte($this->parameters->get('start'))) {
|
||||
$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
|
||||
* transaction. That date must be AFTER $date as a sanity check.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon
|
||||
@ -349,7 +349,7 @@ class BillTransformer extends AbstractTransformer
|
||||
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;
|
||||
if ($steps > 0) {
|
||||
$steps = $steps - 1;
|
||||
|
@ -34,6 +34,7 @@ class CurrencyTransformer extends AbstractTransformer
|
||||
* Transform the currency.
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(TransactionCurrency $currency): array
|
||||
|
@ -34,7 +34,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -36,7 +36,6 @@ use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||
use FireflyIII\Support\NullArrayObject;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class TransactionGroupTransformer
|
||||
|
@ -58,8 +58,8 @@ class AccountTransformer extends AbstractTransformer
|
||||
$this->convertedBalances = app('steam')->balancesByAccountsConverted($objects, $this->getDate());
|
||||
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->default = app('amount')->getDefaultCurrency();
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->default = app('amount')->getDefaultCurrency();
|
||||
|
||||
// get currencies:
|
||||
$accountIds = $objects->pluck('id')->toArray();
|
||||
|
@ -35,7 +35,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class BillTransformer
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\Models\WebhookMessage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Jsonexception;
|
||||
|
||||
/**
|
||||
|
156
app/User.php
156
app/User.php
@ -80,39 +80,39 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class User.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $email
|
||||
* @property bool $isAdmin
|
||||
* @property bool $has2FA
|
||||
* @property array $prefs
|
||||
* @property string $password
|
||||
* @property string $mfa_secret
|
||||
* @property Collection $roles
|
||||
* @property string $blocked_code
|
||||
* @property bool $blocked
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $remember_token
|
||||
* @property string|null $reset
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|AvailableBudget[] $availableBudgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Bill[] $bills
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Client[] $clients
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|CurrencyExchangeRate[] $currencyExchangeRates
|
||||
* @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Recurrence[] $recurrences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|RuleGroup[] $ruleGroups
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Rule[] $rules
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Tag[] $tags
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Token[] $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionGroup[] $transactionGroups
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Transaction[] $transactions
|
||||
* @property int $id
|
||||
* @property string $email
|
||||
* @property bool $isAdmin
|
||||
* @property bool $has2FA
|
||||
* @property array $prefs
|
||||
* @property string $password
|
||||
* @property string $mfa_secret
|
||||
* @property Collection $roles
|
||||
* @property string $blocked_code
|
||||
* @property bool $blocked
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $remember_token
|
||||
* @property string|null $reset
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Attachment[] $attachments
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|AvailableBudget[] $availableBudgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Bill[] $bills
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Client[] $clients
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|CurrencyExchangeRate[] $currencyExchangeRates
|
||||
* @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Recurrence[] $recurrences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|RuleGroup[] $ruleGroups
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Rule[] $rules
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Tag[] $tags
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Token[] $tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionGroup[] $transactionGroups
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Transaction[] $transactions
|
||||
* @method static Builder|User newModelQuery()
|
||||
* @method static Builder|User newQuery()
|
||||
* @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 whereReset($value)
|
||||
* @method static Builder|User whereUpdatedAt($value)
|
||||
* @property string|null $objectguid
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read int|null $available_budgets_count
|
||||
* @property-read int|null $bills_count
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read int|null $clients_count
|
||||
* @property-read int|null $currency_exchange_rates_count
|
||||
* @property-read int|null $notifications_count
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read int|null $preferences_count
|
||||
* @property-read int|null $recurrences_count
|
||||
* @property-read int|null $roles_count
|
||||
* @property-read int|null $rule_groups_count
|
||||
* @property-read int|null $rules_count
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read int|null $tokens_count
|
||||
* @property-read int|null $transaction_groups_count
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read int|null $transactions_count
|
||||
* @property string|null $objectguid
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read int|null $available_budgets_count
|
||||
* @property-read int|null $bills_count
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read int|null $clients_count
|
||||
* @property-read int|null $currency_exchange_rates_count
|
||||
* @property-read int|null $notifications_count
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read int|null $preferences_count
|
||||
* @property-read int|null $recurrences_count
|
||||
* @property-read int|null $roles_count
|
||||
* @property-read int|null $rule_groups_count
|
||||
* @property-read int|null $rules_count
|
||||
* @property-read int|null $tags_count
|
||||
* @property-read int|null $tokens_count
|
||||
* @property-read int|null $transaction_groups_count
|
||||
* @property-read int|null $transaction_journals_count
|
||||
* @property-read int|null $transactions_count
|
||||
* @method static Builder|User whereMfaSecret($value)
|
||||
* @method static Builder|User whereObjectguid($value)
|
||||
* @property string|null $provider
|
||||
* @property string|null $provider
|
||||
* @method static Builder|User whereProvider($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Webhook[] $webhooks
|
||||
* @property-read int|null $webhooks_count
|
||||
* @property string|null $two_factor_secret
|
||||
* @property string|null $two_factor_recovery_codes
|
||||
* @property string|null $guid
|
||||
* @property string|null $domain
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Webhook[] $webhooks
|
||||
* @property-read int|null $webhooks_count
|
||||
* @property string|null $two_factor_secret
|
||||
* @property string|null $two_factor_recovery_codes
|
||||
* @property string|null $guid
|
||||
* @property string|null $domain
|
||||
* @method static Builder|User whereDomain($value)
|
||||
* @method static Builder|User whereGuid($value)
|
||||
* @method static Builder|User whereTwoFactorRecoveryCodes($value)
|
||||
* @method static Builder|User whereTwoFactorSecret($value)
|
||||
* @property int|null $user_group_id
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|GroupMembership[] $groupMemberships
|
||||
* @property-read int|null $group_memberships_count
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @property int|null $user_group_id
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|GroupMembership[] $groupMemberships
|
||||
* @property-read int|null $group_memberships_count
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @method static Builder|User whereUserGroupId($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, TransactionCurrency> $currencies
|
||||
* @property-read int|null $currencies_count
|
||||
* @property-read int|null $currencies_count
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
@ -234,16 +234,6 @@ class User extends Authenticatable
|
||||
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
|
||||
*
|
||||
@ -294,6 +284,16 @@ class User extends Authenticatable
|
||||
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
|
||||
*
|
||||
|
@ -27,7 +27,6 @@ namespace FireflyIII\Validation;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
@ -38,44 +37,6 @@ use Illuminate\Validation\Validator;
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -133,6 +94,43 @@ trait GroupValidation
|
||||
*/
|
||||
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
|
||||
* journal description.
|
||||
|
@ -41,7 +41,8 @@ if (!function_exists('envNonEmpty')) {
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function envNonEmpty(string $key, $default = null) {
|
||||
function envNonEmpty(string $key, $default = null)
|
||||
{
|
||||
$result = env($key, $default);
|
||||
if (is_string($result) && '' === $result) {
|
||||
$result = $default;
|
||||
@ -58,7 +59,8 @@ if (!function_exists('stringIsEqual')) {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function stringIsEqual(string $left, string $right): bool {
|
||||
function stringIsEqual(string $left, string $right): bool
|
||||
{
|
||||
return $left === $right;
|
||||
}
|
||||
}
|
||||
|
@ -51,17 +51,17 @@ return [
|
||||
'connections' => [
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
@ -70,11 +70,11 @@ return [
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
],
|
||||
|
||||
|
@ -25,7 +25,6 @@ namespace Database\Seeders;
|
||||
|
||||
use FireflyIII\Models\Configuration;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ConfigSeeder.
|
||||
|
Loading…
Reference in New Issue
Block a user