chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -95,30 +95,6 @@ class CreateSupportTables extends Migration
}
}
/**
* @return void
*/
private function createConfigurationTable(): void
{
if (!Schema::hasTable('configuration')) {
try {
Schema::create(
'configuration',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name', 50);
$table->text('data');
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'configuration', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
}
/**
* @return void
*/
@@ -147,6 +123,32 @@ class CreateSupportTables extends Migration
}
}
/**
* @return void
*/
private function createTransactionTypeTable(): void
{
if (!Schema::hasTable('transaction_types')) {
try {
Schema::create(
'transaction_types',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('type', 50);
// type must be unique.
$table->unique(['type']);
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'transaction_types', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
}
/**
* @return void
*/
@@ -199,32 +201,6 @@ class CreateSupportTables extends Migration
}
}
/**
* @return void
*/
private function createPermissionRoleTable(): void
{
if (!Schema::hasTable('permission_role')) {
try {
Schema::create(
'permission_role',
static function (Blueprint $table) {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'permission_role', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
}
/**
* @return void
*/
@@ -273,6 +249,32 @@ class CreateSupportTables extends Migration
}
}
/**
* @return void
*/
private function createPermissionRoleTable(): void
{
if (!Schema::hasTable('permission_role')) {
try {
Schema::create(
'permission_role',
static function (Blueprint $table) {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'permission_role', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
}
/**
* @return void
*/
@@ -301,24 +303,22 @@ class CreateSupportTables extends Migration
/**
* @return void
*/
private function createTransactionTypeTable(): void
private function createConfigurationTable(): void
{
if (!Schema::hasTable('transaction_types')) {
if (!Schema::hasTable('configuration')) {
try {
Schema::create(
'transaction_types',
'configuration',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('type', 50);
// type must be unique.
$table->unique(['type']);
$table->string('name', 50);
$table->text('data');
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'transaction_types', $e->getMessage()));
Log::error(sprintf(self::TABLE_ERROR, 'configuration', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}

View File

@@ -136,6 +136,54 @@ class CreateMainTables extends Migration
}
}
private function createPiggyBanksTable(): void
{
if (!Schema::hasTable('piggy_banks')) {
try {
Schema::create(
'piggy_banks',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->string('name', 1024);
$table->decimal('targetamount', 32, 12);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(0);
$table->boolean('encrypted')->default(1);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'piggy_banks', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
if (!Schema::hasTable('piggy_bank_repetitions')) {
try {
Schema::create(
'piggy_bank_repetitions',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->decimal('currentamount', 32, 12);
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'piggy_bank_repetitions', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
}
private function createAttachmentsTable(): void
{
if (!Schema::hasTable('attachments')) {
@@ -296,55 +344,6 @@ class CreateMainTables extends Migration
}
}
private function createPiggyBanksTable(): void
{
if (!Schema::hasTable('piggy_banks')) {
try {
Schema::create(
'piggy_banks',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->string('name', 1024);
$table->decimal('targetamount', 32, 12);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(0);
$table->boolean('encrypted')->default(1);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'piggy_banks', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
if (!Schema::hasTable('piggy_bank_repetitions')) {
try {
Schema::create(
'piggy_bank_repetitions',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->decimal('currentamount', 32, 12);
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf(self::TABLE_ERROR, 'piggy_bank_repetitions', $e->getMessage()));
Log::error(self::TABLE_ALREADY_EXISTS);
}
}
}
private function createPreferencesTable(): void
{
if (!Schema::hasTable('preferences')) {

View File

@@ -46,7 +46,7 @@ class ExpandTransactionsTable extends Migration
$table->dropColumn('identifier');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column "identifier": %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -74,7 +74,7 @@ class ChangesForV431 extends Migration
$table->renameColumn('start_date', 'startdate');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -89,7 +89,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('end_date');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -103,7 +103,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('decimal_places');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -140,7 +140,7 @@ class ChangesForV431 extends Migration
$table->renameColumn('startdate', 'start_date');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -170,7 +170,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('repeats');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -183,7 +183,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('repeat_freq');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -52,7 +52,7 @@ class ChangesForV440 extends Migration
}
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -47,7 +47,7 @@ class ChangesForV450 extends Migration
$table->dropColumn('foreign_amount');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -75,7 +75,7 @@ class ChangesForV450 extends Migration
$table->dropColumn('foreign_currency_id');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -47,7 +47,7 @@ class ChangesForV470a extends Migration
$table->dropColumn('reconciled');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -63,7 +63,7 @@ class ChangesForV472 extends Migration
$table->dropColumn('order');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -85,7 +85,7 @@ class ChangesForV472 extends Migration
$table->dropColumn('notes');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -54,7 +54,7 @@ class ChangesForV473 extends Migration
$table->dropColumn('transaction_currency_id');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -68,7 +68,7 @@ class ChangesForV473 extends Migration
$table->dropColumn('strict');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -54,7 +54,7 @@ class ChangesForV477 extends Migration
$table->dropColumn(['transaction_currency_id']);
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -49,7 +49,7 @@ class ChangesForV479 extends Migration
$table->dropColumn(['enabled']);
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -49,7 +49,7 @@ class FixLdapConfiguration extends Migration
$table->dropColumn(['objectguid']);
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -58,7 +58,7 @@ class ChangesForV480 extends Migration
}
try {
$table->dropColumn('transaction_group_id');
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -78,7 +78,7 @@ class ChangesForV480 extends Migration
static function (Blueprint $table) {
try {
$table->dropColumn('stop_processing');
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -98,7 +98,7 @@ class ChangesForV480 extends Migration
static function (Blueprint $table) {
try {
$table->dropColumn('mfa_secret');
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -50,7 +50,7 @@ class ChangesForV530a extends Migration
$table->dropColumn('order');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -50,7 +50,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('provider');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -64,7 +64,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('order');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -78,7 +78,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('end_date');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -91,7 +91,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('extension_date');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -78,7 +78,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('budget_limit_id');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -97,7 +97,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('period');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -110,7 +110,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('generated');
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -53,7 +53,7 @@ class ChangesForV550b2 extends Migration
}
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -43,7 +43,7 @@ class AddLdapColumnsToUsersTable extends Migration
$table->dropColumn(['domain']);
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -73,7 +73,7 @@ class UserGroups extends Migration
}
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -93,7 +93,7 @@ class UserGroups extends Migration
}
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -75,7 +75,7 @@ return new class () extends Migration {
}
}
);
} catch (QueryException|ColumnDoesNotExist $e) {
} catch (QueryException | ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -72,11 +72,36 @@ class ExchangeRateSeeder extends Seeder
}
/**
* @param User $user
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param string $date
* @param float $rate
* @param string $code
* @return TransactionCurrency|null
*/
private function getCurrency(string $code): ?TransactionCurrency
{
return TransactionCurrency::whereNull('deleted_at')->where('code', $code)->first();
}
/**
* @param User $user
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param string $date
* @return bool
*/
private function hasRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date): bool
{
return $user->currencyExchangeRates()
->where('from_currency_id', $from->id)
->where('to_currency_id', $to->id)
->where('date', $date)
->count() > 0;
}
/**
* @param User $user
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param string $date
* @param float $rate
* @return void
*/
private function addRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date, float $rate): void
@@ -92,29 +117,4 @@ class ExchangeRateSeeder extends Seeder
]
);
}
/**
* @param string $code
* @return TransactionCurrency|null
*/
private function getCurrency(string $code): ?TransactionCurrency
{
return TransactionCurrency::whereNull('deleted_at')->where('code', $code)->first();
}
/**
* @param User $user
* @param TransactionCurrency $from
* @param TransactionCurrency $to
* @param string $date
* @return bool
*/
private function hasRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date): bool
{
return $user->currencyExchangeRates()
->where('from_currency_id', $from->id)
->where('to_currency_id', $to->id)
->where('date', $date)
->count() > 0;
}
}