2015-02-06 04:41:00 +01:00
|
|
|
<?php
|
2016-02-05 15:01:33 +01:00
|
|
|
declare(strict_types = 1);
|
|
|
|
/**
|
|
|
|
* TestDataSeeder.php
|
|
|
|
* Copyright (C) 2016 Sander Dorigo
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
2016-01-16 09:15:24 +01:00
|
|
|
|
2016-01-20 09:15:33 +01:00
|
|
|
use Carbon\Carbon;
|
2016-01-30 07:36:11 +01:00
|
|
|
use FireflyIII\Support\Migration\TestData;
|
2015-02-11 07:35:10 +01:00
|
|
|
use Illuminate\Database\Seeder;
|
2015-02-06 04:41:00 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class TestDataSeeder
|
|
|
|
*/
|
|
|
|
class TestDataSeeder extends Seeder
|
|
|
|
{
|
2016-02-05 15:01:33 +01:00
|
|
|
/** @var Carbon */
|
|
|
|
public $end;
|
2016-01-24 20:38:58 +01:00
|
|
|
/** @var Carbon */
|
|
|
|
public $start;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TestDataSeeder constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2016-02-05 15:01:33 +01:00
|
|
|
$this->start = Carbon::create()->subYears(2)->startOfYear();
|
|
|
|
$this->end = Carbon::now();
|
2016-01-24 20:38:58 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-06 04:41:00 +01:00
|
|
|
/**
|
2016-01-16 09:15:24 +01:00
|
|
|
* Run the database seeds.
|
2015-06-29 15:23:50 +02:00
|
|
|
*
|
2016-01-16 09:15:24 +01:00
|
|
|
* @return void
|
2015-02-06 04:41:00 +01:00
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
2016-02-05 15:01:33 +01:00
|
|
|
// start by creating all users:
|
|
|
|
// method will return the first user.
|
|
|
|
$user = TestData::createUsers();
|
2016-01-24 16:05:14 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// create all kinds of static data:
|
2016-01-29 13:24:33 +01:00
|
|
|
TestData::createAssetAccounts($user);
|
|
|
|
TestData::createBills($user);
|
2016-02-04 11:00:26 +01:00
|
|
|
TestData::createBudgets($user);
|
2016-02-05 15:01:33 +01:00
|
|
|
TestData::createCategories($user);
|
2016-01-29 13:24:33 +01:00
|
|
|
TestData::createPiggybanks($user);
|
2016-02-05 15:01:33 +01:00
|
|
|
TestData::createExpenseAccounts($user);
|
|
|
|
TestData::createRevenueAccounts($user);
|
2016-02-04 17:13:58 +01:00
|
|
|
TestData::createAttachments($user, $this->start);
|
2016-02-05 15:01:33 +01:00
|
|
|
TestData::openingBalanceSavings($user, $this->start);
|
|
|
|
TestData::createRules($user);
|
2016-01-24 20:38:58 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// 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)));
|
2016-02-04 11:00:26 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// pay bills:
|
|
|
|
TestData::createRent($user, 'Rent for ' . $month, $current, '800');
|
2016-02-05 15:20:44 +01:00
|
|
|
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');
|
2016-01-30 07:36:11 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// pay daily groceries:
|
2016-02-05 15:20:44 +01:00
|
|
|
TestData::createGroceries($user, $current);
|
2016-01-20 09:31:24 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// create tag (each type of tag, for date):
|
2016-02-05 15:20:44 +01:00
|
|
|
TestData::createTags($user, $current);
|
2016-01-24 20:38:58 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// go out for drinks:
|
2016-02-05 15:20:44 +01:00
|
|
|
TestData::createDrinksAndOthers($user, $current);
|
2016-01-24 20:38:58 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// save money every month:
|
2016-02-05 15:20:44 +01:00
|
|
|
TestData::createSavings($user, $current);
|
2016-01-20 10:47:29 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// buy gas for the car every month:
|
2016-02-05 15:20:44 +01:00
|
|
|
TestData::createCar($user, $current);
|
2016-01-20 10:47:29 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
// create budget limits.
|
|
|
|
TestData::createBudgetLimit($user, $current, 'Groceries', '400');
|
|
|
|
TestData::createBudgetLimit($user, $current, 'Bills', '1000');
|
|
|
|
TestData::createBudgetLimit($user, $current, 'Car', '100');
|
2016-01-20 10:47:29 +01:00
|
|
|
|
2016-02-05 15:01:33 +01:00
|
|
|
$current->addMonth();
|
|
|
|
}
|
2016-01-20 10:47:29 +01:00
|
|
|
}
|
2015-03-29 08:14:32 +02:00
|
|
|
}
|