Skip to content

Firefly III: a personal finances manager

Fix the fake import routine.

James Cole8fd5b45a72b5
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index adfa1e14d4..3fede3ee27 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -305,7 +305,7 @@ class TransactionJournalFactory
$transactionFactory->setCurrency($sourceCurrency);
$transactionFactory->setForeignCurrency($sourceForeignCurrency);
$transactionFactory->setReconciled($row['reconciled'] ?? false);
- $transactionFactory->createNegative($row['amount'], $row['foreign_amount']);
+ $transactionFactory->createNegative((string)$row['amount'], $row['foreign_amount']);
// and the destination one:
/** @var TransactionFactory $transactionFactory */
@@ -316,7 +316,7 @@ class TransactionJournalFactory
$transactionFactory->setCurrency($destCurrency);
$transactionFactory->setForeignCurrency($destForeignCurrency);
$transactionFactory->setReconciled($row['reconciled'] ?? false);
- $transactionFactory->createPositive($row['amount'], $row['foreign_amount']);
+ $transactionFactory->createPositive((string)$row['amount'], $row['foreign_amount']);
// verify that journal has two transactions. Otherwise, delete and cancel.
// TODO this can't be faked so it can't be tested.
diff --git a/app/Support/Import/Routine/Fake/StageFinalHandler.php b/app/Support/Import/Routine/Fake/StageFinalHandler.php
index aea3f756de..35f2a98b8c 100644
--- a/app/Support/Import/Routine/Fake/StageFinalHandler.php
+++ b/app/Support/Import/Routine/Fake/StageFinalHandler.php
@@ -67,18 +67,22 @@ class StageFinalHandler
// transaction data:
'transactions' => [
[
- 'currency_id' => null,
- 'currency_code' => 'EUR',
- 'description' => null,
- 'amount' => random_int(500, 5000) / 100,
- 'budget_id' => null,
- 'budget_name' => null,
- 'category_id' => null,
- 'category_name' => null,
- 'source_id' => null,
- 'source_name' => 'Checking Account',
- 'destination_id' => null,
- 'destination_name' => 'Random expense account #' . random_int(1, 10000),
+ 'type' => 'withdrawal',
+ 'date' => Carbon::now()->format('Y-m-d'),
+ 'currency_id' => null,
+ 'currency_code' => 'EUR',
+ 'description' => 'Some random description #' . random_int(1, 10000),
+ 'amount' => random_int(500, 5000) / 100,
+ 'tags' => [],
+ 'user' => $this->importJob->user_id,
+ 'budget_id' => null,
+ 'budget_name' => null,
+ 'category_id' => null,
+ 'category_name' => null,
+ 'source_id' => null,
+ 'source_name' => 'Checking Account',
+ 'destination_id' => null,
+ 'destination_name' => 'Random expense account #' . random_int(1, 10000),
'foreign_currency_id' => null,
'foreign_currency_code' => null,
'foreign_amount' => null,
@@ -112,9 +116,13 @@ class StageFinalHandler
// transaction data:
'transactions' => [
[
+ 'type' => 'transfer',
+ 'user' => $this->importJob->user_id,
+ 'date' => '2017-02-28',
'currency_id' => null,
'currency_code' => 'EUR',
- 'description' => null,
+ 'tags' => [],
+ 'description' => 'Saving money for February',
'amount' => '140',
'budget_id' => null,
'budget_name' => null,