firefly-iii / firefly-iii

Firefly III: a personal finances manager
https://firefly-iii.org/
GNU Affero General Public License v3.0
16.37k stars 1.49k forks source link

Exception when importing CSV #819

Closed DieBauer closed 7 years ago

DieBauer commented 7 years ago

I'm trying to import a CSV file. I'm using the latest Develop commit (a50945ad53ab)

However, on import it fails with Trying to get property of non-object. The stack trace looks a lot like the one in #760, but apparently the fix doesn't apply to me.

This is the debug output:

Going to import job with key "Yoq6zJVpu0vx" of type "csv"
[2017-09-08 12:53:39] production.INFO: Start with import job Yoq6zJVpu0vx [] []
[2017-09-08 12:53:39] production.DEBUG: Job is configured, start with run() [] []
[2017-09-08 12:53:39] production.DEBUG: Now in CsvProcessor run(). Job is now running... [] []
[2017-09-08 12:53:39] production.DEBUG: Content size is 62 bytes. [] []
[2017-09-08 12:53:39] production.DEBUG: Created a CSV reader starting at offset 0 [] []
[2017-09-08 12:53:39] production.NOTICE: Building importable objects from CSV file. [] []
[2017-09-08 12:53:39] production.DEBUG: Number of entries: 1 [] []
[2017-09-08 12:53:39] production.DEBUG: Number of entries left: 1 [] []
[2017-09-08 12:53:39] production.DEBUG: Number of steps: 5 [] []
[2017-09-08 12:53:39] production.DEBUG: Now at row 0 [] []
[2017-09-08 12:53:39] production.DEBUG: Created ImportAccount. [] []
[2017-09-08 12:53:39] production.DEBUG: Created ImportAccount. [] []
[2017-09-08 12:53:39] production.DEBUG: Created ImportBill. [] []
[2017-09-08 12:53:39] production.DEBUG: Created ImportCategory. [] []
[2017-09-08 12:53:39] production.DEBUG: Created ImportBudget. [] []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"account-number","value":"1234567","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"currency-name","value":"EUR","mapped":1} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"date-transaction","value":"20160909","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"_ignore","value":"10,00","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"_ignore","value":"11,00","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"_ignore","value":"20160909","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"amount","value":"-1,00","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"description","value":"Description","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: Annotated value {"role":"opposing-name","value":"Unknown","mapped":null} []
[2017-09-08 12:53:39] production.INFO: Returned 1 valid objects from file processor [] []
[2017-09-08 12:53:39] production.DEBUG: Found 0 user rules. [] []
[2017-09-08 12:53:39] production.DEBUG: Going to store object #0 with description "Description" [] []
[2017-09-08 12:53:39] production.DEBUG: In findMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountId" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountIban" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountNumber" with value {"role":"account-number","value":"1234567","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: No map present for value "1234567". Return NULL. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountName" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Found no account on mapped data or no map present. [] []
[2017-09-08 12:53:39] production.DEBUG: In findExistingObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Found NO existing accounts. [] []
[2017-09-08 12:53:39] production.DEBUG: Will try to find an asset account just in case. [] []
[2017-09-08 12:53:39] production.DEBUG: In findExistingObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Found NO existing accounts. [] []
[2017-09-08 12:53:39] production.DEBUG: Fall back to default account #1 "ABN Amro" [] []
[2017-09-08 12:53:39] production.DEBUG: In createCurrency() [] []
[2017-09-08 12:53:39] production.DEBUG: In findMappedObject() [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped currency based on field "id" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped currency based on field "code" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped currency based on field "name" with value {"role":"currency-name","value":"EUR","mapped":1} []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() [] []
[2017-09-08 12:53:39] production.DEBUG: Finding a mapped object based on {"role":"currency-name","value":"EUR","mapped":1} []
[2017-09-08 12:53:39] production.DEBUG: Found currency! #1 ("Euro"). Return it [] []
[2017-09-08 12:53:39] production.DEBUG: Found currency #1! [] []
[2017-09-08 12:53:39] production.DEBUG: Mapped existing currency. {"new":{"id":1,"created_at":"2017-09-08 00:00:00","updated_at":"2017-09-08 00:00:00","deleted_at":null,"code":"EUR","name":"Euro","symbol":"€","decimal_places":2}} []
[2017-09-08 12:53:39] production.DEBUG: -1,00 is positive, create opposing revenue account. [] []
[2017-09-08 12:53:39] production.DEBUG: In findMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountId" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountIban" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountNumber" with value [] []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Array is empty, nothing will come of this. [] []
[2017-09-08 12:53:39] production.DEBUG: Find mapped account based on field "accountName" with value {"role":"opposing-name","value":"Unknown","mapped":null} []
[2017-09-08 12:53:39] production.DEBUG: In getMappedObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: No map present for value "Unknown". Return NULL. [] []
[2017-09-08 12:53:39] production.DEBUG: Found no account on mapped data or no map present. [] []
[2017-09-08 12:53:39] production.DEBUG: In findExistingObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Finding account of type 5 and name Unknown [] []
[2017-09-08 12:53:39] production.DEBUG: Found nothing. [] []
[2017-09-08 12:53:39] production.DEBUG: Found NO existing accounts. [] []
[2017-09-08 12:53:39] production.DEBUG: Will try to find an asset account just in case. [] []
[2017-09-08 12:53:39] production.DEBUG: In findExistingObject() for Account [] []
[2017-09-08 12:53:39] production.DEBUG: Finding account of type 3 and name Unknown [] []
[2017-09-08 12:53:39] production.DEBUG: Found nothing. [] []
[2017-09-08 12:53:39] production.DEBUG: Found NO existing accounts. [] []
[2017-09-08 12:53:39] production.DEBUG: Found no account of type Revenue account so must create one ourselves. [] []
[2017-09-08 12:53:39] production.DEBUG: Searching for account named "Unknown" (of user #1) of the following type(s) {"types":["Revenue account"]} []
[2017-09-08 12:53:39] production.DEBUG: There is no account with name "Unknown" or types ["Revenue account"] []
[2017-09-08 12:53:39] production.DEBUG: Final account creation dataset {"user_id":1,"account_type_id":5,"name":"Unknown","virtual_balance":null,"active":true,"iban":null} []
[2017-09-08 12:53:39] production.DEBUG: Created new account #11 named "Unknown" of type Revenue account. [] []
[2017-09-08 12:53:39] production.DEBUG: Array does not have valid opening balance data. [] []
[2017-09-08 12:53:39] production.DEBUG: Could not find a opening balance journal, return empty one. [] []
[2017-09-08 12:53:39] production.DEBUG: Successfully stored new account #11: Unknown [] []
[2017-09-08 12:53:39] production.ERROR: Exception is: {"class":"ErrorException","errorMessage":"Trying to get property of non-object","time":"Fri, 08 Sep 2017 12:53:39 +0000","file":"\/var\/www\/firefly-iii\/app\/Import\/Storage\/ImportSupport.php","line":359,"code":0,"version":"4.6.4"} [] []
[2017-09-08 12:53:40] production.ERROR: ErrorException: Trying to get property of non-object in /var/www/firefly-iii/app/Import/Storage/ImportSupport.php:359 Stack trace: #0 /var/www/firefly-iii/app/Import/Storage/ImportSupport.php(359): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/firefl...', 359, Array) #1 /var/www/firefly-iii/app/Import/Storage/ImportStorage.php(162): FireflyIII\Import\Storage\ImportStorage->storeJournal(Array) #2 /var/www/firefly-iii/app/Import/Storage/ImportStorage.php(97): FireflyIII\Import\Storage\ImportStorage->storeImportJournal(0, Object(FireflyIII\Import\Object\ImportJournal)) #3 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Support/Collection.php(288): FireflyIII\Import\Storage\ImportStorage->FireflyIII\Import\Storage\{closure}(Object(FireflyIII\Import\Object\ImportJournal), 0) #4 /var/www/firefly-iii/app/Import/Storage/ImportStorage.php(102): Illuminate\Support\Collection->each(Object(Closure)) #5 /var/www/firefly-iii/app/Import/Routine/ImportRoutine.php(171): FireflyIII\Import\Storage\ImportStorage->store() #6 /var/www/firefly-iii/app/Import/Routine/ImportRoutine.php(66): FireflyIII\Import\Routine\ImportRoutine->storeObjects(Object(Illuminate\Support\Collection)) #7 /var/www/firefly-iii/app/Console/Commands/Import.php(81): FireflyIII\Import\Routine\ImportRoutine->run() #8 [internal function]: FireflyIII\Console\Commands\Import->handle() #9 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array) #10 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #11 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #12 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #13 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array) #14 /var/www/firefly-iii/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #15 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #16 /var/www/firefly-iii/vendor/symfony/console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /var/www/firefly-iii/vendor/symfony/console/Application.php(228): Symfony\Component\Console\Application->doRunCommand(Object(FireflyIII\Console\Commands\Import), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #18 /var/www/firefly-iii/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #19 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20 /var/www/firefly-iii/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #21 {main} [] []

  [ErrorException]
  Trying to get property of non-object

formatted stack trace for readability:

ErrorException: 
Trying to get property of non-object in /var/www/firefly-iii/app/Import/Storage/ImportSupport.php:359 
Stack trace: 
  #0 /var/www/firefly-iii/app/Import/Storage/ImportSupport.php(359): 
    Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/firefl...', 359, Array) 
  #1 /var/www/firefly-iii/app/Import/Storage/ImportStorage.php(162): 
    FireflyIII\Import\Storage\ImportStorage->storeJournal(Array) 
  #2 /var/www/firefly-iii/app/Import/Storage/ImportStorage.php(97): 
    FireflyIII\Import\Storage\ImportStorage->storeImportJournal(0, Object(FireflyIII\Import\Object\ImportJournal)) 
  #3 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Support/Collection.php(288): 
    FireflyIII\Import\Storage\ImportStorage->FireflyIII\Import\Storage\{closure}(Object(FireflyIII\Import\Object\ImportJournal), 0) 
  #4 /var/www/firefly-iii/app/Import/Storage/ImportStorage.php(102): 
    Illuminate\Support\Collection->each(Object(Closure)) 
  #5 /var/www/firefly-iii/app/Import/Routine/ImportRoutine.php(171): 
    FireflyIII\Import\Storage\ImportStorage->store() 
  #6 /var/www/firefly-iii/app/Import/Routine/ImportRoutine.php(66): 
    FireflyIII\Import\Routine\ImportRoutine->storeObjects(Object(Illuminate\Support\Collection)) 
  #7 /var/www/firefly-iii/app/Console/Commands/Import.php(81): 
    FireflyIII\Import\Routine\ImportRoutine->run() 
  #8 [internal function]: 
    FireflyIII\Console\Commands\Import->handle() 
  #9 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): 
    call_user_func_array(Array, Array) 
  #10 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): 
    Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() 
  #11 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): 
    Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) 
  #12 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): 
    Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) 
  #13 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): 
    Illuminate\Container\Container->call(Array) 
  #14 /var/www/firefly-iii/vendor/symfony/console/Command/Command.php(264): 
    Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) 
  #15 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): 
    Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) 
  #16 /var/www/firefly-iii/vendor/symfony/console/Application.php(874): 
    Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
  #17 /var/www/firefly-iii/vendor/symfony/console/Application.php(228): 
    Symfony\Component\Console\Application->doRunCommand(Object(FireflyIII\Console\Commands\Import), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
  #18 /var/www/firefly-iii/vendor/symfony/console/Application.php(130): 
    Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
  #19 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): 
    Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
  #20 /var/www/firefly-iii/artisan(35): 
    Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
  #21 {main} [] []

I use the following configuration:

{
    "initial-config-complete": false,
    "has-headers": false,
    "date-format": "Ymd",
    "delimiter": "tab",
    "import-account": 1,
    "specifics": {
        "AbnAmroDescription": 1
    },
    "column-count": 10,
    "column-roles": [
        "account-number",
        "currency-name",
        "date-transaction",
        "_ignore",
        "_ignore",
        "_ignore",
        "amount",
        "description",
        "opposing-name",
        "opposing-iban"
    ],
    "column-do-mapping": [
        true,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        true
    ],
    "column-roles-complete": false,
    "column-mapping-config": {
        "0": {
            "1234567": 1
        },
        "1": {
            "EUR": 1
        }
    },
    "column-mapping-complete": false
} 

and input:

1234567 EUR 20160909    10,00   11,00   20160909    -1,00   Description         

Could you tell me what is going wrong? I can't figure it out.

pkoziol commented 7 years ago

You reminded me that I had similiar (maybe the same?) problem. I probably fixed it by using dot instead of comma as decimal separator.

Try:

1234567 EUR 20160909    10.00   11.00   20160909    -1.00   Description         

Edit: Yes, I had the same problem. Try using dot.

DieBauer commented 7 years ago

Wow, life-saver! That was indeed the issue. Locale english and number formatting in Dutch (, separated).. When switching to Dutch locale it works. (or replacing the comma-separator by dots)

What a terrible error message though!

JC5 commented 7 years ago

It's a terrible error message indeed, it's a bug. Firefly III should be able to handle the comma just fine. I will reopen this and look into it.

JC5 commented 7 years ago

Alright I think I fixed this, although technically I did not very much. There is now a lot of debug logging concerning the conversion of the amount, with comma's or without, to a readable number. In your example, this results in:

[2017-09-08 18:21:13] local.DEBUG: Now in getAmount()
[2017-09-08 18:21:13] local.DEBUG: convertedAmount is NULL
[2017-09-08 18:21:13] local.DEBUG: Start with amount "-1,00"
[2017-09-08 18:21:13] local.DEBUG: Decimal character in "-1,00" seems to be a comma.
[2017-09-08 18:21:13] local.DEBUG: Converted amount from "-1,00" to "-1.00".
[2017-09-08 18:21:13] local.DEBUG: First attempt to convert gives "-1"
[2017-09-08 18:21:13] local.DEBUG: After modifiers the result is: "-1"
[2017-09-08 18:21:13] local.DEBUG: convertedAmount is: "-1"

This works no matter the locale.

JC5 commented 7 years ago

New release is live.