diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php
index 5a8c0fd9ed..12ac4e6550 100644
--- a/app/Api/V1/Controllers/Controller.php
+++ b/app/Api/V1/Controllers/Controller.php
@@ -94,7 +94,7 @@ abstract class Controller extends BaseController
$obj = Carbon::parse($date);
} catch (InvalidDateException | InvalidFormatException $e) {
// don't care
- Log::warn(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', (string) $date, $e->getMessage()));
+ Log::warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', (string) $date, $e->getMessage()));
}
}
$bag->set($field, $obj);
diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.php
index 9a68e1437f..f8a6fc1335 100644
--- a/app/Exceptions/GracefulNotFoundHandler.php
+++ b/app/Exceptions/GracefulNotFoundHandler.php
@@ -71,6 +71,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
return parent::render($request, $e);
case 'accounts.show':
+ case 'accounts.edit':
case 'accounts.show.all':
return $this->handleAccount($request, $e);
case 'transactions.show':
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 9b52ef9dc6..fc07889266 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -153,6 +153,12 @@ class Handler extends ExceptionHandler
$userData['id'] = auth()->user()->id;
$userData['email'] = auth()->user()->email;
}
+
+ $headers = [];
+ if (request()->headers) {
+ $headers = request()->headers->all();
+ }
+
$data = [
'class' => get_class($e),
'errorMessage' => $e->getMessage(),
@@ -165,11 +171,12 @@ class Handler extends ExceptionHandler
'url' => request()->fullUrl(),
'userAgent' => request()->userAgent(),
'json' => request()->acceptsJson(),
+ 'headers' => $headers,
];
// create job that will mail.
$ipAddress = request()->ip() ?? '0.0.0.0';
- $job = new MailError($userData, (string)config('firefly.site_owner'), $ipAddress, $data);
+ $job = new MailError($userData, (string) config('firefly.site_owner'), $ipAddress, $data);
dispatch($job);
parent::report($e);
diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php
index 4d6779a911..555f9e025f 100644
--- a/app/Factory/TransactionCurrencyFactory.php
+++ b/app/Factory/TransactionCurrencyFactory.php
@@ -43,6 +43,15 @@ class TransactionCurrencyFactory
*/
public function create(array $data): TransactionCurrency
{
+ // if the code already exists (deleted)
+ // force delete it and then create the transaction:
+ $count = TransactionCurrency::withTrashed()->whereCode($data['code'])->count();
+ if(1 === $count) {
+ $old = TransactionCurrency::withTrashed()->whereCode($data['code'])->first();
+ $old->forceDelete();
+ Log::warning(sprintf('Force deleted old currency with ID #%d and code "%s".', $old->id, $data['code']));
+ }
+
try {
/** @var TransactionCurrency $result */
$result = TransactionCurrency::create(
diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php
index ff967fd6e6..fef1df8068 100644
--- a/app/Helpers/Collector/Extensions/MetaCollection.php
+++ b/app/Helpers/Collector/Extensions/MetaCollection.php
@@ -226,7 +226,9 @@ trait MetaCollection
$q1->where(function (Builder $q2) {
$q2->where('journal_meta.name', '=', 'external_url');
$q2->whereNull('journal_meta.data');
- })->orWhereNull('journal_meta.name');
+ })->orWhere(function (Builder $q3) {
+ $q3->where('journal_meta.name', '!=', 'external_url');
+ });
});
return $this;
@@ -416,6 +418,7 @@ trait MetaCollection
static function (JoinClause $join) {
$join->on('notes.noteable_id', '=', 'transaction_journals.id');
$join->where('notes.noteable_type', '=', 'FireflyIII\Models\TransactionJournal');
+ $join->whereNull('notes.deleted_at');
}
);
// add fields
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 39b87ed9b6..c96cad13f6 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -120,50 +120,53 @@ class DebugController extends Controller
*/
public function index(Request $request)
{
- $search = ['~', '#'];
- $replace = ['\~', '# '];
-
- $now = Carbon::now()->format('Y-m-d H:i:s e');
- $installationIdConfig = app('fireflyconfig')->get('installation_id', '');
- $installationId = $installationIdConfig ? $installationIdConfig->data : '';
- $phpVersion = str_replace($search, $replace, PHP_VERSION);
- $phpOs = str_replace($search, $replace, PHP_OS);
- $interface = PHP_SAPI;
- $drivers = implode(', ', DB::availableDrivers());
- $currentDriver = DB::getDriverName();
- $userAgent = $request->header('user-agent');
- $trustedProxies = config('firefly.trusted_proxies');
- $displayErrors = ini_get('display_errors');
- $errorReporting = $this->errorReporting((int)ini_get('error_reporting'));
- $appEnv = config('app.env');
- $appDebug = var_export(config('app.debug'), true);
- $logChannel = config('logging.default');
- $appLogLevel = config('logging.level');
- $cacheDriver = config('cache.default');
- $loginProvider = config('auth.providers.users.driver');
- $bcscale = bcscale();
- $layout = env('FIREFLY_III_LAYOUT');
- $tz = env('TZ');
- $buildNr = '(unknown)';
- $buildDate = '(unknown)';
-
+ // basic scope information:
+ $now = Carbon::now()->format('Y-m-d H:i:s e');
+ $buildNr = '(unknown)';
+ $buildDate = '(unknown)';
+ $expectedDBversion = config('firefly.db_version');
+ $foundDBversion = FireflyConfig::get('db_version', 1)->data;
if (file_exists('/var/www/counter-main.txt')) {
$buildNr = trim(file_get_contents('/var/www/counter-main.txt'));
}
if (file_exists('/var/www/build-date-main.txt')) {
$buildDate = trim(file_get_contents('/var/www/build-date-main.txt'));
}
+ $phpVersion = PHP_VERSION;
+ $phpOs = PHP_OS;
+
+ // system information
+ $tz = env('TZ');
+ $appEnv = config('app.env');
+ $appDebug = var_export(config('app.debug'), true);
+ $cacheDriver = config('cache.default');
+ $logChannel = config('logging.default');
+ $appLogLevel = config('logging.level');
+ $displayErrors = ini_get('display_errors');
+ $errorReporting = $this->errorReporting((int) ini_get('error_reporting'));
+ $interface = PHP_SAPI;
+ $defaultLanguage = (string) config('firefly.default_language');
+ $defaultLocale = (string) config('firefly.default_locale');
+ $bcscale = bcscale();
+ $drivers = implode(', ', DB::availableDrivers());
+ $currentDriver = DB::getDriverName();
+ $trustedProxies = config('firefly.trusted_proxies');
+
+ // user info
+ $loginProvider = config('auth.providers.users.driver');
+ $userGuard = config('auth.defaults.guard');
+ $remoteHeader = $userGuard === 'remote_user_guard' ? config('auth.guard_header') : 'N/A';
+ $remoteMailHeader = $userGuard === 'remote_user_guard' ? config('auth.guard_email') : 'N/A';
+ $userLanguage = app('steam')->getLanguage();
+ $userLocale = app('steam')->getLocale();
+ $userAgent = $request->header('user-agent');
+ $stateful = join(', ', config('sanctum.stateful'));
+
// expected + found DB version:
- $expectedDBversion = config('firefly.db_version');
- $foundDBversion = FireflyConfig::get('db_version', 1)->data;
// some new vars.
- $defaultLanguage = (string)config('firefly.default_language');
- $defaultLocale = (string)config('firefly.default_locale');
- $userLanguage = app('steam')->getLanguage();
- $userLocale = app('steam')->getLocale();
- $isDocker = env('IS_DOCKER', false);
+ $isDocker = env('IS_DOCKER', false);
// set languages, see what happens:
$original = setlocale(LC_ALL, 0);
@@ -209,19 +212,21 @@ class DebugController extends Controller
'appEnv',
'appDebug',
'logChannel',
+ 'stateful',
'tz',
'appLogLevel',
+ 'remoteHeader',
+ 'remoteMailHeader',
'now',
'drivers',
'currentDriver',
+ 'userGuard',
'loginProvider',
'buildNr',
'buildDate',
'bcscale',
- 'layout',
'userAgent',
'displayErrors',
- 'installationId',
'errorReporting',
'phpOs',
'interface',
@@ -260,7 +265,7 @@ class DebugController extends Controller
$return = ' ';
/** @var Route $route */
foreach ($set as $route) {
- $name = (string)$route->getName();
+ $name = (string) $route->getName();
if (in_array('GET', $route->methods(), true)) {
$found = false;
foreach ($ignore as $string) {
diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.php
index a73fcc91c9..ce85fe0f43 100644
--- a/app/Http/Requests/CurrencyFormRequest.php
+++ b/app/Http/Requests/CurrencyFormRequest.php
@@ -59,9 +59,9 @@ class CurrencyFormRequest extends FormRequest
{
// fixed
$rules = [
- 'name' => 'required|max:48|min:1|unique:transaction_currencies,name',
- 'code' => 'required|min:3|max:51|unique:transaction_currencies,code',
- 'symbol' => 'required|min:1|max:51|unique:transaction_currencies,symbol',
+ 'name' => 'required|max:48|min:1|uniqueCurrencyName',
+ 'code' => 'required|min:3|max:51|uniqueCurrencyCode',
+ 'symbol' => 'required|min:1|max:51|uniqueCurrencySymbol',
'decimal_places' => 'required|min:0|max:12|numeric',
'enabled' => 'in:0,1',
];
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index 370abf6eaa..add524c435 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -250,6 +250,7 @@ class CreateRecurringTransactions implements ShouldQueue
private function hasNotStartedYet(Recurrence $recurrence): bool
{
$startDate = $this->getStartDate($recurrence);
+ Log::debug(sprintf('Start date is %s', $startDate->format('Y-m-d')));
return $startDate->gt($this->date);
}
diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.php
index e5657705fd..2f8b56ddba 100644
--- a/app/Jobs/MailError.php
+++ b/app/Jobs/MailError.php
@@ -60,7 +60,8 @@ class MailError extends Job implements ShouldQueue
$this->exception = $exceptionData;
$debug = $exceptionData;
unset($debug['stackTrace']);
- Log::error('Exception is: ' . json_encode($debug));
+ unset($debug['headers']);
+ Log::error(sprintf('Exception is: %s', json_encode($debug)));
}
/**
@@ -81,7 +82,7 @@ class MailError extends Job implements ShouldQueue
$args,
function (Message $message) use ($email) {
if ('mail@example.com' !== $email) {
- $message->to($email, $email)->subject((string)trans('email.error_subject'));
+ $message->to($email, $email)->subject((string) trans('email.error_subject'));
}
}
);
diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php
index 5ee8e19516..3d60e2add8 100644
--- a/app/Services/Internal/Support/JournalServiceTrait.php
+++ b/app/Services/Internal/Support/JournalServiceTrait.php
@@ -172,7 +172,7 @@ trait JournalServiceTrait
private function findAccountByNumber(?Account $account, array $data, array $types): ?Account
{
// third attempt, find by account number
- if (null === $account && null !== $data['number']) {
+ if (null === $account && null !== $data['number'] && '' !== (string) $data['number']) {
Log::debug(sprintf('Searching for account number "%s".', $data['number']));
// find by preferred type.
$source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);
diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php
index bcb1a776a5..7cb0e77c1f 100644
--- a/app/TransactionRules/Actions/SetDestinationAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationAccount.php
@@ -66,7 +66,7 @@ class SetDestinationAccount implements ActionInterface
return false;
}
-
+ $type = $object->transactionType->type;
$this->repository->setUser($user);
// if this is a transfer or a deposit, the new destination account must be an asset account or a default account, and it MUST exist:
diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php
index 42e6c83356..21d4b60561 100644
--- a/app/TransactionRules/Actions/SetSourceAccount.php
+++ b/app/TransactionRules/Actions/SetSourceAccount.php
@@ -58,15 +58,14 @@ class SetSourceAccount implements ActionInterface
$user = User::find($journal['user_id']);
$type = $journal['transaction_type_type'];
/** @var TransactionJournal|null $object */
- $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
+ $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
$this->repository = app(AccountRepositoryInterface::class);
-
if (null === $object) {
Log::error('Could not find journal.');
return false;
}
-
+ $type = $object->transactionType->type;
$this->repository->setUser($user);
// if this is a transfer or a withdrawal, the new source account must be an asset account or a default account, and it MUST exist:
@@ -93,7 +92,7 @@ class SetSourceAccount implements ActionInterface
return false;
}
- if (null !== $newAccount && (int)$newAccount->id === (int)$destination->account_id) {
+ if (null !== $newAccount && (int) $newAccount->id === (int) $destination->account_id) {
Log::error(
sprintf(
'New source account ID #%d and current destination account ID #%d are the same. Do nothing.', $newAccount->id,
diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php
index dfcc2e43ba..55c2caf746 100644
--- a/app/Transformers/BudgetLimitTransformer.php
+++ b/app/Transformers/BudgetLimitTransformer.php
@@ -34,7 +34,7 @@ use League\Fractal\Resource\Item;
class BudgetLimitTransformer extends AbstractTransformer
{
/** @var string[] */
- protected $availableIncludes
+ protected array $availableIncludes
= [
'budget',
];
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 69f6b11762..18e77c7301 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -53,6 +53,48 @@ use function is_string;
*/
class FireflyValidator extends Validator
{
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrencyName($attribute, $value): bool
+ {
+ return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
+ }
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrencyCode($attribute, $value): bool
+ {
+ return $this->validateUniqueCurrency('code', (string) $attribute, (string) $value);
+ }
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrencySymbol($attribute, $value): bool
+ {
+ return $this->validateUniqueCurrency('symbol', (string) $attribute, (string) $value);
+ }
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrency(string $field, string $attribute, string $value): bool
+ {
+ return 0 === DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
+ }
+
+
/**
* @param mixed $attribute
* @param mixed $value
@@ -84,7 +126,7 @@ class FireflyValidator extends Validator
{
$field = $parameters[1] ?? 'id';
- if (0 === (int)$value) {
+ if (0 === (int) $value) {
return true;
}
$count = DB::table($parameters[0])->where('user_id', auth()->user()->id)->where($field, $value)->count();
@@ -202,7 +244,7 @@ class FireflyValidator extends Validator
return false;
}
- return 1 === (int)$checksum;
+ return 1 === (int) $checksum;
}
/**
@@ -217,7 +259,7 @@ class FireflyValidator extends Validator
/** @var mixed $compare */
$compare = $parameters[0] ?? '0';
- return bccomp((string)$value, (string)$compare) < 0;
+ return bccomp((string) $value, (string) $compare) < 0;
}
/**
@@ -232,7 +274,7 @@ class FireflyValidator extends Validator
/** @var mixed $compare */
$compare = $parameters[0] ?? '0';
- return bccomp((string)$value, (string)$compare) > 0;
+ return bccomp((string) $value, (string) $compare) > 0;
}
/**
@@ -246,7 +288,7 @@ class FireflyValidator extends Validator
{
$field = $parameters[1] ?? 'id';
- if (0 === (int)$value) {
+ if (0 === (int) $value) {
return true;
}
$count = DB::table($parameters[0])->where($field, $value)->count();
@@ -266,7 +308,7 @@ class FireflyValidator extends Validator
// first, get the index from this string:
$value = $value ?? '';
$parts = explode('.', $attribute);
- $index = (int)($parts[1] ?? '0');
+ $index = (int) ($parts[1] ?? '0');
// get the name of the trigger from the data array:
$actionType = $this->data['actions'][$index]['type'] ?? 'invalid';
@@ -330,7 +372,7 @@ class FireflyValidator extends Validator
{
// first, get the index from this string:
$parts = explode('.', $attribute);
- $index = (int)($parts[1] ?? '0');
+ $index = (int) ($parts[1] ?? '0');
// get the name of the trigger from the data array:
$triggerType = $this->data['triggers'][$index]['type'] ?? 'invalid';
@@ -358,7 +400,7 @@ class FireflyValidator extends Validator
// check if it's an existing account.
if (in_array($triggerType, ['destination_account_id', 'source_account_id'])) {
- return is_numeric($value) && (int)$value > 0;
+ return is_numeric($value) && (int) $value > 0;
}
// check transaction type.
@@ -396,7 +438,7 @@ class FireflyValidator extends Validator
{
$verify = false;
if (array_key_exists('verify_password', $this->data)) {
- $verify = 1 === (int)$this->data['verify_password'];
+ $verify = 1 === (int) $this->data['verify_password'];
}
if ($verify) {
/** @var Verifier $service */
@@ -433,7 +475,7 @@ class FireflyValidator extends Validator
}
$parameterId = $parameters[0] ?? null;
if (null !== $parameterId) {
- return $this->validateByParameterId((int)$parameterId, $value);
+ return $this->validateByParameterId((int) $parameterId, $value);
}
if (array_key_exists('id', $this->data)) {
return $this->validateByAccountId($value);
@@ -483,7 +525,7 @@ class FireflyValidator extends Validator
}
$accountTypes = AccountType::whereIn('type', $search)->get();
- $ignore = (int)($parameters[0] ?? 0.0);
+ $ignore = (int) ($parameters[0] ?? 0.0);
$accountTypeIds = $accountTypes->pluck('id')->toArray();
/** @var Collection $set */
$set = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)->get();
@@ -506,7 +548,7 @@ class FireflyValidator extends Validator
private function validateByAccountTypeId($value, $parameters): bool
{
$type = AccountType::find($this->data['account_type_id'])->first();
- $ignore = (int)($parameters[0] ?? 0.0);
+ $ignore = (int) ($parameters[0] ?? 0.0);
/** @var Collection $set */
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
@@ -580,9 +622,9 @@ class FireflyValidator extends Validator
*/
public function validateUniqueAccountNumberForUser($attribute, $value, $parameters): bool
{
- $accountId = (int)($this->data['id'] ?? 0.0);
+ $accountId = (int) ($this->data['id'] ?? 0.0);
if (0 === $accountId) {
- $accountId = (int)($parameters[0] ?? 0.0);
+ $accountId = (int) ($parameters[0] ?? 0.0);
}
$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
@@ -615,7 +657,7 @@ class FireflyValidator extends Validator
*/
public function validateUniqueExistingWebhook($value, $parameters, $something): bool
{
- $existingId = (int)($something[0] ?? 0);
+ $existingId = (int) ($something[0] ?? 0);
$trigger = 0;
$response = 0;
$delivery = 0;
@@ -671,15 +713,15 @@ class FireflyValidator extends Validator
public function validateUniqueObjectForUser($attribute, $value, $parameters): bool
{
[$table, $field] = $parameters;
- $exclude = (int)($parameters[2] ?? 0.0);
+ $exclude = (int) ($parameters[2] ?? 0.0);
/*
* If other data (in $this->getData()) contains
* ID field, set that field to be the $exclude.
*/
$data = $this->getData();
- if (!array_key_exists(2, $parameters) && array_key_exists('id', $data) && (int)$data['id'] > 0) {
- $exclude = (int)$data['id'];
+ if (!array_key_exists(2, $parameters) && array_key_exists('id', $data) && (int) $data['id'] > 0) {
+ $exclude = (int) $data['id'];
}
// get entries from table
$set = DB::table($table)->where('user_id', auth()->user()->id)->whereNull('deleted_at')
@@ -711,7 +753,7 @@ class FireflyValidator extends Validator
->where('object_groups.user_id', auth()->user()->id)
->where('object_groups.title', $value);
if (null !== $exclude) {
- $query->where('object_groups.id', '!=', (int)$exclude);
+ $query->where('object_groups.id', '!=', (int) $exclude);
}
return 0 === $query->count();
@@ -732,7 +774,7 @@ class FireflyValidator extends Validator
$query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id);
if (null !== $exclude) {
- $query->where('piggy_banks.id', '!=', (int)$exclude);
+ $query->where('piggy_banks.id', '!=', (int) $exclude);
}
$query->where('piggy_banks.name', $value);
diff --git a/changelog.md b/changelog.md
index 9d617d5002..5512ac21cd 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+## 5.6.16 - 2022-03-01
+
+### Fixed
+- Broken migration would clash during startup.
+
## 5.6.15 - 2022-03-01
### Changed
diff --git a/composer.json b/composer.json
index a70a4afd54..2d6c328a31 100644
--- a/composer.json
+++ b/composer.json
@@ -101,9 +101,8 @@
"predis/predis": "^1.1",
"psr/log": "<3",
"ramsey/uuid": "^4.2",
- "rcrowe/twigbridge": "^0.13",
- "spatie/data-transfer-object": "^3.7",
- "nunomaduro/collision": "^6.1"
+ "rcrowe/twigbridge": "^0.14",
+ "spatie/data-transfer-object": "^3.7"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.6",
diff --git a/config/firefly.php b/config/firefly.php
index 88e086d912..5bba14568b 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -101,7 +101,7 @@ return [
'webhooks' => false,
'handle_debts' => true,
],
- 'version' => '5.6.15',
+ 'version' => '5.6.16',
'api_version' => '1.5.5',
'db_version' => 18,
diff --git a/config/sanctum.php b/config/sanctum.php
index 194cceb0d6..c65fa32064 100644
--- a/config/sanctum.php
+++ b/config/sanctum.php
@@ -36,7 +36,7 @@ return [
|
*/
- 'guard' => ['web'],
+ 'guard' => [env('AUTHENTICATION_GUARD', 'web')],
/*
|--------------------------------------------------------------------------
diff --git a/database/migrations/2021_12_27_000001_create_personal_access_tokens_table.php b/database/migrations/2021_12_27_000001_create_local_personal_access_tokens_table.php
similarity index 89%
rename from database/migrations/2021_12_27_000001_create_personal_access_tokens_table.php
rename to database/migrations/2021_12_27_000001_create_local_personal_access_tokens_table.php
index baf2db2bd7..2112b66b3e 100644
--- a/database/migrations/2021_12_27_000001_create_personal_access_tokens_table.php
+++ b/database/migrations/2021_12_27_000001_create_local_personal_access_tokens_table.php
@@ -6,9 +6,9 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
- * Class CreatePersonalAccessTokensTable
+ * Class CreateLocalPersonalAccessTokensTable
*/
-class CreatePersonalAccessTokensTable extends Migration
+class CreateLocalPersonalAccessTokensTable extends Migration
{
/**
* Run the migrations.
diff --git a/frontend/src/api/accounts/destroy.js b/frontend/src/api/accounts/destroy.js
deleted file mode 100644
index 3b784bf218..0000000000
--- a/frontend/src/api/accounts/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/accounts/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/accounts/get.js b/frontend/src/api/accounts/get.js
index 6d9cb854ed..e6cf5163fd 100644
--- a/frontend/src/api/accounts/get.js
+++ b/frontend/src/api/accounts/get.js
@@ -18,18 +18,34 @@
* along with this program. If not, see .
*/
-import {api} from "boot/axios";
+import Api from "src/api/root/api";
-export default class Get {
- get(identifier, date) {
- let url = '/api/v1/accounts/' + identifier;
- if(!date) {
- return api.get(url);
- }
- return api.get(url, {params: {date: date}});
+export default class Get extends Api {
+ constructor() {
+ super('accounts'); // call the super class constructor and pass in the name parameter
}
- transactions(identifier, page, cacheKey) {
- let url = '/api/v1/accounts/' + identifier + '/transactions';
- return api.get(url, {params: {page: page, cache: cacheKey}});
+
+ /**
+ *
+ * @param identifier
+ * @param date
+ * @returns {Promise>}
+ */
+ get(identifier, date) {
+ let params = {date: date};
+ if(!date) {
+ return this.apiGet(identifier);
+ }
+ return this.apiGet(identifier, params);
+ }
+
+ /**
+ *
+ * @param identifier
+ * @param page
+ * @returns {Promise>}
+ */
+ transactions(identifier, page) {
+ return this.apiGetChildren('transactions', identifier, page);
}
}
diff --git a/frontend/src/api/accounts/list.js b/frontend/src/api/accounts/list.js
index 90a0fea825..72b5f4e20b 100644
--- a/frontend/src/api/accounts/list.js
+++ b/frontend/src/api/accounts/list.js
@@ -19,10 +19,27 @@
*/
import {api} from "boot/axios";
+import Api from "src/api/root/api";
+
+export default class List extends Api{
+ constructor() {
+ super('accounts');
+ }
-export default class List {
list(type, page, cacheKey) {
let url = '/api/v1/accounts';
return api.get(url, {params: {page: page, cache: cacheKey, type: type}});
+ // console.log('list');
+ //
+ //
+ // let params = {
+ // type: type,
+ // page: page
+ // }
+ // this.apiList(page, params).then((response) => {
+ // console.log('response OK');
+ // }).catch((err) => {
+ // console.error('api list failed');
+ // });
}
}
diff --git a/frontend/src/api/budgets/destroy.js b/frontend/src/api/budgets/destroy.js
deleted file mode 100644
index 3b17de392a..0000000000
--- a/frontend/src/api/budgets/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = 'api/v1/budgets/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/categories/destroy.js b/frontend/src/api/categories/destroy.js
deleted file mode 100644
index dcb150dc0d..0000000000
--- a/frontend/src/api/categories/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/categories/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/currencies/destroy.js b/frontend/src/api/currencies/destroy.js
deleted file mode 100644
index f9ec216790..0000000000
--- a/frontend/src/api/currencies/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/currencies/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/rules/destroy.js b/frontend/src/api/generic/destroy.js
similarity index 82%
rename from frontend/src/api/rules/destroy.js
rename to frontend/src/api/generic/destroy.js
index 025f961208..90e32cb0dd 100644
--- a/frontend/src/api/rules/destroy.js
+++ b/frontend/src/api/generic/destroy.js
@@ -1,5 +1,5 @@
/*
- * post.js
+ * destroy.js
* Copyright (c) 2022 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -18,11 +18,10 @@
* along with this program. If not, see .
*/
-import {api} from "boot/axios";
+import Api from "src/api/root/api";
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/rules/' + identifier;
- return api.delete(url);
+export default class Destroy extends Api {
+ constructor(path) {
+ super(path);
}
}
diff --git a/frontend/src/api/groups/destroy.js b/frontend/src/api/groups/destroy.js
deleted file mode 100644
index a21e6ba7d1..0000000000
--- a/frontend/src/api/groups/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/object_groups/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/piggy-banks/destroy.js b/frontend/src/api/piggy-banks/destroy.js
deleted file mode 100644
index f7d7a24744..0000000000
--- a/frontend/src/api/piggy-banks/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/piggy_banks/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/recurring/destroy.js b/frontend/src/api/recurring/destroy.js
deleted file mode 100644
index ffb61a8ac7..0000000000
--- a/frontend/src/api/recurring/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/recurrences/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/root/api.js b/frontend/src/api/root/api.js
new file mode 100644
index 0000000000..54695ee1a1
--- /dev/null
+++ b/frontend/src/api/root/api.js
@@ -0,0 +1,104 @@
+import {api} from "boot/axios";
+
+/**
+ *
+ */
+export default class Api {
+ root = '/api/v1/';
+ path = '';
+
+ constructor(path) {
+ this.path = path;
+ }
+
+ apiPath() {
+ return this.root + this.path;
+ }
+
+ apiPathId(identifier) {
+ return this.root + this.path + '/' + identifier;
+ }
+
+ /**
+ *
+ * @param identifier
+ * @param params
+ * @returns {Promise>}
+ */
+ apiGet(identifier, params) {
+ let url = this.apiPathId(identifier);
+ if (params) {
+ return api.get(url, {params: params});
+ }
+ return api.get(url);
+ }
+
+ destroy(identifier) {
+ let url = this.apiPathId(identifier);
+ return api.delete(url);
+ }
+
+ apiPathChildren(identifier, type) {
+ return this.apiPathId(identifier) + '/' + type;
+ }
+
+ apiGetChildren(type, identifier, page) {
+ let url = this.apiPathChildren(identifier, type);
+ let cacheKey = 'still-todo';
+ // needs a cache key. Based on type.
+ return api.get(url, {params: {page: page, cache: cacheKey}});
+ }
+
+
+ /**
+ *
+ * @param page
+ * @param params
+ * @returns {Promise>}
+ */
+ apiList(page, params) {
+ let type = 'transactions';
+ let identifier = '1';
+
+ let cacheKey = 'still-todo';
+ let url = this.apiPathChildren(identifier, type);
+
+ // needs a cache key. Based on type.
+ return api.get(url, {params: {page: page, cache: cacheKey}});
+
+
+ // let identifier = 'abc';
+ // // test:
+ // let type= 'expense';
+
+ // let type ='accounts';
+ //
+ // this.store.getters["fireflyiii/getScopedCacheKey"](type);
+ // let cacheKey = 'def';
+ // let url = this.apiPath();
+ //
+ // // needs a cache key. Based on type.
+ // return api.get(url, {params: {page: page, cache: cacheKey}});
+
+ //
+ //
+ // console.log('apiList');
+ // let cacheKey;
+ //
+ // //let $q = useQuasar();
+ // //const store = useStore();
+ // cacheKey = 'OK';
+ // console.log('path: ' + this.path);
+ // //cacheKey = $store.getters["fireflyiii/getScopedCacheKey"](this.path);
+ // //store.getters["fireflyiii/getScopedCacheKey"](this.path)
+ // let cache = {
+ // cache: cacheKey
+ // };
+ // let merged = {...params, ...cache};
+ // console.log(merged);
+ // let url = this.apiPath();
+ // console.log(url);
+ // return api.get(url, {params: merged});
+ }
+
+}
diff --git a/frontend/src/api/rule-groups/destroy.js b/frontend/src/api/rule-groups/destroy.js
deleted file mode 100644
index f72620bf1a..0000000000
--- a/frontend/src/api/rule-groups/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/rule_groups/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/subscriptions/destroy.js b/frontend/src/api/subscriptions/destroy.js
deleted file mode 100644
index 83bb5c833c..0000000000
--- a/frontend/src/api/subscriptions/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/bills/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/transactions/destroy.js b/frontend/src/api/transactions/destroy.js
deleted file mode 100644
index 1eca9641a6..0000000000
--- a/frontend/src/api/transactions/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/transactions/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/webhooks/destroy.js b/frontend/src/api/webhooks/destroy.js
deleted file mode 100644
index b99a699a89..0000000000
--- a/frontend/src/api/webhooks/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 james@firefly-iii.org
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import {api} from "boot/axios";
-
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/webhooks/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/components/transactions/LargeTable.vue b/frontend/src/components/transactions/LargeTable.vue
index ff9ea71ffb..43ad39ca1b 100644
--- a/frontend/src/components/transactions/LargeTable.vue
+++ b/frontend/src/components/transactions/LargeTable.vue
@@ -127,7 +127,7 @@