Extract payee from memo field

Thomas Baumgart thb at net-bembel.de
Mon Jan 15 20:51:38 UTC 2018


Hi Timon,

On Montag, 15. Januar 2018 20:44:34 CET Timon Fiddike wrote:

> Hello everybody,
> 
> short version:
> 
> How does the "Extract payee from memo field" feature work?
> 
> You can find in here:
> "Edit Account" > "Online Settings" > "Extract payee from memo field using
> regular expressions”
> 
> I can supply a screenshot if needed and sending those to the list is O.K.!?
> 
> 
> TL;DR
> 
> I searched using Google, searched inside "The KMyMoney Handbook for KMyMoney
> version 4.8.1" and looked over the documentation of the QRegExp class
> http://doc.qt.io/archives/qt-4.8/qregexp.html#1 without success. Any RTFMs
> with pointers to specific documentation would be greatly appreciated.
> 
> 
> Here's some background and transaction information and what I tried:
> 
> My KMyMoney version is 4.8.0, built on KDE Plattform 4.14.16 on Ubuntu
> 16.04.3, installed via this PPA
> https://launchpad.net/~michael-ruoss/+archive/ubuntu/kmymoney I would have
> preferred 4.8.1, but I didn't find a PPA of 4.8.1 that was compiled with
> AqBanking support (if you know one, I'd be grateful for a hint).
> 
> I use KMyMoney with Aqbanking to download transaction data from my bank.
> I rely on payees default category to achieve automatic category assignments.
> 
> This works perfectly for transfers and direct debit payments, because in
> these cases my bank (GLS) fills the the payee field correctly.
> 
> However, for debit card payements the payee information is included only in
> the memo field.
> 
> Therefore I would like to extract the payee information from the memo field.
> 
> I was very happy when I discovered "Edit Account" > "Online Settings" >
> "Extract payee from memo field using regular expressions”.
> 
> Here are some example transaction for all three types (2 work, 1 doesn’t):

[... examples removed on purpose ...]

> So if memo starts with "Kartenzahlung Debitkarte" I need all the following
> characters up to the first /
> 
> So I klick to "Edit Account" > "Online Settings" > "Extract payee from memo
> field using regular expressions”.
> 
> How are the fields
> "Regular Expression for Payee"
> "Regular Expression for Memo"
> intended to be used?
> 
> Not quite knowing what to expect I tried using regular expressions that
> would extract everything and then trim them down to just what I need. Using
> these expressions for both Payee and Memo did not have any effect: (.*?)
> [\s\S]*
> 
> When I tried .* in both fields, the last transaction's memo was reduced to
> it’s last line: "
> WELADEDDXXX/DE86300500000001052141"
> 
> So there was some kind of effect. However, the payee field was still empty.
> 
> As mentioned above, I searched using Google, searched inside "The KMyMoney
> Handbook for KMyMoney version 4.8.1" and looked over the documentation of
> the QRegExp class http://doc.qt.io/archives/qt-4.8/qregexp.html#1 without
> success.
> 
> The QRegExp class implements different variants of regexp, which one is used
> for payee extraction?

It might have different ctors but only one regex 'language'. And that is, what 
we need here.


> How are the two fields meant to be used?

These fields are only evaluated, when the payee field is empty, which is the 
case when you need the feature. The payee field should contain the regex that 
extracts the payee from the memo (Verwendungszweck), the second one should 
extrac the memo part.

In your case it seems to be something like

   ^Kartenzahlung Debitkarte([^/]+)/.*

for the payee and

   ^Kartenzahlung Debitkarte[^/]+/(.*)

for the memo. The strings you enter in the fields are used as QString str in

  QRegExp regex(str, Qt::CaseInsensitive)

and evaluated in

  if(regex.indexIn(memo_from_bank) != -1) {
    result = regex.cap(1);
  }

The QRegExp::cap(1) member is used to extract the info for payee and memo.

> Any RTFMs with pointers to specific documentation would be greatly
> appreciated.

I hope that helps. The example code is taken from the Qt5 based version but is 
otherwise identical in the Qt4 version.

> http://fiddike.com

Interessant.


-- 

Regards

Thomas Baumgart

https://www.telegram.org/       Telegram, the better WhatsApp
-------------------------------------------------------------
If you have a choice of two things and can't decide, take both.
 -- Gregory Corso
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 846 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney/attachments/20180115/5a320c3b/attachment.sig>


More information about the KMyMoney mailing list