Fix the fake import routine.

This commit is contained in:
James Cole 2019-09-13 05:30:51 +02:00
parent 055673370b
commit 8fd5b45a72
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 23 additions and 15 deletions

View File

@ -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.

View File

@ -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,