Thanks :)
This is for "bean-extract", right?
Can you also provide me the correct entry for the config.py?
On Saturday, November 16, 2019 at 3:58:14 PM UTC+1, Patrick Ruckstuhl wrote:
>
> Hi,
>
>
> That's what I'm currently using. It stores original values as meta
> information in original key and conversions as originalIn and originalOut
>
> from dateutil.parser import parse
> from io import StringIO
>
> from beancount.ingest import importer
> from beancount.core import data
> from beancount.core import amount
> from beancount.core.number import D
> from beancount.ingest.importers.mixins import identifier
>
> import csv
>
> class Importer(identifier.IdentifyMixin, importer.ImporterProtocol):
> """An importer for Revolut CSV files."""
>
> def __init__(self, regexps, account, currency):
> identifier.IdentifyMixin.__init__(self, matchers=[
> ('filename', regexps)
> ])
> self.account = account
> self.currency = currency
>
> def name(self):
> return super().name() + self.account
>
> def file_account(self, file):
> return self.account
>
> def extract(self, file, existing_entries):
> entries = []
>
> with StringIO(file.contents()) as csvfile:
> reader = csv.DictReader(csvfile, ['Date',
> 'Reference','PaidOut', 'PaidIn', 'ExchangeOut', 'ExchangeIn', 'Balance',
> 'Category', 'Notes'], delimiter=';', skipinitialspace=True)
> next(reader)
> for row in reader:
> metakv = {
> 'category': row['Category'].strip(),
> }
> exchangeIn = row['ExchangeIn'].strip()
> exchangeOut = row['ExchangeOut'].strip()
> if exchangeIn and exchangeOut:
> metakv['originalIn'] = exchangeIn
> metakv['originalOut'] = exchangeOut
> elif exchangeIn:
> metakv['original'] = exchangeIn
> elif exchangeOut:
> metakv['original'] = exchangeOut
>
> meta = data.new_metadata(file.name, 0, metakv)
> entry = data.Transaction(
> meta,
> parse(row['Date'].strip()).date(),
> '*',
> '',
> (row['Reference'].strip() + ' ' +
> row['Notes'].strip()).strip(),
> data.EMPTY_SET,
> data.EMPTY_SET,
> [
> data.Posting(self.account,
> amount.Amount(D(row['PaidIn'].strip()) - D(row['PaidOut'].strip()),
> self.currency), None, None, None, None),
> ]
> )
> entries.append(entry)
> return entries
>
>
> On 16.11.2019 14:45, [email protected] <javascript:> wrote:
>
> Hi
>
> Does anybody has a Revolut statement (csv) parser to import the
> transactions to beancounts?
>
> Example rows:
>
> Completed Date ; Description ; Paid Out (CHF) ; Paid In (CHF) ; Exchange
> Out; Exchange In; Balance (CHF); Category; Notes
> Nov 16, 2019 ; Top-Up by *8753 ; ; 600.00 ; ; ; 703.83; general;
> Nov 16, 2019 ; Paypal *collintanaw FX Rate Fr1 = US$1.0066 ; 403.30 ; ;
> USD 405.96 ; ; 103.83; services;
>
> Thanks for help :)
> --
> 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] <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/90613531-9c08-45a5-8dfc-7be50029c224%40googlegroups.com
>
> <https://groups.google.com/d/msgid/beancount/90613531-9c08-45a5-8dfc-7be50029c224%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
--
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/31a28fff-21f2-4005-a1a9-bfb7efd41696%40googlegroups.com.