Clean up test data.

This commit is contained in:
James Cole 2016-05-14 21:49:16 +02:00
parent f78d56b149
commit e5eabdf7e7
5 changed files with 730 additions and 1095 deletions

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,10 @@ return [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('export'), 'root' => storage_path('export'),
], ],
'database' => [
'driver' => 'local',
'root' => storage_path('database'),
],
'ftp' => [ 'ftp' => [
'driver' => 'ftp', 'driver' => 'ftp',

View File

@ -21,10 +21,7 @@ class DatabaseSeeder extends Seeder
$this->call('TransactionCurrencySeeder'); $this->call('TransactionCurrencySeeder');
$this->call('TransactionTypeSeeder'); $this->call('TransactionTypeSeeder');
$this->call('PermissionSeeder'); $this->call('PermissionSeeder');
if (App::environment() == 'testing') {
$this->call('TestDataSeeder'); $this->call('TestDataSeeder');
} }
}
} }

View File

@ -9,8 +9,6 @@ declare(strict_types = 1);
*/ */
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Events\BudgetLimitStored;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Support\Migration\TestData; use FireflyIII\Support\Migration\TestData;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -19,19 +17,11 @@ use Illuminate\Database\Seeder;
*/ */
class TestDataSeeder extends Seeder class TestDataSeeder extends Seeder
{ {
/** @var Carbon */
public $end;
/** @var Carbon */
public $start;
/** /**
* TestDataSeeder constructor. * TestDataSeeder constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->start = Carbon::create()->subYears(2)->startOfYear();
$this->end = Carbon::now();
} }
/** /**
@ -41,12 +31,13 @@ class TestDataSeeder extends Seeder
*/ */
public function run() public function run()
{ {
$disk = Storage::disk('database');
$current = clone $this->start; $env = App::environment();
while ($current < $this->end) { $fileName = 'seed.' . $env . '.json';
$month = $current->format('F Y'); if ($disk->exists($fileName)) {
$file = json_decode($disk->get($fileName), true);
$current->addMonth(); // run the file:
TestData::run($file);
} }
} }
} }

View File

@ -16,7 +16,7 @@
"roles": [ "roles": [
{ {
"user_id": 1, "user_id": 1,
"role": "owner" "role": 1
} }
], ],
"accounts": [ "accounts": [
@ -73,8 +73,7 @@
{ {
"user_id": 1, "user_id": 1,
"account_type_id": 4, "account_type_id": 4,
"name": "PLUS", "name": "PLUS"
"0": "Apple"
}, },
{ {
"user_id": 1, "user_id": 1,
@ -290,69 +289,81 @@
{ {
"name": "Another Empty Budget", "name": "Another Empty Budget",
"user_id": 1 "user_id": 1
},
{
"name": "Going out",
"user_id": 1
} }
], ],
"budget-limits": [ "budget-limits": [
{ {
"budget_id": 1, "budget_id": 1,
"startdate": "2016-05-01", "startdate": "2016-04-01",
"amount": 196, "amount_min": 100,
"repeats": 0, "amount_max": 200,
"repeat_freq": "daily" "repeat_freq": "daily"
}, },
{ {
"budget_id": 1, "budget_id": 1,
"startdate": "2016-05-01", "startdate": "2016-05-01",
"amount": 154, "amount_min": 100,
"repeats": 0, "amount_max": 200,
"repeat_freq": "weekly" "repeat_freq": "weekly"
}, },
{ {
"budget_id": 1, "budget_id": 1,
"startdate": "2016-05-01", "startdate": "2016-06-01",
"amount": 159, "amount_min": 100,
"repeats": 0, "amount_max": 200,
"repeat_freq": "monthly" "repeat_freq": "monthly"
}, },
{ {
"budget_id": 1, "budget_id": 1,
"startdate": "2016-05-01", "startdate": "2016-07-01",
"amount": 157, "amount_min": 100,
"repeats": 0, "amount_max": 200,
"repeat_freq": "quarterly" "repeat_freq": "quarterly"
}, },
{ {
"budget_id": 1, "budget_id": 1,
"startdate": "2016-05-01", "startdate": "2016-08-01",
"amount": 190, "amount_min": 100,
"repeats": 0, "amount_max": 200,
"repeat_freq": "half-year" "repeat_freq": "half-year"
}, },
{ {
"budget_id": 1, "budget_id": 1,
"startdate": "2016-05-01", "startdate": "2016-09-01",
"amount": 145, "amount_min": 100,
"repeats": 0, "amount_max": 200,
"repeat_freq": "yearly" "repeat_freq": "yearly"
} }
], ],
"monthly-limits": [ "monthly-limits": [
{ {
"budget_id": 1, "budget_id": 1,
"amount": 100 "amount_min": 200,
"amount_max": 200
}, },
{ {
"budget_id": 2, "budget_id": 2,
"amount": 100 "amount_min": 1000,
"amount_max": 1000
}, },
{ {
"budget_id": 3, "budget_id": 3,
"amount": 100 "amount_min": 200,
"amount_max": 200
},
{
"budget_id": 6,
"amount_min": 100,
"amount_max": 100
} }
], ],
"categories": [ "categories": [
{ {
"name": "Groceries", "name": "Daily groceries",
"user_id": 1 "user_id": 1
}, },
{ {
@ -366,6 +377,14 @@
{ {
"name": "Salary", "name": "Salary",
"user_id": 1 "user_id": 1
},
{
"name": "Bills",
"user_id": 1
},
{
"name": "Going out",
"user_id": 1
} }
], ],
"piggy-banks": [ "piggy-banks": [
@ -497,6 +516,7 @@
"rule_id": 1, "rule_id": 1,
"order": 1, "order": 1,
"active": 1, "active": 1,
"stop_processing": 0,
"action_type": "prepend_description", "action_type": "prepend_description",
"action_value": "Bought the world from " "action_value": "Bought the world from "
}, },
@ -504,6 +524,7 @@
"rule_id": 1, "rule_id": 1,
"order": 2, "order": 2,
"active": 1, "active": 1,
"stop_processing": 0,
"action_type": "set_category", "action_type": "set_category",
"action_value": "Large expenses" "action_value": "Large expenses"
} }
@ -584,179 +605,214 @@
], ],
"monthly-deposits": [ "monthly-deposits": [
{ {
"user": 1, "user_id": 1,
"day-of-month": 24, "day-of-month": 24,
"description": "Salary in :month", "description": "Salary in :month",
"source": "Job", "source_id": 30,
"destination": "Checking Account", "destination_id": 1,
"min_amount": 2000, "min_amount": 1500,
"max_amount": 2100 "max_amount": 1700,
"category_id": 4
} }
], ],
"monthly-transfers": [ "monthly-transfers": [
{ {
"user": 1, "user_id": 1,
"day-of-month": 28, "day-of-month": 28,
"description": "Saving money for :month", "description": "Saving money for :month",
"source": "Checking Account", "source_id": 1,
"destination": "Savings Account", "destination_id": 3,
"min_amount": 150, "min_amount": 150,
"max_amount": 150 "max_amount": 150
} }
], ],
"monthly-withdrawals": [ "monthly-withdrawals": [
{ {
"user": 1, "user_id": 1,
"day-of-month": 2, "day-of-month": "02",
"description": "Rent for :month", "description": "Rent for :month",
"source": "Checking Account", "source_id": 1,
"destination": "Land lord", "destination_id": 29,
"min_amount": 800, "min_amount": 800,
"max_amount": 800 "max_amount": 800,
"category_id": 5,
"budget_id": 2
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 4, "day-of-month": "04",
"description": "Water bill :month", "description": "Water bill :month",
"source": "Checking Account", "source_id": 1,
"destination": "Land lord", "destination_id": 8,
"min_amount": 800, "min_amount": 8,
"max_amount": 800 "max_amount": 12,
"category_id": 5,
"budget_id": 2
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 6, "day-of-month": "06",
"description": "TV bill :month", "description": "TV bill :month",
"source": "Checking Account", "source_id": 1,
"destination": "Land lord", "destination_id": 26,
"min_amount": 800, "min_amount": 50,
"max_amount": 800 "max_amount": 60,
"category_id": 5,
"budget_id": 2
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 8, "day-of-month": "08",
"description": "Power bill :month", "description": "Power bill :month",
"source": "Checking Account", "source_id": 1,
"destination": "Land lord", "destination_id": 24,
"min_amount": 800, "min_amount": 75,
"max_amount": 800 "max_amount": 90,
"category_id": 5,
"budget_id": 2
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 7, "day-of-month": "07",
"description": "Bought gas", "description": "Bought gas",
"source": "Checking Account", "source_id": 1,
"destination": "Shell", "destination_id": 17,
"min_amount": 40, "min_amount": 40,
"max_amount": 50 "max_amount": 50,
"category_id": 2,
"budget_id": 3
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 17, "day-of-month": 17,
"description": "Filled the car up again", "description": "Filled the car up again",
"source": "Checking Account", "source_id": 1,
"destination": "Shell", "destination_id": 17,
"min_amount": 40, "min_amount": 40,
"max_amount": 50 "max_amount": 50,
"category_id": 2,
"budget_id": 3
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 27, "day-of-month": 27,
"description": "Needed gas again", "description": "Needed gas again",
"source": "Checking Account", "source_id": 1,
"destination": "Shell", "destination_id": 17,
"min_amount": 45, "min_amount": 45,
"max_amount": 55 "max_amount": 55,
"category_id": 2,
"budget_id": 3
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 2, "day-of-month": "02",
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "Albert Heijn", "destination_id": 9,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 6, "day-of-month": "06",
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "PLUS", "destination_id": 10,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 8, "day-of-month": "08",
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "Bakker", "destination_id": 11,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 11, "day-of-month": 11,
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "Albert Heijn", "destination_id": 9,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 15, "day-of-month": 15,
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "PLUS", "destination_id": 10,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 19, "day-of-month": 19,
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "Albert Heijn", "destination_id": 11,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 23, "day-of-month": 23,
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "Bakker", "destination_id": 9,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 26, "day-of-month": 26,
"description": "Groceries", "description": "Groceries",
"source": "Checking Account", "source_id": 1,
"destination": "Albert Heijn", "destination_id": 10,
"min_amount": 15, "min_amount": 15,
"max_amount": 25 "max_amount": 25,
"category_id": 1,
"budget_id": 1
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 23, "day-of-month": 13,
"description": "Going out for drinks", "description": "Going out for drinks",
"source": "Checking Account", "source_id": 1,
"destination": "Cafe Central", "destination_id": 14,
"min_amount": 15, "min_amount": 15,
"max_amount": 36 "max_amount": 36,
"category_id": 6,
"budget_id": 6
}, },
{ {
"user": 1, "user_id": 1,
"day-of-month": 26, "day-of-month": 26,
"description": "Going out for drinks again", "description": "Going out for drinks again",
"source": "Checking Account", "source_id": 1,
"destination": "Cafe Central", "destination_id": 14,
"min_amount": 15, "min_amount": 15,
"max_amount": 36 "max_amount": 36,
"category_id": 6,
"budget_id": 6
} }
], ],
"attachments": [ "attachments": [
@ -777,7 +833,7 @@
"attachable_type": "FireflyIII\\Models\\TransactionJournal", "attachable_type": "FireflyIII\\Models\\TransactionJournal",
"user_id": 1, "user_id": 1,
"content": "This is attachment number two.", "content": "This is attachment number two.",
"filename": "empty-file.txt", "filename": "empty-file2.txt",
"title": "Empty file", "title": "Empty file",
"description": "This file is empty", "description": "This file is empty",
"notes": "Some notes", "notes": "Some notes",