From d02df4651786c34b6d2767c3b63bffaf92367bc7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 17 Apr 2016 20:40:26 +0200 Subject: [PATCH] Fix bug in bill name import routine --- app/Helpers/Csv/Converter/BillName.php | 2 +- app/Helpers/Csv/Importer.php | 11 +++++++++-- app/Helpers/Csv/PostProcessing/Bill.php | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Helpers/Csv/Converter/BillName.php b/app/Helpers/Csv/Converter/BillName.php index 043bf770f7..fc462a952a 100644 --- a/app/Helpers/Csv/Converter/BillName.php +++ b/app/Helpers/Csv/Converter/BillName.php @@ -21,7 +21,7 @@ class BillName extends BasicConverter implements ConverterInterface /** @var BillRepositoryInterface $repository */ $repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $bill = null; + $bill = new Bill; // is mapped? Then it's easy! if (isset($this->mapped[$this->index][$this->value])) { $bill = $repository->find($this->mapped[$this->index][$this->value]); diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 90aadc3a0e..2066f3bd8a 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -147,8 +147,15 @@ class Importer $transactionType = $this->getTransactionType(); // defaults to deposit $errors = new MessageBag; $journal = TransactionJournal::create( - ['user_id' => Auth::user()->id, 'transaction_type_id' => $transactionType->id, 'transaction_currency_id' => $this->importData['currency']->id, - 'description' => $this->importData['description'], 'completed' => 0, 'date' => $date, 'bill_id' => $this->importData['bill-id'],] + [ + 'user_id' => Auth::user()->id, + 'transaction_type_id' => $transactionType->id, + 'transaction_currency_id' => $this->importData['currency']->id, + 'description' => $this->importData['description'], + 'completed' => 0, + 'date' => $date, + 'bill_id' => $this->importData['bill-id'], + ] ); if ($journal->getErrors()->count() == 0) { // first transaction diff --git a/app/Helpers/Csv/PostProcessing/Bill.php b/app/Helpers/Csv/PostProcessing/Bill.php index 9369fc26ad..5bae80b862 100644 --- a/app/Helpers/Csv/PostProcessing/Bill.php +++ b/app/Helpers/Csv/PostProcessing/Bill.php @@ -20,7 +20,7 @@ class Bill implements PostProcessorInterface { // get bill id. - if (!is_null($this->data['bill'])) { + if (!is_null($this->data['bill']->id)) { $this->data['bill-id'] = $this->data['bill']->id; }