mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
More test data and better views.
This commit is contained in:
55
app/Support/Binder/UnfinishedJournal.php
Normal file
55
app/Support/Binder/UnfinishedJournal.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* UnfinishedJournal.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* Date.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class Date
|
||||
*
|
||||
* @package FireflyIII\Support\Binder
|
||||
*/
|
||||
class UnfinishedJournal implements BinderInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $route
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function routeBinder($value, $route): TransactionJournal
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$object = TransactionJournal::where('transaction_journals.id', $value)
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->where('completed', 0)
|
||||
->where('user_id', Auth::user()->id)->first(['transaction_journals.*']);
|
||||
if ($object) {
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException;
|
||||
|
||||
}
|
||||
}
|
@@ -415,6 +415,73 @@ class TestData
|
||||
DB::table('transactions')->insert($transactions);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function createMultiDeposits()
|
||||
{
|
||||
foreach ($this->data['multi-deposits'] as $deposit) {
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
[
|
||||
'created_at' => DB::raw('NOW()'),
|
||||
'updated_at' => DB::raw('NOW()'),
|
||||
'user_id' => $deposit['user_id'],
|
||||
'transaction_type_id' => 2,
|
||||
'transaction_currency_id' => 1,
|
||||
'description' => Crypt::encrypt($deposit['description']),
|
||||
'completed' => 1,
|
||||
'date' => $deposit['date'],
|
||||
'interest_date' => $deposit['interest_date'] ?? null,
|
||||
'book_date' => $deposit['book_date'] ?? null,
|
||||
'process_date' => $deposit['process_date'] ?? null,
|
||||
'encrypted' => 1,
|
||||
'order' => 0,
|
||||
'tag_count' => 0,
|
||||
]
|
||||
);
|
||||
foreach ($deposit['source_ids'] as $index => $source) {
|
||||
$description = $deposit['description'] . ' (#' . ($index + 1) . ')';
|
||||
$amount = $deposit['amounts'][$index];
|
||||
$first = DB::table('transactions')->insertGetId(
|
||||
[
|
||||
'created_at' => DB::raw('NOW()'),
|
||||
'updated_at' => DB::raw('NOW()'),
|
||||
'account_id' => $deposit['destination_id'],
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount,
|
||||
]
|
||||
);
|
||||
$second = DB::table('transactions')->insertGetId(
|
||||
[
|
||||
'created_at' => DB::raw('NOW()'),
|
||||
'updated_at' => DB::raw('NOW()'),
|
||||
'account_id' => $source,
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount * -1,
|
||||
]
|
||||
);
|
||||
// link first and second to budget and category, if present.
|
||||
|
||||
if (isset($deposit['category_ids'][$index])) {
|
||||
DB::table('category_transaction')->insert(
|
||||
[
|
||||
'category_id' => $deposit['category_ids'][$index],
|
||||
'transaction_id' => $first,
|
||||
]
|
||||
);
|
||||
DB::table('category_transaction')->insert(
|
||||
[
|
||||
'category_id' => $deposit['category_ids'][$index],
|
||||
'transaction_id' => $second,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -660,6 +727,7 @@ class TestData
|
||||
$this->createJournals();
|
||||
$this->createAttachments();
|
||||
$this->createMultiWithdrawals();
|
||||
$this->createMultiDeposits();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user