mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 17:33:45 +00:00
Extend transaction model for #351
This commit is contained in:
@@ -467,7 +467,7 @@ class TestData
|
||||
private function createMultiDeposits()
|
||||
{
|
||||
foreach ($this->data['multi-deposits'] as $deposit) {
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
[
|
||||
'created_at' => $this->time,
|
||||
'updated_at' => $this->time,
|
||||
@@ -485,6 +485,7 @@ class TestData
|
||||
'tag_count' => 0,
|
||||
]
|
||||
);
|
||||
$identifier = 0;
|
||||
foreach ($deposit['source_ids'] as $index => $source) {
|
||||
$description = $deposit['description'] . ' (#' . ($index + 1) . ')';
|
||||
$amount = $deposit['amounts'][$index];
|
||||
@@ -496,6 +497,7 @@ class TestData
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount,
|
||||
'identifier' => $identifier,
|
||||
]
|
||||
);
|
||||
$second = DB::table('transactions')->insertGetId(
|
||||
@@ -506,8 +508,10 @@ class TestData
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount * -1,
|
||||
'identifier' => $identifier,
|
||||
]
|
||||
);
|
||||
$identifier++;
|
||||
// link first and second to budget and category, if present.
|
||||
|
||||
if (isset($deposit['category_ids'][$index])) {
|
||||
@@ -531,7 +535,7 @@ class TestData
|
||||
private function createMultiTransfers()
|
||||
{
|
||||
foreach ($this->data['multi-transfers'] as $transfer) {
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
[
|
||||
'created_at' => $this->time,
|
||||
'updated_at' => $this->time,
|
||||
@@ -549,6 +553,7 @@ class TestData
|
||||
'tag_count' => 0,
|
||||
]
|
||||
);
|
||||
$identifier = 0;
|
||||
foreach ($transfer['destination_ids'] as $index => $destination) {
|
||||
$description = $transfer['description'] . ' (#' . ($index + 1) . ')';
|
||||
$amount = $transfer['amounts'][$index];
|
||||
@@ -561,6 +566,7 @@ class TestData
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount * -1,
|
||||
'identifier' => $identifier,
|
||||
]
|
||||
);
|
||||
$second = DB::table('transactions')->insertGetId(
|
||||
@@ -571,9 +577,10 @@ class TestData
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount,
|
||||
'identifier' => $identifier,
|
||||
]
|
||||
);
|
||||
|
||||
$identifier++;
|
||||
if (isset($transfer['category_ids'][$index])) {
|
||||
DB::table('category_transaction')->insert(
|
||||
[
|
||||
@@ -598,7 +605,7 @@ class TestData
|
||||
private function createMultiWithdrawals()
|
||||
{
|
||||
foreach ($this->data['multi-withdrawals'] as $withdrawal) {
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
$journalId = DB::table('transaction_journals')->insertGetId(
|
||||
[
|
||||
'created_at' => $this->time,
|
||||
'updated_at' => $this->time,
|
||||
@@ -616,6 +623,7 @@ class TestData
|
||||
'tag_count' => 0,
|
||||
]
|
||||
);
|
||||
$identifier = 0;
|
||||
foreach ($withdrawal['destination_ids'] as $index => $destination) {
|
||||
$description = $withdrawal['description'] . ' (#' . ($index + 1) . ')';
|
||||
$amount = $withdrawal['amounts'][$index];
|
||||
@@ -627,6 +635,7 @@ class TestData
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount * -1,
|
||||
'identifier' => $identifier,
|
||||
]
|
||||
);
|
||||
$second = DB::table('transactions')->insertGetId(
|
||||
@@ -637,8 +646,10 @@ class TestData
|
||||
'transaction_journal_id' => $journalId,
|
||||
'description' => $description,
|
||||
'amount' => $amount,
|
||||
'identifier' => $identifier,
|
||||
]
|
||||
);
|
||||
$identifier++;
|
||||
// link first and second to budget and category, if present.
|
||||
if (isset($withdrawal['budget_ids'][$index])) {
|
||||
DB::table('budget_transaction')->insert(
|
||||
|
Reference in New Issue
Block a user