mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Various code cleanup things and preparation for a new demo user.
This commit is contained in:
@@ -50,11 +50,10 @@ class CreateImport extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// find the file
|
||||
/** @var UserRepositoryInterface $userRepository */
|
||||
$userRepository = app(UserRepositoryInterface::class);
|
||||
$file = $this->argument('file');
|
||||
@@ -67,7 +66,6 @@ class CreateImport extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
// try to parse configuration data:
|
||||
$configurationData = json_decode(file_get_contents($configuration));
|
||||
if (is_null($configurationData)) {
|
||||
$this->error(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
|
||||
@@ -82,21 +80,17 @@ class CreateImport extends Command
|
||||
|
||||
/** @var ImportJobRepositoryInterface $jobRepository */
|
||||
$jobRepository = app(ImportJobRepositoryInterface::class, [$user]);
|
||||
|
||||
$job = $jobRepository->create($type);
|
||||
$this->line(sprintf('Created job "%s"...', $job->key));
|
||||
|
||||
// put the file in the proper place:
|
||||
Artisan::call('firefly:encrypt', ['file' => $file, 'key' => $job->key]);
|
||||
$this->line('Stored import data...');
|
||||
|
||||
// store the configuration in the job:
|
||||
$job->configuration = $configurationData;
|
||||
$job->status = 'settings_complete';
|
||||
$job->save();
|
||||
$this->line('Stored configuration...');
|
||||
|
||||
// if user wants to run it, do!
|
||||
if ($this->option('start') === true) {
|
||||
$this->line('The import will start in a moment. This process is not visible...');
|
||||
Log::debug('Go for import!');
|
||||
@@ -109,10 +103,10 @@ class CreateImport extends Command
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.
|
||||
*/
|
||||
private function validArguments(): bool
|
||||
{
|
||||
// find the file
|
||||
/** @var UserRepositoryInterface $userRepository */
|
||||
$userRepository = app(UserRepositoryInterface::class);
|
||||
$file = $this->argument('file');
|
||||
|
@@ -18,6 +18,7 @@ use FireflyIII\Import\Logging\CommandHandler;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -69,34 +70,15 @@ class Import extends Command
|
||||
$monolog = Log::getMonolog();
|
||||
$handler = new CommandHandler($this);
|
||||
$monolog->pushHandler($handler);
|
||||
|
||||
$importProcedure = new ImportProcedure;
|
||||
|
||||
$result = $importProcedure->runImport($job);
|
||||
|
||||
|
||||
/**
|
||||
* @var int $index
|
||||
* @var TransactionJournal $journal
|
||||
*/
|
||||
foreach ($result as $index => $journal) {
|
||||
if (!is_null($journal->id)) {
|
||||
$this->line(sprintf('Line #%d has been imported as transaction #%d.', $index, $journal->id));
|
||||
continue;
|
||||
}
|
||||
$this->error(sprintf('Could not store line #%d', $index));
|
||||
}
|
||||
|
||||
// display result to user:
|
||||
$this->presentResults($result);
|
||||
$this->line('The import has completed.');
|
||||
|
||||
// get any errors from the importer:
|
||||
$extendedStatus = $job->extended_status;
|
||||
if (isset($extendedStatus['errors']) && count($extendedStatus['errors']) > 0) {
|
||||
$this->line(sprintf('The following %d error(s) occured during the import:', count($extendedStatus['errors'])));
|
||||
foreach ($extendedStatus['errors'] as $error) {
|
||||
$this->error($error);
|
||||
}
|
||||
}
|
||||
$this->presentErrors($job);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -122,4 +104,36 @@ class Import extends Command
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
private function presentErrors(ImportJob $job)
|
||||
{
|
||||
$extendedStatus = $job->extended_status;
|
||||
if (isset($extendedStatus['errors']) && count($extendedStatus['errors']) > 0) {
|
||||
$this->line(sprintf('The following %d error(s) occured during the import:', count($extendedStatus['errors'])));
|
||||
foreach ($extendedStatus['errors'] as $error) {
|
||||
$this->error($error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $result
|
||||
*/
|
||||
private function presentResults(Collection $result)
|
||||
{
|
||||
/**
|
||||
* @var int $index
|
||||
* @var TransactionJournal $journal
|
||||
*/
|
||||
foreach ($result as $index => $journal) {
|
||||
if (!is_null($journal->id)) {
|
||||
$this->line(sprintf('Line #%d has been imported as transaction #%d.', $index, $journal->id));
|
||||
continue;
|
||||
}
|
||||
$this->error(sprintf('Could not store line #%d', $index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -60,42 +60,26 @@ class ScanAttachments extends Command
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($attachments as $attachment) {
|
||||
$fileName = $attachment->fileName();
|
||||
|
||||
// try to grab file content:
|
||||
try {
|
||||
$content = $disk->get($fileName);
|
||||
} catch (FileNotFoundException $e) {
|
||||
$this->error(sprintf('Could not find data for attachment #%d', $attachment->id));
|
||||
continue;
|
||||
}
|
||||
// try to decrypt content.
|
||||
try {
|
||||
$decrypted = Crypt::decrypt($content);
|
||||
} catch (DecryptException $e) {
|
||||
$this->error(sprintf('Could not decrypt data of attachment #%d', $attachment->id));
|
||||
continue;
|
||||
}
|
||||
|
||||
// make temp file:
|
||||
$tmpfname = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||
|
||||
// store content in temp file:
|
||||
file_put_contents($tmpfname, $decrypted);
|
||||
|
||||
// get md5 and mime
|
||||
$md5 = md5_file($tmpfname);
|
||||
$mime = mime_content_type($tmpfname);
|
||||
|
||||
// update attachment:
|
||||
$attachment->md5 = $md5;
|
||||
$attachment->mime = $mime;
|
||||
$attachment->save();
|
||||
|
||||
|
||||
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
|
||||
|
||||
// find file:
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ class CreateSupportTables extends Migration
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
@@ -42,56 +41,20 @@ class CreateSupportTables extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
/*
|
||||
* account_types
|
||||
*/
|
||||
$this->createAccountTypeTable();
|
||||
/*
|
||||
* transaction_currencies
|
||||
*/
|
||||
$this->createCurrencyTable();
|
||||
|
||||
/*
|
||||
* transaction_types
|
||||
*/
|
||||
$this->createTransactionTypeTable();
|
||||
|
||||
/*
|
||||
* jobs
|
||||
*/
|
||||
$this->createJobsTable();
|
||||
|
||||
/*
|
||||
* password_resets
|
||||
*/
|
||||
$this->createPasswordTable();
|
||||
|
||||
/*
|
||||
* permissions
|
||||
*/
|
||||
$this->createPermissionsTable();
|
||||
|
||||
/*
|
||||
* roles
|
||||
*/
|
||||
$this->createRolesTable();
|
||||
|
||||
/*
|
||||
* permission_role
|
||||
*/
|
||||
$this->createPermissionRoleTable();
|
||||
|
||||
/*
|
||||
* sessions
|
||||
*/
|
||||
$this->createSessionsTable();
|
||||
|
||||
$this->createConfigurationTable();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -21,7 +21,7 @@ class CreateUsersTable extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
@@ -43,8 +43,6 @@ class CreateUsersTable extends Migration
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
@@ -55,6 +55,8 @@ class CreateMainTables extends Migration
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
@@ -89,14 +91,9 @@ class CreateMainTables extends Migration
|
||||
$table->string('name', 1024);
|
||||
$table->decimal('virtual_balance', 14, 4)->nullable();
|
||||
$table->string('iban', 255)->nullable();
|
||||
|
||||
$table->boolean('active')->default(1);
|
||||
$table->boolean('encrypted')->default(0);
|
||||
|
||||
// link user id to users table
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// link account type id to account types table
|
||||
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
@@ -110,8 +107,6 @@ class CreateMainTables extends Migration
|
||||
$table->integer('account_id', false, true);
|
||||
$table->string('name');
|
||||
$table->text('data');
|
||||
|
||||
// link account id to accounts:
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
@@ -183,12 +178,10 @@ class CreateMainTables extends Migration
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.
|
||||
*/
|
||||
private function createBudgetTables()
|
||||
{
|
||||
|
||||
|
||||
if (!Schema::hasTable('budgets')) {
|
||||
Schema::create(
|
||||
'budgets', function (Blueprint $table) {
|
||||
@@ -199,8 +192,6 @@ class CreateMainTables extends Migration
|
||||
$table->string('name', 1024);
|
||||
$table->boolean('active')->default(1);
|
||||
$table->boolean('encrypted')->default(0);
|
||||
|
||||
// link user id to users table
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
|
||||
@@ -210,7 +201,6 @@ class CreateMainTables extends Migration
|
||||
if (!Schema::hasTable('budget_limits')) {
|
||||
Schema::create(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('budget_id', false, true);
|
||||
@@ -218,8 +208,6 @@ class CreateMainTables extends Migration
|
||||
$table->decimal('amount', 14, 4);
|
||||
$table->string('repeat_freq', 30);
|
||||
$table->boolean('repeats')->default(0);
|
||||
|
||||
// link budget id to budgets table
|
||||
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
||||
|
||||
}
|
||||
@@ -234,8 +222,6 @@ class CreateMainTables extends Migration
|
||||
$table->date('startdate');
|
||||
$table->date('enddate');
|
||||
$table->decimal('amount', 14, 4);
|
||||
|
||||
// link budget limit id to budget_limitss table
|
||||
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
@@ -319,8 +305,6 @@ class CreateMainTables extends Migration
|
||||
$table->integer('order', false, true)->default(0);
|
||||
$table->boolean('active')->default(0);
|
||||
$table->boolean('encrypted')->default(1);
|
||||
|
||||
// link to account_id to accounts
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
@@ -335,13 +319,10 @@ class CreateMainTables extends Migration
|
||||
$table->date('startdate')->nullable();
|
||||
$table->date('targetdate')->nullable();
|
||||
$table->decimal('currentamount', 14, 4);
|
||||
|
||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +369,8 @@ class CreateMainTables extends Migration
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five
|
||||
*/
|
||||
private function createRuleTables()
|
||||
{
|
||||
@@ -503,7 +485,9 @@ class CreateMainTables extends Migration
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity) // cannot be helped
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five
|
||||
*/
|
||||
private function createTransactionTables()
|
||||
{
|
||||
@@ -513,26 +497,19 @@ class CreateMainTables extends Migration
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->integer('user_id', false, true);
|
||||
$table->integer('transaction_type_id', false, true);
|
||||
$table->integer('bill_id', false, true)->nullable();
|
||||
$table->integer('transaction_currency_id', false, true);
|
||||
|
||||
$table->string('description', 1024);
|
||||
|
||||
$table->date('date');
|
||||
$table->date('interest_date')->nullable();
|
||||
$table->date('book_date')->nullable();
|
||||
$table->date('process_date')->nullable();
|
||||
|
||||
$table->integer('order', false, true)->default(0);
|
||||
$table->integer('tag_count', false, true);
|
||||
|
||||
$table->boolean('encrypted')->default(1);
|
||||
$table->boolean('completed')->default(1);
|
||||
|
||||
// links to other tables:
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
|
||||
$table->foreign('bill_id')->references('id')->on('bills')->onDelete('set null');
|
||||
@@ -550,7 +527,6 @@ class CreateMainTables extends Migration
|
||||
$table->string('name', 255);
|
||||
$table->text('data');
|
||||
$table->string('hash', 64);
|
||||
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
}
|
||||
);
|
||||
@@ -562,7 +538,6 @@ class CreateMainTables extends Migration
|
||||
$table->increments('id');
|
||||
$table->integer('tag_id', false, true);
|
||||
$table->integer('transaction_journal_id', false, true);
|
||||
|
||||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
@@ -577,7 +552,6 @@ class CreateMainTables extends Migration
|
||||
$table->increments('id');
|
||||
$table->integer('budget_id', false, true);
|
||||
$table->integer('transaction_journal_id', false, true);
|
||||
|
||||
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
}
|
||||
@@ -590,7 +564,6 @@ class CreateMainTables extends Migration
|
||||
$table->increments('id');
|
||||
$table->integer('category_id', false, true);
|
||||
$table->integer('transaction_journal_id', false, true);
|
||||
|
||||
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
}
|
||||
|
@@ -20,8 +20,6 @@ class ChangesFor3101 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
@@ -31,7 +29,7 @@ class ChangesFor3101 extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
@@ -21,8 +21,6 @@ class FixNullables extends Migration
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
@@ -32,7 +30,7 @@ class FixNullables extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
@@ -19,8 +19,6 @@ class ExpandTransactionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
@@ -30,7 +28,7 @@ class ExpandTransactionsTable extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
@@ -20,8 +20,6 @@ class ChangesForV410 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
@@ -31,7 +29,7 @@ class ChangesForV410 extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
@@ -19,8 +19,6 @@ class ChangesForV420 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
@@ -30,7 +28,7 @@ class ChangesForV420 extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
@@ -1,21 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV430
|
||||
*/
|
||||
class ChangesForV430 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('available_budgets');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('available_budgets', function (Blueprint $table) {
|
||||
Schema::create(
|
||||
'available_budgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
@@ -28,16 +37,7 @@ class ChangesForV430 extends Migration
|
||||
|
||||
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('available_budgets');
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,12 @@ class PermissionSeeder extends Seeder
|
||||
$owner->description = 'User runs this instance of FF3'; // optional
|
||||
$owner->save();
|
||||
|
||||
$demo = new Role;
|
||||
$demo->name ='demo';
|
||||
$demo->display_name = 'Demo User';
|
||||
$demo->description = 'User is a demo user';
|
||||
$demo->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -54,7 +54,6 @@ function removeRow(e) {
|
||||
$('table.split-table tbody tr[data-split="' + index + '"]').remove();
|
||||
|
||||
|
||||
|
||||
resetSplits();
|
||||
|
||||
return false;
|
||||
@@ -171,8 +170,9 @@ function calculateSum() {
|
||||
for (var i = 0; i < set.length; i++) {
|
||||
var current = $(set[i]);
|
||||
sum += (current.val() == "" ? 0 : parseFloat(current.val()));
|
||||
|
||||
}
|
||||
sum = Math.round(sum * 100) / 100;
|
||||
|
||||
console.log("Sum is now " + sum);
|
||||
$('.amount-warning').remove();
|
||||
if (sum != originalSum) {
|
||||
|
@@ -14,7 +14,6 @@
|
||||
"type": "image\/png"
|
||||
}
|
||||
],
|
||||
"theme_color": "#ffffff",
|
||||
"display": "standalone",
|
||||
"start_url": "/",
|
||||
"orientation": "portrait"
|
||||
|
Reference in New Issue
Block a user