Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A quotation mark in a QFX file breaks transformation #102

Open
colindean opened this issue Jun 16, 2020 · 1 comment
Open

A quotation mark in a QFX file breaks transformation #102

colindean opened this issue Jun 16, 2020 · 1 comment

Comments

@colindean
Copy link
Contributor

$ ledger-autosync -l 2019.ledger -a "Liabilities:CreditCard:Citi:Costco" --unknown-account "Expenses:Stuff" ~/Downloads/Last\ year\ \(2019\).QFX >> 2019.ledger
While parsing value expression:
  (tag("AutosyncPayee") == "IKE"S FOOD & COCKTAILS")&((account =~ /Liabilities:CreditCard:Citi:Costco/))
                                ^
Error: Invalid token '<ident 'S'>' (wanted ')')
Traceback (most recent call last):
  File "/usr/local/bin/ledger-autosync", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/cli.py", line 363, in run
    import_ofx(ledger, args)
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/cli.py", line 183, in import_ofx
    print_results(converter, ofx, ledger, txns, args)
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/cli.py", line 74, in print_results
    print(converter.convert(txn).format(args.indent))
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/converter.py", line 436, in convert
    payee=self.format_payee(txn),
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/converter.py", line 326, in format_payee
    payee = self.lgr.get_autosync_payee(payee, self.name)
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/ledgerwrap.py", line 181, in get_autosync_payee
    r = self.run(q)
  File "/usr/local/lib/python3.7/site-packages/ledgerautosync/ledgerwrap.py", line 160, in run
    universal_newlines=True).splitlines(),
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ledger', '--args-only', '-f', '2019.ledger', 'csv', 'Liabilities:CreditCard:Citi:Costco', '--last', '1', '--format', '%(quoted(payee))\n', '--limit', 'tag("AutosyncPayee") == "IKE"S FOOD & COCKTAILS"']' returned non-zero exit status 1.

The easiest workaround was to just… replace the " with ' in the source QFX file but it would be nice if ledger-autosync handled that automatically or provided an option that sanitizes payee names before they are queried against the tx record.

@egh
Copy link
Owner

egh commented Jun 16, 2020

I think we just need to escape " here as \", the ledger expression parser seems like its blowing up on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants