mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
More test data tweaks.
This commit is contained in:
@@ -158,7 +158,7 @@ class TransactionJournal extends Model
|
|||||||
$transaction = $this->transactions->sortByDesc('amount')->first();
|
$transaction = $this->transactions->sortByDesc('amount')->first();
|
||||||
$amount = $transaction->amount;
|
$amount = $transaction->amount;
|
||||||
if ($this->isWithdrawal()) {
|
if ($this->isWithdrawal()) {
|
||||||
$amount = $amount * -1;
|
$amount = bcmul($amount, '-1');
|
||||||
}
|
}
|
||||||
$cache->store($amount);
|
$cache->store($amount);
|
||||||
|
|
||||||
|
@@ -39,6 +39,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class TestData
|
class TestData
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
@@ -99,7 +101,7 @@ class TestData
|
|||||||
[
|
[
|
||||||
'account_id' => $fromAccount->id,
|
'account_id' => $fromAccount->id,
|
||||||
'transaction_journal_id' => $journal->id,
|
'transaction_journal_id' => $journal->id,
|
||||||
'amount' => -100,
|
'amount' => '-100',
|
||||||
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -229,6 +231,88 @@ class TestData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return static
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
|
public static function createCar(User $user, Carbon $date)
|
||||||
|
{
|
||||||
|
// twice:
|
||||||
|
$date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$toAccount = TestData::findAccount($user, 'Shell');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
|
||||||
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
|
||||||
|
$amount = strval(rand(4000, 5000) / 100);
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => 'Bought gas',
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
|
||||||
|
// and again!
|
||||||
|
$date = new Carbon($date->format('Y-m') . '-20'); // paid on 20th
|
||||||
|
$amount = rand(4000, 5000) / 100;
|
||||||
|
|
||||||
|
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => 'Gas for car',
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount * -1,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// and again!
|
||||||
|
|
||||||
|
return $journal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
@@ -238,6 +322,64 @@ class TestData
|
|||||||
Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
|
Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
|
public static function createDrinksAndOthers(User $user, Carbon $date)
|
||||||
|
{
|
||||||
|
$start = clone $date;
|
||||||
|
$end = clone $date;
|
||||||
|
$today = new Carbon;
|
||||||
|
$start->startOfMonth();
|
||||||
|
$end->endOfMonth();
|
||||||
|
$current = clone $start;
|
||||||
|
while ($current < $end && $current < $today) {
|
||||||
|
|
||||||
|
// weekly drink:
|
||||||
|
$thisDate = clone $current;
|
||||||
|
$thisDate->addDay();
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$toAccount = TestData::findAccount($user, 'Cafe Central');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'Drinks', 'user_id' => $user->id]);
|
||||||
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Going out', 'user_id' => $user->id]);
|
||||||
|
$amount = strval(rand(1500, 3600) / 100);
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => 'Going out for drinks',
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $thisDate,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
|
||||||
|
// shopping at some (online) shop:
|
||||||
|
|
||||||
|
|
||||||
|
$current->addWeek();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
@@ -263,53 +405,61 @@ class TestData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string $description
|
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
* @param string $amount
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*
|
|
||||||
* @return TransactionJournal
|
|
||||||
*/
|
*/
|
||||||
public static function createRent(User $user, string $description, Carbon $date, string $amount): TransactionJournal
|
public static function createGroceries(User $user, Carbon $date)
|
||||||
{
|
{
|
||||||
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
$start = clone $date;
|
||||||
$toAccount = TestData::findAccount($user, 'Land lord');
|
$end = clone $date;
|
||||||
$category = Category::firstOrCreateEncrypted(['name' => 'Rent', 'user_id' => $user->id]);
|
$today = new Carbon;
|
||||||
$budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]);
|
$start->startOfMonth();
|
||||||
$journal = TransactionJournal::create(
|
$end->endOfMonth();
|
||||||
[
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'transaction_type_id' => 1,
|
|
||||||
'transaction_currency_id' => 1,
|
|
||||||
'bill_id' => 1,
|
|
||||||
'description' => $description,
|
|
||||||
'completed' => 1,
|
|
||||||
'date' => $date,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
Transaction::create(
|
|
||||||
[
|
|
||||||
'account_id' => $fromAccount->id,
|
|
||||||
'transaction_journal_id' => $journal->id,
|
|
||||||
'amount' => $amount * -1,
|
|
||||||
|
|
||||||
]
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
);
|
$stores = ['Albert Heijn', 'PLUS', 'Bakker'];
|
||||||
Transaction::create(
|
$descriptions = ['Groceries', 'Bought some groceries', 'Got groceries'];
|
||||||
[
|
$category = Category::firstOrCreateEncrypted(['name' => 'Daily groceries', 'user_id' => $user->id]);
|
||||||
'account_id' => $toAccount->id,
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]);
|
||||||
'transaction_journal_id' => $journal->id,
|
|
||||||
'amount' => $amount,
|
|
||||||
|
|
||||||
]
|
$current = clone $start;
|
||||||
);
|
while ($current < $end && $current < $today) {
|
||||||
$journal->categories()->save($category);
|
// daily groceries:
|
||||||
$journal->budgets()->save($budget);
|
$amount = rand(1500, 2500) / 100;
|
||||||
|
$toAccount = TestData::findAccount($user, $stores[rand(0, count($stores) - 1)]);
|
||||||
|
|
||||||
return $journal;
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => $descriptions[rand(0, count($descriptions) - 1)],
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $current,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount * -1,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
$current->addDay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string $description
|
* @param string $description
|
||||||
@@ -344,7 +494,7 @@ class TestData
|
|||||||
[
|
[
|
||||||
'account_id' => $fromAccount->id,
|
'account_id' => $fromAccount->id,
|
||||||
'transaction_journal_id' => $journal->id,
|
'transaction_journal_id' => $journal->id,
|
||||||
'amount' => $amount * -1,
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -500,6 +650,104 @@ class TestData
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $description
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param $amount
|
||||||
|
*
|
||||||
|
* @return TransactionJournal
|
||||||
|
*/
|
||||||
|
public static function createPower(User $user, string $description, Carbon $date, string $amount)
|
||||||
|
{
|
||||||
|
$date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$toAccount = TestData::findAccount($user, 'Greenchoice');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $user->id]);
|
||||||
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]);
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => $description,
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if ($journal->getErrors()->count() > 0) {
|
||||||
|
echo $journal->getErrors()->first();
|
||||||
|
}
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
|
||||||
|
return $journal;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
* @param string $description
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param string $amount
|
||||||
|
*
|
||||||
|
* @return TransactionJournal
|
||||||
|
*/
|
||||||
|
public static function createRent(User $user, string $description, Carbon $date, string $amount): TransactionJournal
|
||||||
|
{
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$toAccount = TestData::findAccount($user, 'Land lord');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'Rent', 'user_id' => $user->id]);
|
||||||
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]);
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'bill_id' => 1,
|
||||||
|
'description' => $description,
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
|
||||||
|
return $journal;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
@@ -599,6 +847,99 @@ class TestData
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return TransactionJournal
|
||||||
|
*/
|
||||||
|
public static function createSavings(User $user, Carbon $date): TransactionJournal
|
||||||
|
{
|
||||||
|
$date = new Carbon($date->format('Y-m') . '-24'); // paid on 24th.
|
||||||
|
$toAccount = TestData::findAccount($user, 'TestData Savings');
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'Money management', 'user_id' => $user->id]);
|
||||||
|
// create journal:
|
||||||
|
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 3,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => 'Save money',
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => -150,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => 150,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
|
||||||
|
return $journal;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
* @param string $description
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param string $amount
|
||||||
|
*
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public static function createTV(User $user, string $description, Carbon $date, string $amount)
|
||||||
|
{
|
||||||
|
$date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$toAccount = TestData::findAccount($user, 'XS4All');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $user->id]);
|
||||||
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]);
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => $description,
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
|
||||||
|
return $journal;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Carbon|null $date
|
* @param Carbon|null $date
|
||||||
@@ -638,6 +979,54 @@ class TestData
|
|||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param User $user
|
||||||
|
* @param string $description
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param string $amount
|
||||||
|
*
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public static function createWater(User $user, string $description, Carbon $date, string $amount): TransactionJournal
|
||||||
|
{
|
||||||
|
$date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th
|
||||||
|
$fromAccount = TestData::findAccount($user, 'TestData Checking Account');
|
||||||
|
$toAccount = TestData::findAccount($user, 'Vitens');
|
||||||
|
$category = Category::firstOrCreateEncrypted(['name' => 'House', 'user_id' => $user->id]);
|
||||||
|
$budget = Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]);
|
||||||
|
$journal = TransactionJournal::create(
|
||||||
|
[
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'transaction_type_id' => 1,
|
||||||
|
'transaction_currency_id' => 1,
|
||||||
|
'description' => $description,
|
||||||
|
'completed' => 1,
|
||||||
|
'date' => $date,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $fromAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => bcmul($amount, '-1'),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $toAccount->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => $amount,
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$journal->categories()->save($category);
|
||||||
|
$journal->budgets()->save($budget);
|
||||||
|
|
||||||
|
return $journal;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param $name
|
* @param $name
|
||||||
|
@@ -133,7 +133,7 @@ class Steam
|
|||||||
$result = [];
|
$result = [];
|
||||||
foreach ($balances as $entry) {
|
foreach ($balances as $entry) {
|
||||||
$accountId = intval($entry->account_id);
|
$accountId = intval($entry->account_id);
|
||||||
$balance = round($entry->aggregate, 2);
|
$balance = $entry->aggregate;
|
||||||
$result[$accountId] = $balance;
|
$result[$accountId] = $balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\Attachment;
|
|
||||||
use FireflyIII\Models\Category;
|
|
||||||
use FireflyIII\Models\Role;
|
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Support\Migration\TestData;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Database\Seeder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class OldTestDataSeeder
|
|
||||||
*/
|
|
||||||
class OldTestDataSeeder extends Seeder
|
|
||||||
{
|
|
||||||
/** @var Carbon */
|
|
||||||
public $start;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TestDataSeeder constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->start = Carbon::create()->subYear()->startOfYear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the database seeds.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
// create budget limits for these budgets
|
|
||||||
// TestData::createBudgetLimit($user, new Carbon, 'Groceries', 400);
|
|
||||||
// TestData::createBudgetLimit($user, new Carbon, 'Bills', 1000);
|
|
||||||
// TestData::createBudgetLimit($user, new Carbon, 'Car', 100);
|
|
||||||
|
|
||||||
// create some categories for user #1
|
|
||||||
$this->createCategories($user);
|
|
||||||
|
|
||||||
// create some piggy banks for user #1
|
|
||||||
TestData::createPiggybanks($user);
|
|
||||||
|
|
||||||
// create some expense accounts for user #1
|
|
||||||
$this->createExpenseAccounts($user);
|
|
||||||
|
|
||||||
// create some revenue accounts for user #1
|
|
||||||
$this->createRevenueAccounts($user);
|
|
||||||
|
|
||||||
// create journal + attachment:
|
|
||||||
TestData::createAttachments($user, $this->start);
|
|
||||||
|
|
||||||
// create opening balance for savings account:
|
|
||||||
$this->openingBalanceSavings($user);
|
|
||||||
|
|
||||||
// need at least one rule group and one rule:
|
|
||||||
TestData::createRules($user);
|
|
||||||
|
|
||||||
// create a tag:
|
|
||||||
TestData::createTags($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -64,25 +64,24 @@ class TestDataSeeder extends Seeder
|
|||||||
|
|
||||||
// pay bills:
|
// pay bills:
|
||||||
TestData::createRent($user, 'Rent for ' . $month, $current, '800');
|
TestData::createRent($user, 'Rent for ' . $month, $current, '800');
|
||||||
// $this->createWater('Water bill for ' . $month, $current, 15);
|
TestData::createWater($user, 'Water bill for ' . $month, $current, '15');
|
||||||
// $this->createTV('TV bill for ' . $month, $current, 60);
|
TestData::createTV($user, 'TV bill for ' . $month, $current, '60');
|
||||||
// $this->createPower('Power bill for ' . $month, $current, 120);
|
TestData::createPower($user, 'Power bill for ' . $month, $current, '120');
|
||||||
|
|
||||||
|
|
||||||
// pay daily groceries:
|
// pay daily groceries:
|
||||||
// $this->createGroceries($current);
|
TestData::createGroceries($user, $current);
|
||||||
|
|
||||||
// create tag (each type of tag, for date):
|
// create tag (each type of tag, for date):
|
||||||
// TestData::createTags($this->user, $current);
|
TestData::createTags($user, $current);
|
||||||
|
|
||||||
// go out for drinks:
|
// go out for drinks:
|
||||||
// $this->createDrinksAndOthers($current);
|
TestData::createDrinksAndOthers($user, $current);
|
||||||
|
|
||||||
// save money every month:
|
// save money every month:
|
||||||
// $this->createSavings($current);
|
TestData::createSavings($user, $current);
|
||||||
|
|
||||||
// buy gas for the car every month:
|
// buy gas for the car every month:
|
||||||
// $this->createCar($current);
|
TestData::createCar($user, $current);
|
||||||
|
|
||||||
// create budget limits.
|
// create budget limits.
|
||||||
TestData::createBudgetLimit($user, $current, 'Groceries', '400');
|
TestData::createBudgetLimit($user, $current, 'Groceries', '400');
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user