Skip to content

Firefly III: a personal finances manager

Create bills in test data, sort them [skip ci]

James Colee0d863a46fc1
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index ec6984ccc6..052343f1c5 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -93,6 +93,12 @@ class BillRepository implements BillRepositoryInterface
/** @var Collection $set */
$set = Auth::user()->bills()->orderBy('name', 'ASC')->get();
+ $set = $set->sortBy(
+ function (Bill $bill) {
+ return strtolower($bill->name);
+ }
+ );
+
return $set;
}
diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php
index 770079ebe9..f68ffb6d80 100644
--- a/database/seeds/TestDataSeeder.php
+++ b/database/seeds/TestDataSeeder.php
@@ -44,6 +44,7 @@ class TestDataSeeder extends Seeder
$this->createAssetAccounts();
$this->createExpenseAccounts();
$this->createRevenueAccounts();
+ $this->createBills();
// dates:
$start = Carbon::now()->subyear()->startOfMonth();
@@ -173,6 +174,38 @@ class TestDataSeeder extends Seeder
}
}
+ public function createBills()
+ {
+ Bill::create(
+ [
+ 'name' => 'Rent',
+ 'match' => 'rent,land,lord',
+ 'amount_min' => 795,
+ 'amount_max' => 805,
+ 'user_id' => $this->user->id,
+ 'date' => '2015-01-01',
+ 'active' => 1,
+ 'automatch' => 1,
+ 'repeat_freq' => 'monthly',
+ 'skip' => 0,
+ ]
+ );
+ Bill::create(
+ [
+ 'name' => 'Health insurance',
+ 'match' => 'zilveren,kruis,health',
+ 'amount_min' => 120,
+ 'amount_max' => 140,
+ 'user_id' => $this->user->id,
+ 'date' => '2015-01-01',
+ 'active' => 1,
+ 'automatch' => 1,
+ 'repeat_freq' => 'monthly',
+ 'skip' => 0,
+ ]
+ );
+ }
+
/**
* @param $description
* @param Carbon $date
@@ -499,7 +532,7 @@ class TestDataSeeder extends Seeder
$toAccount = $this->findAccount('Cafe Central');
$category = Category::firstOrCreateEncrypted(['name' => 'Drinks', 'user_id' => $this->user->id]);
$budget = Budget::firstOrCreateEncrypted(['name' => 'Going out', 'user_id' => $this->user->id]);
- $amount = rand(1500, 3600) / 100;
+ $amount = rand(1500, 3600) / 100;
$journal = TransactionJournal::create(
[
'user_id' => $this->user->id,