Incorrect payee assignments during csv import when a payee field ends in semicolon

Thomas Baumgart thb at net-bembel.de
Sat Feb 17 17:10:57 GMT 2024


On Samstag, 17. Februar 2024 08:50:10 CET Thomas Baumgart via KMyMoney wrote:

> On Donnerstag, 15. Februar 2024 20:54:45 CET Steve via KMyMoney wrote:
> 
> > Hi Jack
> > 
> > I have attached a short csv file with the contents
> > 
> > 01-04-2022,KENT,70.00
> > 02-04-2022,Happy Store;,6000.00
> > 03-04-2022,MITCHELL,70.00
> > 04-04-2022,HILTON,50.00
> > 05-04-2022,KENT,70.00
> > 
> > The Happy Store payee ends with a semicolon
> > I should have mentioned this happens with a brand new, empty kmm project
> > 
> > I would expect the new ledger to reflect exactly the entries shown above
> > In fact the ledger shows
> > 
> > 01-04-2022,KENT,70.00
> > 02-04-2022,Happy Store;,6000.00
> > 03-04-2022,Happy Store;,70.00
> > 04-04-2022,Happy Store;,50.00
> > 05-04-2022,KENT,70.00
> > 
> > So KENT and Happy Store; are assigned as expected
> > The entries after Happy Store; are matched to Happy Store;
> >    -except for KENT which is assigned correctly because it had already
> > been imported before Happy Store;
> > 
> > Under Payees > Matching I see
> > one entry for KENT:
> >      ^KENT$
> > two entries for Happy Store;
> >      ^Happy Store
> >      $
> > 
> > Somehow the terminal ; is interpreted as a second entry $ in the
> > matching list ...
> 
> Ah, that explains it. The second entry matches basically every string.
> It's meaning is "match what has an end of string". KENT is matched,
> because it is known.
> 
> Multiple entries are separated in the data file by the line feed
> character (known as \n or 0x0A or in HTML 
 ). Example from my
> life data:
> 
>     <PAYEE id="P000020" name="Familienkasse" reference="" email="" matchingenabled="1" usingmatchkey="1" matchignorecase="1" matchkey="Bundesagentur fuer Arbeit -
FAMILIENKASSE
FAMKASSE
Bundesagentur fur Arbeit -">
> 
> The matchkey attribute contains 4 entries.
> 
> > I ran a test which shows that a $ entry in the matching list matches all
> > subsequent entries to that payee ...
> > 
> > This happens with v5.1.3
> 
> ... and most likely with master as well. Thanks for the sample data.
> That should allow to find and resolve the issue.

Finding was sort of easy: the code location is here

https://invent.kde.org/office/kmymoney/-/blob/master/kmymoney/mymoney/mymoneypayee.cpp#L229

Resolving is a bit harder, because that is a feature (as the source
code even states). But in the end, I found a solution:

https://invent.kde.org/office/kmymoney/-/commit/a333ac69b9491d13efa227188ab5a9cf80a9176a

Don't know, if this can be simply cherry-picked onto the 5.1 branch but
at least in master the problem is fixed.

-- 

Regards

Thomas Baumgart

-------------------------------------------------------------
'A programmer is just a tool which converts caffeine into code' -- anonymous
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney/attachments/20240217/e9debf8a/attachment.sig>


More information about the KMyMoney mailing list