UUID based Filtering

52 views
Skip to first unread message

mail.ghanas...@gmail.com

unread,
Jul 15, 2020, 2:18:59 AM7/15/20
to Ledger
Hello, 

I started to use ledger recently for tracking finances and the primary inputs
my ledger is my checking account and credit card statement. 
Using a rudimentary 
python script, I parse out these statements to populate the ledger. 

For credit card bill payment transactions, I have duplicate transactions and I use 
UUID metadata to drop of them. My script uses a UUID format of <date>:<cc-bill> 
while parsing the statement. 

See suggestion here from reddit Dealing with Duplicate Transactions
 
I'd like to therefore double check at any time, I had same UUID used more than 
twice. Does ledger allow for reporting transactions based on UUID filtering? 

Any other options to make sure UUIDs are not duplicate for more than one pair 
of transactions?

An example of the transactions that I am talking about

2020/01/09 * BANK OF AMERICA CREDIT CARD Bill Payment
    ; bofacc
    ; UUID: 2020.01.09-cc-ma:bofa
    Liabilities:cc-ma:bofa                 $563.85
    Assets:checking:bofa

2019/01/09 * PAYMENT - THANK YOU
    ; payment to CC
    ; UUID: 2020.01.09:cc-ma:bofa
    Liabilities:cc-ma:bofa                 $-$563.85
    Assets:checking:bofa

Pete Keen

unread,
Jul 15, 2020, 6:21:40 AM7/15/20
to ledge...@googlegroups.com
I do something similar when importing from Tiller. I run a ledger command to dump out all the Tiller IDs that are in my ledger and then parse that list into a set in my Ruby script. The script checks against the set when deciding whether to print a transaction or not.

The ledger command I use is here: 

You should just have to replace tiller_id with your tag and convert the parsing to python. Yours should be a little simpler because mine allows for multiple tiller ids per transaction fir silly reasons. 

Be aware that if you try to run that command in a shell you have to put single quotes around the format string and the query.

—Pete

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/639d1c41-e35e-4475-a50c-0625064a127ao%40googlegroups.com.

Martin Michlmayr

unread,
Jul 15, 2020, 6:25:56 AM7/15/20
to ledge...@googlegroups.com
* mail.ghanas...@gmail.com <mail.ghanas...@gmail.com> [2020-07-14 10:42]:
> I'd like to therefore double check at any time, I had same UUID used
> more than twice. Does ledger allow for reporting transactions based
> on UUID filtering?

How about some shell commands?

grep "; *UUID:" *.ledger | sort | uniq -c | sed -e "s/^ *//" | cut -d" " -f1 | grep -v "^\(1\|2\)$"

--
Martin Michlmayr
https://www.cyrius.com/

Ghanashyam

unread,
Jul 16, 2020, 2:57:28 AM7/16/20
to ledge...@googlegroups.com
Thanks for the feedback!
I updated my UUID formatting to the below 

; UUID:YYYYMMDD:<account>:<amount>  
where 
    > account primarily indicates a credit card account to which the bill was paid 
    > amount being absolute value - while parsing checking account, amount is typically positive 
      indicating a debit from the checking account paid towards the credit card account and 
      while parsing the credit card statement, the amount is negative implying a credit into this 
      account. 

The above format can help me sort transactions by date and uniqifies more than 1 transaction
from the same day - (of course there are cases of duplicate UUID if even the amount paid is the 
same on two or more transactions made on the same day but ignoring it for now.. ) 

And then as Martin suggested, I am using a shell command to parse out these UUIDs 

> awk 'BEGIN { FS = "; UUID:" }; {print /$2}' | sort | uniq -c | grep -v -G '^\s\+\?\(1\|2\)\s'


- Ghanashyam 

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages