Bug 323480 - OFX import Online Statement Balance error
Summary: OFX import Online Statement Balance error
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.6.3
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on: 381818
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-14 07:34 UTC by maps
Modified: 2019-08-29 01:43 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.8.1,5.0.0


Attachments
Screenshot showing the OFX import bug in ledger view (49.52 KB, image/png)
2014-02-14 06:12 UTC, Manoj
Details
OFX file to reproduce the error (1.63 KB, application/octet-stream)
2014-02-14 06:40 UTC, Manoj
Details
Screenshot showing the OFX import bug in ledger view (165.08 KB, image/png)
2014-02-14 06:42 UTC, Manoj
Details
kmymoney test file (24.67 KB, text/xml)
2017-08-03 10:54 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description maps 2013-08-14 07:34:13 UTC
KMyMoney is a fantastic application!  I have chosen it over Quicken, GNUcash, and NolaPro after extensive testing.  Thank you for the fabulous development to date.

When I download an OFX file for a previous period ending date 1/31/2013 prior to the current date 8/14/2013 for my checking account from CHASE bank, the following code appears toward the end of the OFX file when viewed using Microsoft Notepad:
<LEDGERBAL>
<BALAMT>15945.01
<DTASOF>20130814120000[0:GMT]
</LEDGERBAL>
When I import the file, unfortunately, KMyMoney creates and uneditable register entry:
1/31/2013 Online Statement Balance $15,945.01 that cannot be deleted.
This unfortunately is NOT the balance for 1/31/2014 - it is the balance for 8/14/2013.  KMyMoney does not appear to compare the ending date to the field <DTASOF> and suppress entry of an erroneously dated Online Statement Balance.  The program still functions properly, as this value is ignored, but it is bothersome to look at as it conflicts with the program balance immediately above it which is correct for 1/31/2013.
I am able to work around the problem by first using Microsoft Notepad to edit the OFX file and delete the four lines above, after which importing works fine and does not create any Online Statement Balance register entry at all, which is preferable as the entry is going to be the wrong balance.

Reproducible: Always
Comment 1 Jack 2013-08-14 15:02:41 UTC
One quick question - what is the opening date of the account?  You can't edit any transactions prior to that date.  (You shouldn't be able to create them either, but it does happen.)  Also, what type of transaction does that "uneditable register entry" seem to be?  Is it just a deposit, or has it been made the opening balance of the account?  On the other hand, if that entry is just the warning that shows up at the bottom of the ledger, it is not really an entry - it is just a notice that will change when you do the next OFX import.
Comment 2 Manoj 2014-02-14 06:02:58 UTC
I can confirm this observation too. I see a red notice at the bottom of the ledger showing the balance as of the "future" date well past the last transaction. It would be nice to adjust the date on that red, indelible 'transaction' in the ledger. Currently, the date shown is that for the last imported transaction even though the DTASOF field shows the 'future' date.

My model for using kmymoney is to import all transactions for the previous month on the first weekend of the current month. Hence there will be a few days in the current month in which there have been account transactions, and hence the latest balance in the OFX download will most likely be different from the balance at the end of the imported transactions. The reported usage, above, seems to be following a similar approach, ending with a transaction well in the past, to align to some particular interval.

To have this red, indelible transaction with the wrong date catch my eye in the ledger view is quite distracting.
Comment 3 Manoj 2014-02-14 06:12:11 UTC
Created attachment 85137 [details]
Screenshot showing the OFX import bug in ledger view
Comment 4 Manoj 2014-02-14 06:40:24 UTC
Created attachment 85138 [details]
OFX file to reproduce the error

Create an account with opening balance $5857.66 as of 01 Jan 2014
Import this OFX file
See the last, red, indelible ledger entry with wrong statement balance DATE
Comment 5 Manoj 2014-02-14 06:42:10 UTC
Created attachment 85139 [details]
Screenshot showing the OFX import bug in ledger view

Effect of the OFX attachment, when imported.
Comment 6 Cristian Oneț 2014-07-31 13:22:37 UTC
I confirm this.
Comment 7 Cristian Oneț 2014-08-22 22:46:51 UTC
This is actually a bug in libOFX since ofxdump produces this result:

ofx_proc_statement():
    Currency: USD
    Account ID: 000000000  3243783275
    Start date of this statement: Wed Jan  1 08:00:00 2014 EET
    End date of this statement: Fri Jan 31 07:00:00 2014 EET
    Ledger balance: 8697.95
    Available balance: 8697.95

It's even stranger that libOFX has the following field 'ledger_balance_date' but it's never set so KMyMoney can't detect that the balance date is different from the last transaction date.

Need to notify upstream about this.
Comment 8 Benoit Grégoire 2014-09-12 20:11:34 UTC
Ok, I just fixed ledger_balance_date and available_balance_date in libofx 0.9.10.  Assuming kmymoney actually uses it, it should fix part of the bug.

Howewer, kmymoney should make some changes to never assume the balance at some specific date unless the date is available.  1)  If the date isn't available for some reason, the meaning of the balance is too ambiguous to use for accounting purposes.  2)  Will avoid using the balance until 0.9.10 percolates to end user machines, which may take a year or two.
Comment 9 Cristian Oneț 2014-09-12 21:52:26 UTC
(In reply to Benoit Grégoire from comment #8)
> Ok, I just fixed ledger_balance_date and available_balance_date in libofx
> 0.9.10.  Assuming kmymoney actually uses it, it should fix part of the bug.
> 
> Howewer, kmymoney should make some changes to never assume the balance at
> some specific date unless the date is available.  1)  If the date isn't
> available for some reason, the meaning of the balance is too ambiguous to
> use for accounting purposes.  2)  Will avoid using the balance until 0.9.10
> percolates to end user machines, which may take a year or two.

Thanks Benoit for fixing libofx and for the suggestions for how should KMyMoney handle this. I'll take a look at it and see what we can do.
Comment 10 Cristian Oneț 2014-09-23 13:21:44 UTC
I would like to be able to fix this until 4.7.0 is released.
Comment 11 Ralf Habacker 2017-08-02 07:10:40 UTC
Issue is still present in 4.8.0
Comment 12 Ralf Habacker 2017-08-02 07:29:16 UTC
Git commit 67d663f4ea27320d73cc72c9c6743316fb12986b by Ralf Habacker.
Committed on 01/08/2017 at 22:19.
Pushed by habacker into branch '4.8'.

Fix 'OFX import Online Statement Balance error'

Set closing balance and end date of MyMoneyStatement from
ledger_balance and ledger_balance_date only if both are present
to follow libofx maintainer hint mentioned in the related bug.

FIXED-IN:4.8.1

M  +4    -1    kmymoney/plugins/ofximport/ofximporterplugin.cpp

https://commits.kde.org/kmymoney/67d663f4ea27320d73cc72c9c6743316fb12986b
Comment 13 Ralf Habacker 2017-08-03 10:54:10 UTC
Created attachment 107054 [details]
kmymoney test file

How to use:
1. Open this file
2. import the ofx file