mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 10:16:49 +00:00
Various code cleanup.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* EmptyFactory.php
|
||||
* Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use FireflyIII\User;
|
||||
|
||||
$factory->define(User::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* AccountFactory.php
|
||||
* Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories\FireflyIII\Models;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Class AccountFactory
|
||||
*/
|
||||
class AccountFactory extends Factory
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Account::class;
|
||||
|
||||
/**
|
||||
* @return AccountFactory
|
||||
*/
|
||||
public function asset()
|
||||
{
|
||||
return $this->state(
|
||||
function () {
|
||||
return [
|
||||
'account_type_id' => 3,
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'account_type_id' => 1,
|
||||
'name' => $this->faker->words(3, true),
|
||||
'virtual_balance' => '0',
|
||||
'active' => 1,
|
||||
'encrypted' => 0,
|
||||
'order' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountFactory
|
||||
*/
|
||||
public function expense()
|
||||
{
|
||||
return $this->state(
|
||||
function () {
|
||||
return [
|
||||
'account_type_id' => 4,
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountFactory
|
||||
*/
|
||||
public function initialBalance()
|
||||
{
|
||||
return $this->state(
|
||||
function () {
|
||||
return [
|
||||
'account_type_id' => 6,
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* TransactionFactory.php
|
||||
* Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories\FireflyIII\Models;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Class TransactionFactory
|
||||
*/
|
||||
class TransactionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Transaction::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'transaction_journal_id' => 0,
|
||||
'account_id' => 0,
|
||||
'amount' => 5,
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* TransactionJournalFactory.php
|
||||
* Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories\FireflyIII\Models;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalFactory
|
||||
*/
|
||||
class TransactionJournalFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = TransactionJournal::class;
|
||||
|
||||
/**
|
||||
* @return Factory
|
||||
*/
|
||||
public function brokenOpeningBalance()
|
||||
{
|
||||
return $this->state(
|
||||
function () {
|
||||
return [
|
||||
'transaction_type_id' => 4,
|
||||
];
|
||||
}
|
||||
)->afterCreating(
|
||||
function (TransactionJournal $journal) {
|
||||
$ob1 = Account::factory(Account::class)->initialBalance()->create();
|
||||
$ob2 = Account::factory(Account::class)->initialBalance()->create();
|
||||
|
||||
Transaction::factory()->create(
|
||||
[
|
||||
'account_id' => $ob1->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => '5',
|
||||
]
|
||||
);
|
||||
Transaction::factory()->create(
|
||||
[
|
||||
'account_id' => $ob2->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => '5',
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'transaction_type_id' => 1,
|
||||
'description' => $this->faker->words(3, true),
|
||||
'tag_count' => 0,
|
||||
'date' => $this->faker->date('Y-m-d'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Factory
|
||||
*/
|
||||
public function openingBalance()
|
||||
{
|
||||
return $this
|
||||
->state(fn() => ['transaction_type_id' => 4])
|
||||
->afterCreating(
|
||||
function (TransactionJournal $journal) {
|
||||
// fix factory
|
||||
$obAccount = Account::factory(Account::class)->initialBalance()->create();
|
||||
$assetAccount = Account::factory(Account::class)->asset()->create();
|
||||
Transaction::factory()->create(
|
||||
[
|
||||
'account_id' => $obAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => '5',
|
||||
]
|
||||
);
|
||||
Transaction::factory()->create(
|
||||
[
|
||||
'account_id' => $assetAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => '-5',
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -51,7 +51,7 @@ class AccountTypeSeeder extends Seeder
|
||||
try {
|
||||
AccountType::create(['type' => $type]);
|
||||
} catch (PDOException $e) {
|
||||
// dont care.
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ class LinkTypeSeeder extends Seeder
|
||||
try {
|
||||
LinkType::create($type);
|
||||
} catch (PDOException $e) {
|
||||
// dont care
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class PermissionSeeder extends Seeder
|
||||
try {
|
||||
Role::create($role);
|
||||
} catch (PDOException $e) {
|
||||
// dont care
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@ class TransactionCurrencySeeder extends Seeder
|
||||
try {
|
||||
TransactionCurrency::create($currency);
|
||||
} catch (PDOException $e) {
|
||||
// dont care
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ class TransactionTypeSeeder extends Seeder
|
||||
try {
|
||||
TransactionType::create(['type' => $type]);
|
||||
} catch (PDOException $e) {
|
||||
// dont care
|
||||
// @ignoreException
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user