You could patch basic csv importer, but I find that frequently used 
importers outgrow that pretty quickly on many other small requirements like 
this. Writing your own importer can be a good idea if you find that 
happening. Red’s importers has this 
<https://github.com/redstreet/beancount_reds_importers/blob/b60e97fb80ca1d14cb1e65321b896721f0277da1/beancount_reds_importers/libreader/csvreader.py#L217-L219>.
 
Here’s an example 
<https://github.com/redstreet/beancount_reds_importers/blob/b60e97fb80ca1d14cb1e65321b896721f0277da1/beancount_reds_importers/importers/schwab/schwab_csv_checking.py#L33>
.
​


On Thursday, September 19, 2024 at 7:20:12 AM UTC-7 [email protected] wrote:

> Hi everyone,
>
> Short version: How does one handle reverted transactions?  They have their 
> own line in my CSV, listing -2 CHF, but the status is REVERTED.
>
> Longer version, to potentially avoid an XY problem:
>
> I'm very new to beancount and set about writing an importer for Revolut 
> based on beangulp's csvbase (which IIUC is the newer way to do it).  I 
> found an older thread 
> <https://groups.google.com/g/beancount/c/NnRK0Pow31Y/m/vKp108RxBQAJ> on 
> the list, but it seems that the csv header has changed since then, and it 
> uses the older beancount.ingest.  I also like building things on my own, I 
> suppose that's no surprise around here :)
>
> I got the basics working, but I wonder how to handle reverted 
> transactions.  Google is not super helpful, so maybe Revolut is using the 
> wrong word for this, but AFAICT it's tiny transactions that merchants do to 
> figure out the card is legit:
>
> Type,Product,Started Date,Completed 
> Date,Description,Amount,Fee,Currency,State,Balance
> CARD_PAYMENT,Current,2023-09-09 20:35:29,,Google,-2.00,0.00,CHF,REVERTED,
>
> I have a few ideas, but I wonder if this isn't already a solved problem:
>
> 1. Use `grep -v` (or awk, if we're being extra careful) to filter out 
> these lines prior to importing.  But I'd like to see if I can do this 
> entirely with beancount
>
> 2. Override `finalize`, check the `State` column, and add a posting of 
> (-value) to reverted transactions.  This works, but I don't like that it 
> pollutes the ledger.  I also don't like that these reverted lines have an 
> empty `Balance` cell, which means I can't use csvbase's nifty automatic 
> balance handling.
>
> 3. Is it possible to add a `skip_line` customization point to the csvbase 
> importer?  This would allow configuring my importer to skip reverted lines, 
> while keeping the balance handling (because lines will be skipped before 
> attempting to fetch the balance column).  If you think that's a sensible 
> approach I'm happy to take a stab at contributing a patch.
>
> Thanks in advance,
> Vlad
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/3b14aa08-0456-471e-bd6f-a3074392c543n%40googlegroups.com.

Reply via email to