From f78d56b149d0d1f972307ca564138195f07dc4dc Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 14 May 2016 17:08:28 +0200 Subject: [PATCH] Will implement changes to test database. --- .gitignore | 1 - database/seeds/DatabaseSeeder.php | 7 +- database/seeds/SplitDataSeeder.php | 3 +- database/seeds/TestDataSeeder.php | 69 --- storage/database/seed.local.json | 788 +++++++++++++++++++++++++++++ storage/debugbar/.gitignore | 2 + 6 files changed, 793 insertions(+), 77 deletions(-) create mode 100644 storage/database/seed.local.json create mode 100644 storage/debugbar/.gitignore diff --git a/.gitignore b/.gitignore index 24a6fb22e5..8edc368963 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ /node_modules .env -storage/ .env.local diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 45131e047b..8975b71238 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -22,14 +22,9 @@ class DatabaseSeeder extends Seeder $this->call('TransactionTypeSeeder'); $this->call('PermissionSeeder'); - // set up basic test data (as little as possible): - if (App::environment() == 'testing' || App::environment() == 'local') { + if (App::environment() == 'testing') { $this->call('TestDataSeeder'); } - // set up basic test data (as little as possible): - if (App::environment() == 'split') { - $this->call('SplitDataSeeder'); - } } } diff --git a/database/seeds/SplitDataSeeder.php b/database/seeds/SplitDataSeeder.php index 1134bc6097..8e734eb4ae 100644 --- a/database/seeds/SplitDataSeeder.php +++ b/database/seeds/SplitDataSeeder.php @@ -102,7 +102,7 @@ class SplitDataSeeder extends Seeder $categories = ['Salary', 'Reimbursements']; $amounts = [50, 50]; $destination = TestData::findAccount($user, 'Alternate Checking Account'); - $date = new Carbon('2012-03-15'); + $date = new Carbon('2012-03-12'); $journal = TransactionJournal::create( ['user_id' => $user->id, 'transaction_type_id' => 2, 'transaction_currency_id' => 1, 'description' => 'Split Even Income (journal (50/50))', 'completed' => 1, 'date' => $date->format('Y-m-d'),] @@ -134,6 +134,7 @@ class SplitDataSeeder extends Seeder $amounts = [15, 34, 51]; $destination = TestData::findAccount($user, 'Checking Account'); $date = new Carbon; + $date->subDays(3); $journal = TransactionJournal::create( ['user_id' => $user->id, 'transaction_type_id' => 2, 'transaction_currency_id' => 1, 'description' => 'Split Uneven Income (journal (15/34/51=100))', 'completed' => 1, 'date' => $date->format('Y-m-d'),] diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index b58b090c47..1fe98fffe5 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -41,81 +41,12 @@ class TestDataSeeder extends Seeder */ public function run() { - // start by creating all users: - // method will return the first user. - $user = TestData::createUsers(); - // create all kinds of static data: - TestData::createAssetAccounts($user, []); - TestData::createBills($user); - TestData::createBudgets($user); - TestData::createCategories($user); - TestData::createPiggybanks($user, 'TestData Savings'); - TestData::createExpenseAccounts($user); - TestData::createRevenueAccounts($user); - TestData::createAttachments($user, $this->start); - TestData::openingBalanceSavings($user, $this->start); - TestData::createRules($user); - - // loop from start to end, create dynamic info. $current = clone $this->start; while ($current < $this->end) { $month = $current->format('F Y'); - // create salaries: - TestData::createIncome($user, 'Salary ' . $month, $current, strval(rand(2000, 2100))); - - // pay bills: - TestData::createRent($user, 'Rent for ' . $month, $current, '800'); - TestData::createWater($user, 'Water bill for ' . $month, $current, '15'); - TestData::createTV($user, 'TV bill for ' . $month, $current, '60'); - TestData::createPower($user, 'Power bill for ' . $month, $current, '120'); - - // pay daily groceries: - TestData::createGroceries($user, $current); - - // create tag (each type of tag, for date): - TestData::createTags($user, $current); - - // go out for drinks: - TestData::createDrinksAndOthers($user, $current); - - // save money every month: - TestData::createSavings($user, $current); - - // buy gas for the car every month: - TestData::createCar($user, $current); - - // create budget limits. - TestData::createBudgetLimit($user, $current, 'Groceries', '400'); - TestData::createBudgetLimit($user, $current, 'Bills', '1000'); - TestData::createBudgetLimit($user, $current, 'Car', '100'); $current->addMonth(); } - - // create some special budget limits to test stuff with multiple budget limits - // for a range of dates: - $this->end->startOfMonth()->addDay(); - - $budget = TestData::findBudget($user, 'Bills'); - $ranges = ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly']; - foreach ($ranges as $range) { - $limit = BudgetLimit::create( - [ - 'budget_id' => $budget->id, - 'startdate' => $this->end->format('Y-m-d'), - 'amount' => rand(100, 200), - 'repeats' => 0, - 'repeat_freq' => $range, - ] - ); - // also trigger event. - $thisEnd = Navigation::addPeriod($this->end, $range, 0); - $thisEnd->subDay(); - event(new BudgetLimitStored($limit, $thisEnd)); - $this->end->addDay(); - } - - // b } } diff --git a/storage/database/seed.local.json b/storage/database/seed.local.json new file mode 100644 index 0000000000..2b6a8f17ce --- /dev/null +++ b/storage/database/seed.local.json @@ -0,0 +1,788 @@ +{ + "users": [ + { + "email": "thegrumpydictator@gmail.com", + "password": "james" + }, + { + "email": "thegrumpydictator+empty@gmail.com", + "password": "james" + }, + { + "email": "thegrumpydictator+deleteme@gmail.com", + "password": "james" + } + ], + "roles": [ + { + "user_id": 1, + "role": "owner" + } + ], + "accounts": [ + { + "user_id": 1, + "account_type_id": 3, + "name": "Checking Account", + "iban": "NL11XOLA6707795988" + }, + { + "user_id": 1, + "account_type_id": 3, + "name": "Alternate Checking Account", + "iban": "NL40UKBK3619908726" + }, + { + "user_id": 1, + "account_type_id": 3, + "name": "Savings Account", + "iban": "NL96DZCO4665940223" + }, + { + "user_id": 1, + "account_type_id": 3, + "name": "Shared Checking Account", + "iban": "NL81RCQZ7160379858" + }, + { + "user_id": 1, + "account_type_id": 3, + "name": "Emergency Savings Account", + "iban": "NL38SRMN4325934708" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Adobe" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Google" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Vitens" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Albert Heijn" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "PLUS", + "0": "Apple" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Bakker" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Belastingdienst" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "bol.com" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Cafe Central" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "conrad.nl" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Coolblue" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Shell" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "SixtyFive" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "EightyFour" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Fiftyone" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "DUO" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Etos" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "FEBO" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Greenchoice" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Halfords" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "XS4All" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "iCentre" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Jumper" + }, + { + "user_id": 1, + "account_type_id": 4, + "name": "Land lord" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Job" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Belastingdienst" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Bank" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "KPN" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Google" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Work SixtyFive" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Work EightyFour" + }, + { + "user_id": 1, + "account_type_id": 5, + "name": "Work Fiftyone" + }, + { + "user_id": 1, + "account_type_id": 6, + "name": "Opposing for Savings Account" + }, + { + "user_id": 1, + "account_type_id": 6, + "name": "Opposing for Emergency Savings Account" + } + ], + "account-meta": [ + { + "account_id": 1, + "name": "accountRole", + "data": "\"defaultAsset\"" + }, + { + "account_id": 2, + "name": "accountRole", + "data": "\"defaultAsset\"" + }, + { + "account_id": 3, + "name": "accountRole", + "data": "\"savingAsset\"" + }, + { + "account_id": 4, + "name": "accountRole", + "data": "\"sharedAsset\"" + } + ], + "bills": [ + { + "name": "Rent", + "match": "rent,land,lord", + "amount_min": 795, + "amount_max": 805, + "user_id": 1, + "date": "2015-01-01", + "active": 1, + "automatch": 1, + "repeat_freq": "monthly", + "skip": 0 + }, + { + "name": "Health insurance", + "match": "insurer,insurance,health", + "amount_min": 120, + "amount_max": 140, + "user_id": 1, + "date": "2015-01-01", + "active": 1, + "automatch": 1, + "repeat_freq": "monthly", + "skip": 0 + } + ], + "budgets": [ + { + "name": "Groceries", + "user_id": 1 + }, + { + "name": "Bills", + "user_id": 1 + }, + { + "name": "Car", + "user_id": 1 + }, + { + "name": "One Empty Budget", + "user_id": 1 + }, + { + "name": "Another Empty Budget", + "user_id": 1 + } + ], + "budget-limits": [ + { + "budget_id": 1, + "startdate": "2016-05-01", + "amount": 196, + "repeats": 0, + "repeat_freq": "daily" + }, + { + "budget_id": 1, + "startdate": "2016-05-01", + "amount": 154, + "repeats": 0, + "repeat_freq": "weekly" + }, + { + "budget_id": 1, + "startdate": "2016-05-01", + "amount": 159, + "repeats": 0, + "repeat_freq": "monthly" + }, + { + "budget_id": 1, + "startdate": "2016-05-01", + "amount": 157, + "repeats": 0, + "repeat_freq": "quarterly" + }, + { + "budget_id": 1, + "startdate": "2016-05-01", + "amount": 190, + "repeats": 0, + "repeat_freq": "half-year" + }, + { + "budget_id": 1, + "startdate": "2016-05-01", + "amount": 145, + "repeats": 0, + "repeat_freq": "yearly" + } + ], + "monthly-limits": [ + { + "budget_id": 1, + "amount": 100 + }, + { + "budget_id": 2, + "amount": 100 + }, + { + "budget_id": 3, + "amount": 100 + } + ], + "categories": [ + { + "name": "Groceries", + "user_id": 1 + }, + { + "name": "Car", + "user_id": 1 + }, + { + "name": "Reimbursements", + "user_id": 1 + }, + { + "name": "Salary", + "user_id": 1 + } + ], + "piggy-banks": [ + { + "account_id": 3, + "name": "New camera", + "targetamount": 1000, + "startdate": "2015-04-01", + "reminder_skip": 0, + "remind_me": 0, + "order": 1, + "currentamount": 735 + }, + { + "account_id": 3, + "name": "New phone", + "targetamount": 600, + "startdate": "2015-04-01", + "reminder_skip": 0, + "remind_me": 0, + "order": 2, + "currentamount": 333 + }, + { + "account_id": 3, + "name": "New couch", + "targetamount": 500, + "startdate": "2015-04-01", + "reminder_skip": 0, + "remind_me": 0, + "order": 3, + "currentamount": 120 + } + ], + "piggy-events": [ + { + "piggy_bank_id": 1, + "date": "2015-05-01", + "amount": 245 + }, + { + "piggy_bank_id": 1, + "date": "2015-06-02", + "amount": 245 + }, + { + "piggy_bank_id": 1, + "date": "2015-07-03", + "amount": 245 + }, + { + "piggy_bank_id": 2, + "date": "2015-08-04", + "amount": 111 + }, + { + "piggy_bank_id": 2, + "date": "2015-09-05", + "amount": 111 + }, + { + "piggy_bank_id": 2, + "date": "2015-10-06", + "amount": 111 + }, + { + "piggy_bank_id": 3, + "date": "2015-11-07", + "amount": 40 + }, + { + "piggy_bank_id": 3, + "date": "2015-12-08", + "amount": 40 + }, + { + "piggy_bank_id": 3, + "date": "2016-01-09", + "amount": 40 + } + ], + "rule-groups": [ + { + "user_id": 1, + "order": 1, + "title": "Default rules", + "description": "All your rules not in a particular group." + } + ], + "rules": [ + { + "user_id": 1, + "rule_group_id": 1, + "order": 1, + "active": 1, + "stop_processing": 0, + "title": "Your first default rule", + "description": "This rule is an example. You can safely delete it." + } + ], + "rule-triggers": [ + { + "rule_id": 1, + "order": 1, + "active": 1, + "stop_processing": 0, + "trigger_type": "user_action", + "trigger_value": "store-journal" + }, + { + "rule_id": 1, + "order": 2, + "active": 1, + "stop_processing": 0, + "trigger_type": "description_is", + "trigger_value": "The Man Who Sold the World" + }, + { + "rule_id": 1, + "order": 3, + "active": 1, + "stop_processing": 0, + "trigger_type": "from_account_is", + "trigger_value": "David Bowie" + } + ], + "rule-actions": [ + { + "rule_id": 1, + "order": 1, + "active": 1, + "action_type": "prepend_description", + "action_value": "Bought the world from " + }, + { + "rule_id": 1, + "order": 2, + "active": 1, + "action_type": "set_category", + "action_value": "Large expenses" + } + ], + "tags": [ + { + "user_id": 1, + "tag": "TagJanuary", + "tagMode": "nothing", + "date": "2015-01-01" + }, + { + "user_id": 1, + "tag": "TagFebruary", + "tagMode": "nothing", + "date": "2015-02-02" + }, + { + "user_id": 1, + "tag": "TagMarch", + "tagMode": "nothing", + "date": "2015-03-03" + }, + { + "user_id": 1, + "tag": "TagApril", + "tagMode": "nothing", + "date": "2015-04-04" + }, + { + "user_id": 1, + "tag": "TagMay", + "tagMode": "nothing", + "date": "2015-05-05" + }, + { + "user_id": 1, + "tag": "TagJune", + "tagMode": "nothing", + "date": "2015-06-06" + }, + { + "user_id": 1, + "tag": "TagJuly", + "tagMode": "nothing", + "date": "2015-07-07" + }, + { + "user_id": 1, + "tag": "TagAugust", + "tagMode": "nothing", + "date": "2015-08-08" + }, + { + "user_id": 1, + "tag": "TagSeptember", + "tagMode": "nothing", + "date": "2015-09-09" + }, + { + "user_id": 1, + "tag": "TagOctober", + "tagMode": "nothing", + "date": "2015-10-10" + }, + { + "user_id": 1, + "tag": "TagNovember", + "tagMode": "nothing", + "date": "2015-11-11" + }, + { + "user_id": 1, + "tag": "TagDecember", + "tagMode": "nothing", + "date": "2015-12-12" + } + ], + "monthly-deposits": [ + { + "user": 1, + "day-of-month": 24, + "description": "Salary in :month", + "source": "Job", + "destination": "Checking Account", + "min_amount": 2000, + "max_amount": 2100 + } + ], + "monthly-transfers": [ + { + "user": 1, + "day-of-month": 28, + "description": "Saving money for :month", + "source": "Checking Account", + "destination": "Savings Account", + "min_amount": 150, + "max_amount": 150 + } + ], + "monthly-withdrawals": [ + { + "user": 1, + "day-of-month": 2, + "description": "Rent for :month", + "source": "Checking Account", + "destination": "Land lord", + "min_amount": 800, + "max_amount": 800 + }, + { + "user": 1, + "day-of-month": 4, + "description": "Water bill :month", + "source": "Checking Account", + "destination": "Land lord", + "min_amount": 800, + "max_amount": 800 + }, + { + "user": 1, + "day-of-month": 6, + "description": "TV bill :month", + "source": "Checking Account", + "destination": "Land lord", + "min_amount": 800, + "max_amount": 800 + }, + { + "user": 1, + "day-of-month": 8, + "description": "Power bill :month", + "source": "Checking Account", + "destination": "Land lord", + "min_amount": 800, + "max_amount": 800 + }, + { + "user": 1, + "day-of-month": 7, + "description": "Bought gas", + "source": "Checking Account", + "destination": "Shell", + "min_amount": 40, + "max_amount": 50 + }, + { + "user": 1, + "day-of-month": 17, + "description": "Filled the car up again", + "source": "Checking Account", + "destination": "Shell", + "min_amount": 40, + "max_amount": 50 + }, + { + "user": 1, + "day-of-month": 27, + "description": "Needed gas again", + "source": "Checking Account", + "destination": "Shell", + "min_amount": 45, + "max_amount": 55 + }, + { + "user": 1, + "day-of-month": 2, + "description": "Groceries", + "source": "Checking Account", + "destination": "Albert Heijn", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 6, + "description": "Groceries", + "source": "Checking Account", + "destination": "PLUS", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 8, + "description": "Groceries", + "source": "Checking Account", + "destination": "Bakker", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 11, + "description": "Groceries", + "source": "Checking Account", + "destination": "Albert Heijn", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 15, + "description": "Groceries", + "source": "Checking Account", + "destination": "PLUS", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 19, + "description": "Groceries", + "source": "Checking Account", + "destination": "Albert Heijn", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 23, + "description": "Groceries", + "source": "Checking Account", + "destination": "Bakker", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 26, + "description": "Groceries", + "source": "Checking Account", + "destination": "Albert Heijn", + "min_amount": 15, + "max_amount": 25 + }, + { + "user": 1, + "day-of-month": 23, + "description": "Going out for drinks", + "source": "Checking Account", + "destination": "Cafe Central", + "min_amount": 15, + "max_amount": 36 + }, + { + "user": 1, + "day-of-month": 26, + "description": "Going out for drinks again", + "source": "Checking Account", + "destination": "Cafe Central", + "min_amount": 15, + "max_amount": 36 + } + ], + "attachments": [ + { + "attachable_id": 1, + "attachable_type": "FireflyIII\\Models\\TransactionJournal", + "user_id": 1, + "content": "This is attachment number one.", + "filename": "empty-file.txt", + "title": "Empty file", + "description": "This file is empty", + "notes": "Some notes", + "mime": "text\/plain", + "uploaded": 1 + }, + { + "attachable_id": 2, + "attachable_type": "FireflyIII\\Models\\TransactionJournal", + "user_id": 1, + "content": "This is attachment number two.", + "filename": "empty-file.txt", + "title": "Empty file", + "description": "This file is empty", + "notes": "Some notes", + "mime": "text\/plain", + "uploaded": 1 + } + ] +} \ No newline at end of file diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 0000000000..d6b7ef32c8 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore