mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Will implement changes to test database.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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'),]
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user